lima: refactor plb_max_blk

Move plb_max_blk to lima_screen, and add a new debug option:
LIMA_PLB_MAX_BLK

Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
This commit is contained in:
Patrick Lerda 2019-05-13 00:03:22 +02:00
parent f53ebfb450
commit 38c5a5a8b5
5 changed files with 34 additions and 11 deletions

View file

@ -214,12 +214,8 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
util_dynarray_init(&ctx->vs_cmd_array, ctx);
util_dynarray_init(&ctx->plbu_cmd_array, ctx);
if (screen->gpu_type == DRM_LIMA_PARAM_GPU_ID_MALI450)
ctx->plb_max_blk = 4096;
else
ctx->plb_max_blk = 512;
ctx->plb_size = ctx->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
ctx->plb_gp_size = ctx->plb_max_blk * 4;
ctx->plb_size = screen->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
ctx->plb_gp_size = screen->plb_max_blk * 4;
for (int i = 0; i < lima_ctx_num_plb; i++) {
ctx->plb[i] = lima_bo_create(screen, ctx->plb_size, 0);
@ -241,7 +237,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
/* plb gp stream is static for any framebuffer */
for (int i = 0; i < lima_ctx_num_plb; i++) {
uint32_t *plb_gp_stream = ctx->plb_gp_stream->map + i * ctx->plb_gp_size;
for (int j = 0; j < ctx->plb_max_blk; j++)
for (int j = 0; j < screen->plb_max_blk; j++)
plb_gp_stream[j] = ctx->plb[i]->va + LIMA_CTX_PLB_BLK_SIZE * j;
}

View file

@ -222,7 +222,6 @@ struct lima_context {
#define LIMA_CTX_PLB_MAX_NUM 4
#define LIMA_CTX_PLB_DEF_NUM 2
#define LIMA_CTX_PLB_BLK_SIZE 512
unsigned plb_max_blk;
unsigned plb_size;
unsigned plb_gp_size;

View file

@ -42,6 +42,8 @@
#include "xf86drm.h"
int lima_plb_max_blk = 0;
static void
lima_screen_destroy(struct pipe_screen *pscreen)
{
@ -343,6 +345,19 @@ lima_screen_get_compiler_options(struct pipe_screen *pscreen,
return lima_program_get_compiler_options(shader);
}
static bool
lima_screen_set_plb_max_blk(struct lima_screen *screen)
{
if (lima_plb_max_blk)
screen->plb_max_blk = lima_plb_max_blk;
else if (screen->gpu_type == DRM_LIMA_PARAM_GPU_ID_MALI450)
screen->plb_max_blk = 4096;
else
screen->plb_max_blk = 512;
return true;
}
static bool
lima_screen_query_info(struct lima_screen *screen)
{
@ -369,6 +384,8 @@ lima_screen_query_info(struct lima_screen *screen)
screen->num_pp = param.value;
lima_screen_set_plb_max_blk(screen);
return true;
}
@ -431,6 +448,13 @@ lima_screen_parse_env(void)
lima_ctx_num_plb = LIMA_CTX_PLB_DEF_NUM;
}
lima_plb_max_blk = debug_get_num_option("LIMA_PLB_MAX_BLK", 0);
if (lima_plb_max_blk < 0 || lima_plb_max_blk > 65536) {
fprintf(stderr, "lima: LIMA_PLB_MAX_BLK %d out of range [%d %d], "
"reset to default %d\n", lima_plb_max_blk, 0, 65536, 0);
lima_plb_max_blk = 0;
}
lima_ppir_force_spilling = debug_get_num_option("LIMA_PPIR_FORCE_SPILLING", 0);
if (lima_ppir_force_spilling < 0) {
fprintf(stderr, "lima: LIMA_PPIR_FORCE_SPILLING %d less than 0, "
@ -450,6 +474,8 @@ lima_screen_create(int fd, struct renderonly *ro)
screen->fd = fd;
lima_screen_parse_env();
if (!lima_screen_query_info(screen))
goto err_out0;
@ -532,8 +558,6 @@ lima_screen_create(int fd, struct renderonly *ro)
screen->refcnt = 1;
lima_screen_parse_env();
return &screen->base;
err_out2:

View file

@ -40,6 +40,7 @@
extern uint32_t lima_debug;
extern FILE *lima_dump_command_stream;
extern int lima_ctx_num_plb;
extern int lima_plb_max_blk;
extern int lima_ppir_force_spilling;
struct ra_regs;
@ -54,6 +55,7 @@ struct lima_screen {
int fd;
int gpu_type;
int num_pp;
uint32_t plb_max_blk;
/* bo table */
mtx_t bo_table_lock;

View file

@ -58,13 +58,15 @@ lima_set_framebuffer_state(struct pipe_context *pctx,
int width = align(framebuffer->width, 16) >> 4;
int height = align(framebuffer->height, 16) >> 4;
if (fb->tiled_w != width || fb->tiled_h != height) {
struct lima_screen *screen = lima_screen(ctx->base.screen);
fb->tiled_w = width;
fb->tiled_h = height;
fb->shift_h = 0;
fb->shift_w = 0;
int limit = ctx->plb_max_blk;
int limit = screen->plb_max_blk;
while ((width * height) > limit) {
if (width >= height) {
width = (width + 1) >> 1;