feat(shader): implement buffer_atomic_inc/dec and the 64-bit integer buffer atomics #321
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/321"
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 adriadam10 on 2026-10-02T05:17:12Z.
What
These threw "MUBUF opcode is not supported":
buffer_atomic_inc,buffer_atomic_decbuffer_atomic_cmpswap_x2buffer_atomic_{add,sub,smin,umin,smax,umax,and,xor}_x2The 64-bit ops get IR ops
BufferAtomic{IAdd,ISub,SMin,UMin,SMax,UMax,And,Xor,CmpSwap}64, which reuseBufferAtomic64, the native 64-bit SPIR-V atomic path thatswap_x2andor_x2already use.cmpswap_x2does anOpAtomicCompareExchangewithvdata[0:1]as the new value andvdata[2:3]as the comparator, like the 32-bitcmpswap.inc/dec(BufferAtomicInc32/Dec32) use the compare-exchange loop with the existingAtomicIncrement/AtomicDecrementhelpers (old >= data ? 0 : old + 1,old == 0 || old > data ? data : old - 1). Withglcevery op returns the old value, as before.Test
agc_driver_buffer_atomics: one wave32 shader. Each op runs on its own slot of the output buffer, set to a known value first. The test checks the memory afterwards and theglcreturn values ofinc,dec,add_x2andcmpswap_x2. Inputs are signed/unsigned 64-bit edges (0, -1, INT64_MIN/MAX), random values, small values for the inc/dec wrap, and matching/non-matching compare values forcmpswap_x2.Tested
Linux, full ctest (99) passes.
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-02T05:17:34Z.
Progress report (
2cf901b→ae36aaf)📈 GPU shader instructions: 81.22% (+0.95%, +11 implemented instructions)
✅ 11 implemented
BUFFER_ATOMIC_ADD_X2BUFFER_ATOMIC_AND_X2BUFFER_ATOMIC_CMPSWAP_X2BUFFER_ATOMIC_DECBUFFER_ATOMIC_INCBUFFER_ATOMIC_SMAX_X2BUFFER_ATOMIC_SMIN_X2BUFFER_ATOMIC_SUB_X2BUFFER_ATOMIC_UMAX_X2BUFFER_ATOMIC_UMIN_X2BUFFER_ATOMIC_XOR_X2Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:57:19Z.
This passed my PPSA21564 check, but it now conflicts with main after #319, #329, #330 and #331 merged. Could you rebase? Then it's ready to merge from my side.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T10:01:58Z.
Rebased on current main (conflict was the MUBUF table next to the new D16 format rows from #319-#331, both kept). BufferAtomics passes on RADV and lavapipe.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:37:48Z.
Thanks for the rebase. The rebased commit has exactly the content I ran through my PPSA21564 check, and the full ctest passes here on current main. Ready to merge.