RDNA2 691/721: LDS atomics (sub/rsub/inc/dec/min_i32/max_i32/cmpst/wrxchg) #23
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!23
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/23/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?
@SchmashinPrunes on GitHub · 2026-11-21 17:59 UTC · original
SchmashinPrunes:lds-atomics→main· +163 −37 · 8 files · 1 commits · closed without mergingLibrary / area: tombox-xshader (RDNA2 shader translator) / progress map (RDNA2 instructions). Part of #17.
Exports changed (exports.txt rows): none
Source of the behaviour: RDNA2 ISA DS semantics as encoded by LLVM's AMDGPU backend for GFX10 (
llvm/lib/Target/AMDGPU/DSInstructions.td, LangRefatomicrmw). The same semantics are already used and tested by the GDS path (src/hlsl/gds.rs,tests/exec_mem/gds.rs). No console files used.What changed
The LDS (group-shared) path only lowered
ds_add/min_u32/max_u32/and/or/xor. The rest of the DS atomics were lowered for GDS only, so they never counted as verified. This lowers them for LDS too:ds_sub_u32,ds_wrxchg_rtn_b32,ds_cmpst_b32.ds_rsub_u32,ds_inc_u32,ds_dec_u32,ds_min_i32,ds_max_i32.tb_ldsisuint, so the signed min/max don't rely on DXC picking a signedInterlockedMin/Maxoverload._rtnforms: 15 mnemonics.Semantics worth calling out:
ds_inc/ds_decareuinc_wrap/udec_wrap:old u>= data ? 0 : old+1and(old == 0 || old u> data) ? data : old-1.ds_cmpsttakes data0 = compare value, data1 = value stored on a match. LLVM: "the order of src and cmp is the opposite of BUFFER_ATOMIC_CMPSWAP"; GFX11 swaps them back asds_cmpstore.Tests
New
tests/exec_mem/ds.rsds_lds_atomics_ext: 106 cases, each also rerun with runtime inputs.ds_min_i32compare unsigned, makes the test fail (26 failing cases).python tools/progress/gen.py: RDNA2 instructions 676/721 → 691/721 (rebased onto8cd153d; the code was unchanged by the rebase and upstream has not touched tombox-xshader since the original test run). Only the instruction metric changes in LIBRARY_MAP / MILESTONES / summary / badges. Touches the same generated progress files as other open RDNA2 PRs; whichever merges later just rerunsgen.py.Full
cargo test -p tombox-xshader --release(Windows 11 LTSC, WARP)No new failures. Failures that are identical on unpatched
main(fef9a6e):exec:vop::basic::{salu,vop1,vop2,vop3}_basic, the same 4 that #15 reports.amp/fixtures/mesh: 11 tests that needanalysis/shaders/...dump fixtures (#13 makes these skip).mesh::mesh_refusals_are_explicit: panics atmesh.rs:247(expect("refusal")) on unpatchedmaintoo.cargo test -p tombox-xshaderpasses for the changed area. Remaining failures are pre-existing, listed above.No game or console files and no binaries included
No fake success; anything not possible is left
missingwith a note🤖 Generated with Claude Code
@QuentinDanblon on GitHub · 2026-11-21 18:30 UTC · original
FYI: #25 included LDS atomics too, written before I saw your claim in #17. I've removed them from #25 so it doesn't overlap this PR. One thing to check: #21 changes the GDS base to M0[31:16] (RDNA2 ISA §3.7/§10.5). That only touches
hlsl/gds.rsand shouldn't affect your LDS path.@SchmashinPrunes on GitHub · 2026-11-21 18:55 UTC · original
Thanks for the heads-up. I checked #21 against this branch: its
hlsl.rshunk is only the loop-order sort (around line 2230, far from the LDS atomic arm), and thegds.rschange is addressing only (M0[31:16]base plus the size check). The LDS path here doesn't read M0, which matches RDNA2 (no M0 requirement for LDS on GFX9+), so there's no interaction. A test merge of #21 with this branch is clean too.@SchmashinPrunes on GitHub · 2026-11-21 22:12 UTC · original
Closing: this landed on main in
1159c96(the LDS atomic arm inhlsl.rsandds_lds_atomics_extintests/exec_mem/ds.rsmatch this branch apart from comments). Thanks!Pull request closed