[Mesa-dev] [PATCH 2/9] glsl: add dimension_count to glsl_types
Timothy Arceri
t_arceri at yahoo.com.au
Wed Jan 15 22:27:23 PST 2014
Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
src/glsl/glsl_types.cpp | 15 +++++++++++----
src/glsl/glsl_types.h | 17 ++++++++++++++++-
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 12d4ac0..1c9add7 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -277,12 +277,13 @@ _mesa_glsl_release_types(void)
}
-glsl_type::glsl_type(const glsl_type *array, unsigned length) :
+glsl_type::glsl_type(const glsl_type *array, unsigned length,
+ unsigned dimension_count) :
base_type(GLSL_TYPE_ARRAY),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
sampler_type(0), interface_packing(0),
vector_elements(0), matrix_columns(0),
- name(NULL), length(length)
+ name(NULL), length(length), dimension_count(dimension_count)
{
this->fields.array = array;
/* Inherit the gl type of the base. The GL type is used for
@@ -416,10 +417,16 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
return error_type;
}
-
const glsl_type *
glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
{
+ return get_array_instance(base, array_size, 1);
+}
+
+const glsl_type *
+glsl_type::get_array_instance(const glsl_type *base, unsigned array_size,
+ unsigned dimension_count)
+{
if (array_types == NULL) {
array_types = hash_table_ctor(64, hash_table_string_hash,
@@ -436,7 +443,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
const glsl_type *t = (glsl_type *) hash_table_find(array_types, key);
if (t == NULL) {
- t = new glsl_type(base, array_size);
+ t = new glsl_type(base, array_size, dimension_count);
hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
}
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index fb7c928..e047a16 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -146,6 +146,12 @@ struct glsl_type {
unsigned length;
/**
+ * For \c GLSL_TYPE_ARRAY, this is how many dimensions the array
+ * contains.
+ */
+ unsigned dimension_count;
+
+ /**
* Subtype of composite data types.
*/
union {
@@ -223,6 +229,14 @@ struct glsl_type {
unsigned elements);
/**
+ * Get the instance of an array type include dimension count
+ * for arrays of arrays
+ */
+ static const glsl_type *get_array_instance(const glsl_type *base,
+ unsigned elements,
+ unsigned dimension_count);
+
+ /**
* Get the instance of a record type
*/
static const glsl_type *get_record_instance(const glsl_struct_field *fields,
@@ -571,7 +585,8 @@ private:
enum glsl_interface_packing packing, const char *name);
/** Constructor for array types */
- glsl_type(const glsl_type *array, unsigned length);
+ glsl_type(const glsl_type *array, unsigned length,
+ unsigned dimension_count);
/** Hash table containing the known array types. */
static struct hash_table *array_types;
--
1.8.3.1
More information about the mesa-dev
mailing list