From 84bb6078f44a8518bd7080ae2362ae1a8a6383c8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 27 Jun 2023 12:54:47 -0400 Subject: [PATCH] zink: do initial program unref during program creation this ensures that programs are never created with more than $num_shaders refs, which is otherwise not necessarily a bug but can lead to bugs Fixes: a0e69e7601a ("zink: split out first-time shader module creation") Part-of: --- src/gallium/drivers/zink/zink_program.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 86fd636f28a..b83358a59c3 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -446,7 +446,6 @@ generate_gfx_program_modules(struct zink_context *ctx, struct zink_screen *scree variant_hash ^= prog->module_hash[i]; } - p_atomic_dec(&prog->base.reference.count); state->modules_changed = true; prog->last_variant_hash = variant_hash; @@ -469,7 +468,6 @@ generate_gfx_program_modules_optimal(struct zink_context *ctx, struct zink_scree prog->objects[i] = zm->obj.obj; } - p_atomic_dec(&prog->base.reference.count); state->modules_changed = true; prog->last_variant_hash = state->shader_keys_optimal.key.val; } @@ -1136,6 +1134,7 @@ zink_create_gfx_program(struct zink_context *ctx, } } _mesa_sha1_final(&sctx, prog->base.sha1); + p_atomic_dec(&prog->base.reference.count); if (!zink_descriptor_program_init(ctx, &prog->base)) goto fail;