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

Open
romn4rch wants to merge 5 commits from upstream-pr/3344 into main
romn4rch commented 2026-11-28 11:21:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by romn4rch on 2026-11-28T11:21:35Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5539590420 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344). Originally posted by [romn4rch](https://github.com/romn4rch) on 2026-11-28T11:21:35Z. --- 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.
KelboLive commented 2026-11-28 21:23:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:23:55Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100143902 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6100143902). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:23:55Z. **Review:** APPROVED --- 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 commented 2026-11-28 21:57:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:48Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100255246 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6100255246). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:48Z. **Review:** APPROVED --- 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 commented 2026-11-29 07:20:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T07:20:42Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101886983 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344#pullrequestreview-6101886983). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T07:20:42Z. **Review:** CHANGES_REQUESTED --- 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: ```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`.
JohnConnorNPC commented 2026-11-29 13:24:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:24:37Z.


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. #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 #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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7256516496 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344#issuecomment-7256516496). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-29T13:24:37Z. --- 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. #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 #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 commented 2026-12-02 07:13:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T07:13:22Z.


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!

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7337921989 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3344#issuecomment-7337921989). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-02T07:13:22Z. --- 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!
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3344:upstream-pr/3344'
git switch 'upstream-pr/3344'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3344'
git switch 'upstream-pr/3344'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3344'
git switch 'upstream-pr/3344'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3344'
git switch 'main'
git merge --squash 'upstream-pr/3344'
git switch 'main'
git merge --ff-only 'upstream-pr/3344'
git switch 'main'
git merge 'upstream-pr/3344'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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!3344
No description provided.