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: 7d552d71e9 ("ac/nir: optimize txd(coord, ddx/ddy(coord))")
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
(cherry picked from commit d256c1f49e)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41540>
This commit is contained in:
Georg Lehmann 2026-05-11 17:41:57 +02:00 committed by Eric Engestrom
parent 00967135c8
commit ca89a69436
2 changed files with 5 additions and 3 deletions

View file

@ -304,7 +304,7 @@
"description": "ac/nir/lower_tex_coords: fix optimizing cube txd to tex",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "7d552d71e94b3080eb569b3fa6763ab905d98b7a",
"notes": null

View file

@ -419,6 +419,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);
@ -432,8 +436,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;