startup: buffer_load_format_* needs the descriptor DATA_FORMAT, which the translator does not track #1802

Closed
opened 2026-11-24 19:02:52 +00:00 by triggered02 · 1 comment
triggered02 commented 2026-11-24 19:02:52 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T19:02:52Z.


Census group at 1 refused shader (#870). Recorded because it looks like a small missing handler but is blocked on state the translator does not have — the same shape as #1802 (gather4).

Problem

buffer_load_format_xyz v[6:8], off, s[32:35], 0
-> REFUSED: buffer_load_format_xyz

tools/startup/gfx2hlsl.py has op_tbuffer_load_format_* (MTBUF) and op_buffer_load_dword* (MUBUF dwords), but no MUBUF typed-format load. Stage.buffer_address() already handles the off address form correctly (address = offset, no index/offset enable), so the address path is not the blocker.

Why it is not a small handler

MTBUF and MUBUF differ exactly where it matters: tbuffer_load_format_* carries the format in the instruction (format:[BUF_FMT_…], which Stage.tbuffer() reads and maps through its table), while buffer_load_format_* has no format field — the format comes from the resource descriptor's DATA_FORMAT bits (WORD0[11:8]… per the RDNA 2 resource descriptor), which is loaded at run time.

Stage.descriptor() only tracks symbolic keys — ('desc', source, byte offset, dword index) — never the descriptor's contents:

for i in range(count):
    self.sym[dst[1] + i] = ('desc', p[1], off, i)

So at translation time the format of s[32:35] is unknown. Picking one (for example assuming BUF_FMT_32_32_32_FLOAT because the destination is three dwords) would emit a load whose interpretation is a guess, and a wrong typed load is silently wrong data — worse than a refusal, and exactly the class of defect the reviews have been catching.

Deliverable

Lower buffer_load_format_{x,xy,xyz,xyzw} in a slice that first establishes how the descriptor's DATA_FORMAT becomes known, one of:

  • the pipeline state supplies the descriptor words for a resource (then decode DATA_FORMAT and reuse the Stage.tbuffer() format table — but note the MUBUF rules differ from MTBUF for some formats and the table must be extended deliberately, with refusals for the rest);
  • or the load is only lowered when the descriptor is proven to come from a known constant-buffer image, with the descriptor word bits threaded through descriptor().

Either way:

  • refuse by name when the format is unknown — that is the current behaviour and should stay until the state exists;
  • do not assume a format from the destination width;
  • a ctest that begins from synthetic encoded instructions and pins both the accepted form and each refusal, plus docs/experiments.md.

Done when

  • Either the census form lowers with a proven format, or the issue is closed with the descriptor-format question answered and the form refused by name with that reason.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589253868 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1809). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T19:02:52Z. --- Census group at **1** refused shader (#870). Recorded because it looks like a small missing handler but is blocked on state the translator does not have — the same shape as #1802 (gather4). ## Problem ``` buffer_load_format_xyz v[6:8], off, s[32:35], 0 -> REFUSED: buffer_load_format_xyz ``` `tools/startup/gfx2hlsl.py` has `op_tbuffer_load_format_*` (MTBUF) and `op_buffer_load_dword*` (MUBUF dwords), but no MUBUF typed-format load. `Stage.buffer_address()` already handles the `off` address form correctly (`address = offset`, no index/offset enable), so the address path is not the blocker. ## Why it is not a small handler MTBUF and MUBUF differ exactly where it matters: **`tbuffer_load_format_*` carries the format in the instruction** (`format:[BUF_FMT_…]`, which `Stage.tbuffer()` reads and maps through its table), while **`buffer_load_format_*` has no format field** — the format comes from the resource descriptor's `DATA_FORMAT` bits (`WORD0[11:8]`… per the RDNA 2 resource descriptor), which is loaded at run time. `Stage.descriptor()` only tracks *symbolic* keys — `('desc', source, byte offset, dword index)` — never the descriptor's contents: ```python for i in range(count): self.sym[dst[1] + i] = ('desc', p[1], off, i) ``` So at translation time the format of `s[32:35]` is unknown. Picking one (for example assuming `BUF_FMT_32_32_32_FLOAT` because the destination is three dwords) would emit a load whose interpretation is a guess, and a wrong typed load is silently wrong data — worse than a refusal, and exactly the class of defect the reviews have been catching. ## Deliverable Lower `buffer_load_format_{x,xy,xyz,xyzw}` in a slice that first establishes **how the descriptor's DATA_FORMAT becomes known**, one of: - the pipeline state supplies the descriptor words for a resource (then decode `DATA_FORMAT` and reuse the `Stage.tbuffer()` format table — but note the MUBUF rules differ from MTBUF for some formats and the table must be extended deliberately, with refusals for the rest); - or the load is only lowered when the descriptor is proven to come from a known constant-buffer image, with the descriptor word bits threaded through `descriptor()`. Either way: - refuse by name when the format is unknown — that is the current behaviour and should stay until the state exists; - do not assume a format from the destination width; - a ctest that begins from **synthetic** encoded instructions and pins both the accepted form and each refusal, plus `docs/experiments.md`. ## Done when - Either the census form lowers with a proven format, or the issue is closed with the descriptor-format question answered and the form refused by name with that reason. AI-assisted (Claude Code).
triggered02 commented 2026-11-26 04:04:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T03:21:15Z.


Closing as implemented on main. This was the MUBUF typed-format load gap, and it landed via #2138 (31f70a1 startup: lower buffer_load_format_x/xy/xyz with the format from the buffer descriptor) plus the compute-side follow-up 1e4e1451 shader: lower startup compute formatted buffer reads.

What main does now, instead of refusing:

  • ools/startup/gfx2hlsl.py has the four MUBUF forms � op_buffer_load_format_x/xy/xyz/xyzw � and states the contract in the handler: "FORMAT and DST_SEL come from word 3 of the descriptor, known at draw time". That is exactly the state this issue said the translator did not have; the format now comes from the resource descriptor's DATA_FORMAT/DST_SEL bits rather than from the instruction.
  • src/startup_stubs/buffer_format_word3.h builds that word from the title's buffer view and refuses views and hardware words it cannot decode, so an unknown format still refuses by design instead of being guessed.
  • Coverage: startup_buffer_format_word3 (fixture) and startup_buffer_format_word3_table (translation table vs DXGI), with the _mapping_control negative control.

Verified just now on current main (7967c5af) in a clean worktree:

cmake --build --preset dev --target startup_buffer_format_word3_check # exit 0 ctest --preset dev --no-tests=error -R '^startup_buffer_format_word3' 1/2 startup_buffer_format_word3 ................... Passed 2/2 startup_buffer_format_word3_mapping_control ... Passed 100% tests passed, 0 tests failed out of 2 python -B tests/startup_buffer_format_word3_table_check.py buffer format word 3 table: 14 DXGI formats match the translation

The mapping_control variant is a WILL_FAIL control, so the mapping assertion is pinned rather than incidental. If a specific BUF_FMT* still refuses in a census run, that is the word-3 decode refusing a format it cannot represent � please reopen with the form and the descriptor format, not with the generic MUBUF gap.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181640865 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1809#issuecomment-7181640865). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-26T03:21:15Z. --- Closing as implemented on main. This was the MUBUF typed-format load gap, and it landed via **#2138** (31f70a1 startup: lower buffer_load_format_x/xy/xyz with the format from the buffer descriptor) plus the compute-side follow-up 1e4e1451 shader: lower startup compute formatted buffer reads. What main does now, instead of refusing: - ools/startup/gfx2hlsl.py has the four MUBUF forms � op_buffer_load_format_x/xy/xyz/xyzw � and states the contract in the handler: *"FORMAT and DST_SEL come from word 3 of the descriptor, known at draw time"*. That is exactly the state this issue said the translator did not have; the format now comes from the resource descriptor's DATA_FORMAT/DST_SEL bits rather than from the instruction. - src/startup_stubs/buffer_format_word3.h builds that word from the title's buffer view and refuses views and hardware words it cannot decode, so an unknown format still refuses by design instead of being guessed. - Coverage: startup_buffer_format_word3 (fixture) and startup_buffer_format_word3_table (translation table vs DXGI), with the _mapping_control negative control. Verified just now on current main (7967c5af) in a clean worktree: ` cmake --build --preset dev --target startup_buffer_format_word3_check # exit 0 ctest --preset dev --no-tests=error -R '^startup_buffer_format_word3' 1/2 startup_buffer_format_word3 ................... Passed 2/2 startup_buffer_format_word3_mapping_control ... Passed 100% tests passed, 0 tests failed out of 2 python -B tests/startup_buffer_format_word3_table_check.py buffer format word 3 table: 14 DXGI formats match the translation ` The _mapping_control variant is a WILL_FAIL control, so the mapping assertion is pinned rather than incidental. If a specific BUF_FMT_* still refuses in a census run, that is the word-3 decode refusing a format it cannot represent � please reopen with the form and the descriptor format, not with the generic MUBUF gap.
Sign in to join this conversation.
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#1802
No description provided.