summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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