Mesa (master): freedreno/ir3: use uniform base

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 3 21:14:01 UTC 2019


Module: Mesa
Branch: master
Commit: 1ef459297c7208ff6279557ccfd0dc702f8f99e1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ef459297c7208ff6279557ccfd0dc702f8f99e1

Author: Rob Clark <robdclark at chromium.org>
Date:   Thu Aug  8 14:31:50 2019 -0700

freedreno/ir3: use uniform base

When lowering from ubo, use the constant base field in the load_uniform
instruction for the constant part of the offset.  Doesn't change much
for constant indexing, but this will help for indirect indexing because
constant-folding can't completely clean up the result.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
index b3191a36c14..06c1c2212f2 100644
--- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
+++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
@@ -108,20 +108,20 @@ lower_ubo_load_to_uniform(nir_intrinsic_instr *instr, nir_builder *b,
 
 	nir_ssa_def *ubo_offset = nir_ssa_for_src(b, instr->src[1], 1);
 	nir_ssa_def *new_offset = ir3_nir_try_propagate_bit_shift(b, ubo_offset, -2);
+	nir_ssa_def *uniform_offset;
 	if (new_offset)
-		ubo_offset = new_offset;
+		uniform_offset = new_offset;
 	else
-		ubo_offset = nir_ushr(b, ubo_offset, nir_imm_int(b, 2));
+		uniform_offset = nir_ushr(b, ubo_offset, nir_imm_int(b, 2));
 
 	const int range_offset =
 		(state->range[block].offset - state->range[block].start) / 4;
-	nir_ssa_def *uniform_offset =
-		nir_iadd(b, ubo_offset, nir_imm_int(b, range_offset));
 
 	nir_intrinsic_instr *uniform =
 		nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_uniform);
 	uniform->num_components = instr->num_components;
 	uniform->src[0] = nir_src_for_ssa(uniform_offset);
+	nir_intrinsic_set_base(uniform, range_offset);
 	nir_ssa_dest_init(&uniform->instr, &uniform->dest,
 					  uniform->num_components, instr->dest.ssa.bit_size,
 					  instr->dest.ssa.name);




More information about the mesa-commit mailing list