Shaders: lower ds_add{_rtn}_f32 and ds_cmpst{_rtn}_f32 LDS atomics #1488
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!1488
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1488"
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?
@AscilCH on GitHub · 2026-11-24 18:22 UTC · original
AscilCH:fix/ds-float-atomics→main· +334 −18 · 2 files · 1 commits · openSummary
Lower GFX10 floating-point LDS atomics
ds_add_f32(0x015),ds_add_rtn_f32(0x055),ds_cmpst_f32(0x011), andds_cmpst_rtn_f32(0x031) inLower::ds()(crates/victory-shader/src/emit/lower.rs).(Complementary to #164 which covers integer LDS atomics and leaves out float atomics, and disjoint from #628 which covers
ds_min_f32/ds_max_f32.)Reproduction (Before Fix)
Lowering a synthetic compute shader containing
ds_add_f32,ds_add_rtn_f32,ds_cmpst_f32, ords_cmpst_rtn_f32failed with:Implementation
ds_add_f32/ds_add_rtn_f32: Emits a guardedcmpxchgCAS loop on the LDS dword: readscur, computesnext = bitcast(bitcast(cur, f32) + bitcast(src, f32), i32), and retriescmpxchg cur -> nextuntil the previous word equalscur(handling both normal updates and NaN/no-op termination cleanly).ds_cmpst_f32/ds_cmpst_rtn_f32: Emits a guardedcmpxchgloop using IEEE-754 ordered float equality (fcmp oeq) against the loaded word — matching RDNA2's floating-point compare-and-swap semantics where+0.0 == -0.0succeeds andNaN == NaNfails (leaving LDS untouched and returning the old bits for_rtn).Test
Added synthetic end-to-end test
emit::valu_tests::ds_add_f32_and_ds_cmpst_f32_match_rdna2(64-thread two-wave compute shaders, validated bydxil.dlland executed on hardware GPU + WARP):v_cmpx_eq_u32EXEC-guarded)ds_add_rtn_f32andds_add_f32old/new values and NaN add termination.ds_cmpst_rtn_f32andds_cmpst_f32covering matching values, mismatching values,+0.0 == -0.0,-0.0 == +0.0, andNaN != NaN.ds_add_f32accumulation across two waves verifying the exact sum1 + 2 + ... + 64 = 2080.0.Verification
rustfmt --edition 2024 --check crates/victory-shader/src/emit/valu_tests.rsand modified lines oflower.rs: cleancargo test -p victory-shader --locked ds_add_f32_and_ds_cmpst_f32_match_rdna2(hardware + WARP +dxil.dll): passedVICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1: 121 passed, 0 failedcargo xtask policy: 154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean@marquezinii on GitHub · 2026-11-24 18:48 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
62c4ded.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 121 passed, 0 failed, 1 ignored, with the new LDS float atomic test passing on the hardware adapter and WARP. Running the compare-exchange loop on the raw bits (prev == curas integers) means a NaN already stored can't make theds_add_f32loop spin, which was the part I wanted to see. On this hardware the loop also completes when the lanes of a wave contend for one address.@wwwwwwww3333333 on GitHub · 2026-11-24 19:15 UTC · original
Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head
62c4dedon mainffe310e(clean merge).cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignored (main alone: 120 passed).ds_add_f32_and_ds_cmpst_f32_match_rdna2ran on the hardware adapter and then on WARP, and passed on both. This adds an AMD result to the NVIDIA runs already posted.Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
@sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
62c4dedontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 01:29 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/valu_tests.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.