From efbbdeffc09eb0555829c0411d06170537a4d80c Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 26 May 2023 13:43:05 -0700 Subject: [PATCH] compiler/types: Be consistent when naming array element/size The element type passed is different than the array type and it is not a "base type" in the glsl_type sense, so pick a name that reflects that. Also stick to a single name for the array_size. Just renames, no behavior change. Reviewed-by: Jesse Natalie Reviewed-by: Ian Romanick Part-of: --- src/compiler/glsl_types.cpp | 9 ++++----- src/compiler/glsl_types.h | 4 ++-- src/compiler/nir_types.cpp | 4 ++-- src/compiler/nir_types.h | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index adfa8d8f6fb..2447f371e0e 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -1231,7 +1231,7 @@ glsl_type::get_image_instance(enum glsl_sampler_dim dim, } const glsl_type * -glsl_type::get_array_instance(const glsl_type *base, +glsl_type::get_array_instance(const glsl_type *element, unsigned array_size, unsigned explicit_stride) { @@ -1241,7 +1241,7 @@ glsl_type::get_array_instance(const glsl_type *base, * named 'foo'. */ char key[128]; - snprintf(key, sizeof(key), "%p[%u]x%uB", (void *) base, array_size, + snprintf(key, sizeof(key), "%p[%u]x%uB", (void *) element, array_size, explicit_stride); simple_mtx_lock(&glsl_type::hash_mutex); @@ -1254,7 +1254,7 @@ glsl_type::get_array_instance(const glsl_type *base, const struct hash_entry *entry = _mesa_hash_table_search(array_types, key); if (entry == NULL) { - const glsl_type *t = new glsl_type(base, array_size, explicit_stride); + const glsl_type *t = new glsl_type(element, array_size, explicit_stride); entry = _mesa_hash_table_insert(array_types, strdup(key), @@ -1263,7 +1263,7 @@ glsl_type::get_array_instance(const glsl_type *base, assert(((glsl_type *) entry->data)->base_type == GLSL_TYPE_ARRAY); assert(((glsl_type *) entry->data)->length == array_size); - assert(((glsl_type *) entry->data)->fields.array == base); + assert(((glsl_type *) entry->data)->fields.array == element); glsl_type *t = (glsl_type *) entry->data; @@ -1447,7 +1447,6 @@ glsl_type::record_key_hash(const void *a) return retval; } - const glsl_type * glsl_type::get_struct_instance(const glsl_struct_field *fields, unsigned num_fields, diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 05924fa20bb..10b94a959c7 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -479,8 +479,8 @@ public: /** * Get the instance of an array type */ - static const glsl_type *get_array_instance(const glsl_type *base, - unsigned elements, + static const glsl_type *get_array_instance(const glsl_type *element, + unsigned array_size, unsigned explicit_stride = 0); /** diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index eb5a2d0a2c3..8a59b064383 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -649,10 +649,10 @@ glsl_explicit_matrix_type(const glsl_type *mat, } const glsl_type * -glsl_array_type(const glsl_type *base, unsigned elements, +glsl_array_type(const glsl_type *element, unsigned array_size, unsigned explicit_stride) { - return glsl_type::get_array_instance(base, elements, explicit_stride); + return glsl_type::get_array_instance(element, array_size, explicit_stride); } const glsl_type * diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index c2825aa5e4b..11f32f3a5f9 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -205,8 +205,8 @@ const struct glsl_type *glsl_explicit_matrix_type(const struct glsl_type *mat, unsigned stride, bool row_major); -const struct glsl_type *glsl_array_type(const struct glsl_type *base, - unsigned elements, +const struct glsl_type *glsl_array_type(const struct glsl_type *element, + unsigned array_size, unsigned explicit_stride); const struct glsl_type *glsl_struct_type(const struct glsl_struct_field *fields,