Shaders: use DXIL IsNaN for unordered/ordered and self float compares #154
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!154
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/154/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?
@lordon1a on GitHub · 2026-11-24 01:00 UTC · original
fix/fcmp-dxil-isnan→main· +121 −19 · 3 files · 1 commits · closed without mergingSummary
Follow-up to #110 (
med3): extendsLower::compare()incrates/victory-shader/src/emit/lower.rsto use DXIL'sdx.op.isSpecialFloat.f32(IsNaN, opcode 8) for floato(ORD),u(UNO), and same-operand NaN-sensitive comparisons (eq,le,ge,neq,nge,nle).On Intel Iris Xe D3D12 (
8086:46a6, driver32.0.101.7088), the driver's DXIL compiler assumes no NaNs for plain LLVMfcmp, causing all 10 of these cases to return the wrong result onmain@9aef3d9:v1 = NaN, v2 = 1.0):v_cmp_o_f32returns1(want0),v_cmp_u_f32returns0(want1).v1 = NaN, v1 = NaN— standard shaderisnan(x)/!isnan(x)idioms):v_cmp_eq_f32,v_cmp_le_f32,v_cmp_ge_f32,v_cmp_o_f32all return1(want0), andv_cmp_u_f32,v_cmp_nge_f32,v_cmp_nle_f32,v_cmp_neq_f32all return0(want1).Because
fsrc()may emit two separatebitcastinstructions for the same source register (which host CSE then merges intofcmp ... %f, %f),same_srcchecks both SSA equality and identical source operands/modifiers.Verification
Tested on Windows 11 (
rustc 1.100.0,x86_64-pc-windows-gnullvm, Intel Iris Xe8086:46a6driver32.0.101.7088+ WARP):main@9aef3d9lower.rswith the new test):cargo test -p victory-shader v_cmp_f32_nan_matches_rdna2-> FAILED:hardware: v_cmp_eq_f32(same reg, case 0) = 1, want 0(and all 9 other cases above fail on hardware while passing on WARP).cargo test -p victory-shader v_cmp_f32_nan_matches_rdna2-> ok on both Intel Iris Xe and WARP.cargo test -p victory-shader -- --skip v_med3_f32_matches_rdna2_with_nan-> 69 passed, 0 failed (skipping only the pre-existingmed3failure fixed in #110).cargo xtask policy: 151 files ok (synthetic GFX10 shader only; zero game data).AI-assisted.
@DaviTostes on GitHub · 2026-11-24 01:30 UTC · original
Tested
d5fca30on Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 56 passed, 0 failed (2 test binaries), including the {adds} test{'s' if adds != 1 else ''} this PR adds.victory-gpuE0425.No game data used.
@marquezinii on GitHub · 2026-11-24 05:15 UTC · original
Ran
d5fca30merged ontomaind2a4bae(clean; the branch was 2 commits behind) on NVIDIA.valu_testsruns each case on the hardware device and on WARP.x86_64-pc-windows-msvc, debugv_cmp_f32_nan_matches_rdna2: ok on bothcargo test -p victory-shader --lib -- --test-threads=1: 70 passed, 0 failedcargo test --workspace -- --test-threads=1: 265 passed, 0 failed, 4 ignoredPull request closed