From 9f094cdeaf40d45161a1519788ed8f38e4a629fa Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 4 Sep 2024 15:45:39 +0200 Subject: [PATCH] panvk: Fix valhall_pack_buf_idx() The descriptor lowering pass can add UBO loads to read descriptors, and these loads already assume a nir_address_format_32bit_index_offset format. Bail out if we detect that case in valhall_pack_buf_idx(). Reported-by: Erik Faye-Lund Fixes: 27beadcbdb51 ("panvk: Extend the shader logic to support Valhall") Signed-off-by: Boris Brezillon Reviewed-by: Rebecca Mckeever Reviewed-by: Mary Guillemard Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: John Anthony Acked-by: Erik Faye-Lund Part-of: --- src/panfrost/vulkan/panvk_vX_shader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index 0c794996e47..22323fad4a6 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -387,9 +387,15 @@ valhall_pack_buf_idx(nir_builder *b, nir_instr *instr, UNUSED void *data) intrin->intrinsic != nir_intrinsic_load_ssbo) return false; - b->cursor = nir_before_instr(&intrin->instr); nir_def *index = intrin->src[0].ssa; + /* The descriptor lowering pass can add UBO loads, and those already have the + * right index format. */ + if (index->num_components == 1) + return false; + + b->cursor = nir_before_instr(&intrin->instr); + /* The valhall backend expects nir_address_format_32bit_index_offset, * but address mode is nir_address_format_vec2_index_32bit_offset to allow * us to store the array size, set and index without losing information