diff options
author | Chia-I Wu <[email protected]> | 2014-08-20 14:40:28 +0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-10-30 02:26:19 -0700 |
commit | a6706163cb539fdb1f0432795d5c24b3e38f5cd7 (patch) | |
tree | 252f090723f4e9c1b419aedd2ac9d27281e70ae2 /src | |
parent | 61c3d493882440d4d8d01a12b7b83fce63d6a7c7 (diff) |
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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 79f849465c3..27e3301e209 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -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); |