fix(shader): isolate wave32 operations in wide host subgroups #587
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/587"
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 nicolasabosch on 2026-10-05T00:01:08Z.
What
Addresses #487: a wave32 shader on a 64-wide host subgroup currently uses the lower ballot word and physical lane IDs for both guest waves. This can mix EXEC/VCC counts and lane reads between independent waves, including the reported RDNA4 pixel-helper failure.
Keep lane IDs in 0..31, select the ballot word belonging to the current 32-lane partition, and translate guest shuffle targets back to physical subgroup lanes. Apply the mapping to lane reads, DPP/DS operations, lane activity, and append/consume broadcasts. Wave64 handling and native wave32 targets keep their existing paths. The partition is derived from the actual invocation ID, so a wide target can also execute on a 32-wide subgroup.
Add a hardware-independent test that evaluates emitted SPIR-V fragments for 32-, 64-, and 128-wide subgroups with independent and empty EXEC masks. Expand the compute test to run native wide subgroups and the pixel/compute tests to exercise wide-target emission on 32-wide hardware.
Tested
Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 4070 Laptop GPU; synthetic shader fixtures, no commercial title tested. Built with
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ON.cmake --build build --target libspassed.ANYPS5_REQUIRE_VULKAN=1and SPIRV-Tools enabled (88.69 seconds).The RTX 4070 has 32-wide subgroups: its wide-target runs validate the generated code and lower partition, not physical 64-wide execution. Upper partitions are covered by the CPU test. Direct confirmation on the AMD hardware from #487 remains pending; this PR does not claim measured title compatibility or FPS improvements.
Rebased onto
9651ec9a, including the newly merged #574. During validation,agc_shader_memoryexposed the existing vectorOpSelecterror on clean07404b67; #574 contains the same correction independently validated locally. The final suite includes that upstream fix and passes completely.The ballot and shuffle mapping follows the Vulkan subgroup operation semantics.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none added).mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T00:22:27Z.
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/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hppL9-10core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cppL30-33core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hppL9-10core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cppL30-33core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hppL9-10core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cppL30-33Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T01:18:32Z.
Thanks, this is a clean way to do it. I went through every subgroup operation the SPIR-V backend emits: the ballots, the shuffles (readlane, readfirstlane and DPP go through
Shuffle),EmitDsMaskedLaneRead, the lane-active check and the append/consume broadcast all go through the new mapping, andFirstLaneworks on the already reduced ballot, so I couldn't find a path that still sees the other wave's lanes. On a 32-wide target every helper returns its input, so the SPIR-V there is unchanged.I can only run it on 32-wide subgroups, so here the new
wave32_wide_subgrouptest is the part that shows the fix: it passes on this branch and doesn't build on main's code. The wide-target passes added to the pixel helper and wave32 tests also pass on main on 32-wide hardware, as expected, since the whole subgroup is partition 0 there. A run from the AMD reporter in #487 would be the real check, as you say.Heads-up: #513, #515 and #522 (DPP) edit lines next to yours in
SpirvSubgroup.hpp/.cpp, so whichever lands second needs a small rebase. #515's new source-lane check usesctx.Ballotwith the guest lane, so it stays correct with this change.This doesn't affect PPSA21564 on my setup (32-wide subgroups). Ready to merge from my side.