From 8404e7428b6c25a32f8cbc3eb218dec5725bb5ff Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Wed, 5 Feb 2025 12:49:26 +0100 Subject: [PATCH] ir3: fix emitting descriptor prefetches at end of preamble The fix in e7ac1094f69 to emit preamble defs in the correct block would move the cursor of the builder that is later used to insert descriptor prefetches, emitting them at the wrong place. Fix this by resetting the cursor before emitting the prefetches. Signed-off-by: Job Noorman Fixes: e7ac1094f69 ("ir3: rematerialize preamble defs in block dominated by sources") Part-of: --- src/freedreno/ir3/ir3_nir_opt_preamble.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/freedreno/ir3/ir3_nir_opt_preamble.c b/src/freedreno/ir3/ir3_nir_opt_preamble.c index 7c764fc6f40..ba458b1138f 100644 --- a/src/freedreno/ir3/ir3_nir_opt_preamble.c +++ b/src/freedreno/ir3/ir3_nir_opt_preamble.c @@ -752,6 +752,8 @@ ir3_nir_opt_prefetch_descriptors(nir_shader *nir, struct ir3_shader_variant *v) preamble_defs); } + /* ir3_rematerialize_def_for_preamble may have moved the cursor. */ + b.cursor = nir_after_impl(preamble); progress |= emit_descriptor_prefetch(&b, instr, preamble_descs, &state); if (state.sampler.num_prefetches == MAX_PREFETCHES &&