startup: lower a typed buffer load of BUF_FMT_16_16_16_16_FLOAT #1699

Manually merged
github merged 4 commits from gh-pr/1699/head into gh-pr/1699/base 2026-11-26 23:27:02 +00:00
Owner

@⁠triggered02 on GitHub · 2026-11-24 17:20 UTC · original
triggered02:startup/tbuffer-16f → main · +172 −6 · 5 files · 4 commits · merged 2026-11-24 19:17 UTC

Fixes #1695. This is the second group from the loading-screen refusal census (#870): 5 of 29 shaders.

Change

The typed-load format table had the two-channel half-float form but not the four-channel one, so a load of BUF_FMT_16_16_16_16_FLOAT was refused. The format stores four binary16 channels in one 8-byte element — x and y in the first dword, z and w in the second — each converted with f16tof32:

tbuffer_load_format_xyz v[0:2], v0, s[20:23], 0 format:[BUF_FMT_16_16_16_16_FLOAT] idxen
  -> v0 = f16tof32(Load(a)); v1 = f16tof32(Load(a) >> 16); v2 = f16tof32(Load(a + 4))
tbuffer_load_format_xyzw ... same format
  -> also v3 = f16tof32(Load(a + 4) >> 16)

Test

The instruction bytes are constructed in the test from the field layout the checked-in decoder reads ( ools/disasm_rdna2.py, MTBUF branch) — no game-derived bytes, per the review on #1693 — then decoded and translated:

bytes decoded form covers
00203aea00000580 tbuffer_load_format_xyz … BUF_FMT_16_16_16_16_FLOAT real encoding from the cache
00203bea00000580 same, xyzw w from the high half of the second dword
002038ea00000580 same, x one channel only
00207aea00000580 numeric format the table does not name stays refused
00203aea00002580 tbuffer_load_format_d16_xyz stays refused (no lowering)
dev:     startup_gfx2hlsl_tbuffer_16f Passed 0.17 s
release: startup_gfx2hlsl_tbuffer_16f Passed 0.16 s
five neighbouring startup_gfx2hlsl tests still pass

Fail-first: removing the format entry fails the test with Unsupported: buffer format BUF_FMT_16_16_16_16_FLOAT.

Census A/B (local, aggregates only)

With the change, refusals whose reason is this format go 5 → 0. Those five shaders either translate or stop at the next refusal in their stream: the count of v_cndmask_b32_e64 v30, v29, -v29 rises 0 → 4, which is progress through the stream, not a regression.

What this does not establish

  • That the loading screen gets further — needs a run that visibly reaches it.
  • Other unnamed formats and the d16 forms are separate slices; the rest of the census is untouched.

AI-assisted (Claude Code).

**@⁠triggered02** on GitHub · 2026-11-24 17:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699) `triggered02:startup/tbuffer-16f` → `main` · +172 −6 · 5 files · 4 commits · merged 2026-11-24 19:17 UTC Fixes #1695. This is the second group from the loading-screen refusal census (#870): **5 of 29** shaders. ## Change The typed-load format table had the two-channel half-float form but not the four-channel one, so a load of `BUF_FMT_16_16_16_16_FLOAT` was refused. The format stores four binary16 channels in one 8-byte element — x and y in the first dword, z and w in the second — each converted with `f16tof32`: ``` tbuffer_load_format_xyz v[0:2], v0, s[20:23], 0 format:[BUF_FMT_16_16_16_16_FLOAT] idxen -> v0 = f16tof32(Load(a)); v1 = f16tof32(Load(a) >> 16); v2 = f16tof32(Load(a + 4)) tbuffer_load_format_xyzw ... same format -> also v3 = f16tof32(Load(a + 4) >> 16) ``` ## Test The instruction bytes are **constructed in the test** from the field layout the checked-in decoder reads ( ools/disasm_rdna2.py, MTBUF branch) — no game-derived bytes, per the review on #1693 — then decoded and translated: | bytes | decoded form | covers | |---|---|---| | `00203aea00000580` | `tbuffer_load_format_xyz … BUF_FMT_16_16_16_16_FLOAT` | real encoding from the cache | | `00203bea00000580` | same, `xyzw` | w from the high half of the second dword | | `002038ea00000580` | same, `x` | one channel only | | `00207aea00000580` | numeric format the table does not name | stays refused | | `00203aea00002580` | `tbuffer_load_format_d16_xyz` | stays refused (no lowering) | ``` dev: startup_gfx2hlsl_tbuffer_16f Passed 0.17 s release: startup_gfx2hlsl_tbuffer_16f Passed 0.16 s five neighbouring startup_gfx2hlsl tests still pass ``` Fail-first: removing the format entry fails the test with `Unsupported: buffer format BUF_FMT_16_16_16_16_FLOAT`. ## Census A/B (local, aggregates only) With the change, refusals whose reason is this format go **5 → 0**. Those five shaders either translate or stop at the next refusal in their stream: the count of `v_cndmask_b32_e64 v30, v29, -v29` rises 0 → 4, which is progress through the stream, not a regression. ## What this does not establish - That the loading screen gets further — needs a run that visibly reaches it. - Other unnamed formats and the `d16` forms are separate slices; the rest of the census is untouched. AI-assisted (Claude Code).
Fixes #1695. The typed-load format table had the two-channel half-float form but not the four-channel one, so
a load of BUF_FMT_16_16_16_16_FLOAT was refused with `buffer format BUF_FMT_16_16_16_16_FLOAT`. That refusal
covered 5 of the 29 refused shaders in the first main-game loading-screen cache (#870).

The format stores four binary16 channels in one 8-byte element: x and y in the first dword, z and w in the
second, each converted with f16tof32. The x, xy and xyz forms read the channels they need:

  tbuffer_load_format_xyz v[0:2], v0, s[20:23], 0 format:[BUF_FMT_16_16_16_16_FLOAT] idxen
    -> v0 = f16tof32(Load(a)); v1 = f16tof32(Load(a) >> 16); v2 = f16tof32(Load(a + 4))
  tbuffer_load_format_xyzw ... same format
    -> also v3 = f16tof32(Load(a + 4) >> 16)

The test (startup_gfx2hlsl_tbuffer_16f) starts from encoded instructions and goes through decode():

  00203aea00000580  tbuffer_load_format_xyz  with the format   (real encoding from the cache)
  00203bea00000580  tbuffer_load_format_xyzw with the format
  002038ea00000580  tbuffer_load_format_x    with the format
  00207aea00000580  a numeric format the table does not name   -> stays refused
  00203aea00002580  tbuffer_load_format_d16_xyz                -> stays refused (no lowering)

Measured: dev 0.17 s, release 0.16 s; five neighbouring startup_gfx2hlsl tests still pass. Fail-first:
removing the format entry fails the test with `Unsupported: buffer format BUF_FMT_16_16_16_16_FLOAT`.

Local census A/B over the same cache (aggregates only): with the change, refusals whose reason is
BUF_FMT_16_16_16_16_FLOAT go from 5 to 0, and those five shaders now either translate or stop at the next
refusal in their instruction stream - the count of `operand '-v29'` (`v_cndmask_b32_e64 v30, v29, -v29`) rises
from 0 to 4, which is progress through the stream rather than a new regression.

What this does not establish: that the loading screen gets further (needs a run that visibly reaches it), and
the other grouping refusals are untouched. Other unnamed formats and the d16 forms remain separate slices.
Review on #1693 rejected tests that cite cache-derived bytes as input. This test now encodes each MTBUF instruction from the field layout the checked-in decoder reads (tools/disasm_rdna2.py), then decodes it and translates it, so no game-derived bytes are involved. Expected decoded text and emitted HLSL are unchanged in substance; the case set also now covers the default format (1, which the disassembler omits).
# Conflicts:
#	CMakeLists.txt
#	docs/experiments.md
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:27:00 +00:00
github manually merged commit 59471eedda into gh-pr/1699/base 2026-11-26 23:27:02 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:20 UTC · original · edited 2026-11-24 17:22 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-24T17:22:12.386927Z 92f27f1 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 17:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#issuecomment-7139043275) · edited 2026-11-24 17:22 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"92f27f1287d424cbb8b8c9dd0b7eed63814b2c81","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-24T17:22:12.386927Z">2026-11-24T17:22:12.386927Z</relative-time> | `92f27f1` | 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>
Author
Owner

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

P1 Badge Replace the game-cache instruction fixture

The preceding comment identifies this byte string as a real encoding from the loading-screen cache, so adding it to the test introduces game-derived dump data rather than a source-built, synthetic, or licensed public fixture. Please replace it with an allowed fixture before committing.

AGENTS.md reference: AGENTS.md:L21-L27

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 17:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#discussion_r4683863255) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Replace the game-cache instruction fixture** The preceding comment identifies this byte string as a real encoding from the loading-screen cache, so adding it to the test introduces game-derived dump data rather than a source-built, synthetic, or licensed public fixture. Please replace it with an allowed fixture before committing. AGENTS.md reference: [AGENTS.md:L21-L27](https://github.com/R0Y00/Xbox2Windows/blob/92f27f1287d424cbb8b8c9dd0b7eed63814b2c81/AGENTS.md#L21-L27) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 17:24 UTC · original

Already fixed in cd654de9, which is the current head of this branch — the review you posted is on 92f27f12.

What changed: the test no longer contains any cache-derived byte string. It builds each MTBUF instruction from the field layout the checked-in decoder reads (tools/disasm_rdna2.py, MTBUF branch) via a local encode_mtbuf(op, fmt, *, vdata, vaddr, srsrc, soffset, idxen, ...) helper, then calls decode() on the result and translates that. The same helper produces the two refusal cases. The PR body no longer claims any encoding comes from the cache.

Your point stands and I have recorded it as a rule for the rest of this work — the earlier PR that used cache bytes (#1693) was closed, and no test I open from here will embed game-derived data.

**@⁠triggered02** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#issuecomment-7139136411) Already fixed in `cd654de9`, which is the current head of this branch — the review you posted is on `92f27f12`. What changed: the test no longer contains any cache-derived byte string. It builds each MTBUF instruction from the field layout the checked-in decoder reads (`tools/disasm_rdna2.py`, MTBUF branch) via a local `encode_mtbuf(op, fmt, *, vdata, vaddr, srsrc, soffset, idxen, ...)` helper, then calls `decode()` on the result and translates that. The same helper produces the two refusal cases. The PR body no longer claims any encoding comes from the cache. Your point stands and I have recorded it as a rule for the rest of this work — the earlier PR that used cache bytes (#1693) was closed, and no test I open from here will embed game-derived data.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 17:38 UTC · original

Thanks for replacing the byte strings with the field encoder. One issue on the current head: the new format still passes the computed byte address straight to ByteAddressBuffer.Load, which requires a 4-byte-aligned address. The existing 16_16_FLOAT path uses ldu because the dynamic stride and byte offset can produce a halfword-aligned address. The new path has no check that rules that out. Please use alignment-safe reads consistent with the existing half-float path, or prove and enforce a narrower address contract. A source-built GPU readback with a 2-mod-4 address and four distinct halves (including the second word's high half) should distinguish this from the aligned-only lowering. #1696 has a reusable readback harness. The clean final diff can land by squash so the earlier fixture commit stays out of main.

**@⁠R0Y00** on GitHub · 2026-11-24 17:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#issuecomment-7139496235) Thanks for replacing the byte strings with the field encoder. One issue on the current head: the new format still passes the computed byte address straight to ByteAddressBuffer.Load, which requires a 4-byte-aligned address. The existing 16_16_FLOAT path uses ldu because the dynamic stride and byte offset can produce a halfword-aligned address. The new path has no check that rules that out. Please use alignment-safe reads consistent with the existing half-float path, or prove and enforce a narrower address contract. A source-built GPU readback with a 2-mod-4 address and four distinct halves (including the second word's high half) should distinguish this from the aligned-only lowering. #1696 has a reusable readback harness. The clean final diff can land by squash so the earlier fixture commit stays out of main.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 19:14 UTC · original

I pushed 59471eed. Both packed dwords use the existing alignment-safe loader. The vertex-fetch test now includes four distinct binary16 values at alternating aligned and halfword-aligned addresses. WARP and RTX 4060 Laptop matched the expected words, and aligning the second dword down changed the result as required. Windows Release passed the typed-buffer and vertex-format checks 4/4. This clean final diff will use squash so the superseded fixture commit stays out of main.

**@⁠R0Y00** on GitHub · 2026-11-24 19:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#issuecomment-7141797839) I pushed 59471eed. Both packed dwords use the existing alignment-safe loader. The vertex-fetch test now includes four distinct binary16 values at alternating aligned and halfword-aligned addresses. WARP and RTX 4060 Laptop matched the expected words, and aligning the second dword down changed the result as required. Windows Release passed the typed-buffer and vertex-format checks 4/4. This clean final diff will use squash so the superseded fixture commit stays out of main.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 17:22 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92f27f1287

ℹ️ 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 17:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#pullrequestreview-6044087620) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `92f27f1287` <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>
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 17:24 UTC · original · reviewed

Review of head 92f27f1287d424cbb8b8c9dd0b7eed63814b2c81 (1 commit on top of main; touches tools/startup/gfx2hlsl.py +4, the new test, CMakeLists.txt +3, docs/experiments.md +8).

Linux limits. Linux x86_64 only. I did not configure CMake or run ctest, so the startup_gfx2hlsl_tbuffer_16f registration is unexercised; I ran the check script directly with python3 -B. No Windows, no DXC or FXC, no GPU: the emitted HLSL was compared as text and never compiled or executed, so the half-float arithmetic is not proven numerically.

What I ran

  • python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py: PASS.
  • llvm-mc-19 --disassemble -triple=amdgcn -mcpu=gfx1030 on the five byte strings: each decodes to exactly the text the test expects (xyz, xyzw, x with BUF_FMT_16_16_16_16_FLOAT; format:79 for the unnamed one; tbuffer_load_format_d16_xyz for the last).
  • Assembling those same instructions with llvm-mc-19 -show-encoding gives the identical bytes (00203aea00000580, 00203bea…, 002038ea…, 00207aea…).
  • git diff --check origin/main...HEAD: clean. tests/bidi_controls_check.py and tests/docs_links_check.py: pass.
  • Eight local mutations of the new table entry, each run against the test, then restored (git status clean): y shift 16 -> 8; z offset +4 -> +8; w without f16tof32; x read from the second dword; w read from the first dword; y masked with 65535 instead of shifted; asfloat instead of f16tof32; x without the U() wrapper. All eight FAIL. The channel layout in the table is correct against the format definition, and the test pins it.

Findings

  1. Blocking, repository rule. The test comment (line 77) and the docstring call 00203aea00000580 "a real encoding from the loading-screen cache", and the PR text repeats "first main-game loading-screen cache". AGENTS.md allows only source-built or synthetic fixtures and title-neutral wording, and the Codex P1 on this head raises the same point. The bytes need no cache: llvm-mc-19 reproduces all four from the assembly text (see above). Suggest saying "encoded with llvm-mc from the asm text", dropping the cache wording from the test, docs and PR body, and keeping #870 only as the issue reference.
  2. The test docstring says "issue #1675"; the issue is #1695 (the PR body and CMake comment have it right).
  3. Minor, not blocking. BUF_FMT_16_16_FLOAT goes through ldu, which handles an address that is not 4-aligned. The new entry uses plain Load(a) and Load(a + 4) like the 32-bit formats, which round the address down. For an 8-byte element at a multiple of 8 this is the same; with an odd offset: the two paths would differ. Worth a sentence saying the alignment is assumed.
  4. Minor. The assertions match the exact emitted strings (for example U(f16tof32(r0.Load(a)))), so a harmless rewrite of the same math would fail them. That matches the neighbouring tests, so I leave it to you.

Not verified: the "5 of 29" census and the A/B counts, which come from a local cache I cannot see.

AI-assisted review; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#pullrequestreview-6044119937) · **reviewed** Review of head `92f27f1287d424cbb8b8c9dd0b7eed63814b2c81` (1 commit on top of main; touches `tools/startup/gfx2hlsl.py` +4, the new test, `CMakeLists.txt` +3, `docs/experiments.md` +8). **Linux limits.** Linux x86_64 only. I did not configure CMake or run `ctest`, so the `startup_gfx2hlsl_tbuffer_16f` registration is unexercised; I ran the check script directly with `python3 -B`. No Windows, no DXC or FXC, no GPU: the emitted HLSL was compared as text and never compiled or executed, so the half-float arithmetic is not proven numerically. **What I ran** - `python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py`: PASS. - `llvm-mc-19 --disassemble -triple=amdgcn -mcpu=gfx1030` on the five byte strings: each decodes to exactly the text the test expects (xyz, xyzw, x with `BUF_FMT_16_16_16_16_FLOAT`; `format:79` for the unnamed one; `tbuffer_load_format_d16_xyz` for the last). - Assembling those same instructions with `llvm-mc-19 -show-encoding` gives the identical bytes (`00203aea00000580`, `00203bea…`, `002038ea…`, `00207aea…`). - `git diff --check origin/main...HEAD`: clean. `tests/bidi_controls_check.py` and `tests/docs_links_check.py`: pass. - Eight local mutations of the new table entry, each run against the test, then restored (`git status` clean): y shift 16 -> 8; z offset +4 -> +8; w without `f16tof32`; x read from the second dword; w read from the first dword; y masked with 65535 instead of shifted; `asfloat` instead of `f16tof32`; x without the `U()` wrapper. All eight FAIL. The channel layout in the table is correct against the format definition, and the test pins it. **Findings** 1. Blocking, repository rule. The test comment (line 77) and the docstring call `00203aea00000580` "a real encoding from the loading-screen cache", and the PR text repeats "first main-game loading-screen cache". AGENTS.md allows only source-built or synthetic fixtures and title-neutral wording, and the Codex P1 on this head raises the same point. The bytes need no cache: `llvm-mc-19` reproduces all four from the assembly text (see above). Suggest saying "encoded with llvm-mc from the asm text", dropping the cache wording from the test, docs and PR body, and keeping #870 only as the issue reference. 2. The test docstring says "issue #1675"; the issue is #1695 (the PR body and CMake comment have it right). 3. Minor, not blocking. `BUF_FMT_16_16_FLOAT` goes through `ldu`, which handles an address that is not 4-aligned. The new entry uses plain `Load(a)` and `Load(a + 4)` like the 32-bit formats, which round the address down. For an 8-byte element at a multiple of 8 this is the same; with an odd `offset:` the two paths would differ. Worth a sentence saying the alignment is assumed. 4. Minor. The assertions match the exact emitted strings (for example `U(f16tof32(r0.Load(a)))`), so a harmless rewrite of the same math would fail them. That matches the neighbouring tests, so I leave it to you. Not verified: the "5 of 29" census and the A/B counts, which come from a local cache I cannot see. AI-assisted review; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 17:24 UTC · original · reviewed

Follow-up review of head cd654de9a50d479d8a3bc22cacce47806012d434. My previous review was written against 92f27f1287d424cbb8b8c9dd0b7eed63814b2c81; the author pushed this commit while I was reviewing, so GitHub attached that review to the new head. Read it as a review of 92f27f12. This one replaces it for the current head.

Linux limits. Linux x86_64 only. No CMake configure and no ctest (the CMake registration is unexercised), no Windows, no DXC or FXC, no GPU. The emitted HLSL is compared as text and never compiled or run.

What changed since 92f27f12. Only tests/startup_gfx2hlsl_tbuffer_16f_check.py: the hard-coded cache byte strings are replaced by an encode_mtbuf() that builds each instruction from the MTBUF field layout, the docstring issue number is fixed (#1695), and a default-format case is added. The table entry in tools/startup/gfx2hlsl.py is unchanged.

What I ran on this head

  • python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py: PASS. git diff --check origin/main...HEAD: clean.
  • encode_mtbuf() against llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encoding: xyz, xyzw, x (format 71), xyz with format 127 and d16_xyz with format 71 all produce byte-identical output. The synthetic encoder matches the assembler, not only the repository's own decoder.
  • Five mutations of the table entry (y shift 16 -> 8; z offset +4 -> +8; w without f16tof32; w from the first dword; asfloat instead of f16tof32), each run and then restored: all FAIL, git status clean.

Findings

  1. Resolved: the game-derived fixture (AGENTS.md hard rule) and the issue-number typo.
  2. Remaining wording. The test docstring (line 8) and the PR text still say "first main-game loading-screen cache". AGENTS.md asks for title-neutral public wording; consider "the first startup shader cache" or just the #870 reference.
  3. Minor, not blocking. BUF_FMT_16_16_FLOAT reads through ldu, which handles an address that is not 4-aligned; the new entry uses plain Load(a) and Load(a + 4) like the 32-bit formats, which round down. Identical for an 8-byte element at a multiple of 8, different with an odd offset:. A sentence stating the assumption would be enough.
  4. Not verified: the "5 of 29" census and its A/B counts (local cache).

AI-assisted review; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#pullrequestreview-6044130413) · **reviewed** Follow-up review of head `cd654de9a50d479d8a3bc22cacce47806012d434`. My previous review was written against `92f27f1287d424cbb8b8c9dd0b7eed63814b2c81`; the author pushed this commit while I was reviewing, so GitHub attached that review to the new head. Read it as a review of 92f27f12. This one replaces it for the current head. **Linux limits.** Linux x86_64 only. No CMake configure and no `ctest` (the CMake registration is unexercised), no Windows, no DXC or FXC, no GPU. The emitted HLSL is compared as text and never compiled or run. **What changed since 92f27f12.** Only `tests/startup_gfx2hlsl_tbuffer_16f_check.py`: the hard-coded cache byte strings are replaced by an `encode_mtbuf()` that builds each instruction from the MTBUF field layout, the docstring issue number is fixed (#1695), and a default-format case is added. The table entry in `tools/startup/gfx2hlsl.py` is unchanged. **What I ran on this head** - `python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py`: PASS. `git diff --check origin/main...HEAD`: clean. - `encode_mtbuf()` against `llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encoding`: xyz, xyzw, x (format 71), xyz with format 127 and d16_xyz with format 71 all produce byte-identical output. The synthetic encoder matches the assembler, not only the repository's own decoder. - Five mutations of the table entry (y shift 16 -> 8; z offset +4 -> +8; w without `f16tof32`; w from the first dword; `asfloat` instead of `f16tof32`), each run and then restored: all FAIL, `git status` clean. **Findings** 1. Resolved: the game-derived fixture (AGENTS.md hard rule) and the issue-number typo. 2. Remaining wording. The test docstring (line 8) and the PR text still say "first main-game loading-screen cache". AGENTS.md asks for title-neutral public wording; consider "the first startup shader cache" or just the #870 reference. 3. Minor, not blocking. `BUF_FMT_16_16_FLOAT` reads through `ldu`, which handles an address that is not 4-aligned; the new entry uses plain `Load(a)` and `Load(a + 4)` like the 32-bit formats, which round down. Identical for an 8-byte element at a multiple of 8, different with an odd `offset:`. A sentence stating the assumption would be enough. 4. Not verified: the "5 of 29" census and its A/B counts (local cache). AI-assisted review; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 19:19 UTC · original · reviewed

Review of head 59471eeddaa8a37fea37caefdf49bc3a902d0ef6 (4 commits over main: 92f27f12, cd654de9, merge ea111d9a, 59471eed; touches tools/startup/gfx2hlsl.py +4, two tests, CMakeLists.txt +3, docs/experiments.md +10). My earlier reviews were on 92f27f12 and cd654de9; this one covers what changed since, mainly 59471eed.

Verdict: no blocking finding. The alignment point raised on the previous head is fixed in the lowering, and the new readback case is shaped to catch it.

Linux limits. Linux x86_64 only. No CMake configure and no ctest, no Windows, no DXC or FXC, no GPU. I could not run the pipeline's Windows helper from here, so the WARP and RTX 4060 Laptop results in the author's comment of 19:14Z are reported, not reproduced by me. The emitted HLSL is compared as text and not compiled.

What changed since cd654de9. The table entry now reads both packed dwords through ldu:
'BUF_FMT_16_16_16_16_FLOAT': (None, ['U(f16tof32(ldu({0}, a)))', 'U(f16tof32(ldu({0}, a) >> 16))', 'U(f16tof32(ldu({0}, a + 4)))', 'U(f16tof32(ldu({0}, a + 4) >> 16))'])
(tools/startup/gfx2hlsl.py:695-698). ldu is emitted in every prologue (gfx2hlsl.py:1245), so it is defined whenever the entry is used. For a & 3 == 2 both reads cross a dword boundary and ldu handles that; the second read at a + 4 has the same alignment as the first. Only the requested channels are loaded (x reads one ldu, xyz does not touch the high half of the second dword). The vertex-fetch fixture gains BUF_FMT_16_16_16_16_FLOAT with stride 18 and offset 10 (tests/startup_vertex_fetch_formats_check.py:49), so vertices alternate between address 2 mod 4 and 0 mod 4; the controls now require four distinct normal halves per vertex for every f16 format (lines 151-159) and a new mutation second dword aligned down (lines 125-126).

What I ran on this head (worktree at the exact SHA; git status clean after every mutation)

  • python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py: PASS.
  • python3 -B tests/startup_vertex_fetch_formats_check.py controls: passed.
  • git diff --check origin/main...HEAD: clean. tests/docs_links_check.py: 17 files, 366 links. tests/bidi_controls_check.py: no bidirectional controls.
  • Three source mutations, each restored: second dword read at a + 8 instead of a + 4; the w channel without >> 16; the first dword read with Load(a & ~3u) instead of ldu. All three make startup_gfx2hlsl_tbuffer_16f_check.py exit 1. The controls mode of the vertex-fetch check is red only for the w-channel one (rc 1; the other two give rc 0), which is expected: the aligned-down and wrong-offset cases are decided by the GPU readback, which I did not run.

Findings

  1. P3, wording, still open from my previous review: docs/experiments.md (new paragraph) and the test docstring still say "first main-game loading-screen cache". AGENTS.md asks for title-neutral public text; "the first startup shader cache" or just "#870" would do.
  2. Not verified by me: the "5 of 29" census and the A/B counts (local cache), and the GPU result of startup_vertex_fetch_formats_{warp,hardware} on this SHA. If the author's 4/4 Windows Release run is the evidence, a line naming the SHA it ran on would close the loop (the comment says "I pushed 59471eed" and then reports the run, so it reads as this head).

Resolved since my last review: the unaligned-address assumption (previous finding 3).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 19:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1699#pullrequestreview-6045789029) · **reviewed** Review of head `59471eeddaa8a37fea37caefdf49bc3a902d0ef6` (4 commits over main: `92f27f12`, `cd654de9`, merge `ea111d9a`, `59471eed`; touches `tools/startup/gfx2hlsl.py` +4, two tests, `CMakeLists.txt` +3, `docs/experiments.md` +10). My earlier reviews were on `92f27f12` and `cd654de9`; this one covers what changed since, mainly `59471eed`. **Verdict: no blocking finding.** The alignment point raised on the previous head is fixed in the lowering, and the new readback case is shaped to catch it. **Linux limits.** Linux x86_64 only. No CMake configure and no `ctest`, no Windows, no DXC or FXC, no GPU. I could not run the pipeline's Windows helper from here, so the WARP and RTX 4060 Laptop results in the author's comment of 19:14Z are reported, not reproduced by me. The emitted HLSL is compared as text and not compiled. **What changed since `cd654de9`.** The table entry now reads both packed dwords through `ldu`: `'BUF_FMT_16_16_16_16_FLOAT': (None, ['U(f16tof32(ldu({0}, a)))', 'U(f16tof32(ldu({0}, a) >> 16))', 'U(f16tof32(ldu({0}, a + 4)))', 'U(f16tof32(ldu({0}, a + 4) >> 16))'])` (`tools/startup/gfx2hlsl.py:695-698`). `ldu` is emitted in every prologue (`gfx2hlsl.py:1245`), so it is defined whenever the entry is used. For `a & 3 == 2` both reads cross a dword boundary and `ldu` handles that; the second read at `a + 4` has the same alignment as the first. Only the requested channels are loaded (x reads one `ldu`, xyz does not touch the high half of the second dword). The vertex-fetch fixture gains `BUF_FMT_16_16_16_16_FLOAT` with stride 18 and offset 10 (`tests/startup_vertex_fetch_formats_check.py:49`), so vertices alternate between address `2 mod 4` and `0 mod 4`; the controls now require four distinct normal halves per vertex for every f16 format (lines 151-159) and a new mutation `second dword aligned down` (lines 125-126). **What I ran on this head** (worktree at the exact SHA; `git status` clean after every mutation) - `python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py`: PASS. - `python3 -B tests/startup_vertex_fetch_formats_check.py controls`: passed. - `git diff --check origin/main...HEAD`: clean. `tests/docs_links_check.py`: 17 files, 366 links. `tests/bidi_controls_check.py`: no bidirectional controls. - Three source mutations, each restored: second dword read at `a + 8` instead of `a + 4`; the w channel without `>> 16`; the first dword read with `Load(a & ~3u)` instead of `ldu`. All three make `startup_gfx2hlsl_tbuffer_16f_check.py` exit 1. The `controls` mode of the vertex-fetch check is red only for the w-channel one (rc 1; the other two give rc 0), which is expected: the aligned-down and wrong-offset cases are decided by the GPU readback, which I did not run. **Findings** 1. P3, wording, still open from my previous review: `docs/experiments.md` (new paragraph) and the test docstring still say "first main-game loading-screen cache". AGENTS.md asks for title-neutral public text; "the first startup shader cache" or just "#870" would do. 2. Not verified by me: the "5 of 29" census and the A/B counts (local cache), and the GPU result of `startup_vertex_fetch_formats_{warp,hardware}` on this SHA. If the author's 4/4 Windows Release run is the evidence, a line naming the SHA it ran on would close the loop (the comment says "I pushed 59471eed" and then reports the run, so it reads as this head). Resolved since my last review: the unaligned-address assumption (previous finding 3). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.