fix(shader): keep Demon's Souls loop shader valid after optimization #4018
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4018"
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 Mouhand-Kaddo on 2026-10-11T21:28:36Z.
What
Demon's Souls (PPSA01342 v1.04) registers a compute shader that passes initial SPIR-V validation but fails after optimization. Captured on Windows main
0a8b1d32bwith SPIRV-Tools enabled, and reproduced against current main14a7e64dc:For a loop that branches back to its own instruction block, give its back edge a dedicated empty continue block. Isolating the semantic header then keeps the instruction block in the loop body. This prevents block merging from folding the continuation into the loop header when memory instructions emit nested selections. Optimization and validation remain enabled.
The regression recompiles a synthetic loop containing a buffer store for 32- and 64-lane subgroups, checks structured control flow, and compares guest instruction executions before and after structurization.
Overlap checked across open, merged and closed PRs. #1964 and closed #2311 address terminating image paths before optimization. Current main includes #2471 and still fails both this captured shader and the new synthetic regression after optimization; its handling of inner-loop latches is retained.
Tested
Windows 11, Radeon RX 6900 XT, MinGW GCC 15.2, Release, pinned SPIRV-Tools enabled:
14a7e64dc: shader library build passed;agc_structurizer,agc_shader_control_flowandagc_spirv_optimizerpassed 3/3 (1.47 s), including the newly merged control-flow cases.b3ae11201plus the change: full Windows build passed; full ctest had 841 passes, 6 skips and 2 failures out of 849 (335.89 s).agc_driver_lds_mixed_width_atomicsandagc_driver_pixel_interlockfailed identically with main's original loop construction and with the fix. The five focused control-flow/optimizer/driver/shader-memory tests passed.b3ae11201plus the change: a loop stores the correct final value after four iterations for all 64 threads, with guest wave32 and wave64. Vulkan was required; RX 6900 XT was selected.0a8b1d32bplus this change: no repeat of the captured error; initialization did not finish before the time limit. Main menu remains unverified. This does not establish a fix for the audio crash with SPIRV-Tools disabled.git diff --check: passed. Local tests were Windows-only.The full Windows build on current main is blocked by
Socket.cppcalling the non-Windows-onlyHostPollhelper. Build errors were reported on #3462; this PR contains only the shader fix and regression.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)Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-11T21:51:40Z.
Tested on Linux (CachyOS x86_64, GCC) with an NVIDIA GeForce RTX 5060 Ti (Blackwell, driver 615.78.08, Vulkan 1.4):
agc_structurizer: PASSED (0.02s)agc_shader_control_flow: PASSED (0.12s)agc_structurizer_intersection_off: PASSED (0.02s)agc_driver_scalar_program_flow: PASSED (0.23s)tools/check_conventions.pypasses clean.Validates the loop continue block isolation on NVIDIA and Linux beyond the Windows/Radeon testbed. LGTM!