From: Eric Anholt Date: Wed, 9 Sep 2020 17:21:49 +0000 (-0700) Subject: nir/nir_lower_uniforms_to_ubo: Set better alignments on our new instructions. X-Git-Tag: upstream/21.0.0~4792 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffbfc1ec0eb9190e8e7fa099631917e2987db325;p=platform%2Fupstream%2Fmesa.git nir/nir_lower_uniforms_to_ubo: Set better alignments on our new instructions. The change on freedreno is in the noise. Reviewed-by: Rob Clark Part-of: --- diff --git a/src/compiler/nir/nir_lower_uniforms_to_ubo.c b/src/compiler/nir/nir_lower_uniforms_to_ubo.c index 4d1a5a7..47e92fa 100644 --- a/src/compiler/nir/nir_lower_uniforms_to_ubo.c +++ b/src/compiler/nir/nir_lower_uniforms_to_ubo.c @@ -69,7 +69,24 @@ lower_instr(nir_intrinsic_instr *instr, nir_builder *b, int multiplier) load->src[0] = nir_src_for_ssa(ubo_idx); load->src[1] = nir_src_for_ssa(ubo_offset); assert(instr->dest.ssa.bit_size >= 8); - nir_intrinsic_set_align(load, instr->dest.ssa.bit_size / 8, 0); + + /* If it's const, set the alignment to our known constant offset. If + * not, set it to a pessimistic value based on the multiplier (or the + * scalar size, for qword loads). + * + * We could potentially set up stricter alignments for indirects by + * knowing what features are enabled in the APIs (see comment in + * nir_lower_ubo_vec4.c) + */ + if (nir_src_is_const(instr->src[0])) { + nir_intrinsic_set_align(load, NIR_ALIGN_MUL_MAX, + (nir_src_as_uint(instr->src[0]) + + nir_intrinsic_base(instr) * multiplier) % + NIR_ALIGN_MUL_MAX); + } else { + nir_intrinsic_set_align(load, MAX2(multiplier, + instr->dest.ssa.bit_size / 8), 0); + } nir_ssa_dest_init(&load->instr, &load->dest, load->num_components, instr->dest.ssa.bit_size, instr->dest.ssa.name);