startup: lower a typed buffer load of BUF_FMT_16_16_16_16_FLOAT #1692
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1699"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:20:04Z.
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_FLOATwas 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 withf16tof32: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:
00203aea00000580tbuffer_load_format_xyz … BUF_FMT_16_16_16_16_FLOAT00203bea00000580xyzw002038ea00000580x00207aea0000058000203aea00002580tbuffer_load_format_d16_xyzFail-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, -v29rises 0 → 4, which is progress through the stream, not a regression.What this does not establish
d16forms are separate slices; the rest of the census is untouched.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:22:09Z.
Review: COMMENTED
💡 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
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".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:24:05Z.
Review: COMMENTED
Review of head
92f27f1287d424cbb8b8c9dd0b7eed63814b2c81(1 commit on top of main; touchestools/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 thestartup_gfx2hlsl_tbuffer_16fregistration is unexercised; I ran the check script directly withpython3 -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=gfx1030on the five byte strings: each decodes to exactly the text the test expects (xyz, xyzw, x withBUF_FMT_16_16_16_16_FLOAT;format:79for the unnamed one;tbuffer_load_format_d16_xyzfor the last).llvm-mc-19 -show-encodinggives the identical bytes (00203aea00000580,00203bea…,002038ea…,00207aea…).git diff --check origin/main...HEAD: clean.tests/bidi_controls_check.pyandtests/docs_links_check.py: pass.git statusclean): y shift 16 -> 8; z offset +4 -> +8; w withoutf16tof32; x read from the second dword; w read from the first dword; y masked with 65535 instead of shifted;asfloatinstead off16tof32; x without theU()wrapper. All eight FAIL. The channel layout in the table is correct against the format definition, and the test pins it.Findings
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-19reproduces 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.BUF_FMT_16_16_FLOATgoes throughldu, which handles an address that is not 4-aligned. The new entry uses plainLoad(a)andLoad(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 oddoffset:the two paths would differ. Worth a sentence saying the alignment is assumed.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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:24:46Z.
Review: COMMENTED
Follow-up review of head
cd654de9a50d479d8a3bc22cacce47806012d434. My previous review was written against92f27f1287d424cbb8b8c9dd0b7eed63814b2c81; the author pushed this commit while I was reviewing, so GitHub attached that review to the new head. Read it as a review of92f27f12. 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. Onlytests/startup_gfx2hlsl_tbuffer_16f_check.py: the hard-coded cache byte strings are replaced by anencode_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 intools/startup/gfx2hlsl.pyis 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()againstllvm-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.f16tof32; w from the first dword;asfloatinstead off16tof32), each run and then restored: all FAIL,git statusclean.Findings
BUF_FMT_16_16_FLOATreads throughldu, which handles an address that is not 4-aligned; the new entry uses plainLoad(a)andLoad(a + 4)like the 32-bit formats, which round down. Identical for an 8-byte element at a multiple of 8, different with an oddoffset:. A sentence stating the assumption would be enough.AI-assisted review; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:20:18Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
92f27f1ℹ️ 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.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:24:02Z.
Already fixed in
cd654de9, which is the current head of this branch — the review you posted is on92f27f12.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 localencode_mtbuf(op, fmt, *, vdata, vaddr, srsrc, soffset, idxen, ...)helper, then callsdecode()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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:38:39Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:22:10Z.
Code review location:
tests/startup_gfx2hlsl_tbuffer_16f_check.py; line 78The 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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:19:42Z.
Review: COMMENTED
Review of head
59471eeddaa8a37fea37caefdf49bc3a902d0ef6(4 commits over main:92f27f12,cd654de9, mergeea111d9a,59471eed; touchestools/startup/gfx2hlsl.py+4, two tests,CMakeLists.txt+3,docs/experiments.md+10). My earlier reviews were on92f27f12andcd654de9; this one covers what changed since, mainly59471eed.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 throughldu:'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).lduis emitted in every prologue (gfx2hlsl.py:1245), so it is defined whenever the entry is used. Fora & 3 == 2both reads cross a dword boundary andlduhandles that; the second read ata + 4has the same alignment as the first. Only the requested channels are loaded (x reads oneldu, xyz does not touch the high half of the second dword). The vertex-fetch fixture gainsBUF_FMT_16_16_16_16_FLOATwith stride 18 and offset 10 (tests/startup_vertex_fetch_formats_check.py:49), so vertices alternate between address2 mod 4and0 mod 4; the controls now require four distinct normal halves per vertex for every f16 format (lines 151-159) and a new mutationsecond dword aligned down(lines 125-126).What I ran on this head (worktree at the exact SHA;
git statusclean 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.a + 8instead ofa + 4; the w channel without>> 16; the first dword read withLoad(a & ~3u)instead ofldu. All three makestartup_gfx2hlsl_tbuffer_16f_check.pyexit 1. Thecontrolsmode 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
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.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 pushed59471eed" 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T19:14:05Z.
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.