Skip to content

shader: formatted buffer byte-window review follow-up - #3344

Open
romn4rch wants to merge 5 commits into
R0Y00:mainfrom
romn4rch:copilot/pr-3232-review-2e633a14
Open

romn4rch wants to merge 5 commits into
R0Y00:mainfrom
romn4rch:copilot/pr-3232-review-2e633a14

Conversation

@romn4rch

Copy link
Copy Markdown
Contributor

Replacement submission for #3232. This branch contains the existing formatted-buffer work plus the verified review follow-up commit. The original PR remains open because its author-owned branch was not writable from this account; these PRs overlap in scope, so please keep only one submission and close/mark the other as superseded when choosing.

Validation: build, native_direct_container, hardware dispatch, and docs-link checks passed. In-box WARP was skipped because of its 4-lane wave limit.

JB2WIN and others added 5 commits November 28, 2026 08:03
formatted_byte_load asked resource() for raw_vector_srv even when the
descriptor was the byte-address rewrite (stride cleared in word 1), so a
tbuffer_load_format_* through such a window was refused with
"non-contiguous resource descriptor", for a table descriptor and for a
GPU-selected heap descriptor under the raw_buffer contract. It now picks
byte_window_srv by the same rule as the raw MUBUF load. Conversion, the
getDimensions element bound and the raw loads are unchanged.

Tests:
- native_global_srv_heap_replay_check.py: a 32_UINT tbuffer load through
  the heap window is recorded, compiled and replayed for selections 0
  and 1, with the cross-slot mismatch control; the loop guard refuses
  it; an 8_8_8_8_UNORM load through the window compiles.
- native_mtbuf_check.py: the 11-format value check also runs through a
  byte window of its table SRV (native_store_replay accepts the window
  binding as the same raw view).
- native_direct_container_check.py: compute table windows with both
  formats compile; without the byte-count product they are refused.

Refs R0Y00#3023

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e67f101)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean extension of MTBUF formatted loads to the SRV byte window with identity DST_SEL enforcement.

  • requires_identity_dst_sel threads cleanly from manifest → cache encoding → binder → dispatch refusal.
  • Writable MTBUF byte windows refuse without a verified view contract.
  • indirect_table_buffer checks identity DST_SEL (word 3) and component mapping (shader4component) before binding.
  • gfx1013_compute_mtbuf.inl detects the zero-stride rewrite and routes through byte_window_srv.
  • New startup_compute_mtbuf_window_check.py covers identity readback, swapped X/Y refusal, CBV-token refusal, and cold/warm cache manifest equality.
  • Existing tests updated for both raw and formatted window loads.

The flag propagation and refusal granularity are consistent with the existing codebase patterns.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean extension of MTBUF formatted loads to the SRV byte window with identity DST_SEL enforcement.

  • requires_identity_dst_sel threads cleanly from manifest → cache encoding → binder → dispatch refusal.
  • Writable MTBUF byte windows refuse without a verified view contract.
  • indirect_table_buffer checks identity DST_SEL (word 3) and component mapping (shader4component) before binding.
  • gfx1013_compute_mtbuf.inl detects the zero-stride rewrite and routes through byte_window_srv.
  • New startup_compute_mtbuf_window_check.py covers identity readback, swapped X/Y refusal, CBV-token refusal, and cold/warm cache manifest equality.
  • Existing tests updated for both raw and formatted window loads.

The flag propagation and refusal granularity are consistent with the existing codebase patterns.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2e633a14 by its diff, against main 212d4b5f; by reading only, nothing built or run. The body declares this a replacement for #3232. The src/ patch is line-for-line the one in #3232 at 1b3ee661 (same six files, same commits 587fc6d2 and 80952189); the two heads differ in src/ only by base drift. The three points of my review there still apply:

  1. Conflict and argument shift. git merge-tree --write-tree origin/main 2e633a14 exits 1 with conflicts in gfx1013_compute_mtbuf.inl, d3d12_compute_dispatch.inl, d3d12_draw.inl and native_mtbuf_check.py. main added a sixth parameter to indirect_table_buffer (d3d12_draw.inl:2514), before the snapshot bool:
    UINT alignment = D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT,
    The PR's call at d3d12_compute_dispatch.inl:655 is:
    indirect_table_buffer(self, words, false, &reason, 16u << 20, true,
                          slot.requires_identity_dst_sel);
    With requires_identity_dst_sel appended to main's signature, this call still compiles if kept as is: true becomes alignment 1, the flag becomes the snapshot bool, and the DST_SEL check is never requested. Fix: (..., 16u << 20, D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, true, slot.requires_identity_dst_sel), as main passes at d3d12_compute_dispatch.inl:794.
  2. Graphics path. Vertex and pixel stages reach the same MTBUF lowering (gfx1013_direct_graphics.inl:1960, then gfx1013_direct_compute.inl:561). The graphics manifest (direct_compute_cache.cpp:913) writes srv <i> buf table without identity_dst_sel, and the graphics binder (d3d12_draw.inl:2986) calls indirect_table_buffer(self, words) with no DST_SEL check. Fix: refuse a flagged binding in the graphics formatter, or limit the byte window to compute, and add a pixel-shader refusal case.
  3. Mask mutants. The only non-identity input swaps X and Y on a two-component load (0x0103efa5 against 0x0103efac; DST_SEL_X is bits 2:0, tools/startup/gfx2hlsl.py:179). Changing (words[3] & 0xfffu) != 0xfacu to (words[3] & 0x3fu) != 0x2cu at d3d12_draw.inl:2422 still refuses that input, so the suite passes. The same holds at :2390 for a low-6-bit compare of Shader4ComponentMapping, since the only control is ENCODE(1, 0, 2, 3). Fix: an xyzw load with a Z/W swap control, for both the DST_SEL word and the SRV mapping.

On a pull request, CI runs ctest --preset pr (.github/workflows/windows.yml:493). Its include list (CMakePresets.json:51) matches none of native_mtbuf_*, native_direct_container, native_global_srv_heap_replay_* or startup_compute_mtbuf_window_*, so the green check does not cover these tests. After the rebase, please post the ctest -R command and its result for them.

Request changes for 1-3 on 2e633a14.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Review of head 2e633a14 against main c04e0dd6. I read git objects only; nothing was built or run.

This looks superseded by #3232, which has merged. #3232 merged on 29 November (94ce06a3).

  • Both src/ commits of this branch are on main: git merge-base --is-ancestor 587fc6d2 origin/main and the same for 80952189 both exit 0.
  • The only commit unique to this branch is b450fe44 (test: cover MTBUF byte-window refusals), and git merge-base --is-ancestor b450fe44 origin/main exits 1. Carry formatted buffer loads through byte-address windows to main #3232 landed a different follow-up for the same review point, 5399a2d8 (test: cover MTBUF writable alias and CBV refusals). On main, tests/startup_compute_mtbuf_window_check.py already refuses the writable alias (reason = 'a writable MTBUF byte window has no verified view contract').
  • The argument-shift point from the review of this head is resolved on main. The call in d3d12_compute_dispatch.inl reads indirect_table_buffer(self, words, false, &reason, 16u << 20, D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, true, slot.requires_identity_dst_sel).
  • git merge-tree --write-tree origin/main 2e633a14 exits 1, with conflicts in docs/experiments/native-global-srv-heap-replay.md, tests/startup_compute_mtbuf_window_check.py and tests/startup_stream_consumer.cpp. Those are the files where b450fe44 and 5399a2d8 differ.

MUST

  1. Don't merge this branch as it is. Rebasing it would only bring back a second version of a test follow-up that main already has. I suggest closing it as superseded by Carry formatted buffer loads through byte-address windows to main #3232. If any b450fe44 case is still wanted, open a small PR against main with just that case. One example is the direct-container compute-tbuffer-writable-byte-window control, which main doesn't have.

The graphics-path and DST_SEL mask points from the review of this head were raised against the src/ patch that is now on main. If they still hold on main, they need an issue against main, not this branch.

SHOULD / NIT: none.

AI-assisted.

@Leyukaka

Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

This looks fully superseded by #3232, which merged on 29 November: as noted above, both src/ commits here are already ancestors of main. Unless something is still missing from it, I think this one can be closed. Thanks for the work on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants