From d256c1f49e2c1a833e5679f19e4146106625d1a7 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 11 May 2026 17:41:57 +0200 Subject: [PATCH] ac/nir/lower_tex_coords: fix optimizing cube txd to tex We need to remove ddx/ddy before doing the cube lowering, otherwise we insert instructions that break dominance. Affects Sable. Fixes: 7d552d71e94 ("ac/nir: optimize txd(coord, ddx/ddy(coord))") Reviewed-by: Rhys Perry Part-of: --- src/amd/common/nir/ac_nir_lower_tex_coords.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/amd/common/nir/ac_nir_lower_tex_coords.c b/src/amd/common/nir/ac_nir_lower_tex_coords.c index f1dfe87156c..080bfd880d5 100644 --- a/src/amd/common/nir/ac_nir_lower_tex_coords.c +++ b/src/amd/common/nir/ac_nir_lower_tex_coords.c @@ -442,6 +442,10 @@ move_tex_coords(struct move_tex_coords_state *state, nir_function_impl *impl, ni components[i] = nir_get_scalar(build_coordinate(state, components[i], infos[i]), 0); nir_def *linear_vgpr = nir_vec_scalars(&state->toplevel_b, components, tex->coord_components); + + /* This must be done before lowering tex coords because of cubes. */ + optimize_txd(tex); + lower_tex_coords(&state->toplevel_b, tex, &linear_vgpr, state->options); linear_vgpr = nir_strict_wqm_coord_amd(&state->toplevel_b, linear_vgpr, coord_base * 4); @@ -455,8 +459,6 @@ move_tex_coords(struct move_tex_coords_state *state, nir_function_impl *impl, ni if (offset_src >= 0) /* Workaround requirement in nir_tex_instr_src_size(). */ tex->src[offset_src].src_type = nir_tex_src_backend2; - optimize_txd(tex); - state->num_wqm_vgprs += linear_vgpr_size; return true;