native: read formatted loads through a byte-address rewritten descriptor #3034

Manually merged
github merged 1 commit from github-bot/gh-3034 into gh-pr/3034/base 2026-11-27 10:43:30 +00:00 AGit
Owner

@⁠JB2WIN on GitHub · 2026-11-27 09:15 UTC · original
JB2WIN:native/heap-typed-load → cpp-migration · +96 −27 · 6 files · 1 commits · merged 2026-11-27 10:16 UTC

Change

Target branch cpp-migration. Refs #3023. Follow-up to #3025 (merged as 1507f0e2); rebased onto cpp-migration b8f49259, so this PR is the one formatted-load commit.

formatted_byte_load (src/gfx1013_compute_mtbuf.inl) asked resource() for raw_vector_srv even when its descriptor was the byte-address rewrite (word 1 with the stride cleared). A tbuffer_load_format_* through such a window was therefore refused with "non-contiguous resource descriptor", both for a table descriptor and for a GPU-selected heap descriptor under the raw_buffer contract of #3025. It now picks byte_window_srv by the same rule as the raw MUBUF load (buffer_load_dword*). The instruction's format still drives the in-shader conversion, getDimensions on the raw view still bounds the element, and the loads stay rawBufferLoad.

  • src/gfx1013_compute_mtbuf.inl: the view-kind choice, plus the file comment.
  • tests/native_store_replay.cpp: the replay harness binds a byte_window_srv input as the same raw view and seed as raw_vector_srv.

Why this step: on a local start-up capture (compile_dxil --refusals, 2,689 slot 67 requests, counts only), with the raw heap contract forced and a typed heap load prototyped (both uncommitted, not reproducible from the repo), 861 requests stopped first at this refusal. With this change they move on to other, already-known refusals. No additional request compiles from this alone; typed heap loads (buffer_load_format_*) remain the next step of #3023 and need their own view contract.

Verification

Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), MSVC 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled. Base 837728dd (#3025); rerun after the rebase on b8f49259: the four targeted tests pass again.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^(native_mtbuf_hardware|native_direct_container|compute_load_format_controls|native_global_srv_heap_replay_hardware)$" -V
ctest --preset dev --no-tests=error -R "native_|startup_compute_dispatch|compute_heap" -j 6
  • Targeted tests: 4/4 passed.
    • native_global_srv_heap_replay_hardware: 94 assertions (84 before). A 32_UINT tbuffer_load_format_x through the heap window is recorded, compiled with compile_dxil --requests and replayed for selections 0 and 1 (output equals the slot's data); replaying selection 0 against slot 1 reports a mismatch; a loop around the heap load refuses it ("heap byte window loaded inside a loop"); an 8_8_8_8_UNORM tbuffer_load_format_xyzw through the window compiles.
    • native_mtbuf_hardware: the existing 11-format value check also runs through a byte window of its table SRV and matches, including the element at the end of the view that reads 0.
    • native_direct_container: compute table windows with 32_UINT and 8_8_8_8_UNORM compile; without the byte-count product they are refused ("non-contiguous resource descriptor"; an over-acceptance control only, the old code refuses it with the same text).
  • Discrimination: the new checks run with compile_dxil, native_global_srv_heap_replay and native_store_replay built at 837728dd fail: the heap check at the twindow_loop shape (the earlier 74 assertions pass), the MTBUF check at the window run, the container check at compute-tbuffer-byte-window, each with "non-contiguous resource descriptor".
  • Regression set: 147 tests, 1 failed (native_cvt_pk_u8_hardware, failing at the base as well), WARP skips; the same as before the change.
  • compile_dxil --refusals on the local capture without a contract: identical output before and after.
  • tests/docs_links_check.py and tests/bidi_controls_check.py pass.

Evidence and follow-up

  • Instruction words were assembled with LLVM 15 (clang -cc1as -triple amdgcn-amd-amdhsa -target-cpu gfx1013 -show-encoding); fixtures are source-built.
  • Limits (also in docs/experiments/native-global-srv-heap-replay.md): the MTBUF element bound is the desktop raw view's size, so a runtime that binds a window must size the raw view to the guest window's byte count. The startup manifest route already does so for a table window (max(stride, 1) * num_records, indirect_table_buffer), but no fixture runs that route for a window. The descriptor's DST_SEL is not applied (identity only, unchecked).
  • Follow-ups on #3023: typed heap loads (new view contract); the runtime contract (stage 3).

Checklist

  • One behaviour, tests added, no test weakened
  • Docs updated
  • No game files, dumps or title-specific content

AI-assisted.

🤖 Generated with Claude Code

**@⁠JB2WIN** on GitHub · 2026-11-27 09:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3034) `JB2WIN:native/heap-typed-load` → `cpp-migration` · +96 −27 · 6 files · 1 commits · merged 2026-11-27 10:16 UTC ## Change Target branch `cpp-migration`. Refs #3023. Follow-up to #3025 (merged as `1507f0e2`); rebased onto `cpp-migration` `b8f49259`, so this PR is the one formatted-load commit. `formatted_byte_load` (`src/gfx1013_compute_mtbuf.inl`) asked `resource()` for `raw_vector_srv` even when its descriptor was the byte-address rewrite (word 1 with the stride cleared). A `tbuffer_load_format_*` through such a window was therefore refused with "non-contiguous resource descriptor", both for a table descriptor and for a GPU-selected heap descriptor under the `raw_buffer` contract of #3025. It now picks `byte_window_srv` by the same rule as the raw MUBUF load (`buffer_load_dword*`). The instruction's format still drives the in-shader conversion, `getDimensions` on the raw view still bounds the element, and the loads stay `rawBufferLoad`. - `src/gfx1013_compute_mtbuf.inl`: the view-kind choice, plus the file comment. - `tests/native_store_replay.cpp`: the replay harness binds a `byte_window_srv` input as the same raw view and seed as `raw_vector_srv`. Why this step: on a local start-up capture (`compile_dxil --refusals`, 2,689 slot 67 requests, counts only), with the raw heap contract forced and a typed heap load prototyped (both uncommitted, not reproducible from the repo), 861 requests stopped first at this refusal. With this change they move on to other, already-known refusals. **No additional request compiles from this alone**; typed heap loads (`buffer_load_format_*`) remain the next step of #3023 and need their own view contract. ## Verification Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), MSVC 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled. Base `837728dd` (#3025); rerun after the rebase on `b8f49259`: the four targeted tests pass again. ``` cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R "^(native_mtbuf_hardware|native_direct_container|compute_load_format_controls|native_global_srv_heap_replay_hardware)$" -V ctest --preset dev --no-tests=error -R "native_|startup_compute_dispatch|compute_heap" -j 6 ``` - Targeted tests: 4/4 passed. - `native_global_srv_heap_replay_hardware`: 94 assertions (84 before). A 32_UINT `tbuffer_load_format_x` through the heap window is recorded, compiled with `compile_dxil --requests` and replayed for selections 0 and 1 (output equals the slot's data); replaying selection 0 against slot 1 reports a mismatch; a loop around the heap load refuses it ("heap byte window loaded inside a loop"); an 8_8_8_8_UNORM `tbuffer_load_format_xyzw` through the window compiles. - `native_mtbuf_hardware`: the existing 11-format value check also runs through a byte window of its table SRV and matches, including the element at the end of the view that reads 0. - `native_direct_container`: compute table windows with 32_UINT and 8_8_8_8_UNORM compile; without the byte-count product they are refused ("non-contiguous resource descriptor"; an over-acceptance control only, the old code refuses it with the same text). - Discrimination: the new checks run with `compile_dxil`, `native_global_srv_heap_replay` and `native_store_replay` built at `837728dd` fail: the heap check at the `twindow_loop` shape (the earlier 74 assertions pass), the MTBUF check at the window run, the container check at `compute-tbuffer-byte-window`, each with "non-contiguous resource descriptor". - Regression set: 147 tests, 1 failed (`native_cvt_pk_u8_hardware`, failing at the base as well), WARP skips; the same as before the change. - `compile_dxil --refusals` on the local capture without a contract: identical output before and after. - `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. ## Evidence and follow-up - Instruction words were assembled with LLVM 15 (`clang -cc1as -triple amdgcn-amd-amdhsa -target-cpu gfx1013 -show-encoding`); fixtures are source-built. - Limits (also in `docs/experiments/native-global-srv-heap-replay.md`): the MTBUF element bound is the desktop raw view's size, so a runtime that binds a window must size the raw view to the guest window's byte count. The startup manifest route already does so for a table window (`max(stride, 1) * num_records`, `indirect_table_buffer`), but no fixture runs that route for a window. The descriptor's DST_SEL is not applied (identity only, unchecked). - Follow-ups on #3023: typed heap loads (new view contract); the runtime contract (stage 3). ## Checklist - [x] One behaviour, tests added, no test weakened - [x] Docs updated - [x] No game files, dumps or title-specific content AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Under the raw_buffer heap view contract the direct compute path now tracks
the byte-address rewrite (stride, max 1, byte count, stride cleared, raw
out-of-bounds mode) of a descriptor loaded from the GPU-selected heap slot,
as byte_descriptor_field already does for table descriptors, and reads a raw
load through it as the same ResourceDescriptorHeap[slot] raw view. The words
must come from one heap load; a program with a backward branch refuses the
window as a precaution. Without a contract nothing changes.

Refs #3023, part of #2935.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first guard refused the window for any backward branch in the program.
On a local start-up capture (contract forced locally) that refused 921 of
2,689 requests, although their loops do not contain the heap descriptor
load. Only a loop around that load runs it again for another selection, so
the guard now checks whether a backward branch's range contains the load pc
(symbol.definition). The test refuses a loop back to the load and compiles a
loop after it.

Refs #3023.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 09:16:12 +00:00
github-bot force-pushed github-bot/gh-3034 from b11de4d3fd to e67f10177b 2026-11-27 10:43:26 +00:00 Compare
github-bot changed target branch from cpp-migration to gh-pr/3034/base 2026-11-27 10:43:27 +00:00
github manually merged commit e67f10177b into gh-pr/3034/base 2026-11-27 10:43:30 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 09:31 UTC · original · reviewed

I reviewed the six-file delta above #3025 and tested GitHub's integration tree 7eef58b7 (this head on cpp-migration 999e17cd) in Debug with /Z7 and Release /O2.

ctest --preset <dev|release> --no-tests=error -V -R '^(native_mtbuf_hardware|native_direct_container|native_global_srv_heap_replay_(hardware|warp))$' gave three passes and one capability skip in each configuration. On RTX 4060 Laptop GPU (NVIDIA 616.56, Windows 11 26200.9974, SDK 10.0.26100), capture and offline replay each matched 64 words for both slots and kept all eight guards intact. The wrong-slot control failed at word 0. A back edge spanning the formatted descriptor load refused and produced no bytecode. The table byte-window MTBUF test matched 54 result words and all guards. The heap replay does not enable the D3D12 debug layer. WARP reported 4–4 lanes and exited 77 in both configurations.

#3025 is now on cpp-migration as 1507f0e2. Please rebase the draft onto the updated target so the PR shows only the formatted-load change. The tests above cover the current synthetic capture and replay contract. The runtime checks for stride above one and exact view byte count remain tracked in #3023.

**@⁠R0Y00** on GitHub · 2026-11-27 09:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3034#pullrequestreview-6086075727) · **reviewed** I reviewed the six-file delta above #3025 and tested GitHub's integration tree `7eef58b7` (this head on `cpp-migration` `999e17cd`) in Debug with `/Z7` and Release `/O2`. `ctest --preset <dev|release> --no-tests=error -V -R '^(native_mtbuf_hardware|native_direct_container|native_global_srv_heap_replay_(hardware|warp))$'` gave three passes and one capability skip in each configuration. On RTX 4060 Laptop GPU (NVIDIA 616.56, Windows 11 26200.9974, SDK 10.0.26100), capture and offline replay each matched 64 words for both slots and kept all eight guards intact. The wrong-slot control failed at word 0. A back edge spanning the formatted descriptor load refused and produced no bytecode. The table byte-window MTBUF test matched 54 result words and all guards. The heap replay does not enable the D3D12 debug layer. WARP reported 4–4 lanes and exited 77 in both configurations. #3025 is now on `cpp-migration` as `1507f0e2`. Please rebase the draft onto the updated target so the PR shows only the formatted-load change. The tests above cover the current synthetic capture and replay contract. The runtime checks for stride above one and exact view byte count remain tracked in #3023.
Author
Owner

@⁠JB2WIN on GitHub · 2026-11-27 09:56 UTC · original

Thanks for testing it on the RTX 4060 in both configurations.

Rebased onto cpp-migration b8f49259 (which contains #3025 as 1507f0e2). The PR is now the single commit e67f1017 and is marked ready. I rebuilt on the new base and reran native_mtbuf_hardware, native_direct_container, compute_load_format_controls and native_global_srv_heap_replay_hardware on the RTX 3080 (driver 32.0.16.2124): 4/4 passed, 94 assertions in the heap replay as before. The PR description is updated to match.

Agreed on the remaining runtime checks; the stride, exact byte count and DST_SEL items are recorded in #3023.

AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-11-27 09:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3034#issuecomment-7215276355) Thanks for testing it on the RTX 4060 in both configurations. Rebased onto `cpp-migration` `b8f49259` (which contains #3025 as `1507f0e2`). The PR is now the single commit `e67f1017` and is marked ready. I rebuilt on the new base and reran `native_mtbuf_hardware`, `native_direct_container`, `compute_load_format_controls` and `native_global_srv_heap_replay_hardware` on the RTX 3080 (driver 32.0.16.2124): 4/4 passed, 94 assertions in the heap replay as before. The PR description is updated to match. Agreed on the remaining runtime checks; the stride, exact byte count and DST_SEL items are recorded in #3023. AI-assisted.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 10:14 UTC · original · approved these changes

Reviewed the rebased six-file delta at e67f1017, integration commit e3dbf96f on cpp-migration b8f49259. I rebuilt compile_dxil, native_store_replay, native_global_srv_heap_replay and offscreen_check, then ran ctest --preset <dev|release> --no-tests=error --output-on-failure -j 2 -R '^(native_mtbuf_hardware|native_direct_container|compute_load_format_controls|native_global_srv_heap_replay_(hardware|warp))$'. Each configuration produced four passes and one WARP 77 skip because the adapter has four-lane waves. RTX 4060 Laptop driver 32.0.16.1656, Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818, heap replay debug layer off. Hosted Windows, Linux and gfx1013 passed. This covers the capture and offline compiler contract. Runtime stride, exact view length and DST_SEL remain in #3023.

**@⁠R0Y00** on GitHub · 2026-11-27 10:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3034#pullrequestreview-6086590436) · **approved these changes** Reviewed the rebased six-file delta at `e67f1017`, integration commit `e3dbf96f` on `cpp-migration` `b8f49259`. I rebuilt `compile_dxil`, `native_store_replay`, `native_global_srv_heap_replay` and `offscreen_check`, then ran `ctest --preset <dev|release> --no-tests=error --output-on-failure -j 2 -R '^(native_mtbuf_hardware|native_direct_container|compute_load_format_controls|native_global_srv_heap_replay_(hardware|warp))$'`. Each configuration produced four passes and one WARP 77 skip because the adapter has four-lane waves. RTX 4060 Laptop driver 32.0.16.1656, Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818, heap replay debug layer off. Hosted Windows, Linux and gfx1013 passed. This covers the capture and offline compiler contract. Runtime stride, exact view length and DST_SEL remain in #3023.
This discussion has been locked. Commenting is limited to contributors.
No description provided.