From c58ba21ba80de27565d2a703d0a8b6cdc3ef5696 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Mon, 10 Mar 2025 14:59:24 +0100 Subject: [PATCH] ir3: keep inputs at start block when creating empty preamble It is expected that inputs and prefetches are always in the first block. However, ir3_create_empty_preamble would create blocks before the first one, leaving inputs after the preamble. This causes issues with (probably among others) spilling/RA where precolored inputs could illegally reuse the spill base register. Fixes RA validation failures on a7xx for dEQP-VK.ray_query.multiple_ray_queries.vertex_shader Signed-off-by: Job Noorman Fixes: f3026b3d3e6 ("ir3: add some preamble helpers") Part-of: --- src/freedreno/ir3/ir3.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c index c1e16ffc0b0..7549f8352ce 100644 --- a/src/freedreno/ir3/ir3.c +++ b/src/freedreno/ir3/ir3.c @@ -683,6 +683,17 @@ ir3_create_empty_preamble(struct ir3 *ir) main_start_block->reconvergence_point = true; + /* Inputs are always expected to be in the first block so move them there. */ + struct ir3_cursor inputs_cursor = ir3_before_terminator(shps_block); + + foreach_instr_safe (instr, &main_start_block->instr_list) { + if (instr->opc == OPC_META_INPUT || instr->opc == OPC_META_TEX_PREFETCH) { + list_del(&instr->node); + insert_instr(inputs_cursor, instr); + instr->block = shps_block; + } + } + return shpe; }