Repository navigation
Shader: encode NaN as zero in normalized typed buffer stores - #1315
Merged
ItsNotRexed merged 1 commit intoNov 22, 2026
Merged
Conversation
The buffer unit encodes every half NaN as zero. Passing NaN to FClamp instead produced the negative signed-normalized endpoint on both translated backends.
Contributor
|
Tested b9893db on Windows 11 with llvm-mc 23.1.6 (Linux had no llvm-mc, so the new tests skipped there): pass.
|
Contributor
|
Tested
No game files. |
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.
Claimed in the coordination issue as normalized typed stores, following the BUILD-161 native measurement.
What and why
All 2,046 binary16 NaN encodings stored byte 0x00 in RGBA8_SNORM on native gfx1036. The translated store on main wrote 0x81 for every one of them on both tested GPUs. GLSL.std.450 FClamp leaves its result undefined for NaN.
Produce one NaN-to-zero conversion per source component and share it among the UNORM/SNORM packing branches before clamp, scale and rounding. The floating-point and integer formats continue to read the original component words. The tests check full-precision and packed inputs, both normalized formats, a signaling NaN, a quiet NaN, an infinity, a rounding tie, and retention of a raw NaN payload by 32_FLOAT and 32_UINT stores.
Tested
buffer_store_format_d16_xyzw, for both SNORM and UNORM and in wave32 and wave64. Every finite byte matched the independent reference (clamp, multiply by 127 or 255, nearest-even integer); both infinities saturated and every NaN stored zero. Guard dwords survived.pytest tests/test_translate.py: 371 passed, two skipped. The four normalized-store cases failed on the parent.python -m unittest discover -s tests/semantic: 1,171 tests, one skipped.Checklist
docs/design.md.AI-assisted.