Mesa (master): glsl: protect anonymous struct id with a mutex
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu Oct 30 09:30:11 UTC 2014
Module: Mesa
Branch: master
Commit: a6706163cb539fdb1f0432795d5c24b3e38f5cd7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6706163cb539fdb1f0432795d5c24b3e38f5cd7
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Wed Aug 20 14:40:28 2014 +0800
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 at lunarg.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/glsl_parser_extras.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 79f8494..27e3301 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);
More information about the mesa-commit
mailing list