Shaders: flush subnormals in the f32 cube coordinates #1708
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1709"
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 Calvix2k on 2026-11-24T21:03:32Z.
Rebased 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).Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:03Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.f32 min/max/median and cube ops now flush subnormals like RDNA MAD instructions: write_f_with_ftz + flush_f32 (exponent==0 → signed zero via sign mask). +3 macOS tests.
[PR #1709] Shaders: flush subnormals in f32 min/max/median and cubeto [PR #1709] Shaders: flush subnormals in the f32 cube coordinatesImported from Marvisak/VIctory. Originally posted by tumbubu on 2026-11-24T22:14:27Z.
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.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:21:08Z.
Reworked on the new base as a standalone cube-only PR (no longer stacked on #1554). See updated body.
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-25T00:19:18Z.
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.Imported from Marvisak/VIctory. Originally posted by Marcos-Barranquero on 2026-11-25T01:12:42Z.
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 probe3686431aaf3243+ #1766's probev_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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:35:19Z.
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
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T08:37:16Z.
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