Shaders: lower remaining 32-bit integer and bitwise LDS atomics #1606
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1606
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1606"
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?
@HumanlyDev on GitHub · 2026-11-24 19:43 UTC · original
HumanlyDev:shader/ds-integer-atomics→main· +695 −23 · 6 files · 1 commits · openWhat
Lowers the remaining GFX10 32-bit integer and bitwise LDS atomic instructions in
Lower::ds:ds_rsub_u32(0x002) /ds_rsub_rtn_u32(0x022): atomicmem = data0 - mem.ds_inc_u32(0x003) /ds_inc_rtn_u32(0x023): atomicmem = (mem >= data0) ? 0 : mem + 1(unsigned comparison).ds_dec_u32(0x004) /ds_dec_rtn_u32(0x024): atomicmem = (mem == 0 || mem > data0) ? data0 : mem - 1(unsigned comparison).ds_mskor_b32(0x00c) /ds_mskor_rtn_b32(0x02c): atomicmem = (mem & ~data0) | data1.ds_wrap_rtn_b32(0x034): atomicmem = (mem >= data0) ? mem - data0 : mem + data1(unsigned comparison), along with decoding its second data operand (DATA1) ingfx10::fields.ds_wrxchg2_rtn_b32(0x02e) /ds_wrxchg2st64_rtn_b32(0x02f): paired atomicRmw::Xchgat(offset0, offset1)scaled by 4 or 256 bytes, returning both prior values intovdst[0..2]and preserving inactive lanes' registers underguard.emit::bitcode::Module::cmpxchg_pairexposes both fields of{i32, i1}from LLVM 3.7cmpxchgso the single-block CAS loop branches directly on thei1success bit (CondBr(ok, exit, head)), avoiding ABA/no-op ambiguity whennew == expectedand keeping the exiting block as the loop latch.Verification
Added
emit::ds_testsand SP3 disassembly coverage ingfx10::sp3::tests:ds_rsub_inc_dec_mskor_wrap_and_wrxchg2_match_rdna2: validates every emitted DXIL container and container hash withdxil.dll, then executes all 11 opcodes (both_rtnand non-_rtnforms) on both the hardware SM 6.6 D3D12 adapter and WARP across boundary, wraparound, unsigned high-bit (0x8000_0000vs0x7FFF_FFFF), unmaskedDATA1bits inds_mskor, and stride-64 paired exchange cases.ds_atomics_handle_wave_contention_and_divergent_exec_guards: dispatches 64 threads contending on the same LDS dword (ds_inc_rtn_u32) and executesds_dec_rtn_u32+ds_wrxchg2_rtn_b32under a narrowedv_cmpxEXECguard, verifying exact histogram/wrap counts and confirming disabled lanes neither touch LDS nor overwrite destination VGPRs.ds_cas_loops_nest_inside_shader_loops: runs back-to-back CAS-loop atomics (ds_wrap_rtn_b32andds_mskor_rtn_b32) inside a multi-iteration guest shader loop.Local checks (Windows 11,
rustc 1.98.1):cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: all tests pass (victory-shader: 123 passed, 0 failed;xtaskasset policy: 155 files ok)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-shader --locked: cleanAll test inputs and machine-code sequences are synthetic; no game files were used.
AI-assisted implementation and verification (Antigravity).
Decode both data operands of ds_wrap_rtn_b32 in gfx10::fields, expose the cmpxchg success bit in emit::bitcode, and lower ds_rsub{_rtn}_u32, ds_inc{_rtn}_u32, ds_dec{_rtn}_u32, ds_mskor{_rtn}_b32, ds_wrap_rtn_b32, and ds_wrxchg2{,st64}_rtn_b32 in Lower::ds.@Marvisak on GitHub · 2026-11-25 01:32 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/mod.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.