shader: support BUF_FMT_8_8_8_8_UINT fetch format in gfx2hlsl (Part of #1723) #2004

Closed
github-bot wants to merge 3 commits from gh-pr/2004/head into gh-pr/2004/base
Owner

@⁠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 merging

Part of #1723

What this unblocks: typed buffer loads with BUF_FMT_8_8_8_8_UINT now translate (four unscaled bytes) instead of being refused, so shaders using it can get past startup translation.

Changes:

  • tools/startup/gfx2hlsl.py: add BUF_FMT_8_8_8_8_UINT to FETCH_FORMATS (bytes of one word, no 1/255 scale).
  • tests/startup_gfx2hlsl_buf_8888_uint_check.py + CTest startup_gfx2hlsl_buf_8888_uint: pure Python, evaluates the emitted lines for several words.

Verification:

  • python3 -B tests/startup_gfx2hlsl_buf_8888_uint_check.py with fix: ok
  • Same command with gfx2hlsl.py from origin/main: Unsupported: buffer format BUF_FMT_8_8_8_8_UINT
  • Not run on Win2025 (no GPU/compiler needed by this test); no hardware measurement of the format.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 22:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004) `tedin7:x2w-pipe-buf-8888-uint` → `main` · +59 −1 · 5 files · 3 commits · closed without merging Part of #1723 What this unblocks: typed buffer loads with `BUF_FMT_8_8_8_8_UINT` now translate (four unscaled bytes) instead of being refused, so shaders using it can get past startup translation. Changes: - `tools/startup/gfx2hlsl.py`: add `BUF_FMT_8_8_8_8_UINT` to `FETCH_FORMATS` (bytes of one word, no 1/255 scale). - `tests/startup_gfx2hlsl_buf_8888_uint_check.py` + CTest `startup_gfx2hlsl_buf_8888_uint`: pure Python, evaluates the emitted lines for several words. Verification: - `python3 -B tests/startup_gfx2hlsl_buf_8888_uint_check.py` with fix: `ok` - Same command with `gfx2hlsl.py` from origin/main: `Unsupported: buffer format BUF_FMT_8_8_8_8_UINT` - Not run on Win2025 (no GPU/compiler needed by this test); no hardware measurement of the format. AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:49:01 +00:00
github-bot closed this pull request 2026-11-26 23:49:01 +00:00
Author
Owner

@⁠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.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:00:35.930684Z 3cf4cb9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 22:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#issuecomment-7146852650) · edited 2026-11-24 23:00 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3cf4cb9091831c165514e0bbf9e5cf62f8bc3c4f","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T23:00:35.930684Z">2026-11-24T23:00:35.930684Z</relative-time> | `3cf4cb9` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
@ -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']),
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:00 UTC · original

P1 Badge Document the new typed-buffer capability and validation scope

This adds support for BUF_FMT_8_8_8_8_UINT but leaves both the README and docs/experiments.md unchanged, so contributors following the published experiment documentation cannot discover or reproduce the new capability. AGENTS.md requires 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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#discussion_r4687708963) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the new typed-buffer capability and validation scope** This adds support for `BUF_FMT_8_8_8_8_UINT` but leaves both the README and `docs/experiments.md` unchanged, so contributors following the published experiment documentation cannot discover or reproduce the new capability. `AGENTS.md` requires 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](https://github.com/R0Y00/Xbox2Windows/blob/3cf4cb9091831c165514e0bbf9e5cf62f8bc3c4f/AGENTS.md#L207-L208) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠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_FORMATS and both are Part of #1723.

# BUF_FMT_16_16_SNORM
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_tbuffer_16_16_snorm_check.py   # exit 0
# BUF_FMT_8_8_8_8_UINT
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_buf_8888_uint_check.py          # exit 0
mutation result
SNORM: x and y halves swapped caught
SNORM: the -1.0 clamp removed caught
SNORM: / 32767.0 → / 32768.0 caught
SNORM: x read with asint(w & 0xffffu) instead of the sign-extending shift caught
UINT: x and y channels swapped caught
UINT: z loses its & 255u caught
UINT: w becomes w >> 8 caught

Both 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 every
16-bit half:

values checked: 65536  mismatches: 0  worst delta: 0

0x0000 -> 0.0000000      0x7fff -> 1.0000000       0x8000 -> -1.0000000
0x8001 -> -1.0000000     0xffff -> -0.0000305      0x4000 -> 0.5000153
-32768 with the clamp removed -> -1.0000305 (outside SNORM)

-32768 is the only input that needs the clamp: /32767 gives -1.0000305, and every other half already lands inside [-1, 1]. That is worth a
sentence in the description, because it explains why the clamp is a max on one specific value rather than a general guard, and why a reader who
replaces it with saturate()-style clamping would change nothing for 65,535 of the 65,536 inputs.

The +32767 → 1.0 endpoint is exact and -32767 → -1.0 too, so both extremes of the representable range are hit exactly, which is the property a
signed-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 a
mask 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 main individually, but they are the pair that overlaps at lines 87–89 in FETCH_FORMATS: whichever lands second
needs 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.0
filler 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

  • AI-assisted review.
**@⁠ChazY11** on GitHub · 2026-11-24 23:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#issuecomment-7147322899) ## 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_FORMATS` and both are `Part of #1723`. ```powershell # BUF_FMT_16_16_SNORM out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_tbuffer_16_16_snorm_check.py # exit 0 # BUF_FMT_8_8_8_8_UINT out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_buf_8888_uint_check.py # exit 0 ``` | mutation | result | |---|---| | SNORM: x and y halves swapped | **caught** | | SNORM: the `-1.0` clamp removed | **caught** | | SNORM: `/ 32767.0` → `/ 32768.0` | **caught** | | SNORM: x read with `asint(w & 0xffffu)` instead of the sign-extending shift | **caught** | | UINT: x and y channels swapped | **caught** | | UINT: `z` loses its `& 255u` | **caught** | | UINT: `w` becomes `w >> 8` | **caught** | Both 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 every 16-bit half: ```text values checked: 65536 mismatches: 0 worst delta: 0 0x0000 -> 0.0000000 0x7fff -> 1.0000000 0x8000 -> -1.0000000 0x8001 -> -1.0000000 0xffff -> -0.0000305 0x4000 -> 0.5000153 -32768 with the clamp removed -> -1.0000305 (outside SNORM) ``` `-32768` is the **only** input that needs the clamp: `/32767` gives `-1.0000305`, and every other half already lands inside `[-1, 1]`. That is worth a sentence in the description, because it explains why the clamp is a `max` on one specific value rather than a general guard, and why a reader who replaces it with `saturate()`-style clamping would change nothing for 65,535 of the 65,536 inputs. The `+32767 → 1.0` endpoint is exact and `-32767 → -1.0` too, so both extremes of the representable range are hit exactly, which is the property a signed-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 a mask 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 `main` individually, but they are the pair that overlaps at lines 87–89 in `FETCH_FORMATS`: whichever lands second needs 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.0` filler 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 - AI-assisted review.
@ -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']),
Author
Owner

@⁠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 a929d075 on 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 00:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#discussion_r4688702630) Added the experiment entry in docs/experiments.md (test command, Python-only scope, no DXC/WARP run) in a929d075 on 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 10:58 UTC · original

Closing as superseded by #2193 (merged on main at 19509ee4), which landed the same BUF_FMT_8_8_8_8_UINT fetch format, DXGI 30 entry, and vertex fetch coverage.

**@⁠tedin7** on GitHub · 2026-11-25 10:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#issuecomment-7160416502) Closing as superseded by #2193 (merged on main at `19509ee4`), which landed the same `BUF_FMT_8_8_8_8_UINT` fetch format, DXGI 30 entry, and vertex fetch coverage.
Author
Owner

@⁠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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2004#pullrequestreview-6048761027) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `3cf4cb9091` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". 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". </details>

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.