shader: support BUF_FMT_8_8_8_8_UINT fetch format in gfx2hlsl (Part of #1723) #2004
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2004
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2004/head"
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?
@tedin7 on GitHub · 2026-11-24 22:57 UTC · original
tedin7:x2w-pipe-buf-8888-uint→main· +59 −1 · 5 files · 3 commits · closed without mergingPart of #1723
What this unblocks: typed buffer loads with
BUF_FMT_8_8_8_8_UINTnow translate (four unscaled bytes) instead of being refused, so shaders using it can get past startup translation.Changes:
tools/startup/gfx2hlsl.py: addBUF_FMT_8_8_8_8_UINTtoFETCH_FORMATS(bytes of one word, no 1/255 scale).tests/startup_gfx2hlsl_buf_8888_uint_check.py+ CTeststartup_gfx2hlsl_buf_8888_uint: pure Python, evaluates the emitted lines for several words.Verification:
python3 -B tests/startup_gfx2hlsl_buf_8888_uint_check.pywith fix:okgfx2hlsl.pyfrom origin/main:Unsupported: buffer format BUF_FMT_8_8_8_8_UINTAI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:57 UTC · original · edited 2026-11-24 23:00 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
3cf4cb9ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -85,3 +86,4 @@'BUF_FMT_8_8_8_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', 'U(((w >> 8) & 255) / 255.0)', 'U(((w >> 16) & 255) / 255.0)', 'U((w >> 24) / 255.0)']),'BUF_FMT_8_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', 'U(((w >> 8) & 255) / 255.0)', '0u', 'U(1.0)']),'BUF_FMT_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', '0u', '0u', 'U(1.0)']),'BUF_FMT_8_8_8_8_UINT': ('ldu({0}, a)', ['w & 255u', '(w >> 8) & 255u', '(w >> 16) & 255u', 'w >> 24']),@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:00 UTC · original
This adds support for
BUF_FMT_8_8_8_8_UINTbut leaves both the README anddocs/experiments.mdunchanged, so contributors following the published experiment documentation cannot discover or reproduce the new capability.AGENTS.mdrequires a documentation update when a public capability changes. Add an experiment entry with the new test command and distinguish its Python-only expression checks from compiled-shader or GPU validation.AGENTS.md reference: AGENTS.md:L207-L208
Useful? React with 👍 / 👎.
@ChazY11 on GitHub · 2026-11-24 23:22 UTC · original
Ran both, broke each one four ways — all caught — and checked the SNORM mapping over all 65,536 halves
Two small format additions, reviewed together because they share
FETCH_FORMATSand both arePart of #1723.-1.0clamp removed/ 32767.0→/ 32768.0asint(w & 0xffffu)instead of the sign-extending shiftzloses its& 255uwbecomesw >> 8Both fixtures carry the boundary values, not just mid-range ones — the sign-extending shift and the removed clamp are exactly the two that would
survive a fixture built from small positives.
The SNORM mapping, checked exhaustively
I reimplemented the emitted expression (
max(float(asint(w << 16) >> 16) / 32767.0, -1.0)) and compared it with the DXGI SNORM rule over every16-bit half:
-32768is the only input that needs the clamp:/32767gives-1.0000305, and every other half already lands inside[-1, 1]. That is worth asentence in the description, because it explains why the clamp is a
maxon one specific value rather than a general guard, and why a reader whoreplaces it with
saturate()-style clamping would change nothing for 65,535 of the 65,536 inputs.The
+32767 → 1.0endpoint is exact and-32767 → -1.0too, so both extremes of the representable range are hit exactly, which is the property asigned-normalised vertex attribute depends on.
UINT
w & 255u,(w >> 8) & 255u,(w >> 16) & 255u,w >> 24— the last channel needs no mask because the shift already bounds it to 0..255, and amask there would be dead code rather than a bug. The three masks that exist are each pinned by the mutations above.
Worth noting the asymmetry with SNORM in the same table: one format sign-extends and divides, the other masks and shifts, and both are now covered by
fixtures that fail when the wrong one is used.
Merge state, and the overlap I flagged earlier
Both branches are clean against
mainindividually, but they are the pair that overlaps at lines 87–89 inFETCH_FORMATS: whichever lands secondneeds a one-line rebase. Nothing else in either PR touches the other.
What is not covered
No vertex shader was compiled or run; the values above are the emitted expressions evaluated in Python, not a draw. And the
z = 0u,w = 1.0filler for the two-channel SNORM format matches the other two-channel entries — that is a convention I checked against the table, not a format
property.
Notes
@ -85,3 +86,4 @@'BUF_FMT_8_8_8_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', 'U(((w >> 8) & 255) / 255.0)', 'U(((w >> 16) & 255) / 255.0)', 'U((w >> 24) / 255.0)']),'BUF_FMT_8_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', 'U(((w >> 8) & 255) / 255.0)', '0u', 'U(1.0)']),'BUF_FMT_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', '0u', '0u', 'U(1.0)']),'BUF_FMT_8_8_8_8_UINT': ('ldu({0}, a)', ['w & 255u', '(w >> 8) & 255u', '(w >> 16) & 255u', 'w >> 24']),@tedin7 on GitHub · 2026-11-25 00:53 UTC · original
Added the experiment entry in docs/experiments.md (test command, Python-only scope, no DXC/WARP run) in
a929d075on the rebased branch. AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_buf_8888_uint_check.py; python3 -B tests/startup_vertex_fetch_formats_check.py controls.@tedin7 on GitHub · 2026-11-25 10:58 UTC · original
Closing as superseded by #2193 (merged on main at
19509ee4), which landed the sameBUF_FMT_8_8_8_8_UINTfetch format, DXGI 30 entry, and vertex fetch coverage.@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:00 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
3cf4cb9091ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pull request closed