Shaders: lower image_atomic_inc, _dec, _fcmpswap, _fmin and _fmax #1148
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1148"
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 VermaakLabs on 2026-11-24T16:14:33Z.
DXIL 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.Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T17:23:28Z.
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.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:16Z.
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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:37:44Z.
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