startup: lower buffer_load_format_x/xy/xyz with the format from the buffer descriptor #2130
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2138"
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 tedin7 on 2026-11-25T01:27:59Z.
Part of #2023
What this unblocks:
buffer_load_format_x/_xy/_xyzwith the format taken from word 3 of the buffer descriptor (item B, about 520 pipeline requests), so those vertex and pixel stages translate instead of being refused.Changes:
tools/startup/gfx2hlsl.py: the three loads read descriptor word 3 as the entry constantdescword3. The body switches on FORMAT (bits 12 to 18) over every entry of the existingFETCH_FORMATStable, then DST_SEL (bits 0 to 11) picks a component, 0 or 1 for each destination register.buffer_load_format_xyzwstays refused. A FORMAT outside the table decodes as zeros (documented assumption).src/startup_stubs/d3d12_draw.inl: new manifest sourcedescword3; the draw fills it from word 3 of a hardware buffer descriptor and passes 0 for other buffer bindings.tests/startup_vertex_fetch_formats_check.py(existing_controls/_warp/_hardwaretests, no new CMake entry): each of the 12 formats through a source-built MUBUF xyz load with its own descriptor word, swizzled words (swapped pair, constants 0 and 1, integer 1 for an integer format), four unknown FORMAT values, a descriptor word naming another format, and 11 mutations that must fail the GPU readback.docs/experiments.md: descriptor path and its limits.Verification:
python3 -B tests/startup_vertex_fetch_formats_check.py controls->vertex fetch format controls passed(Linux)python3 -B tests/startup_gfx2hlsl_*_check.py(every script, run one by one) -> pass (Linux)x2w_pipe.py win2025 2138 --scope direct --targets offscreen_check --regex startup_vertex_fetch_formats->startup_vertex_fetch_formats_controls,_warp,_hardware3/3 passed (100%) ata9ac7006AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:48:36Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
a9ac700628ℹ️ 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 R0Y00 on 2026-11-25T01:56:04Z.
Review: CHANGES_REQUESTED
The new head fixes the Linux request-fixture failure. At runtime,
draw_translatedstill initializesdesc_word3to zero for every binding and only assigns it on the hardware descriptor branch. An unresolved or different binding can therefore publish the same shader data as a resolved descriptor. The default FORMAT arm also returns zero without a verified native result.Please carry a separate resolved/valid condition through binding and refuse the draw before submission for missing metadata or an unsupported FORMAT. A source-built negative control should distinguish missing metadata, an unsupported format code, and a supported descriptor whose buffer data is actually zero. A native comparison can establish a specific zero-return case if it is useful later.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:42:11Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
a9ac700ℹ️ 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 chatgpt-codex-connector[bot] on 2026-11-25T01:48:36Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1299The existing
formatted_mubuf_request_controls()still expects_x,_xyand_xyzto produce only.failfiles. Consequently,python3 -B tests/startup_buffer_address_check.py controlsnow raisesFileNotFoundErroron its first formatted load instead of passing (reproduced on Linux; the parent translator passes). This script is registered asstartup_buffer_address_controlsinCMakeLists.txt:2316-2317and run by the Linux job in.github/workflows/windows.yml:230, so enabling these handlers breaks the existing test suites. Update those controls to expect successful translations for the three supported forms while retaining the_xyzwrejection.AGENTS.md reference: AGENTS.md:L170-L170
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:48:36Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1280If a shader rewrites word 3 after
s_load_dwordx4, this fetches the original table word without consulting the current fourth SGPR. For example, a source-built shader loadings[16:19], executings_mov_b32 s19, 0x50facand then issuing an indexedbuffer_load_format_xyztranslates successfully, but its generated loads are unchanged by the move: FORMAT still comes fromdescword3. With an originalBUF_FMT_32_FLOATtable entry, X remains the whole dword rather than the low byte required by the overwrittenBUF_FMT_8_UINTformat. Honor the tracked word-3 value, or reject descriptors whose word 3 was changed, before publishing a translation.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:46Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:49Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:46Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1299Fixed in
8917f825(controls expect translation for _x/_xy/_xyz, xyzw still refused); re-verified ata3f8419a. Verification (Win2025, dev and release): ctest -R startup(vertex_fetch_formats|buffer_address) 6/6 passed (controls, warp, hardware); Linux: python3 -B tests/startup_buffer_address_check.py controls and tests/startup_vertex_fetch_formats_check.py controls pass.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:49Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1280Fixed in
a3f8419a: a formatted buffer load is now refused unless all four descriptor words are still the loaded ones, so a rewritten word 3 is never read from the table. New regression case (s_mov_b32 s19 after the load) fails before the fix and passes after. Verification (Win2025, dev and release): ctest -R startup_(vertex_fetch_formats|buffer_address) 6/6 passed (controls, warp, hardware); Linux: python3 -B tests/startup_buffer_address_check.py controls and tests/startup_vertex_fetch_formats_check.py controls pass.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:18:08Z.
Review: COMMENTED
I verified that the previous Python request-control and rewritten-word-3 findings are fixed at this head. I prepared a local candidate for the remaining runtime review against
8150d800: preflight thedescword3bindings, snapshot the hardware table descriptor once for format validation and buffer binding, and refuse missing metadata, unsupported FORMAT or unresolved backing. Desktop view tokens do not carry raw descriptor word 3. The translator also limits the new path to graphics table descriptors proven in the entry block, so a branch cannot bypass the load or leave a rewritten word live.On Windows build 26200, the Release candidate passed
ctest --test-dir <build> --no-tests=error -j 1 -R '^startup_(mubuf_descriptor|vertex_fetch_formats|buffer_address)_'with 8 passed and 0 skipped. The new source-built draw fixture ran with SDK10.0.26100.0FXC on WARP10.0.26100.9818and RTX 4060 Laptop32.0.16.1656, with debug layers enabled. Missing metadata, unsupported FORMAT 2 and absent backing kept the test strips at their blue clear value, and valid R32_FLOAT with actual zero and one payloads drew black and red. The added branch-bypass control also passes. Please keep these distinguishable outcomes when updating the branch so the existing change request can be reassessed on the published head.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:35:07Z.
Pushed
d34731bafor the remaining runtime finding.Fix:
draw_translatednow tracks, per binding, a separatedesc_hardwareflag (set only in the hardware-descriptor branch, together with word 3) and adesc_backedflag (set only where the buffer range was actually bound). Right after the binding loop, before any list command or viewport/scissor change, everydescword3entry must be hardware, backed, and have a FORMAT from the translated table (supported_descriptor_format, same numbers asDESC_FORMAT_CODES). Otherwise the draw returns false (untranslated path) and logs the cause. A word 3 of 0 from missing metadata no longer looks like a real descriptor, and a valid descriptor over zero data still draws.Regression test:
runtime_gate_controlsintests/startup_vertex_fetch_formats_check.py(runs instartup_vertex_fetch_formats_controls). Positive: the runtime FORMAT list equals the translation switch, and word 3 plus the hardware flag are set in one place. Negative: FORMAT 2 and 0 are not accepted; dropping any of the hardware, backed or FORMAT conditions fails the control; a gate placed after the first list command fails it. Limit: this is a source-level control. I did not add the source-built draw fixture with the blue/black/red strips; your local candidate covers that and I kept its distinguishable outcomes in the docs wording.Verification (Linux):
tests/startup_buffer_address_check.py,tests/startup_translator_check.py,tests/docs_links_check.py,tests/startup_vertex_fetch_formats_check.py controlsall pass.Verification (Win2025, build 26100, 3-slot pool):
x2w_pipe.py win2025 2138 --force --regex '^startup_(mubuf_descriptor|vertex_fetch_formats|buffer_address)_' --py-checks tests/startup_buffer_address_check.py. Dev and release: 6/6 passed, 0 skipped (startup_vertex_fetch_formats_{controls,warp,hardware},startup_buffer_address_{controls,warp,hardware}). An earlier release attempt hit an sccache transport error during build, not a compile error; the rerun passed.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:57:24Z.
I fast-forwarded this branch from
d34731bato45d221e8, preserving your descriptor validation commit and its controls. The follow-up snapshots the descriptor before binding, distinguishes absent metadata from an unsupported format, and refuses to use the identity-buffer fallback for a formatted load with missing backing. A later basic block can lower a formatted load when it loads all four untouched descriptor words locally and every predecessor preserves the table pointer. The updated head passedstartup_vertex_fetch_formats_controls,startup_buffer_address_controlsandstartup_mubuf_descriptor_warp. The WARP test keeps the target clear for the three invalid bindings even with the identity fallback enabled, and draws the two valid zero and one payloads.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-25T11:39:48Z.
Run at head
64c358e7, compilerdxc, backendhardware.startup_vertex_fetch_formats_check.py <dxc> <offscreen_check> hardware— the third argument is the backend selector (it is passed straight to the consumer as its first argument), not an adapter name; the fixture does not echo which adapter it opened. This machine has a single GPU.Two paths, two summaries. The log ends with two lines, and they count different things:
The first is the reference path (13 formats × 16 vertices, 12 mutations), the second the descriptor path this PR adds (16 cases, 16 mutations). Both are green, and a descriptor word carrying the wrong format is caught rather than silently accepted. The components read back are vertex attributes, not texels — there is no texture in this run.
The format table.
DESC_FORMAT_CODEShas 13 entries; compared one by one againstMTBUF_FORMATSintools/disasm_rdna2.py:BUF_FMT_8_8_UNORM14,BUF_FMT_16_16_UNORM23,BUF_FMT_16_16_FLOAT29,BUF_FMT_32_FLOAT22,BUF_FMT_8_8_8_8_UNORM56, …);BUF_FMT_8_UNORM= 1, has no key inMTBUF_FORMATS— that dict goes from 0 straight to 2, and has no 1 among its 77 entries.disasm_rdna2.py:1232already notes that format 1 is LLVM's omitted default, so the value is right and the table is the thing with the hole;disasm_rdna2.pyis untouched by this PR.Worth knowing about the assertion that is supposed to cover this:
tests/startup_vertex_fetch_formats_check.py:316readsso for code 1 the lookup returns the default and the assertion passes whatever
MTBUF_FORMATScontains — the one code that is missing from the table is exactly the one this check cannot catch.A silent path. The generated switch ends in
default: break;(gfx2hlsl.py:2342), so a descriptor naming a format outsideDESC_FORMAT_CODESproduces zeros with no error and no warning. I did not probe that case; I am pointing at it because it fails quietly rather than loudly.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:05:43Z.
Thanks, both points are addressed in
f1b9936c(on top of the merge with main).tests/startup_vertex_fetch_formats_check.py: the.get(code, 'BUF_FMT_8_UNORM')default is gone. Code 1 is now checked explicitly as the omitted tbuffer format (absent fromMTBUF_FORMATS, must beBUF_FMT_8_UNORM). Every other code is looked up without a default. Two negative controls were added: a renamed format for one code is caught, and giving code 1 a name is caught.tools/startup/gfx2hlsl.py: the generated FORMAT switch no longer ends indefault: break;. The default now sets all four components to a NaN sentinel (DESC_FORMAT_UNKNOWN = 0x7fc0f0f0), so a format the draw failed to refuse shows up in a readback instead of passing as zeros. The test checks that the sentinel default is present for the x, xy and xyz variants and thatdefault: breakis gone. With the old default restored, the test fails. With the new one, it passes.Commands run locally on Linux:
python3 -B tests/startup_vertex_fetch_formats_check.py controlspython3 -B tests/startup_buffer_address_check.pypython3 -B tests/startup_gfx2hlsl_refusals_check.pypython3 -B tests/startup_gfx2hlsl_join_symbols_check.pypython3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.pypython3 -B tests/startup_gfx2hlsl_capture_check.pypython3 -B tests/startup_image_load_mip_check.pygit diff --checkAll passed. No Windows or WARP run was done for this change.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T14:30:21Z.
Review: APPROVED
Rechecked
60475aaf. Windows Release passed all 6 selected checks on the descriptor path. The integrated draws stayed clear for missing metadata, an unsupported FORMAT and unresolved storage. With a valid descriptor, zero and one produced the distinct expected outputs on WARP and RTX 4060 Laptop. Each backend also caught the 19 translator mutations. The generated fallback is a detectable sentinel. This clears the earlier silent-zero finding.