Add glsl_types::field_index to get the location of a record field

This commit is contained in:
Ian Romanick
2010-06-09 17:27:31 -07:00
parent ab92d0e53e
commit eeedd355cf
2 changed files with 21 additions and 0 deletions
+15
View 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;
}
+6
View File
@@ -355,6 +355,12 @@ struct glsl_type {
const glsl_type *field_type(const char *name) const;
/**
* 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
*