Shaders: flush subnormals in the f32 cube coordinates #1709
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!1709
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1709/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?
@Calvix2k on GitHub · 2026-11-24 21:03 UTC · original
Calvix2k:codex/shader-denormals-find4→main· +43 −1 · 2 files · 1 commits · closed without mergingRebased onto
70564aeand reduced to the cube path only: upstream77053a0now flushes denormals for min/max/select and med3 itself, so those parts and the #1554 stack are gone. The cube inputs and result go through the sharedftzhelper;v_cube_flushes_subnormals_in_dxilchecks the four sequences.Validation: targeted test passes, clippy
-D warningsandcargo xtask policy(174 files) clean. Hardware measurement on the RX 7800 XT remains the same (the hardware flushes; the lowering now emits it explicitly).@tumbubu on GitHub · 2026-11-24 22:14 UTC · original
On an RX 7900 XT (RDNA3): #1709 removes six of the seven
min/max/med3/cubedisagreements #1614's fuzzer finds. With #1483 on top, all seven agree.RX 7900 XT, driver 32.0.31036.15, Windows 11 26300,
dxil.dll10.0.26100. #1614's fuzzer (fuzz_tests.rsatc3372c1) was copied onto each head, 160 inputs per opcode, comparing the 7900 XT with WARP:mainffe310e3821b530daabccv_min_f32v_max_f32v_min3_f32v_max3_f32v_cubesc_f32v_cubetc_f32v_med3_f32min/max/med3/cubeopcodes (34)v_med3_f32rows left on #1709 alone are all one case: two flushed denormals of opposite sign, where the 7900 XT returns+0and WARP returns-0. One example isv_med3_f32(0x00000001, 0x4e800000, 0x807fffff). That is the-0 < +0ordering #1483 adds tov_med3, and with it the rows agree.cargo test -p victory-shader --locked -- --test-threads=1gives 123 passed, 0 failed, 1 ignored. Both DXIL checks ran, sincedxc.exeis next to the SDK'sdxil.dll.lower.rsmerged cleanly, and invalu_tests.rsI kept both sides' new tests. That gives 129 passed, 0 failed.main's 31 disagreements on this card down to 25. What is left is the i64 compares (#1599), the f16 rounding (#422 /77053a0), the fusedv_fma(c)_f32andv_med3_f32, plus WARP's own inexactv_sin/v_cos/v_log/v_cvt_f32_u32.Synthetic tests only, no game files. AI-assisted (Claude Code); every run was on this machine.
@Calvix2k on GitHub · 2026-11-24 22:21 UTC · original
Reworked on the new base as a standalone cube-only PR (no longer stacked on #1554). See updated body.
@alexdeliu on GitHub · 2026-11-25 00:19 UTC · original
Cross-referencing #1766, which makes the same input flush for
v_cube*_f32. I compared the two there: theftz(r)on the result can't change anything, because cube results are ±an input, 2 × an input, or a face id, andwrite_falready flushesomodproducts. So the two PRs behave the same; only one should merge. This PR was first. #1766's GPU probe (semantics_tests, checked on an RX 9070 and a gfx1036) can go on top of it if wanted.@Marcos-Barranquero on GitHub · 2026-11-25 01:12 UTC · original
NVIDIA data point for this and #1766: RTX 4070 Ti SUPER (Ada), driver 32.0.16.1692, Windows 11. The probe is #1766's
semantics_tests::cube_faces_match_the_hardware: 14,440 inputs per op, checked against its RDNA2 model.v_cubesc_f32hardware vs modelv_cubetc_f32hardware vs modelmain42363ab+ #1766's probe3686431v_cubeid_f32andv_cubema_f32are 0 everywhere. This PR's ownv_cube_flushes_subnormals_in_dxilpasses as well.On
mainthe RTX keeps a denormal coordinate, as AMD does:v_cubesc_f32(0, NaN, 0x00000001)=0x80000001, and WARP gives0x80000000. The mismatch count against the model is the same 2,193 that #1766 reports for the RX 9070. So the flush fixes NVIDIA the same way, and either PR does it. The cross-device fuzzer from #1614 on this card hadv_cubesc/tc_f32among its 9 differences against WARP onmain; the other 7 are WARP's own inexactness and the known fusedv_fma/v_fmac_f32.No game data.
AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 03:35 UTC · original
Automated triage for the maintainers.
Needs work. Flushing denormal cube coordinates through
ftzinlower.rs(thev_cube*_f32arm) is backed by hardware results posted on this PR (RX 7900 XT, RTX 4070 Ti SUPER). However, #1766 makes the same input flush and adds a hardware-checked probe,semantics_tests::cube_faces_match_the_hardware, so the maintainer should pick one. If this one goes ahead:dump_cube_dxilinvalu_tests.rscopiesdump_dxilfromemit/mod.rs; please share that helper.ftz(r)on the result appears to do nothing, since cube results are ± an input, twice an input, or a face id.and i32 ... 2139095040lines, which is weaker than #1766's probe.CI passes.
Generated by Claude Code
@Calvix2k on GitHub · 2026-11-25 08:37 UTC · original
Closing this in favour of #1766 (@alexdeliu), which the triage also recommends: it makes the same flush and adds a hardware-checked probe (
semantics_tests::cube_faces_match_the_hardware) that is stronger than this PR's check for the emittedand 0x7F800000sequences. @alexdeliu already said whichever lands, the other closes; two green PRs for one behaviour only divides the review.Nothing is lost: the four emitted sequences this PR checked are the same ones that probe measures on the hardware. If #1766 ends up not landing, the branch here stays rebased and can be reopened.
Pull request closed