[Mesa-dev] [PATCH 2/6] glsl: add function to return outermost array type
Timothy Arceri
t_arceri at yahoo.com.au
Mon May 12 04:16:28 PDT 2014
This will avoid a bunch of code when implementing arrays of arrays
support.
Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
src/glsl/glsl_types.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index dca5492..51147e9 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -213,6 +213,22 @@ struct glsl_type {
}
/**
+ * Query the type of the outermost elements in a single or
+ * multi dimension array
+ *
+ * \return
+ * Pointer to the type of elements in the outermost array for array types,
+ * or pointer to itself for non-array types.
+ */
+ const glsl_type *outermost_element_type() const
+ {
+ if (is_array())
+ return fields.array->outermost_element_type();
+ else
+ return this;
+ }
+
+ /**
* Get the instance of a built-in scalar, vector, or matrix type
*/
static const glsl_type *get_instance(unsigned base_type, unsigned rows,
--
1.9.0
More information about the mesa-dev
mailing list