shader: emulate DS_ORDERED_COUNT as a GDS atomic #1117
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1117
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1117/head"
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?
@NeySlim on GitHub · 2026-10-06 19:45 UTC · original
NeySlim:feat/ds-ordered-count→main· +129 −0 · 5 files · 3 commits · merged 2026-10-06 21:45 UTCDS opcode 0x3f with the GDS bit (
DS_ORDERED_COUNT) was not implemented, which aborted the CFG build for a compute shader in God of War Ragnarök (PPSA08332).This decodes the instruction (counter index from offset0, add/swap from offset1[5:4], one dword) and emulates it as a plain GDS atomic add or swap at
M0 + index * 4, with the value taken from the ADDR VGPR as the hardware does. Wave-launch ordering is not emulated: every wave still receives a unique pre-op value, which is what append-style users need, but consumers relying on the launch order will see arbitrary order. Multi-dword variants and GDS-less encodings stay unsupported.Tested on Linux, RTX 4090.
@coderabbitai[bot] on GitHub · 2026-10-06 19:51 UTC · original · edited 2026-10-06 20:07 UTC
📝 Walkthrough
Walkthrough
The DS decoder now recognizes
DS_ORDERED_COUNT, decodes its offsets and selector, and marks unsupported encodings. The translator dispatches the instruction and emits a shared atomic swap whensecondary_offsetis 1, or an atomic add otherwise. It uses a ballot to select the first active lane, performs the atomic at address zero, and broadcasts the result to the destination.Priority: ➖ Normal
Change: Feature
Merge Risk: 🟡 Moderate · up to
5f0a8Shaders using a nonzero M0 can receive incorrect counter values. Correct the atomic address before merging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-06 19:51 UTC · original · edited 2026-10-06 20:08 UTC
On
src/graphics/shader/recompiler/frontend/translate/Memory.cppline 894 (outdated):🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Perform one atomic operation per wave.
When multiple lanes are active, this IR executes the atomic for each active lane.
DS_ORDERED_COUNTinstead takes the ADDR value from the first active lane and performs one counter operation per wave. A wave with four active lanes and an increment of one can therefore advance the counter by four and receive different pre-operation values. Select the first active lane’s value, issue one atomic, and distribute its result to the required lanes. (docs.amd.com)✅ Addressed in commit
5f0a83f@coderabbitai[bot] on GitHub · 2026-10-06 19:51 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
e833093b-d615-46e8-9cd7-b30215f8b020📥 Commits
Reviewing files that changed from the base of the PR and between
199d0a9d92and7e5d02f22c.📒 Files selected for processing (4)
src/graphics/shader/recompiler/frontend/decode/MemoryOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/frontend/translate/Translator.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
@NeySlim on GitHub · 2026-10-06 19:57 UTC · original
On
src/graphics/shader/recompiler/frontend/translate/Memory.cppline 894 (outdated):Right, thanks. Fixed in
5f0a83f: the first active lane (from the ballot) issues the single atomic with its ADDR value, and the pre-op result is read back from that lane and written to every lane.@coderabbitai[bot] on GitHub · 2026-10-06 20:07 UTC · original · reviewed
ℹ️ Review info
⚙️ Run configuration
3ce1904a-f231-4c10-a8c4-6bd958f8aa04📥 Commits
Reviewing files that changed from the base of the PR and between
7e5d02f22cand5f0a83f307.📒 Files selected for processing (1)
src/graphics/shader/recompiler/frontend/translate/Memory.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-06 20:09 UTC · original
On
src/graphics/shader/recompiler/frontend/translate/Memory.cppline 894 (outdated):@NeySlim, thanks for the fix. The updated implementation issues one atomic from the first active lane with its ADDR value, then broadcasts the pre-operation result.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@Nmzik on GitHub · 2026-10-06 21:30 UTC · original
@NeySlim Hey. This is wrong impl. I ll push fix