summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-08-09 13:34:04 +1000
committerTimothy Arceri <[email protected]>2017-08-11 10:43:21 +1000
commit49d9286a3f79800a94ddcffbe96a8894273db6d9 (patch)
tree1e5c6ee3530eeb1458f687d58c9b0db96510cb59 /src/mesa
parent43cbcbfee9ab4a6aa1fbb51a1af7fd9619d3b7f5 (diff)
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 <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/program/ir_to_mesa.cpp6
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp34
2 files changed, 19 insertions, 21 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index db7f11c6bf2..96b06621b58 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1602,8 +1602,9 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir)
ir->record->accept(this);
+ assert(ir->field_idx >= 0);
for (i = 0; i < struct_type->length; i++) {
- if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0)
+ if (i == (unsigned) ir->field_idx)
break;
offset += type_size(struct_type->fields.structure[i].type);
}
@@ -1684,8 +1685,7 @@ calc_sampler_offsets(struct gl_shader_program *prog, ir_dereference *deref,
case ir_type_dereference_record: {
ir_dereference_record *deref_record = deref->as_dereference_record();
- unsigned field_index =
- deref_record->record->type->field_index(deref_record->field);
+ unsigned field_index = deref_record->field_idx;
*location +=
deref_record->record->type->record_location_offset(field_index);
calc_sampler_offsets(prog, deref_record->record->as_dereference(),
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index aaa5cddcf3e..bada7f4ea80 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2927,8 +2927,9 @@ glsl_to_tgsi_visitor::visit(ir_dereference_record *ir)
ir->record->accept(this);
+ assert(ir->field_idx >= 0);
for (i = 0; i < struct_type->length; i++) {
- if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0)
+ if (i == (unsigned) ir->field_idx)
break;
offset += type_size(struct_type->fields.structure[i].type);
}
@@ -3784,23 +3785,20 @@ get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
switch (ir->ir_type) {
case ir_type_dereference_record: {
ir_dereference_record *deref_record = ir->as_dereference_record();
- const glsl_type *struct_type = deref_record->record->type;
- for (unsigned i = 0; i < struct_type->length; i++) {
- if (!strcmp(struct_type->fields.structure[i].name,
- deref_record->field)) {
- *type = struct_type->fields.structure[i].type->without_array();
- *memory_coherent =
- struct_type->fields.structure[i].memory_coherent;
- *memory_volatile =
- struct_type->fields.structure[i].memory_volatile;
- *memory_restrict =
- struct_type->fields.structure[i].memory_restrict;
- *image_format =
- struct_type->fields.structure[i].image_format;
- break;
- }
- }
+ *type = deref_record->type;
+
+ const glsl_type *struct_type =
+ deref_record->record->type->without_array();
+ int fild_idx = deref_record->field_idx;
+ *memory_coherent =
+ struct_type->fields.structure[fild_idx].memory_coherent;
+ *memory_volatile =
+ struct_type->fields.structure[fild_idx].memory_volatile;
+ *memory_restrict =
+ struct_type->fields.structure[fild_idx].memory_restrict;
+ *image_format =
+ struct_type->fields.structure[fild_idx].image_format;
break;
}
@@ -4128,7 +4126,7 @@ glsl_to_tgsi_visitor::calc_deref_offsets(ir_dereference *tail,
case ir_type_dereference_record: {
ir_dereference_record *deref_record = tail->as_dereference_record();
const glsl_type *struct_type = deref_record->record->type;
- int field_index = deref_record->record->type->field_index(deref_record->field);
+ int field_index = deref_record->field_idx;
calc_deref_offsets(deref_record->record->as_dereference(), array_elements, index, indirect, location);