Shaders: lower image_atomic_inc, _dec, _fcmpswap, _fmin and _fmax #1148
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!1148
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1148/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?
@VermaakLabs on GitHub · 2026-11-24 16:14 UTC · original
shaders/image-atomic-loops→main· +344 −4 · 3 files · 1 commits · closed without mergingDXIL has no operation for
image_atomic_inc,_dec,_fcmpswap,_fminand_fmax, so a program using one of them stopped. Each is now a compare-and-swap loop on the dword: the new value is made from the old one by RDNA2's definition, starting from a guess of 0, until the exchange finds the value it was made from. A null view reads 0, so the loop leaves at once there.incanddecwrap at the data as the ISA says.fcmpswapcompares as floats: -0 matches +0, NaN matches nothing.fminandfmaxfollowv_min_f32andv_max_f32.64-bit and 16-bit image atomics still stop the program, as before.
Tests:
emit/image_atomic_tests.rsbuilds a synthetic GFX10 compute shader for each (the same way asvalu_tests.rs), validated bydxil.dll, and runs it on the host GPU and WARP, checking the returned old value and the texel left behind. Passes on an Intel Arc 140T, an NVIDIA RTX 5070 Ti Laptop GPU and WARP. Clippy is clean andcargo xtask policypasses.Side note, not part of this change:
valu_tests::v_med3_f32_matches_rdna2_with_nanfails onmaintoo when the default adapter is the Intel Arc (v_med3_f32(1.0, 2.0, NaN)gives 2.0, want 1.0). It passes on the NVIDIA card.@shortselow-byte on GitHub · 2026-11-24 17:23 UTC · original
This PR has no CI run yet, so I ran the CI's checks at head
1661a3eon Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2).On its own base (
8e79c80) everything passes: workspace 315 passed, 0 failed; both clippy runs clean; policy ok.Merged onto current
main(ffe310e) it does not compile, the #801 pattern:resource::tracktakes a fourth argument there.With the call written as
valu_tests.rsdoes onmain(structure first, thenresource::track(&p, &native.layout, native.stage, Some(&st)); local only, not pushed):dxil.dllvalidation (incwrap,decreload,fcmpswapas floats,fmin/fmax);--all-features) clean.So the lowering itself looks good on AMD; the branch only needs a rebase with that one-line test change.
@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
1661a3e:cargo test -p victory-shaderpasses, 93 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:37 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-shader/src/emit/lower.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
Pull request closed