Repository navigation
Shaders: preserve subnormal cube coordinates on negative Z and through clamp - #1
Merged
Moon0755 merged 3 commits intoNov 26, 2026
Conversation
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.
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
CUBESCdisagreed with the model on 336 rows. All 336 selected a nonzero subnormal X with negative Z as the major axis. For X bits0x00000001, Y = 0 and Z = −1, the adapter returned0x80000000where the model predicts0x80000001. 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
CUBESCrows and one of fiveCUBETCrows. Here the expected bits come directly from the published RDNA2 measurements. The second commit preserves those bits for SC/TC withCLAMPand no output multiplier.Verification. All five cube tests passed on the 4090 Laptop and WARP.
CUBEID,CUBESC,CUBETCandCUBEMAeach 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: