shader: support BUF_FMT_16_16_SNORM fetch format in gfx2hlsl (Part of #1723) #2005
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!2005
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2005/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-1616-snorm→main· +144 −0 · 3 files · 1 commits · closed without mergingPart of #1723
What this unblocks: typed buffer loads of
BUF_FMT_16_16_SNORMnow translate ingfx2hlsl.pyinstead of being refused withbuffer format BUF_FMT_16_16_SNORM.Change:
FETCH_FORMATSgetsBUF_FMT_16_16_SNORM: one unaligned dword load, each half sign-extended, divided by 32767 and clamped at -1.0. Missing z reads 0 and missing w reads 1.0, the same default as the other formats.startup_gfx2hlsl_tbuffer_16_16_snorm(registered in CMake). The instruction bytes are built in the test from the decoder's field layout; no game-derived bytes.Verification:
python3 -B tests/startup_gfx2hlsl_tbuffer_16_16_snorm_check.pywith the fix: PASS (10 checks ok).gfx2hlsl.py: fails withUnsupported: buffer format BUF_FMT_16_16_SNORM.python3 -Bonstartup_gfx2hlsl_tbuffer_16f_check.py,startup_gfx2hlsl_refusals_check.py,startup_gfx2hlsl_op_refusals_check.py: exit 0.git diff --check: clean.ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_tbuffer_16_16_snorm$' -V.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:58 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.
2d67c89ℹ️ 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.
@ -86,1 +86,4 @@'BUF_FMT_16_16_UNORM': ('ldu({0}, a)', ['U((w & 65535) / 65535.0)', 'U((w >> 16) / 65535.0)', '0u', 'U(1.0)']),# Signed 16-bit fields: sign-extend, divide by 32767, and clamp -32768 to -1.0 (the SNORM rule).'BUF_FMT_16_16_SNORM': ('ldu({0}, a)', ['U(max(float(asint(w << 16) >> 16) / 32767.0, -1.0))','U(max(float(asint(w) >> 16) / 32767.0, -1.0))', '0u', 'U(1.0)']),@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:00 UTC · original
This changes a previously refused typed-buffer format into a supported one, but neither
README.mdnordocs/experiments.mdwas updated; a repository-wide search finds no documentation for the new format or test.AGENTS.mdrequires a documentation update when a public capability or reproduction command changes. Add an experiment note describing the supported format and test invocation, distinguishing the passing decode/emitted-HLSL checks from the unrun shader-compilation and GPU checks, so contributors can discover and reproduce the supported scope.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
@tedin7 on GitHub · 2026-11-25 00:30 UTC · original
Closing as superseded by #2099 which also wires FETCH_DXGI 37 and the WARP/hardware vertex-fetch suite.
@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:
2d67c89ec2ℹ️ 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