Preserve descriptor-array indices across compatible handle Phis #955

Closed
klimovich008 wants to merge 2 commits from codex/preserve-texture-phi-indices into main
klimovich008 commented 2026-11-09 03:14:16 +00:00 (Migrated from github.com)

What this fixes

A texture handle selected by a Phi can become an array index taken from only one incoming branch. This can select the wrong texture and produce invalid SPIR-V: VUID-VkShaderModuleCreateInfo-pCode-08737 reports that the index definition does not dominate its use. Repeating the same condition can preserve the intended selection while still violating dominance.

Why merge

  • Preserve incoming index selection and structural dominance without dropping the sample or its output.
  • Admit only direct GetCbufU32 handle Phis with the same bank, base, count and default stride.
  • Other handle forms retain their existing behavior; this is not a general Phi fix.

Change

  • gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp: transport compatible offsets through a Phi with the original predecessor edges.
  • tests/texture_phi_dominance_ir.cpp: exercise the real pass, collector and emitter with retained fragment outputs.
  • nx2/test_texture_phi_dominance.py: compile and validate the synthetic cases.
  • tests/run_all.py: register the check and its tools.

Tested

python -I -B tests/run_all.py --strict (CI).

Fails on the old code, passes now: Linux CPU checks cover unresolved handle Phis, repeated conditions, same-block indices and a valid nested offset Phi. Separate checks verify dominance, both reachable selections, retained samples/outputs and Vulkan1.3 SPIR-V validation. CPU-only Linux CI validates all four synthetic modules.

Not covered

  • A separate shader on RX 9070 XT still reports this VUID with the change. This fix does not resolve that case.
  • The four IR/emitter cases ran on Linux only; full-game validation remains pending.

No game data is included.

## What this fixes A texture handle selected by a Phi can become an array index taken from only one incoming branch. This can select the wrong texture and produce invalid SPIR-V: `VUID-VkShaderModuleCreateInfo-pCode-08737` reports that the index definition does not dominate its use. Repeating the same condition can preserve the intended selection while still violating dominance. ## Why merge - Preserve incoming index selection and structural dominance without dropping the sample or its output. - Admit only direct `GetCbufU32` handle Phis with the same bank, base, count and default stride. - Other handle forms retain their existing behavior; this is not a general Phi fix. ## Change - `gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp`: transport compatible offsets through a Phi with the original predecessor edges. - `tests/texture_phi_dominance_ir.cpp`: exercise the real pass, collector and emitter with retained fragment outputs. - `nx2/test_texture_phi_dominance.py`: compile and validate the synthetic cases. - `tests/run_all.py`: register the check and its tools. ## Tested `python -I -B tests/run_all.py --strict` ([CI](https://github.com/NotRexed/Hookshot/actions/runs/42562210285)). Fails on the old code, passes now: Linux CPU checks cover unresolved handle Phis, repeated conditions, same-block indices and a valid nested offset Phi. Separate checks verify dominance, both reachable selections, retained samples/outputs and Vulkan1.3 SPIR-V validation. CPU-only Linux CI validates all four synthetic modules. ## Not covered - **A separate shader on RX 9070 XT still reports this VUID with the change.** This fix does not resolve that case. - The four IR/emitter cases ran on Linux only; full-game validation remains pending. No game data is included.
RufflezAU commented 2026-11-09 05:15:40 +00:00 (Migrated from github.com)

Testing this on a Steam Deck (RADV VANGOGH, SteamOS) against #798 — random heart-container/button icons flashing over the picture and objects showing each other's textures in Kokiri Forest.

I cherry-picked e1de456 onto 15ec28d (with the Deck's other settings) and it built; the game is re-translating now. The texture budget and eviction are ruled out (the flashing persisted with the set under budget), so a texture handle resolving to the wrong descriptor index is the best remaining explanation for that symptom.

Will report back with whether the flashing is gone and the log if it is not. If you already know this Phi case is not what #798 is, say so and I will stop chasing it there.

Testing this on a Steam Deck (RADV VANGOGH, SteamOS) against **#798** — random heart-container/button icons flashing over the picture and objects showing each other's textures in Kokiri Forest. I cherry-picked `e1de456` onto `15ec28d` (with the Deck's other settings) and it built; the game is re-translating now. The texture budget and eviction are ruled out (the flashing persisted with the set under budget), so a texture handle resolving to the wrong descriptor index is the best remaining explanation for that symptom. Will report back with whether the flashing is gone and the log if it is not. If you already know this Phi case is not what #798 is, say so and I will stop chasing it there.
NotRexed commented 2026-11-09 05:31:12 +00:00 (Migrated from github.com)

Closing to keep the queue clear — please rebase on current main and reopen; thanks!

Closing to keep the queue clear — please rebase on current main and reopen; thanks!
Commenting is not possible because the repository is archived.
No description provided.