shader: lower unsigned 16-bit pair vertex fetches (BUF_FMT_16_16_UINT) #2305

Merged
denn0x merged 1 commit from upstream-pr/2313 into main 2026-11-25 12:15:34 +00:00
denn0x commented 2026-11-25 11:56:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T11:56:56Z.


What

tbuffer_load_format_* with gfx10 format 27 was refused as an unknown buffer format in tools/startup/gfx2hlsl.py. LLVM 15 defines the format as BUF_DATA_FORMAT_16_16 with BUF_NUM_FORMAT_UINT (ufmt).

It now reads two unsigned 16-bit fields through ldu(), the low half into X. Z = 0 and W = 1, like the other integer rows. Only the tbuffer table row is added. The DXGI stream-layout mapping is unchanged.

Test

tests/startup_vertex_fetch_formats_check.py gains the format and three mutated translations:

  • a normalized low half;
  • the high half read from the low half;
  • a missing W read as 1.0.

The format uses stride 6 and offset 2, so half of the 16 elements cross a dword.

python -B tests/startup_vertex_fetch_formats_check.py controls
vertex fetch format controls passed
python -B tests/startup_vertex_fetch_formats_check.py <dxc> out/build/<dir>/offscreen_check.exe warp
warp: 14 buffer formats, 16 vertices each, every wrong reference and 15 mutations fail
python -B tests/startup_vertex_fetch_formats_check.py <dxc> out/build/<dir>/offscreen_check.exe hardware
hardware: 14 buffer formats, 16 vertices each, every wrong reference and 15 mutations fail

These are the commands behind startup_vertex_fetch_formats_(controls|warp|hardware).

On main, controls fails with gfx2hlsl.Unsupported: buffer format BUF_FMT_16_16_UINT.

Environment

  • Hardware: AMD Radeon RX 9070 XT, driver 32.0.32015.7029, the first adapter in high-performance order.
  • Software: WARP, Windows 10.0.26300.9974, DXC 1.8.2502.11 (Windows SDK 10.0.26100). The SDK debug layers are installed.
  • Build: all builds (Ninja Release, MSVC Build Tools 18).
  • Skips: none.

Other checks: startup_stream_fetch_check.py, startup_gfx2hlsl_tbuffer_16f_check.py and docs_links_check.py pass.

docs/experiments.md lists the new format and the device result.

Refs #2023 (item G)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6603928304 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2313). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T11:56:56Z. --- ## What `tbuffer_load_format_*` with gfx10 format 27 was refused as an unknown buffer format in `tools/startup/gfx2hlsl.py`. LLVM 15 defines the format as `BUF_DATA_FORMAT_16_16` with `BUF_NUM_FORMAT_UINT` ([ufmt](https://releases.llvm.org/15.0.0/docs/AMDGPUModifierSyntax.html#ufmt)). It now reads two unsigned 16-bit fields through `ldu()`, the low half into X. Z = 0 and W = 1, like the other integer rows. Only the tbuffer table row is added. The DXGI stream-layout mapping is unchanged. ## Test `tests/startup_vertex_fetch_formats_check.py` gains the format and three mutated translations: - a normalized low half; - the high half read from the low half; - a missing W read as 1.0. The format uses stride 6 and offset 2, so half of the 16 elements cross a dword. ``` python -B tests/startup_vertex_fetch_formats_check.py controls vertex fetch format controls passed python -B tests/startup_vertex_fetch_formats_check.py <dxc> out/build/<dir>/offscreen_check.exe warp warp: 14 buffer formats, 16 vertices each, every wrong reference and 15 mutations fail python -B tests/startup_vertex_fetch_formats_check.py <dxc> out/build/<dir>/offscreen_check.exe hardware hardware: 14 buffer formats, 16 vertices each, every wrong reference and 15 mutations fail ``` These are the commands behind `startup_vertex_fetch_formats_(controls|warp|hardware)`. On `main`, `controls` fails with `gfx2hlsl.Unsupported: buffer format BUF_FMT_16_16_UINT`. **Environment** - **Hardware:** AMD Radeon RX 9070 XT, driver 32.0.32015.7029, the first adapter in high-performance order. - **Software:** WARP, Windows 10.0.26300.9974, DXC 1.8.2502.11 (Windows SDK 10.0.26100). The SDK debug layers are installed. - **Build:** `all` builds (Ninja Release, MSVC Build Tools 18). - **Skips:** none. **Other checks:** `startup_stream_fetch_check.py`, `startup_gfx2hlsl_tbuffer_16f_check.py` and `docs_links_check.py` pass. `docs/experiments.md` lists the new format and the device result. Refs #2023 (item G)
tedin7 commented 2026-11-25 12:01:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:00:15Z.

Review: COMMENTED


Review of head 34ff4a6b1de4f5f45b1ba7032d5a2063dcc5156b (comment only, no approval).

Result: P1=0, P2=0. One nit.

What I checked

  • Format 27 = BUF_FMT_16_16_UINT matches the gfx10 unified table: 23 UNORM, 24 SNORM, 27 UINT, 29 FLOAT. The sibling rows already in FETCH_FORMATS and the test table agree with that numbering.
  • tools/startup/gfx2hlsl.py:138: ldu() then w & 65535u (X), w >> 16 (Y), 0u, 1u. Right for unsigned 16-bit pairs. W=1 as an integer matches 8_UINT and 8_8_8_8_UINT. The w >> 16 is a logical shift because w is uint, so no sign issue.
  • Stride 6 / offset 2 in the test puts half of the 16 elements across a dword, so the ldu() path is exercised.
  • Only the tbuffer table is touched. The FETCH_DXGI mapping is unchanged, and the PR says so.
  • Title and body are neutral. Docs sentence and the format list are updated.

Commands run locally (worktree at the head SHA)

  • python3 -B tests/startup_vertex_fetch_formats_check.py controls -> vertex fetch format controls passed
  • python3 tests/docs_links_check.py -> Checked 18 Markdown files and 447 links.
  • python3 tests/bidi_controls_check.py -> no bidirectional controls.
  • git diff --check origin/main...HEAD -> clean
  • gh pr checks: Linux Python checks pass. Windows build/test and gfx1013 fixtures were still pending when I looked.

Mutation on the new logic

  • I swapped the X and Y expressions of the new row (['w >> 16', 'w & 65535u', ...]). controls did not fail on this. It only checks that the mutation anchors still exist in the generated source, so the swap is only caught by the GPU readback run (warp / hardware). The PR reports those as passing. Once the Windows jobs finish, they are the real evidence for this change.
  • Changing the row so the "normalized low half" anchor no longer appears makes controls fail with AssertionError: ('BUF_FMT_16_16_UINT', 'normalized low half'). So the three new mutation entries are tied to the row text, which is fine.
  • Worktree restored with git checkout -- ..

Not run: I did not run the Windows WARP job. The change is one table row, and the PR's own Windows CI covers it. Please wait for those jobs to go green before merging.

Nit

  • The docs paragraph says the check ran on an RX 9070 XT. That is useful, but CI will only show WARP. Fine to keep.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6057206428 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2313#pullrequestreview-6057206428). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:00:15Z. **Review:** COMMENTED --- Review of head `34ff4a6b1de4f5f45b1ba7032d5a2063dcc5156b` (comment only, no approval). **Result: P1=0, P2=0.** One nit. **What I checked** - Format 27 = `BUF_FMT_16_16_UINT` matches the gfx10 unified table: 23 UNORM, 24 SNORM, 27 UINT, 29 FLOAT. The sibling rows already in `FETCH_FORMATS` and the test table agree with that numbering. - `tools/startup/gfx2hlsl.py:138`: `ldu()` then `w & 65535u` (X), `w >> 16` (Y), `0u`, `1u`. Right for unsigned 16-bit pairs. W=1 as an integer matches `8_UINT` and `8_8_8_8_UINT`. The `w >> 16` is a logical shift because `w` is uint, so no sign issue. - Stride 6 / offset 2 in the test puts half of the 16 elements across a dword, so the `ldu()` path is exercised. - Only the tbuffer table is touched. The `FETCH_DXGI` mapping is unchanged, and the PR says so. - Title and body are neutral. Docs sentence and the format list are updated. **Commands run locally (worktree at the head SHA)** - `python3 -B tests/startup_vertex_fetch_formats_check.py controls` -> `vertex fetch format controls passed` - `python3 tests/docs_links_check.py` -> `Checked 18 Markdown files and 447 links.` - `python3 tests/bidi_controls_check.py` -> `no bidirectional controls.` - `git diff --check origin/main...HEAD` -> clean - `gh pr checks`: Linux Python checks pass. Windows build/test and gfx1013 fixtures were still pending when I looked. **Mutation on the new logic** - I swapped the X and Y expressions of the new row (`['w >> 16', 'w & 65535u', ...]`). `controls` did not fail on this. It only checks that the mutation anchors still exist in the generated source, so the swap is only caught by the GPU readback run (`warp` / `hardware`). The PR reports those as passing. Once the Windows jobs finish, they are the real evidence for this change. - Changing the row so the "normalized low half" anchor no longer appears makes `controls` fail with `AssertionError: ('BUF_FMT_16_16_UINT', 'normalized low half')`. So the three new mutation entries are tied to the row text, which is fine. - Worktree restored with `git checkout -- .`. **Not run:** I did not run the Windows WARP job. The change is one table row, and the PR's own Windows CI covers it. Please wait for those jobs to go green before merging. **Nit** - The docs paragraph says the check ran on an RX 9070 XT. That is useful, but CI will only show WARP. Fine to keep. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 13:00:42 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2305
No description provided.