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

Open
github-bot wants to merge 5 commits from github-bot/gh-3344 into main AGit
Owner

@⁠romn4rch on GitHub · 2026-11-28 11:21 UTC · original
romn4rch:copilot/pr-3232-review-2e633a14 → main · +268 −35 · 14 files · 5 commits · open

Replacement submission for #3234. 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.

**@⁠romn4rch** on GitHub · 2026-11-28 11:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344) `romn4rch:copilot/pr-3232-review-2e633a14` → `main` · +268 −35 · 14 files · 5 commits · open Replacement submission for #3234. 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.
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 #3023

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e67f10177b)
Co-authored-by: Copilot App <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 11:27:24 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:23 UTC · original · approved these changes

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** on GitHub · 2026-11-28 21:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6100143902) · **approved these changes** 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.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes

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** on GitHub · 2026-11-28 21:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6100255246) · **approved these changes** 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.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 07:20 UTC · original · requested changes

Reviewed 2e633a14 by its diff, against main 212d4b5f; by reading only, nothing built or run. The body declares this a replacement for #3234. The src/ patch is line-for-line the one in #3234 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.

**@⁠Leyukaka** on GitHub · 2026-11-29 07:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6101886983) · **requested changes** Reviewed `2e633a14` by its diff, against `main` `212d4b5f`; by reading only, nothing built or run. The body declares this a replacement for #3234. The `src/` patch is line-for-line the one in #3234 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: ```cpp UINT alignment = D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, ``` The PR's call at `d3d12_compute_dispatch.inl:655` is: ```cpp 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`.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 13:24 UTC · original

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

This looks superseded by #3234, which has merged. #3234 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. #3234 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 #3234. 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.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 13:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344#issuecomment-7256516496) Review of head `2e633a14` against `main` `c04e0dd6`. I read git objects only; nothing was built or run. **This looks superseded by #3234, which has merged.** #3234 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. #3234 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 #3234. 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.
Author
Owner

@⁠Leyukaka on GitHub · 2026-12-02 07:13 UTC · original

This looks fully superseded by #3234, 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!

**@⁠Leyukaka** on GitHub · 2026-12-02 07:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3344#issuecomment-7337921989) This looks fully superseded by #3234, 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!
This pull request has changes conflicting with the target branch.
  • docs/experiments/native-global-srv-heap-replay.md
  • src/direct_compute_cache.cpp
  • src/gfx1013_compute_mtbuf.inl
  • src/gfx1013_compute_native.h
  • src/gfx1013_direct_compute.inl
  • src/startup_stubs/d3d12_compute_dispatch.inl
  • src/startup_stubs/d3d12_draw.inl
  • tests/cmake/startup_compute_mtbuf_window.cmake
  • tests/native_direct_container_check.py
  • tests/native_mtbuf_check.py
  • tests/native_store_replay.cpp
  • tests/startup_compute_mtbuf_window_check.py
  • tests/startup_stream_consumer.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3346/head:github-bot/gh-3344'
git switch 'github-bot/gh-3344'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3344'
git switch 'github-bot/gh-3344'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3344'
git switch 'github-bot/gh-3344'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3344'
git switch 'main'
git merge --squash 'github-bot/gh-3344'
git switch 'main'
git merge --ff-only 'github-bot/gh-3344'
git switch 'main'
git merge 'github-bot/gh-3344'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.