feat(shader): accept the glc, slc and dlc cache bits on flat, global and scratch #495
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/495"
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-04T09:13:55Z.
What
FLAT, GLOBAL and SCRATCH loads, stores and atomics now accept the
glc,slcanddlccache bits. Before this, the decoder threwunsupported FLAT modifiers or segmentfor any of them, exceptglcon atomics. Found by the modifier sweep over decoded opcodes: everyflat_*/global_*/scratch_*with any of the three bits throws onmain. Compilers emitglc dlcon coherent loads andslcon streaming stores, so these show up whenever a shader uses global memory.This follows what MUBUF/MTBUF already do (
bufferLoad/bufferStore):coherent = glc || dlc. The BDA read and write paths already turn that intoVolatileaccesses (BdaAccessMask).slcis a cache-streaming hint and changes no result. MUBUF ignores it the same way.glcstill selects the pre-op return.slc/dlcare hints there too, and the atomics are device-coherent anyway.lds, segment 3, scratch atomics.Encodings checked with
llvm-mc -mcpu=gfx1013 -show-encoding:dlcis word0 bit 12,glcbit 16,slcbit 17, and every combination assembles on loads, stores, atomics and scratch.Depends on #491 (integer flat/global atomics), which depends on #390 (DotDebian, stores through FLAT/GLOBAL addresses). Both commits are included here so the stores and atomics can be tested with the bits; only the last commit is this PR. Both PRs rewrite the same decoder condition.
Behaviour measured on HW
The test kernel ran on a Radeon 660M (gfx1035, same VMEM encoding as gfx1013) over 32 lanes of edge values plus random rows. It does
global_load_dwordwithglc,slc,dlcand all three;global_load_dwordx2 glc dlc;global_load_ubyte slcandglobal_load_sbyte glc dlc(sign extension);global_store_dword glc slc dlc;global_store_byte slc; returningglobal_atomic_add glc slc dlc; non-returningglobal_atomic_sub slc dlc; andflat_load/store/atomic_xorthrough a 64-bit VGPR address withglc/slc/dlcmixes. All 32 rows (16 results each) match a model where the bits change nothing. The returning atomic gives the pre-op value, and the non-returning one leaves its VGPRs alone.Tested
Arch Linux, RADV (Radeon 660M) plus lavapipe (local Mesa and the CI version, Ubuntu Mesa 25.2.8). New execution test
FlatCacheBitsruns the same kernel as the HW measurement on a guest block. 64 threads run as wave32 and wave64. It checks the 16 results per lane against the HW rows, the final 16 bytes per lane, and that nothing else in the 64 KiB block changes.Negative checks: the test fails if the bits still throw, if
slcdrops the atomic return, or if adlcstore is skipped.Full Release build plus
ctest: 177/178. The one failure,agc_driver_pixel_helper_lanes, also fails onmainon local RADV since #305.FlatCacheBitstakes ~105 s on CI's lavapipe (18 BDA instructions per dispatch, two dispatches; BDA lookups are slow there, as with FlatStore), and under a second on RADV.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-04T09:14:17Z.
Progress report (
00407df→183a0f0)📈 GPU shader instructions: 92.28% (+4.12%, +48 implemented instructions)
✅ 48 implemented
FLAT_ATOMIC_ADDFLAT_ATOMIC_ADD_X2FLAT_ATOMIC_ANDFLAT_ATOMIC_AND_X2FLAT_ATOMIC_CMPSWAPFLAT_ATOMIC_CMPSWAP_X2FLAT_ATOMIC_DECFLAT_ATOMIC_INCFLAT_ATOMIC_ORFLAT_ATOMIC_OR_X2FLAT_ATOMIC_SMAXFLAT_ATOMIC_SMAX_X2FLAT_ATOMIC_SMINFLAT_ATOMIC_SMIN_X2FLAT_ATOMIC_SUBFLAT_ATOMIC_SUB_X2FLAT_ATOMIC_SWAPFLAT_ATOMIC_SWAP_X2FLAT_ATOMIC_UMAXFLAT_ATOMIC_UMAX_X2FLAT_ATOMIC_UMINFLAT_ATOMIC_UMIN_X2FLAT_ATOMIC_XORFLAT_ATOMIC_XOR_X2GLOBAL_ATOMIC_ADDGLOBAL_ATOMIC_ADD_X2GLOBAL_ATOMIC_ANDGLOBAL_ATOMIC_AND_X2GLOBAL_ATOMIC_CMPSWAPGLOBAL_ATOMIC_CMPSWAP_X2GLOBAL_ATOMIC_DECGLOBAL_ATOMIC_INCGLOBAL_ATOMIC_ORGLOBAL_ATOMIC_OR_X2GLOBAL_ATOMIC_SMAXGLOBAL_ATOMIC_SMAX_X2GLOBAL_ATOMIC_SMINGLOBAL_ATOMIC_SMIN_X2GLOBAL_ATOMIC_SUBGLOBAL_ATOMIC_SUB_X2GLOBAL_ATOMIC_SWAPGLOBAL_ATOMIC_SWAP_X2GLOBAL_ATOMIC_UMAXGLOBAL_ATOMIC_UMAX_X2GLOBAL_ATOMIC_UMINGLOBAL_ATOMIC_UMIN_X2GLOBAL_ATOMIC_XORGLOBAL_ATOMIC_XOR_X2Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T10:08:08Z.
Rebased on current main on top of the rebased #491 (no conflicts in this PR's own commit). FlatCacheBits, GlobalAtomics and D16Memory pass on RADV and lavapipe.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T20:36:32Z.
Rebased on current main: the only Windows failure was
guest_audio_in_no_device, fixed by #532. No other changes.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:09:21Z.
Thanks. I reviewed only the last commit (e6bc02a); the #390 and #491 commits are patch-identical to those PRs.
The change matches what MUBUF does: loads and stores get
coherent = glc || dlc, which the BDA paths already turn into Volatile, andslcis ignored. Atomics keepglcas the return bit, andlds, segment 3 and scratch atomics still throw. llvm-mc agrees on the bit positions (dlc12,glc16,slc17), and the test kernel disassembles to the forms the description lists.agc_driver_flat_cache_bitspasses on my machine at this head. On the commit below yours (#390 + #491 only) it fails with "unsupported FLAT modifiers or segment". None of my PPSA21564 shader dumps uses FLAT/GLOBAL with these bits, so this doesn't change my runs.The only issue is the stack. Each branch carries its own rebased copy of the base commits, so merging the heads in order conflicts: this PR on top of #390's head conflicts in
ResourceTracker.cpp,SpirvBda.hppandSpirvBdaRead.cpp, and on top of #491's head inRdnaMemoryOpDecoder.cpp, the condition both rewrite. #569 also conflicts with it in the same BDA files. Once #390 and #491 are in, could you rebase so only this commit is left? It's good to merge from my side after that.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T03:06:45Z.
Rebased: this branch is now #491's new head (
038ded63, which carries #390's patch asbe866e42) plus only this commit, unchanged. #390 → #491 → this one merges cleanly at every step (checked withgit merge-tree), andagc_driver_flat_cache_bitspasses on RADV and lavapipe. Once #390 and #491 are in, only this commit is left.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T05:04:00Z.
Gated on PPSA21564 on top of #491: no visual or FPS change.