Skip to content

Shaders: preserve subnormal cube coordinates on negative Z and through clamp - #1

Merged
Moon0755 merged 3 commits into
Moon0755:fix/cube-denormal-resultsfrom
passerbyyhx:fix/cube-coordinate-bits
Nov 26, 2026
Merged

Moon0755 merged 3 commits into
Moon0755:fix/cube-denormal-resultsfrom
passerbyyhx:fix/cube-coordinate-bits

Conversation

@passerbyyhx

Copy link
Copy Markdown

Hardware follow-up to Marvisak#3127, based on 7d34d385. I verified the RTX 4090 Laptop adapter by LUID and ran the same translated shaders on Microsoft WARP.

Negative Z face. The seven published RDNA2 reference rows already passed on the 4090. In the larger 14,440-input probe, CUBESC disagreed with the model on 336 rows. All 336 selected a nonzero subnormal X with negative Z as the major axis. For X bits 0x00000001, Y = 0 and Z = −1, the adapter returned 0x80000000 where the model predicts 0x80000001. Selecting the raw coordinate and its sign mask separately, then applying a single integer XOR, removed every mismatch. The exact negative-Z example is a model prediction. The published RDNA2 table covers related cases.

Clamped SC and TC. With the first fix alone, both adapters still flushed a selected positive subnormal to zero on two of five CUBESC rows and one of five CUBETC rows. Here the expected bits come directly from the published RDNA2 measurements. The second commit preserves those bits for SC/TC with CLAMP and no output multiplier.

Verification. All five cube tests passed on the 4090 Laptop and WARP. CUBEID, CUBESC, CUBETC and CUBEMA each matched the model on all 14,440 inputs on both adapters. Strict Clippy and the repository policy test passed. The shader library run had 301 passes, three failures and three ignored tests, with one test filtered for Marvisak#2571. The same two stride failures and one gather failure reproduced individually on the unmodified author head.

To rerun the focused probes on Windows:

cargo test --locked -p victory-shader --lib cube -- --nocapture --test-threads=1

A negative Z face negates X by changing its sign bit alone. Selecting the signed values directly lost the subnormal payload on the RTX 4090 Laptop. Select the operand and its sign mask separately, then apply one integer XOR. Check both Z faces and both signs at the endpoints of the subnormal range.
The measured RDNA2 SC and TC clamp rows retain a selected positive subnormal without an output multiplier. Preserve that bit pattern while using the ordinary saturate for other values. Leave output multipliers on their existing path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants