aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/glsl_types.h
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl/glsl_types.h')
-rw-r--r--mesalib/src/glsl/glsl_types.h33
1 files changed, 20 insertions, 13 deletions
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index eeb14c274..474b12914 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -122,16 +122,18 @@ struct glsl_type {
* easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
static void* operator new(size_t size)
{
- if (glsl_type::mem_ctx == NULL) {
- glsl_type::mem_ctx = ralloc_context(NULL);
- assert(glsl_type::mem_ctx != NULL);
- }
+ mtx_lock(&glsl_type::mutex);
+
+ /* mem_ctx should have been created by the static members */
+ assert(glsl_type::mem_ctx != NULL);
void *type;
type = ralloc_size(glsl_type::mem_ctx, size);
assert(type != NULL);
+ mtx_unlock(&glsl_type::mutex);
+
return type;
}
@@ -139,7 +141,9 @@ struct glsl_type {
* ralloc_free in that case. */
static void operator delete(void *type)
{
+ mtx_lock(&glsl_type::mutex);
ralloc_free(type);
+ mtx_unlock(&glsl_type::mutex);
}
/**
@@ -149,18 +153,11 @@ struct glsl_type {
* these will be 0.
*/
/*@{*/
- unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
- unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
+ uint8_t vector_elements; /**< 1, 2, 3, or 4 vector elements. */
+ uint8_t matrix_columns; /**< 1, 2, 3, or 4 matrix columns. */
/*@}*/
/**
- * Name of the data type
- *
- * Will never be \c NULL.
- */
- const char *name;
-
- /**
* For \c GLSL_TYPE_ARRAY, this is the length of the array. For
* \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
* elements in the structure and the number of values pointed to by
@@ -169,6 +166,13 @@ struct glsl_type {
unsigned length;
/**
+ * Name of the data type
+ *
+ * Will never be \c NULL.
+ */
+ const char *name;
+
+ /**
* Subtype of composite data types.
*/
union {
@@ -618,6 +622,9 @@ struct glsl_type {
bool record_compare(const glsl_type *b) const;
private:
+
+ static mtx_t mutex;
+
/**
* ralloc context for all glsl_type allocations
*