Add glsl_types::field_index to get the location of a record field
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 10 Jun 2010 00:27:31 +0000 (17:27 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 11 Jun 2010 20:51:42 +0000 (13:51 -0700)
glsl_types.cpp
glsl_types.h

index 9487819..4b6a61a 100644 (file)
@@ -718,3 +718,18 @@ glsl_type::field_type(const char *name) const
 
    return error_type;
 }
+
+
+int
+glsl_type::field_index(const char *name) const
+{
+   if (this->base_type != GLSL_TYPE_STRUCT)
+      return -1;
+
+   for (unsigned i = 0; i < this->length; i++) {
+      if (strcmp(name, this->fields.structure[i].name) == 0)
+        return i;
+   }
+
+   return -1;
+}
index 823897d..3265016 100644 (file)
@@ -356,6 +356,12 @@ struct glsl_type {
 
 
    /**
+    * Get the location of a filed within a record type
+    */
+   int field_index(const char *name) const;
+
+
+   /**
     * Query the number of elements in an array type
     *
     * \return