Shaders: v_med3 tests NaN from the bits, which NVIDIA's compiler keeps (TEST-MED3-NAN) #1688
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1689"
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 KevinPratap on 2026-11-24T20:46:28Z.
Claimed in #1633 as
TEST-MED3-NAN.Problem
v_med3_f32_matches_rdna2_with_nanfails onmainon NVIDIA (RTX 4050 Laptop):When an operand is NaN, the hardware returns the minimum of the three. The lowering picks that case with float self-compares (
fcmp uno). NVIDIA's shader compiler folds those away, so the median comes back instead. A comment onfractin the same file describes the same kind of folding on NVIDIA.Fix
NaN is tested from the bits instead:
(bits & 0x7FFFFFFF) > 0x7F800000, an integer compare that the driver keeps.med3serves bothv_med3_f32andv_med3_f16, and the f16 operands are widened to f32 before it runs, so the one test covers both.Verified
v_med3_f32_matches_rdna2_with_nanandv_med3_f16_matches_rdna2_with_nanpass on the GPU and on WARP. Before the change, the f32 one failed.cargo test -p victory-shaderpasses: 120 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warningsis clean.cargo fmt --checkreports no changes in the edited lines. The remaining diffs inlower.rsare already onmain.Only
crates/victory-shader/src/emit/lower.rschanges.AI-assisted.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by KevinPratap on 2026-11-24T21:18:21Z.
Closing as a duplicate of #1483, which already tests NaN from the bits in
med3, and in thev_cmplowering too. It passes the same tests on an RTX 4050 Laptop (results on #1483).upstream-sync referenced this pull request2026-11-25 13:02:44 +00:00
upstream-sync referenced this pull request2026-11-25 13:02:44 +00:00
Pull request closed