freedreno: Take a lock around shader variant creation.
Shaders are shared across contexts in gallium (part of making it so that you get shader compile at link time, for shader-db and to reduce compiles at draw time). So, we need to protect from variant creation for a shader from multiple threads at the same time. Reviewed-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:
parent
6e3b220ad3
commit
6f0521b78c
|
@ -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;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#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);
|
||||
|
|
Loading…
Reference in New Issue