Shaders: lower remaining 32-bit integer and bitwise LDS atomics #1605
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by HumanlyDev on 2026-11-24T19:43:30Z.
What
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).
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:56:54Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib emit::ds_tests::— 3 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean lowering of the remaining 32-bit integer and bitwise LDS atomics with
cmpxchg_pairsupport and thorough end-to-end GPU+WARP test coverage inds_tests.rs. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:32:00Z.
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
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:39:23Z.
Review: COMMENTED
Shaders: lower remaining 32-bit integer and bitwise LDS atomics — merge conflict with main (
940d32f69b), verified locally. Relates to the LDS atomic cluster (#571/#996/#1953/#1899). Rebase needed.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.