diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index f366332c303..bbe27ce4dbb 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -239,6 +239,7 @@ struct ir3_shader_variant * ir3_shader_get_variant(struct ir3_shader *shader, struct ir3_shader_key *key, bool binning_pass, bool *created) { + mtx_lock(&shader->variants_lock); struct ir3_shader_variant *v = shader_variant(shader, key, created); @@ -247,8 +248,10 @@ ir3_shader_get_variant(struct ir3_shader *shader, struct ir3_shader_key *key, v->binning = create_variant(shader, key, true); *created = true; } + mtx_unlock(&shader->variants_lock); return v->binning; } + mtx_unlock(&shader->variants_lock); return v; } @@ -264,6 +267,7 @@ ir3_shader_destroy(struct ir3_shader *shader) } free(shader->const_state.immediates); ralloc_free(shader->nir); + mtx_destroy(&shader->variants_lock); free(shader); } @@ -272,6 +276,7 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir) { struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader); + mtx_init(&shader->variants_lock, mtx_plain); shader->compiler = compiler; shader->id = ++shader->compiler->shader_count; shader->type = nir->info.stage; diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index b3291896f4d..77e40a71b5c 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -29,6 +29,7 @@ #include +#include "c11/threads.h" #include "compiler/shader_enums.h" #include "compiler/nir/nir.h" #include "util/bitscan.h" @@ -544,6 +545,7 @@ struct ir3_shader { struct ir3_stream_output_info stream_output; struct ir3_shader_variant *variants; + mtx_t variants_lock; }; void * ir3_shader_assemble(struct ir3_shader_variant *v, uint32_t gpu_id);