mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
glsl: Generated masked write instead of vector array index for UBO lowering
When reading a column from a row-major matrix, we would slot the single value read into the vector using an ir_dereference_array of the vector with a constant index. This will (eventually) get optimized to a masked-write, so just generate the masked write in the first place. v2: Remove unused variable 'chan'. Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Cc: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
65cc68f430
commit
e0131196ca
1 changed files with 3 additions and 7 deletions
|
|
@ -356,18 +356,14 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
|
||||||
unsigned matrix_stride = 16;
|
unsigned matrix_stride = 16;
|
||||||
|
|
||||||
for (unsigned i = 0; i < deref->type->vector_elements; i++) {
|
for (unsigned i = 0; i < deref->type->vector_elements; i++) {
|
||||||
ir_rvalue *chan = new(mem_ctx) ir_constant((int)i);
|
|
||||||
ir_dereference *deref_chan =
|
|
||||||
new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
|
|
||||||
chan);
|
|
||||||
|
|
||||||
ir_rvalue *chan_offset =
|
ir_rvalue *chan_offset =
|
||||||
add(base_offset,
|
add(base_offset,
|
||||||
new(mem_ctx) ir_constant(deref_offset + i * matrix_stride));
|
new(mem_ctx) ir_constant(deref_offset + i * matrix_stride));
|
||||||
|
|
||||||
base_ir->insert_before(assign(deref_chan,
|
base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
|
||||||
ubo_load(glsl_type::float_type,
|
ubo_load(glsl_type::float_type,
|
||||||
chan_offset)));
|
chan_offset),
|
||||||
|
(1U << i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue