summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2022-08-01 15:08:48 -0400
committerDylan Baker <dylan.c.baker@intel.com>2022-08-10 14:16:10 -0700
commitbbcb6f8e06900cd090b2335f6d2f19357cb47c37 (patch)
treed5084ceef6ec9bd50d19afaff7ee1d45314b58d7
parent6be4fee6a6f8e665017ab09307c974eb134299d4 (diff)
downloadmesa-bbcb6f8e06900cd090b2335f6d2f19357cb47c37.tar.gz
zink: fix gfx program cache pruning with generated tcs
if the tcs was generated, then the prgram was added to the non-tcs cache, which means deleting it from the tcs+tes cache will fail and then context_destroy will explode Fixes: 4123ee3c714 ("zink: invoke descriptor_program_deinit for programs on context destroy") Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17866> (cherry picked from commit c7ef4f97350900fb6f9b05e1d1ec4e695033f0f9)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/zink/zink_compiler.c8
-rw-r--r--src/gallium/drivers/zink/zink_context.c2
3 files changed, 10 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json
index b931f2f0efb..ad1c946b360 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3487,7 +3487,7 @@
"description": "zink: fix gfx program cache pruning with generated tcs",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "4123ee3c71461d7d045fec519130128a7fc4e643"
},
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index ed532b58b4d..d5ad17f5408 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -2250,7 +2250,13 @@ zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
enum pipe_shader_type pstage = pipe_shader_type_from_mesa(shader->nir->info.stage);
assert(pstage < ZINK_SHADER_COUNT);
if (!prog->base.removed && (shader->nir->info.stage != MESA_SHADER_TESS_CTRL || !shader->is_generated)) {
- _mesa_hash_table_remove_key(&ctx->program_cache[prog->stages_present >> 2], prog->shaders);
+ unsigned stages_present = prog->stages_present;
+ if (prog->shaders[PIPE_SHADER_TESS_CTRL] && prog->shaders[PIPE_SHADER_TESS_CTRL]->is_generated)
+ stages_present &= ~BITFIELD_BIT(PIPE_SHADER_TESS_CTRL);
+ struct hash_table *ht = &ctx->program_cache[stages_present >> 2];
+ struct hash_entry *he = _mesa_hash_table_search(ht, prog->shaders);
+ assert(he);
+ _mesa_hash_table_remove(ht, he);
prog->base.removed = true;
}
if (shader->nir->info.stage != MESA_SHADER_TESS_CTRL || !shader->is_generated)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 7d968973c82..50dae1b1441 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -102,11 +102,13 @@ zink_context_destroy(struct pipe_context *pctx)
for (unsigned i = 0; i < ARRAY_SIZE(ctx->program_cache); i++) {
hash_table_foreach(&ctx->program_cache[i], entry) {
struct zink_program *pg = entry->data;
+ pg->removed = true;
screen->descriptor_program_deinit(ctx, pg);
}
}
hash_table_foreach(&ctx->compute_program_cache, entry) {
struct zink_program *pg = entry->data;
+ pg->removed = true;
screen->descriptor_program_deinit(ctx, pg);
}