Add utility function to get the name of a shader target
[mesa.git] / glsl_types.h
index 6c9444cbe169c45b05ddfbad23708a441fd5fda2..33b1c98158d08aad30a4b6a155689c98a06a4e84 100644 (file)
@@ -163,6 +163,18 @@ struct glsl_type {
     */
    const glsl_type *get_base_type() const;
 
+   /**
+    * Query the type of elements in an array
+    *
+    * \return
+    * Pointer to the type of elements in the array for array types, or \c NULL
+    * for non-array types.
+    */
+   const glsl_type *element_type() const
+   {
+      return is_array() ? fields.array : NULL;
+   }
+
    /**
     * Get the instance of a built-in scalar, vector, or matrix type
     */
@@ -308,6 +320,19 @@ struct glsl_type {
         : error_type;
    }
 
+   /**
+    * Query the number of elements in an array type
+    *
+    * \return
+    * The number of elements in the array for array types or -1 for non-array
+    * types.  If the number of elements in the array has not yet been declared,
+    * zero is returned.
+    */
+   int array_size() const
+   {
+      return is_array() ? length : -1;
+   }
+
 private:
    /**
     * Constructor for array types