glsl: Add without_array type predicate
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 19 Jul 2014 21:07:18 +0000 (14:07 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 4 Aug 2014 21:40:06 +0000 (14:40 -0700)
Returns the type without any arrays.

This will be used in later patches in this series.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Suggested-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/glsl_types.h

index 50cd655dc76860306fe502af21af5043ed81e434..92578ff47ac13bd06e9ab4bb0da3c6701fcfa0c3 100644 (file)
@@ -464,6 +464,18 @@ struct glsl_type {
       return base_type == GLSL_TYPE_ERROR;
    }
 
+   /**
+    * Get the type stripped of any arrays
+    *
+    * \return
+    * Pointer to the type of elements of the first non-array type for array
+    * types, or pointer to itself for non-array types.
+    */
+   const glsl_type *without_array() const
+   {
+      return this->is_array() ? this->fields.array : this;
+   }
+
    /**
     * Return the amount of atomic counter storage required for a type.
     */