Module: Mesa
Branch: staging/23.0
Commit: 91bd2510eba68382146af3b1f12f718dba48cd84
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91bd2510eba68382146af3b1f12f718dba48cd84

Author: antonino <[email protected]>
Date:   Wed Mar 15 13:09:34 2023 +0100

zink: fix `final_hash` update in `zink_gfx_program_update`

The logic that updates `ctx->gfx_pipeline_state.final_hash` assumed that
the program is replaced. It is supposed to xor `final_hash` with the
hash first and then with the new hash however when the program is
updated it end up xor-ing the new hash twice so it does nothing.

Reviewed-By: Mike Blumenkrantz <[email protected]>
Fixes: 15450d2c2e2 ("zink: incrementally hash all pipeline component hashes")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21925>
(cherry picked from commit 1538a28803d58ccfb754979d701fae8a92e72bda)

---

 .pick_status.json                       | 2 +-
 src/gallium/drivers/zink/zink_program.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index f747b5ab823..c30119e8c69 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5287,7 +5287,7 @@
         "description": "zink: fix `final_hash` update in 
`zink_gfx_program_update`",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "15450d2c2e222d905e0a6ced89e9ceeba3489608"
     },
diff --git a/src/gallium/drivers/zink/zink_program.c 
b/src/gallium/drivers/zink/zink_program.c
index 57b83059601..abda1d901cc 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -566,6 +566,9 @@ zink_gfx_program_update(struct zink_context *ctx)
       struct hash_table *ht = 
&ctx->program_cache[zink_program_cache_stages(ctx->shader_stages)];
       const uint32_t hash = ctx->gfx_hash;
       struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(ht, hash, 
ctx->gfx_stages);
+      /* this must be done before prog is updated */
+      if (ctx->curr_program)
+         ctx->gfx_pipeline_state.final_hash ^= 
ctx->curr_program->last_variant_hash;
       if (entry) {
          prog = (struct zink_gfx_program*)entry->data;
          for (unsigned i = 0; i < ZINK_GFX_SHADER_COUNT; i++) {
@@ -585,8 +588,6 @@ zink_gfx_program_update(struct zink_context *ctx)
       
simple_mtx_unlock(&ctx->program_lock[zink_program_cache_stages(ctx->shader_stages)]);
       if (prog && prog != ctx->curr_program)
          zink_batch_reference_program(&ctx->batch, &prog->base);
-      if (ctx->curr_program)
-         ctx->gfx_pipeline_state.final_hash ^= 
ctx->curr_program->last_variant_hash;
       ctx->curr_program = prog;
       ctx->gfx_pipeline_state.final_hash ^= 
ctx->curr_program->last_variant_hash;
       ctx->gfx_dirty = false;

Reply via email to