Shaders: cube-map face coordinates read denormals as zeros #1765
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1766"
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 alexdeliu on 2026-11-24T22:13:16Z.
v_cubeid/sc/tc/ma_f32return one of the coordinates, or its negation. So a denormal coordinate comes out as the host chooses:v_cubesc_f32(0, NaN, 0x00000001)gives0x80000001on an RX 9070.0x80000000.mainmodels it since77053a0(32-bit denormals flushed on input and output), reads it as a zero of its sign.min/maxoperands already go throughftz(77053a0). The cube coordinates didn't.Change
The three coordinates go through
self.ftzbefore the major-axis compare and the pick (lower.rs, the cube arm).Test
semantics_tests::cube_faces_match_the_hardwareadds a probe family in the existing framework:triples(F32_EDGES, F32_EDGES, F32_THIRD), i.e. 14,440 inputs with signed zeros, denormals, infinities and NaN in each coordinate;cube(): the major-axis rule from the ISA, with coordinates read throughftz.main@70564aev_cubesc_f32alone)Checks
On Windows 11 with the RX 9070:
cargo test --workspace --lockedpasses 475 (main: 474, plus this probe);mainitself with the SDK's 1.7dxil.dll(rect::tests::rectangles_get_their_fourth_corner,tests::elements_sharing_a_row_keep_their_order; see #1744).Found by the cross-device fuzzer in #1614. It is the remaining denormal case after
77053a0(FIND-4 in #1633).🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:18:50Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows.Cube-map face coordinates read denormals as zeros: cube()/cube_probes() + cube_faces_match_the_hardware pins face-coordinate denormal behavior against hardware. Small, precise fix with a hardware test.
upstream-sync referenced this pull request2026-11-24 23:05:22 +00:00
Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:13:58Z.
VIctory V2: community PRs, merged and tested
Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.
Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).
⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.
Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2
Unofficial community fork of Marvisak/VIctory, GPL-3.0.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:46:27Z.
Overlap for the reviewers: #1709 (Calvix2k, opened 21:03, rebased onto
70564ae) makes the same change inlower.rs:let (x, y, z) = (self.ftz(x), self.ftz(y), self.ftz(z));on thev_cube*_f32inputs. It also passes the result throughself.ftz(r). Its test isv_cube_flushes_subnormals_in_dxilinvalu_tests.rs; this PR's is insemantics_tests.rs. Only one of the two code changes can merge as is. From reading both diffs; nothing built.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T23:59:16Z.
@upipibi thanks. #1709 came first and makes the same input flush, so only one of the two should merge. The real difference is that #1709 also flushes the result. I will check on the RX 9070 and the gfx1036 whether the hardware flushes
v_cube*results too, and post it on both PRs. If it does, #1709 is the more complete fix, and this PR'ssemantics_testsprobe can move on top of it.Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-25T00:19:16Z.
Follow-up on the #1709 overlap: the two PRs behave the same. #1709's extra
self.ftz(r)on the result is a no-op, so no hardware check is needed to choose between them.v_cube*_f32result is built from an input or a constant.cubesc/cubetcreturn a coordinate, possibly negated;cubemareturns 2 × the major coordinate;cubeidreturns a face index from 0 to 5. With the inputs flushed, every input is ±0 or normal, so no result can be denormal.omod×0.5 on a value near FLT_MIN.write_falready handles that: it flushes, multiplies, then turns a tiny product into +0 for every VALU op.So either change is correct. #1709 was opened first. This PR adds a
semantics_testsprobe, which runs the GPU on both sides. #1709's test checks the DXIL text. If #1709 is the one taken, I'm happy to move the probe on top of it.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T00:41:35Z.
Thanks for the cross-reference. #1709 was opened first and is still mergeable, so this is a duplicate of it. The GPU probe from this PR (semantics_tests on RX 9070 and gfx1036) is the useful extra piece; it would be welcome as a follow-up on top of #1709. Suggest closing this PR in favour of #1709.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:41:23Z.
Automated triage for the maintainers.
Merge candidate. The new head only merges
main; the change is the same. Thev_cube*_f32arm incrates/victory-shader/src/emit/lower.rsflushes the three coordinates throughself.ftzbefore choosing the major axis. That matchesmain's model of the console's float mode, andmainstill lacks the flush there. Thecube_faces_match_the_hardwareprobe insemantics_tests.rscompares the GPU against an ISA-based model over signed zeros, denormals, infinities and NaN. #1709 makes the same input flush (its extra result flush is a no-op, as argued here) and also merges cleanly. Only one of the two should land, and this one carries the hardware probe.Agreed with the reply: either change is correct, and the choice between this and #1709 is the maintainer's.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-25T04:50:23Z.
@Calvix2k thanks. As I wrote above, the two behave the same. I'll leave the choice to the maintainer; whichever one lands, the other can be closed. If it's #1709, I'll move the
semantics_testsprobe on top of it.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T05:15:15Z.
Understood — whichever the maintainer picks, the other closes. #1709 is green and mergeable; if it lands first, moving your
semantics_testsprobe on top of it is the right follow-up. The difference I saw on my side is only in what the tests compare (mine checks the four emitted sequences; yours measures the hardware's denormal output forv_cube*_f32), and both are useful.upstream-sync referenced this pull request2026-11-25 10:07:33 +00:00