lima: refactor plb_max_blk
authorPatrick Lerda <patrick9876@free.fr>
Sun, 12 May 2019 22:03:22 +0000 (00:03 +0200)
committerPatrick Lerda <patrick9876@free.fr>
Mon, 13 May 2019 11:32:55 +0000 (13:32 +0200)
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>
src/gallium/drivers/lima/lima_context.c
src/gallium/drivers/lima/lima_context.h
src/gallium/drivers/lima/lima_screen.c
src/gallium/drivers/lima/lima_screen.h
src/gallium/drivers/lima/lima_state.c

index 9a373b96728381b04818940f43d6aa9d0a51b394..558d2346653ede4cafb6fa61d152d454dce4069c 100644 (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;
    }
 
index 4bbe915bcdc1defd6170c4a34aea0af8299a7603..c16baeef0bac7c4138ada4fe7887a3e6923ef4e5 100644 (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;
 
index 29dfc16c7ac6d05f7daf2a475ad2636b65f6bfab..0eb472acebd2b9bd63bf8d3c2256903fac423f42 100644 (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:
index af435f71190a8a2c5fa67f83ee2845e13312e80a..7d1f6f829247d523279a3788938e8bece661aeaa 100644 (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;
index 1621618c865953c2a6676eb42ecc16adfcae4d4a..3cb8c57ffc87849986b974a400ef881d0ad10573 100644 (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;