mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
glsl: protect anonymous struct id with a mutex
There may be two contexts compiling shaders at the same time, and we want the anonymous struct id to be globally unique. Signed-off-by: Chia-I Wu <olv@lunarg.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
61c3d49388
commit
a6706163cb
1 changed files with 8 additions and 2 deletions
|
|
@ -1350,9 +1350,15 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier,
|
|||
ast_declarator_list *declarator_list)
|
||||
{
|
||||
if (identifier == NULL) {
|
||||
static mtx_t mutex = _MTX_INITIALIZER_NP;
|
||||
static unsigned anon_count = 1;
|
||||
identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count);
|
||||
anon_count++;
|
||||
unsigned count;
|
||||
|
||||
mtx_lock(&mutex);
|
||||
count = anon_count++;
|
||||
mtx_unlock(&mutex);
|
||||
|
||||
identifier = ralloc_asprintf(this, "#anon_struct_%04x", count);
|
||||
}
|
||||
name = identifier;
|
||||
this->declarations.push_degenerate_list_at_head(&declarator_list->link);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue