summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2019-07-31 12:00:47 +0300
committerLionel Landwerlin <[email protected]>2019-08-21 09:44:10 +0200
commit9f37bc419cb842bee902eb3117a20b7a57d64381 (patch)
treef074b4ef348119d75aedb9f4ec0c0b4f57d9c54f /src/compiler
parent8b913bd1ce6f67c89bd3c6e644db6882544351b6 (diff)
compiler: ensure glsl types are not created without a reference
We want to detect invalid refcounting so assert we have at least one use before creating types. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl_types.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 943ab020487..2213055021d 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -486,7 +486,6 @@ void
glsl_type_singleton_decref()
{
mtx_lock(&glsl_type::hash_mutex);
-
assert(glsl_type_users > 0);
/* Do not release glsl_types if they are still used. */
@@ -639,6 +638,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns,
explicit_stride, row_major ? "RM" : "");
mtx_lock(&glsl_type::hash_mutex);
+ assert(glsl_type_users > 0);
if (explicit_matrix_types == NULL) {
explicit_matrix_types =
@@ -1004,6 +1004,7 @@ glsl_type::get_array_instance(const glsl_type *base,
explicit_stride);
mtx_lock(&glsl_type::hash_mutex);
+ assert(glsl_type_users > 0);
if (array_types == NULL) {
array_types = _mesa_hash_table_create(NULL, _mesa_key_hash_string,
@@ -1204,6 +1205,7 @@ glsl_type::get_struct_instance(const glsl_struct_field *fields,
const glsl_type key(fields, num_fields, name, packed);
mtx_lock(&glsl_type::hash_mutex);
+ assert(glsl_type_users > 0);
if (struct_types == NULL) {
struct_types = _mesa_hash_table_create(NULL, record_key_hash,
@@ -1239,6 +1241,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);
+ assert(glsl_type_users > 0);
if (interface_types == NULL) {
interface_types = _mesa_hash_table_create(NULL, record_key_hash,
@@ -1269,6 +1272,7 @@ glsl_type::get_subroutine_instance(const char *subroutine_name)
const glsl_type key(subroutine_name);
mtx_lock(&glsl_type::hash_mutex);
+ assert(glsl_type_users > 0);
if (subroutine_types == NULL) {
subroutine_types = _mesa_hash_table_create(NULL, record_key_hash,
@@ -1322,6 +1326,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);
+ assert(glsl_type_users > 0);
if (function_types == NULL) {
function_types = _mesa_hash_table_create(NULL, function_key_hash,