summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-06-09 17:27:31 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-06-11 13:51:42 -0700
commiteeedd355cfc2f0c578282657bd4259440a88742c (patch)
tree108af2b7b65b7e2edfec2f13950a3eca77ab0925
parentab92d0e53eab9030742e5e6d938a5739e549f16c (diff)
Add glsl_types::field_index to get the location of a record field
-rw-r--r--glsl_types.cpp15
-rw-r--r--glsl_types.h6
2 files changed, 21 insertions, 0 deletions
diff --git a/glsl_types.cpp b/glsl_types.cpp
index 9487819a44..4b6a61a13c 100644
--- a/glsl_types.cpp
+++ b/glsl_types.cpp
@@ -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;
+}
diff --git a/glsl_types.h b/glsl_types.h
index 823897df4a..3265016146 100644
--- a/glsl_types.h
+++ b/glsl_types.h
@@ -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