diff options
author | Timothy Arceri <[email protected]> | 2017-08-09 13:34:04 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-08-11 10:43:21 +1000 |
commit | 49d9286a3f79800a94ddcffbe96a8894273db6d9 (patch) | |
tree | 1e5c6ee3530eeb1458f687d58c9b0db96510cb59 /src/mesa/program/ir_to_mesa.cpp | |
parent | 43cbcbfee9ab4a6aa1fbb51a1af7fd9619d3b7f5 (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/program/ir_to_mesa.cpp')
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 6 |
1 files changed, 3 insertions, 3 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(), |