Mesa (main): zink: create compute programs on bind

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 25 22:38:31 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jun 10 06:17:03 2021 -0400

zink: create compute programs on bind

this simplifies the launch_grid codepath and gets shader binds out
the shader update bitmask

Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12532>

---

 src/gallium/drivers/zink/zink_draw.cpp  | 16 ----------------
 src/gallium/drivers/zink/zink_program.c | 11 +++++++----
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 196a7a8f7ee..0cf9167ab7a 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -174,20 +174,6 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
    ctx->vertex_buffers_dirty = false;
 }
 
-static void
-update_compute_program(struct zink_context *ctx)
-{
-   const unsigned bits = 1 << PIPE_SHADER_COMPUTE;
-   if (ctx->dirty_shader_stages & bits) {
-      struct zink_compute_program *comp = zink_create_compute_program(ctx, ctx->compute_stage);
-      _mesa_hash_table_insert(&ctx->compute_program_cache, comp->shader, comp);
-      ctx->compute_pipeline_state.dirty = true;
-      ctx->curr_compute = comp;
-      ctx->dirty_shader_stages &= bits;
-      zink_batch_reference_program(&ctx->batch, &ctx->curr_compute->base);
-   }
-}
-
 static void
 update_gfx_program(struct zink_context *ctx)
 {
@@ -775,8 +761,6 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
 
    update_barriers(ctx, true);
 
-   update_compute_program(ctx);
-
    if (zink_program_has_descriptors(&ctx->curr_compute->base))
       screen->descriptors_update(ctx, true);
 
diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c
index b710f9c875b..7f3881c0a2c 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -540,8 +540,6 @@ zink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader
    assert(comp->module->shader);
    _mesa_hash_table_insert(&comp->base.shader_cache[0], shader, comp->module);
 
-   ctx->dirty_shader_stages &= ~(1 << PIPE_SHADER_COMPUTE);
-
    comp->pipelines = _mesa_hash_table_create(NULL, hash_compute_pipeline_state,
                                              equals_compute_pipeline_state);
 
@@ -883,8 +881,13 @@ bind_stage(struct zink_context *ctx, enum pipe_shader_type stage,
          if (entry) {
             ctx->compute_pipeline_state.dirty = true;
             ctx->curr_compute = entry->data;
-         } else
-            ctx->dirty_shader_stages |= 1 << stage;
+         } else {
+            struct zink_compute_program *comp = zink_create_compute_program(ctx, shader);
+            _mesa_hash_table_insert(&ctx->compute_program_cache, comp->shader, comp);
+            ctx->compute_pipeline_state.dirty = true;
+            ctx->curr_compute = comp;
+            zink_batch_reference_program(&ctx->batch, &ctx->curr_compute->base);
+         }
       } else if (!shader)
          ctx->curr_compute = NULL;
       ctx->compute_stage = shader;



More information about the mesa-commit mailing list