Mesa (main): zink: remove screen info stuff from draw templates

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 20 00:37:34 UTC 2021


Module: Mesa
Branch: main
Commit: 59e69e8ec5b2df124b2a9c23fec53a5988563676
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=59e69e8ec5b2df124b2a9c23fec53a5988563676

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri May 14 19:53:24 2021 -0400

zink: remove screen info stuff from draw templates

we can initialize templates that we never need to evaluate again at
runtime, cutting the overhead for all tempaltes

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11964>

---

 src/gallium/drivers/zink/zink_context.c |  4 +---
 src/gallium/drivers/zink/zink_context.h |  6 ++----
 src/gallium/drivers/zink/zink_draw.cpp  | 32 +++++++++++++++++++-------------
 src/gallium/drivers/zink/zink_inlines.h |  3 +--
 4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 600c26bb03c..d92ddbe0542 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3409,14 +3409,13 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    if (!ctx)
       goto fail;
    ctx->have_timelines = screen->info.have_KHR_timeline_semaphore;
-   ctx->dynamic_state = screen->info.have_EXT_extended_dynamic_state;
 
    ctx->pipeline_changed[0] = ctx->pipeline_changed[1] = true;
    ctx->gfx_pipeline_state.dirty = true;
    ctx->compute_pipeline_state.dirty = true;
    ctx->fb_changed = ctx->rp_changed = true;
 
-   zink_init_draw_functions(ctx);
+   zink_init_draw_functions(ctx, screen);
    zink_init_grid_functions(ctx);
 
    ctx->base.screen = pscreen;
@@ -3579,7 +3578,6 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    if (tc && (struct zink_context*)tc != ctx) {
       tc->bytes_mapped_limit = screen->total_mem / 4;
       ctx->base.set_context_param = zink_set_context_param;
-      ctx->multidraw = screen->info.have_EXT_multi_draw;
    }
 
    return (struct pipe_context*)tc;
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index c348aeb8289..21f528e794a 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -162,9 +162,7 @@ struct zink_context {
    struct slab_child_pool transfer_pool_unsync;
    struct blitter_context *blitter;
 
-   zink_multidraw multidraw : 1;
-   zink_dynamic_state dynamic_state : 1;
-   pipe_draw_vbo_func draw_vbo[2][2][2]; //multidraw, dynamic state, batch changed
+   pipe_draw_vbo_func draw_vbo[2]; //batch changed
    pipe_launch_grid_func launch_grid[2]; //batch changed
 
    struct pipe_device_reset_callback reset;
@@ -387,7 +385,7 @@ zink_pipeline_flags_from_pipe_stage(enum pipe_shader_type pstage)
 }
 
 void
-zink_init_draw_functions(struct zink_context *ctx);
+zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen);
 void
 zink_init_grid_functions(struct zink_context *ctx);
 
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 562672a6039..32c2e8eab35 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -804,32 +804,33 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
 
 template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state HAS_DYNAMIC_STATE, bool BATCH_CHANGED>
 static void
-init_batch_changed_functions(struct zink_context *ctx)
+init_batch_changed_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
 {
-   ctx->draw_vbo[HAS_MULTIDRAW][HAS_DYNAMIC_STATE][BATCH_CHANGED] = zink_draw_vbo<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, BATCH_CHANGED>;
+   draw_vbo_array[HAS_MULTIDRAW][HAS_DYNAMIC_STATE][BATCH_CHANGED] =
+   zink_draw_vbo<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, BATCH_CHANGED>;
 }
 
 template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state HAS_DYNAMIC_STATE>
 static void
-init_dynamic_state_functions(struct zink_context *ctx)
+init_dynamic_state_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
 {
-   init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, false>(ctx);
-   init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, true>(ctx);
+   init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, false>(ctx, draw_vbo_array);
+   init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, true>(ctx, draw_vbo_array);
 }
 
 template <zink_multidraw HAS_MULTIDRAW>
 static void
-init_multidraw_functions(struct zink_context *ctx)
+init_multidraw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
 {
-   init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_NO_DYNAMIC_STATE>(ctx);
-   init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_DYNAMIC_STATE>(ctx);
+   init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_NO_DYNAMIC_STATE>(ctx, draw_vbo_array);
+   init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_DYNAMIC_STATE>(ctx, draw_vbo_array);
 }
 
 static void
-init_all_draw_functions(struct zink_context *ctx)
+init_all_draw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
 {
-   init_multidraw_functions<ZINK_NO_MULTIDRAW>(ctx);
-   init_multidraw_functions<ZINK_MULTIDRAW>(ctx);
+   init_multidraw_functions<ZINK_NO_MULTIDRAW>(ctx, draw_vbo_array);
+   init_multidraw_functions<ZINK_MULTIDRAW>(ctx, draw_vbo_array);
 }
 
 template <bool BATCH_CHANGED>
@@ -865,9 +866,14 @@ zink_invalid_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info
 
 extern "C"
 void
-zink_init_draw_functions(struct zink_context *ctx)
+zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen)
 {
-   init_all_draw_functions(ctx);
+   pipe_draw_vbo_func draw_vbo_array[2][2][2]; //multidraw, dynamic state, batch changed
+   init_all_draw_functions(ctx, draw_vbo_array);
+   memcpy(ctx->draw_vbo, &draw_vbo_array[screen->info.have_EXT_multi_draw]
+                                        [screen->info.have_EXT_extended_dynamic_state],
+                                        sizeof(ctx->draw_vbo));
+
    /* Bind a fake draw_vbo, so that draw_vbo isn't NULL, which would skip
     * initialization of callbacks in upper layers (such as u_threaded_context).
     */
diff --git a/src/gallium/drivers/zink/zink_inlines.h b/src/gallium/drivers/zink/zink_inlines.h
index 66939bcd005..fe873828423 100644
--- a/src/gallium/drivers/zink/zink_inlines.h
+++ b/src/gallium/drivers/zink/zink_inlines.h
@@ -5,8 +5,7 @@
 static inline void
 zink_select_draw_vbo(struct zink_context *ctx)
 {
-   ctx->base.draw_vbo = ctx->draw_vbo[ctx->multidraw][ctx->dynamic_state]
-                                     [ctx->pipeline_changed[0]];
+   ctx->base.draw_vbo = ctx->draw_vbo[ctx->pipeline_changed[0]];
    assert(ctx->base.draw_vbo);
 }
 



More information about the mesa-commit mailing list