feat(shader): implement global_store_dword_addtid #569
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/569"
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-04T22:10:42Z.
What
Implements
global_store_dword_addtid(FLAT opcode 0x17, global segment), the store half ofglobal_load_dword_addtid(#530). Each active lane stores its data VGPR atsaddr + offset + lane * 4. It reuses the load's decode checks (global segment only, SGPR pair base) and its address path. The two now shareglobalAddtid(inst, write), likedsAddtid.Encoding: the RDNA2 ISA lists it as GLOBAL opcode 23. llvm-mc encodes it from gfx1030 on (
dc5c....), but not for gfx1013, same as the load.The store goes through the flat/global store path that #390 added (merged with #491 as
be866e4).Behaviour measured on HW (gfx1035, wave32 and wave64)
The oracle kernel runs the same instruction list as the test shader and reads back an 8 KiB window around the base. I measured:
ds_write_addtid_b32.HW matched the model on every dword (184 written in wave32, 368 in wave64), and the test's expected memory comes from that same model.
Tested
Linux (CachyOS), RADV and lavapipe. New
agc_driver_global_store_addtidtest: six stores (offsets 0, -256, -1024, 512 masked by EXEC, -2048, 2044; M0 0, 0x40 and 0xffff) in wave32, wave64 native and wave64 split (ComputeTarget(32)). After each dispatch it compares the whole 64 KiB guest block. It also checks the three decode refusals (flat segment, scratch segment, no SGPR base).The test fails without the fix. I checked this with mutations: lane ignored in the address, EXEC ignored, data read from
vdst, M0 added to the address, and wrong refusal text all fail. Likeagc_driver_lds_addtid, the dispatch part skips when subgroups are narrower than a wave (lavapipe, 8 lanes), becauseLaneIdis the subgroup invocation there. The refusals still run on lavapipe.Release build with full ctest. Failing locally, all also failing on
mainwithout this PR, on RADV:agc_driver_pixel_helper_lanesagc_driver_vop3_carry_outagc_driver_global_load_addtid: "wave32 128 threads thread 32 reports lane 32", from RADV's 64-lane subgroup.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-04T22:11:06Z.
Progress report (
3655c2a→d044384)📈 GPU shader instructions: 95.88% (+0.08%, +1 implemented instructions)
✅ 1 implemented
GLOBAL_STORE_DWORD_ADDTIDImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:43:57Z.
Thanks. The first commit is #390's head unchanged (same patch), so I only reviewed the last one.
I disassembled the test shader with llvm-mc (gfx1030, since gfx1013 has no addtid encoding, as for #530): the six stores are opcode 0x17 with the offsets, M0 values and EXEC mask in the
Storestable, the data is0x101 * tid + 0x5100xor the pattern, and none of the six ranges overlap, soExpected()checks every store separately. The store goes through the sameStoreAddressU32argument order thatStoreAddressreads (data second to last, exec last), and the data VGPR comes from the DATA field because the opcode is now inisFlatStoreOpcode. The decode checks are shared with the load, and llvm-mc also rejects the flat and scratch segment words.Order: this needs #390 first. #491 and #495 also carry #390 and change the same BDA files further (ResourceTracker.cpp, SpirvBda.hpp, SpirvBdaRead.cpp, plus RdnaOpcode.hpp), so whichever of them lands after this one needs a rebase. Once #390 is in, a rebase down to the last commit is all this needs.
agc_driver_global_store_addtidandagc_driver_flat_storepass here on NVIDIA with this head merged into current main, and both fail on main's code (the decoder refusal and the GPU ownership error). PPSA21564 has no addtid instructions, so this doesn't affect my runs. Ready to merge from my side after #390.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T06:44:03Z.
Rebased on current main. #390 landed with #491 (
be866e4), so this branch is now only theglobal_store_dword_addtidcommit (d044384); the cherry-picked #390 commit is gone and the description no longer says it is stacked. The rebase only resolved theRdnaOpcode.hppenum next to the new flat atomics; the code is unchanged.agc_driver_global_store_addtidpasses on RADV (lavapipe skips it, 8-lane subgroups) and the full Release ctest passes exceptagc_driver_pixel_helper_lanesandagc_driver_pixel_lds, which fail the same way on main here.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T07:26:35Z.
Thanks for the quick rebase. The branch is now only your addtid commit on main, and the range-diff against f0730c0 shows just the enum context:
GlobalStoreDwordAddtidnow follows the new flat atomic entries. I had tried the same replay here before your push, and the tree is identical tod044384. The full ctest passes with it,agc_driver_global_store_addtidincluded.PPSA21564 has no
global_store_dword_addtidin the 5,688 shaders I have dumped, so this doesn't need my PPSA21564 check. Ready to merge from my side once CI is green.