Shaders: abs/neg on v_mov_b32 and v_cndmask_b32 change only the sign bit (fixes #883) #1037
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!1037
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1037/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?
@acleofe on GitHub · 2026-11-24 15:14 UTC · original
fix/shader-move-modifiers-bitwise→main· +99 −9 · 2 files · 1 commits · closed without mergingWhat
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
@Baconzido on GitHub · 2026-11-24 15:28 UTC · original
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.
@Zipettte on GitHub · 2026-11-24 16:30 UTC · original
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