feat(shader): implement global_atomic_csub #670
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/670"
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 NahuelGenchi on 2026-10-05T13:34:13Z.
What
global_atomic_csub(GLOBAL opcode 0x34) threwFLAT opcode is not supported. It subtracts the data register from a global dword, clamps the result to zero and returns the previous value, so it's the same asbuffer_atomic_csubfrom #594 but on a global address. It goes throughflatAtomicwith a newAddressAtomicUSubSat32, which the SPIR-V backend runs as a compare and swap loop like the other address atomics that have no native SPIR-V op.RDNA 2 only has this opcode in the global segment, so the decoder throws for the flat segment (scratch atomics already throw). Without glc it throws in the translation, the same way
buffer_atomic_csubdoes.The clamped subtract that #594 wrote inline for the buffer form is now
AtomicUSubSat, next toAtomicIncrementandAtomicDecrement, and both opcodes use it.tools/progress.py: GLOBAL 57/57, shaders 1119/1166.Tested
Ubuntu 26.04, GCC 15.2, AMD R9 380 with RADV and with lavapipe.
New
agc_driver_global_atomic_csub, wave32 and wave64 with 64 threads. Each thread runs csub on its own dword with the same edge rows as the buffer test, then all threads hit two shared dwords, one that never reaches zero and one that runs out and clamps. The values returned from the shared dwords are checked as one ordered chain, and the whole guest block is compared byte by byte afterwards. The test also checks that the form without glc and the flat segment form are refused. With the clamp taken out ofAtomicUSubSat, both this test andagc_driver_buffer_atomic_csubfail.Full ctest on lavapipe with
ANYPS5_REQUIRE_VULKAN=1: 287/287. On RADV the only failures areagc_driver_pixel_helper_lanes,agc_driver_pixel_ldsandagc_driver_pixel_lds_lane_slots, and they fail the same way on main (wave64 pixel shaders on this GPU, see #487).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 github-actions[bot] on 2026-10-05T13:34:41Z.
Progress report (
af92452→a93faff)📈 GPU shader instructions: 96.14% (+0.09%, +1 implemented instructions)
✅ 1 implemented
GLOBAL_ATOMIC_CSUB