From 2611dc106af3a2b65e750a7267adc5d7f3e7bcf4 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 4 Dec 2024 17:25:01 +0100 Subject: [PATCH] pan/bi: Disallow non-zero .{range,base} on load_push_constant instructions There seems to be several lowering pass that don't take the base/range into account, like nir_lower_mem_access_bit_sizes(). This caused issues when we tried using it on push_constants to make sure accesses are 32-bit aligned, so let's make sure the frontend is propagating the base to the offset, and assigns range to zero (AKA undefined). Signed-off-by: Boris Brezillon Reviewed-by: Chia-I Wu Reviewed-by: Mary Guillemard Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/compiler/bifrost_compile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index 0daed066733..e04f28f5c9f 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -1217,8 +1217,10 @@ bi_emit_load_push_constant(bi_builder *b, nir_intrinsic_instr *instr) assert(b->shader->inputs->no_ubo_to_push && "can't mix push constant forms"); nir_src *offset = &instr->src[0]; + assert(!nir_intrinsic_base(instr) && "base must be zero"); + assert(!nir_intrinsic_range(instr) && "range must be zero"); assert(nir_src_is_const(*offset) && "no indirect push constants"); - uint32_t base = nir_intrinsic_base(instr) + nir_src_as_uint(*offset); + uint32_t base = nir_src_as_uint(*offset); assert((base & 3) == 0 && "unaligned push constants"); unsigned bits = instr->def.bit_size * instr->def.num_components;