glsl: stop copying struct and interface member names

We are currently copying the name for each member dereference
but we can just share a single instance of the string provided
by the type.

This change also stops us recalculating the field index
repeatedly.

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
This commit is contained in:
Timothy Arceri
2017-08-09 13:34:04 +10:00
parent 43cbcbfee9
commit 49d9286a3f
13 changed files with 50 additions and 59 deletions
+7 -7
View File
@@ -88,23 +88,23 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc,
if (deref_var != NULL) {
if (deref_var->var->is_interface_instance()) {
unsigned field_index =
deref_record->record->type->field_index(deref_record->field);
assert(field_index < deref_var->var->get_interface_type()->length);
unsigned field_idx = deref_record->field_idx;
assert(field_idx < deref_var->var->get_interface_type()->length);
int *const max_ifc_array_access =
deref_var->var->get_max_ifc_array_access();
assert(max_ifc_array_access != NULL);
if (idx > max_ifc_array_access[field_index]) {
max_ifc_array_access[field_index] = idx;
if (idx > max_ifc_array_access[field_idx]) {
max_ifc_array_access[field_idx] = idx;
/* Check whether this access will, as a side effect, implicitly
* cause the size of a built-in array to be too large.
*/
check_builtin_array_max_size(deref_record->field, idx+1, *loc,
state);
const char *field_name =
deref_record->record->type->fields.structure[field_idx].name;
check_builtin_array_max_size(field_name, idx+1, *loc, state);
}
}
}