Shaders: abs/neg on v_mov_b32 and v_cndmask_b32 change only the sign bit (fixes #883) #1037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1037"
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 acleofe on 2026-11-24T15:14:40Z.
What
v_mov_b32andv_cndmask_b32with abs/neg source modifiers now apply them to the sign bit of the source's bits (& 0x7fffffff,^ 0x80000000) and write the result as an integer, through a newsign_modified_src.v_mov_b32with clamp or omod keeps the float path.srckeeps refusing integer modifiers; its body moved tounmodified_src, which both use.Why
On RDNA2 a move or select copies bits; abs and neg on them only clear or flip bit 31. The lowering went through
fsrc, which applies them as float operations (FAbs,-0.0 - x), so the host flushes denormals and quiets signaling NaNs:v_mov_b32 v0, |v1|with v1 =0x00000001gave0instead of0x00000001. Integer or packed data moved with a modifier came out changed.Test
move_and_select_modifiers_change_only_the_sign_bit(valu_tests, hardware GPU and WARP): abs, neg and both, on denormals, signaling NaNs and 1.0, forv_mov_b32and both arms ofv_cndmask_b32. Before this change it fails on the hardware GPU (0x00000001with abs gave0).cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsandcargo test --workspace --lockedpass.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by Baconzido on 2026-11-24T15:28:26Z.
Tested
6afa565(onmainffe310e) on Windows 11 26300, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP,dxil.dllfrom SDK 10.0.26100, Rust 1.98.1:move_and_select_modifiers_change_only_the_sign_bitcargo test -p victory-shader -- --test-threads=1cargo clippy -p victory-shader --all-targetslower.rsfromffe310e, the new test keptv_mov_b32 abs=1 neg=0 [1, 0, 0, 0]:0, want1)One AMD data point for #883: with
main's float path, the new test's hardware pass succeeds on the RX 5700.run_casesruns the hardware device first and stops at the first mismatch, and the first mismatch came from WARP. So this AMD driver keeps the denormals and signalling NaNs throughFAbsand-0.0 - xhere, and the bug shows on WARP (and the NVIDIA cards in #883), not on this card. The fix is still right: it no longer depends on what the host driver does with denormals.No game data used.
AI use: Claude Code (Claude Opus 5.5) ran the tests over SSH and drafted this comment; the runs are on my machine.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:30:28Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
6afa565:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Pull request closed