diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 84618dd4521..0fed4794527 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -75,6 +75,7 @@ #include #include +#include "util/simple_mtx.h" #include "main/consts_exts.h" #include "main/shader_types.h" #include "main/shaderobj.h" @@ -97,7 +98,7 @@ using namespace ir_builder; -static mtx_t builtins_lock = _MTX_INITIALIZER_NP; +static simple_mtx_t builtins_lock = SIMPLE_MTX_INITIALIZER; /** * Availability predicates: @@ -1388,7 +1389,7 @@ builtin_builder::builtin_builder() builtin_builder::~builtin_builder() { - mtx_lock(&builtins_lock); + simple_mtx_lock(&builtins_lock); ralloc_free(mem_ctx); mem_ctx = NULL; @@ -1396,7 +1397,7 @@ builtin_builder::~builtin_builder() ralloc_free(shader); shader = NULL; - mtx_unlock(&builtins_lock); + simple_mtx_unlock(&builtins_lock); } ir_function_signature * @@ -8510,20 +8511,20 @@ static uint32_t builtin_users = 0; extern "C" void _mesa_glsl_builtin_functions_init_or_ref() { - mtx_lock(&builtins_lock); + simple_mtx_lock(&builtins_lock); if (builtin_users++ == 0) builtins.initialize(); - mtx_unlock(&builtins_lock); + simple_mtx_unlock(&builtins_lock); } extern "C" void _mesa_glsl_builtin_functions_decref() { - mtx_lock(&builtins_lock); + simple_mtx_lock(&builtins_lock); assert(builtin_users != 0); if (--builtin_users == 0) builtins.release(); - mtx_unlock(&builtins_lock); + simple_mtx_unlock(&builtins_lock); } ir_function_signature * @@ -8531,9 +8532,9 @@ _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state, const char *name, exec_list *actual_parameters) { ir_function_signature *s; - mtx_lock(&builtins_lock); + simple_mtx_lock(&builtins_lock); s = builtins.find(state, name, actual_parameters); - mtx_unlock(&builtins_lock); + simple_mtx_unlock(&builtins_lock); return s; } @@ -8543,7 +8544,7 @@ _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name) { ir_function *f; bool ret = false; - mtx_lock(&builtins_lock); + simple_mtx_lock(&builtins_lock); f = builtins.shader->symbols->get_function(name); if (f != NULL) { foreach_in_list(ir_function_signature, sig, &f->signatures) { @@ -8553,7 +8554,7 @@ _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name) } } } - mtx_unlock(&builtins_lock); + simple_mtx_unlock(&builtins_lock); return ret; } diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 63190eec9dd..65409ddbfd7 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -29,7 +29,7 @@ #include "util/u_string.h" -mtx_t glsl_type::hash_mutex = _MTX_INITIALIZER_NP; +simple_mtx_t glsl_type::hash_mutex = SIMPLE_MTX_INITIALIZER; hash_table *glsl_type::explicit_matrix_types = NULL; hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::struct_types = NULL; @@ -519,20 +519,20 @@ hash_free_type_function(struct hash_entry *entry) void glsl_type_singleton_init_or_ref() { - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); glsl_type_users++; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); } void glsl_type_singleton_decref() { - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); /* Do not release glsl_types if they are still used. */ if (--glsl_type_users) { - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return; } @@ -567,7 +567,7 @@ glsl_type_singleton_decref() glsl_type::subroutine_types = NULL; } - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); } @@ -687,7 +687,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns, snprintf(name, sizeof(name), "%sx%ua%uB%s", bare_type->name, explicit_stride, explicit_alignment, row_major ? "RM" : ""); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (explicit_matrix_types == NULL) { @@ -717,7 +717,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns, const glsl_type *t = (const glsl_type *) entry->data; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } @@ -1241,7 +1241,7 @@ glsl_type::get_array_instance(const glsl_type *base, snprintf(key, sizeof(key), "%p[%u]x%uB", (void *) base, array_size, explicit_stride); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (array_types == NULL) { @@ -1264,7 +1264,7 @@ glsl_type::get_array_instance(const glsl_type *base, glsl_type *t = (glsl_type *) entry->data; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } @@ -1453,7 +1453,7 @@ glsl_type::get_struct_instance(const glsl_struct_field *fields, { const glsl_type key(fields, num_fields, name, packed, explicit_alignment); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (struct_types == NULL) { @@ -1478,7 +1478,7 @@ glsl_type::get_struct_instance(const glsl_struct_field *fields, glsl_type *t = (glsl_type *) entry->data; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } @@ -1493,7 +1493,7 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields, { const glsl_type key(fields, num_fields, packing, row_major, block_name); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (interface_types == NULL) { @@ -1516,7 +1516,7 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields, glsl_type *t = (glsl_type *) entry->data; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } @@ -1526,7 +1526,7 @@ glsl_type::get_subroutine_instance(const char *subroutine_name) { const glsl_type key(subroutine_name); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (subroutine_types == NULL) { @@ -1547,7 +1547,7 @@ glsl_type::get_subroutine_instance(const char *subroutine_name) glsl_type *t = (glsl_type *) entry->data; - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } @@ -1582,7 +1582,7 @@ glsl_type::get_function_instance(const glsl_type *return_type, { const glsl_type key(return_type, params, num_params); - mtx_lock(&glsl_type::hash_mutex); + simple_mtx_lock(&glsl_type::hash_mutex); assert(glsl_type_users > 0); if (function_types == NULL) { @@ -1602,7 +1602,7 @@ glsl_type::get_function_instance(const glsl_type *return_type, assert(t->base_type == GLSL_TYPE_FUNCTION); assert(t->length == num_params); - mtx_unlock(&glsl_type::hash_mutex); + simple_mtx_unlock(&glsl_type::hash_mutex); return t; } diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index ecd2fb88def..8f584705d43 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -34,6 +34,7 @@ #include "util/blob.h" #include "util/format/u_format.h" #include "util/macros.h" +#include "util/simple_mtx.h" #ifdef __cplusplus #include "mesa/main/config.h" @@ -1289,7 +1290,7 @@ public: private: - static mtx_t hash_mutex; + static simple_mtx_t hash_mutex; /** * ralloc context for the type itself.