From ff466be7d8832975ef3ffa58a9f30230a18b6955 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 6 Mar 2024 10:23:43 -0500 Subject: [PATCH] zink: always sync and replace separable progs even with ZINK_DEBUG=noopt this otherwise breaks when shader variants are needed and aren't created cc: mesa-stable Part-of: (cherry picked from commit 5910ce4b86343cf92ddae6d9fd813eb2f8367bc8) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_program.c | 29 +++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 54ad90ffe9f..6c6ba5c3727 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -534,7 +534,7 @@ "description": "zink: always sync and replace separable progs even with ZINK_DEBUG=noopt", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 2a060f46b68..34588801186 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -725,12 +725,14 @@ zink_gfx_program_update_optimal(struct zink_context *ctx) ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; if (entry) { prog = (struct zink_gfx_program*)entry->data; - if (prog->is_separable && !(zink_debug & ZINK_DEBUG_NOOPT)) { + if (prog->is_separable) { /* shader variants can't be handled by separable programs: sync and compile */ if (!ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key)) util_queue_fence_wait(&prog->base.cache_fence); /* If the optimized linked pipeline is done compiling, swap it into place. */ - if (util_queue_fence_is_signalled(&prog->base.cache_fence)) { + if (util_queue_fence_is_signalled(&prog->base.cache_fence) && + /* but only if needed for ZINK_DEBUG=noopt */ + (!(zink_debug & ZINK_DEBUG_NOOPT) || !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key))) { prog = replace_separable_prog(screen, entry, prog); } } @@ -755,19 +757,18 @@ zink_gfx_program_update_optimal(struct zink_context *ctx) /* remove old hash */ ctx->gfx_pipeline_state.optimal_key = zink_sanitize_optimal_key(ctx->gfx_stages, ctx->gfx_pipeline_state.shader_keys_optimal.key.val); ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; - if (ctx->curr_program->is_separable && !(zink_debug & ZINK_DEBUG_NOOPT)) { + if (ctx->curr_program->is_separable && !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key)) { struct zink_gfx_program *prog = ctx->curr_program; - if (!ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key)) { - util_queue_fence_wait(&prog->base.cache_fence); - /* shader variants can't be handled by separable programs: sync and compile */ - perf_debug(ctx, "zink[gfx_compile]: non-default shader variant required with separate shader object program\n"); - struct hash_table *ht = &ctx->program_cache[zink_program_cache_stages(ctx->shader_stages)]; - const uint32_t hash = ctx->gfx_hash; - simple_mtx_lock(&ctx->program_lock[zink_program_cache_stages(ctx->shader_stages)]); - struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(ht, hash, ctx->gfx_stages); - ctx->curr_program = replace_separable_prog(screen, entry, prog); - simple_mtx_unlock(&ctx->program_lock[zink_program_cache_stages(ctx->shader_stages)]); - } + + util_queue_fence_wait(&prog->base.cache_fence); + /* shader variants can't be handled by separable programs: sync and compile */ + perf_debug(ctx, "zink[gfx_compile]: non-default shader variant required with separate shader object program\n"); + struct hash_table *ht = &ctx->program_cache[zink_program_cache_stages(ctx->shader_stages)]; + const uint32_t hash = ctx->gfx_hash; + simple_mtx_lock(&ctx->program_lock[zink_program_cache_stages(ctx->shader_stages)]); + struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(ht, hash, ctx->gfx_stages); + ctx->curr_program = replace_separable_prog(screen, entry, prog); + simple_mtx_unlock(&ctx->program_lock[zink_program_cache_stages(ctx->shader_stages)]); } update_gfx_program_optimal(ctx, ctx->curr_program); /* apply new hash */