Skip to content

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

Merged
R0Y00 merged 1 commit into
R0Y00:cpp-migrationfrom
JB2WIN:native/heap-typed-load
Nov 27, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:cpp-migrationfrom
JB2WIN:native/heap-typed-load

Conversation

@JB2WIN

@JB2WIN JB2WIN commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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 cpp-migration: pass captured heap view types into the in-runtime native compute route (#2958) #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

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

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>
@JB2WIN
JB2WIN force-pushed the native/heap-typed-load branch from b11de4d to e67f101 Compare November 27, 2026 09:56
@JB2WIN
JB2WIN marked this pull request as ready for review November 27, 2026 09:56
@JB2WIN

JB2WIN commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

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.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

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.

2 participants