fix(shader): keep runtime image mode switches inside continue targets #1964
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1964"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T03:05:16Z.
What
Fixes #1921. A shader that samples an image inside a loop's last block can't be prepared:
When an image has several runtime modes, the instruction becomes an
OpSwitchover the modes. The default case, and the case of a mode turned off by specialization, end inOpUnreachable. If the instruction sits in the loop latch, that block is the SPIR-V continue target, and theOpUnreachableexits mean the back-edge block no longer post-dominates it, so spirv-val rejects the loop.Inside a continue target, those two cases now branch to the merge with an undefined result instead, like
cd158c6balready does for BDA faults there. Outside continue targets nothing changes, and an enabled mode runs as before. Both cases were already undefined behaviour withOpUnreachable, and the descriptor code never selects them.#757 also edits this switch: it sends the image table default to the merge, but non-table images keep
OpUnreachable, so the issue's stack (main+ #757 + #1836) can still hit this. Whichever merges second needs a small rebase.Tested
Linux (CachyOS), RTX 4070 Ti and Radeon 610M (RADV), SPIRV-Tools on.
agc_shader_memoryhas two new loops whose latch samples a multi-mode image, one through a 2D-array image and one through a bindless image table. Both fail onmainwith the error above and pass with this change.check_conventions.pypasses.Ghost of Yōtei (PPSA26344) from the issue was not rerun: the loops above are synthetic, so whether this was the reporter's shader still needs their rerun.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:11:07Z.
The reproducer and local GPU validation are documented, but this head currently has no upstream check runs (
gh pr checksreports none). CONTRIBUTING says a fork PR with anaction_requiredworkflow needs maintainer approval before CI has actually run. Could you check whether the Build/Conventions workflows are waiting for approval and request a rerun if so?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:14:28Z.
I checked the Actions API for this exact head: Build, Conventions and Progress report are marked
action_required, so upstream CI has not run. Per CONTRIBUTING, a maintainer needs to approve those workflow runs; please request that approval.Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T03:15:06Z.
Same as #1962: the three runs on
33603bffinished asaction_requiredwith no jobs, so CI hasn't run yet:They need a maintainer's approval; I can't rerun them from the fork. Locally, full ctest passes 497/497 on NVIDIA and on RADV, and
check_conventions.py --base origin/mainpasses.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:36Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
33603bf8, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_shader_memory,agc_shader_bindless. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T21:48:08Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL419-446core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppL1590-1591, L1602-1603, L1605-1617, L1619-1622, L1628-1630core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL419-446core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppL1590-1591, L1602-1603, L1605-1617, L1619-1622, L1628-1630core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppL815-816, L818-819Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:06:21Z.
Checked: build + ctest on Linux with SPIRV-Tools on;
agc_shader_memorypasses with this change and fails without it (both new latch cases). The Phi/dominance in the continue-target path is correct, and behaviour outside continue targets is unchanged. Windows run by @popcoder565 also passes. Merging once CI is green.Note: the other instance reported for Astro Bot (graphics-stage program) isn't covered here and needs its own follow-up.