shader: implement 32-bit RDNA2 IMAGE_ATOMIC_CMPSWAP #952
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!952
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/952/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?
@tototomate123 on GitHub · 2026-10-01 08:21 UTC · original
tototomate123:fix/rdna2-image-cmpswap→main· +163 −102 · 12 files · 3 commits · merged 2026-10-01 21:15 UTCThis is the first in a planned series of small, focused PRs adding shader translation and runtime fixes needed to improve support for Horizon Forbidden West and other AAA games; this PR implements 32-bit RDNA2 image
compare-and-swap.MIMG opcode
0x10currently decodes as unsupported and stops shader compilation. This change decodes the 32-bit form, passes the replacement and comparison operands through a dedicated IR operation, and emits SPIR-VOpAtomicCompareExchange.The translation reads replacement from VDATA and comparison from VDATA+1. GLC writes the previous texel into VDATA, including on a failed comparison. The existing EXEC guard suppresses both memory and register changes for inactive lanes. DMASK values other than 0x3 remain unsupported, including the 64-bit form (0xf). Existing image atomic format and memory-barrier policies are retained.
References
amdgpu_isa_rdna2.xml,IMAGE_ATOMIC_CMPSWAP, in the August 2026 archive: identifies opcode 16 and describes conditional replacement and GLC returning the original value. The XML was downloaded and inspected. It does not explicitly establish the consecutive input register order.src, thencmp.Validation
Built
kyty_emulator,shader_cfg_tests, andshader_recompiler_compute_testson Linux with Clang in RelWithDebInfo.shader_cfg_tests: passed, including all 16 DMASK values for the new opcode.shader_recompiler_compute_tests --image-cmpswap-only: passed; SPIR-V validation and GPU readback cover successful/failed comparisons, GLC on/off, unchanged comparison registers, inactive EXEC, and existing image swap/atomic variants.Windows/macOS have not been tested locally
Implemented with the help of AI.
@coderabbitai[bot] on GitHub · 2026-10-01 08:31 UTC · original · edited 2026-10-01 09:33 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
80682c2b-603d-4e27-a7c9-dd22a06a859c📥 Commits
Reviewing files that changed from the base of the PR and between
b7a1fac898and6591be8eab.📒 Files selected for processing (10)
src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inctests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
The change adds image atomic compare-and-swap decoding for DMASK 3, translates the instruction into an IR operation, and emits it as SPIR-V
OpAtomicCompareExchange. The emission uses replacement and comparison operands and the final instruction argument as the execution condition. New tests cover decoding, compare outcomes, GLC behavior, and disabled EXEC. Other edits adjust instruction formatting and decoder declarations.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Feature
Merge Risk: ⚪ Minimal · up to
6591bThe compare-and-swap implementation and its tests are consistent with the intended behavior. No merge-blocking issue was identified; proceed subject to normal build and test checks.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
6591bThe new operation is narrowly constrained and retains existing resource-selection and execution controls. No introduced security defect was established, but broader runtime isolation and hardware failure behavior remain incompletely verified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❓ 1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 7 files. (3 skipped: 1 unsupported, 2 too large.)
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.@tototomate123 on GitHub · 2026-10-01 09:56 UTC · original
@nmzik Quick question for future contributions: do you generally prefer smaller, focused PRs like this one over larger "game-fixing" PRs that can easily end up touching 5k+ lines?
Im mostly trying to understand what tends to be easiest for you to review and merge without wasting maintainer time. For example, would you rather have individual missing shader/runtime features split into separate PRs, even if several of them are ultimately needed to get one game further, or is a larger game-focused PR sometimes preferable?
Just want to structure future contributions in the most useful way for the project.
@Nmzik on GitHub · 2026-10-01 10:41 UTC · original
@tototomate123 I would generally prefer one PR that gets the game in-game, with separate commits describing what each change does.
You can also make PRs for specific things, but please group related changes together. For example, don’t make PR for each new opcode you encounter. Group them/Do something like: new opcodes: ***, ***, ***.
@Nmzik on GitHub · 2026-10-01 10:42 UTC · original
@tototomate123 This PR is fine. This is just for the future :)