[Mesa-dev] [PATCH 04/16] glsl: Add is_{matrix, record, interface}_or_array_of predicates

Ian Romanick idr at freedesktop.org
Mon Jul 21 14:04:20 PDT 2014


From: Ian Romanick <ian.d.romanick at intel.com>

There are a bunch of places, especially in the UBO code, where we check
whether something is a matrix (or record) when we actually want to know
if it a matrix or an array of matrices (ditto for records).

This will be used in later patches in this series.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/glsl_types.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 0b63d48..2dfa8dd 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -354,6 +354,14 @@ struct glsl_type {
    }
 
    /**
+    * Query whether or not a type is a matrix or an array of matrices
+    */
+   bool is_matrix_or_array_of() const
+   {
+      return is_matrix() || (is_array() && fields.array->is_matrix());
+   }
+
+   /**
     * Query whether or not a type is a non-array numeric type
     */
    bool is_numeric() const
@@ -441,6 +449,14 @@ struct glsl_type {
    }
 
    /**
+    * Query whether or not a type is a record or an array of records
+    */
+   bool is_record_or_array_of() const
+   {
+      return is_record() || (is_array() && fields.array->is_record());
+   }
+
+   /**
     * Query whether or not a type is an interface
     */
    bool is_interface() const
@@ -449,6 +465,14 @@ struct glsl_type {
    }
 
    /**
+    * Query whether or not a type is an interface or an array of interfaces
+    */
+   bool is_interface_or_array_of() const
+   {
+      return is_interface() || (is_array() && fields.array->is_interface());
+   }
+
+   /**
     * Query whether or not a type is the void type singleton.
     */
    bool is_void() const
-- 
1.8.1.4



More information about the mesa-dev mailing list