native: carry byte-window formatted loads and typed heap loads to main #3409

Merged
JB2WIN merged 9 commits from upstream-pr/3409 into main 2026-11-29 08:28:13 +00:00
JB2WIN commented 2026-11-28 22:50:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T22:50:56Z.


Brings the two cpp-migration features to main: #3034 (formatted loads through a byte-address rewritten descriptor, as RonLogic's #3232) and #3042 (one-channel typed loads through a GPU-selected heap slot). Takes over #3232 under the 2-hour rule (no activity since 12:39 UTC, see the comment there). RonLogic's commits are kept as they are.

This is the first step toward #3063 on main. Its bucket, "direct resource-heap load requires the selected GPU slot and its view type", is the largest in #3224 (330 shaders, 4.67 M dispatches in Leyukaka's 900 s run).

Changes on top of #3232

  • Merge of main 8ecd30fe. indirect_table_buffer gained alignment as its sixth parameter on main, so the compute input call passes D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT before true, slot.requires_identity_dst_sel (Leyukaka's point 1 on #3232). Every other caller was checked against the new signature. formatted_byte_load uses a byte window the caller already bound (main's graphics path) and otherwise selects byte_window_srv from the zero-stride rewrite.
  • Cherry-pick of #3042. heap_typed_srv goes after indexed_raw_srv (kinds are serialized by value, so appending keeps existing caches valid). The typed_dword cache identity sits in main's cached_compute_ir. Test section 12 sits next to main's sections 10 and 11.
  • Three negative cases: a typed heap load with offen, an immediate offset or a nonzero soffset is refused by the decoder ("formatted load requires zero or a single linear index"). Doc updated (typed_dword contract, 160 assertions).

Leyukaka's point 2 on #3232 (the pixel-shader MTBUF path has no test) is not covered here.

Tests

Windows 11 26200, RTX 3080 (32.0.16.2124), WARP, dev preset, -j1:

  • ^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$: all pass except startup_compute_dispatch_output_{warp,hardware} and startup_compute_half_buffer_uav_{controls,hardware}. Those four fail the same way on main without this PR (see #3353). WARP wave32 cases skip with 77.
  • native_global_srv_heap_replay_hardware: 160 assertions pass. With the src/, tools/ and fixture changes of the #3042 commit reverted, it fails at "record typed select 3".
  • startup_compute_mtbuf_window_{controls,hardware} (identity and swapped X/Y, writable alias, CBV token) pass after the merge.

Refs #3232, #3042, #3034, #3023, #3224.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5545359574 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-28T22:50:56Z. --- Brings the two `cpp-migration` features to `main`: #3034 (formatted loads through a byte-address rewritten descriptor, as RonLogic's #3232) and #3042 (one-channel typed loads through a GPU-selected heap slot). Takes over #3232 under the 2-hour rule (no activity since 12:39 UTC, see the comment there). RonLogic's commits are kept as they are. This is the first step toward #3063 on `main`. Its bucket, "direct resource-heap load requires the selected GPU slot and its view type", is the largest in #3224 (330 shaders, 4.67 M dispatches in Leyukaka's 900 s run). ## Changes on top of #3232 - Merge of `main` 8ecd30fe. `indirect_table_buffer` gained `alignment` as its sixth parameter on `main`, so the compute input call passes `D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT` before `true, slot.requires_identity_dst_sel` (Leyukaka's point 1 on #3232). Every other caller was checked against the new signature. `formatted_byte_load` uses a byte window the caller already bound (`main`'s graphics path) and otherwise selects `byte_window_srv` from the zero-stride rewrite. - Cherry-pick of #3042. `heap_typed_srv` goes after `indexed_raw_srv` (kinds are serialized by value, so appending keeps existing caches valid). The `typed_dword` cache identity sits in `main`'s `cached_compute_ir`. Test section 12 sits next to `main`'s sections 10 and 11. - Three negative cases: a typed heap load with `offen`, an immediate offset or a nonzero `soffset` is refused by the decoder ("formatted load requires zero or a single linear index"). Doc updated (`typed_dword` contract, 160 assertions). Leyukaka's point 2 on #3232 (the pixel-shader MTBUF path has no test) is not covered here. ## Tests Windows 11 26200, RTX 3080 (32.0.16.2124), WARP, dev preset, `-j1`: - `^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$`: all pass except `startup_compute_dispatch_output_{warp,hardware}` and `startup_compute_half_buffer_uav_{controls,hardware}`. Those four fail the same way on `main` without this PR (see #3353). WARP wave32 cases skip with 77. - `native_global_srv_heap_replay_hardware`: 160 assertions pass. With the `src/`, `tools/` and fixture changes of the #3042 commit reverted, it fails at "record typed select 3". - `startup_compute_mtbuf_window_{controls,hardware}` (identity and swapped X/Y, writable alias, CBV token) pass after the merge. Refs #3232, #3042, #3034, #3023, #3224. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
SimSalabimse commented 2026-11-29 00:25:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-29T00:25:28Z.


Hardware test on the Windows test PC (RTX 4070 Ti, Windows 11) at head d4d9af41:

  • cmake --build --preset dev: build exit 0
  • ctest --preset dev -j 1 -R '^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$' -E 'startup_audio_(output|pacing|provider)': 515/519 passed

The 4 failures are startup_compute_dispatch_output_warp, startup_compute_dispatch_output_hardware, startup_compute_half_buffer_uav_controls and startup_compute_half_buffer_uav_hardware. They are the same ones that fail on main without this PR (#3353). No other failures, timeouts or not-run tests.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7248102797 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#issuecomment-7248102797). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-29T00:25:28Z. --- Hardware test on the Windows test PC (RTX 4070 Ti, Windows 11) at head `d4d9af41`: - `cmake --build --preset dev`: build exit 0 - `ctest --preset dev -j 1 -R '^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$' -E 'startup_audio_(output|pacing|provider)'`: 515/519 passed The 4 failures are `startup_compute_dispatch_output_warp`, `startup_compute_dispatch_output_hardware`, `startup_compute_half_buffer_uav_controls` and `startup_compute_half_buffer_uav_hardware`. They are the same ones that fail on `main` without this PR (#3353). No other failures, timeouts or not-run tests. AI-Assisted
JB2WIN commented 2026-11-29 01:18:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T01:18:54Z.


Thanks, that matches my run: the same four failures, which also fail on main without this PR (#3353, fixed by #3389).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7248701992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#issuecomment-7248701992). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T01:18:54Z. --- Thanks, that matches my run: the same four failures, which also fail on `main` without this PR (#3353, fixed by #3389). AI-assisted.
Leyukaka commented 2026-11-29 01:37:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T01:37:15Z.

Review: CHANGES_REQUESTED


Request changes at d4d9af41. Read from the diff only, not built here.

Blocking: the in-process path drops the DST_SEL check. translate_compute_natively (src/startup_stubs/d3d12_compute_dispatch.inl, slot loop) accepts byte_window_srv through accepts_cbv_window and pushes the slot without copying view.requires_identity_dst_sel, so record_translated_dispatch calls indirect_table_buffer(..., false). That path is tried before the published manifest. On main this program was refused at translation. With this PR and X2W_NATIVE_SHADERS set, a V# with swapped DST_SEL, a slot 18 SRV with a non-default mapping or a slot 17 CBV token binds without a check (the three checks in d3d12_draw.inl are all gated on that flag). The same drop applies when the pack returns a prepared program, not only on live translation. I could not find what the doc line "The in-process path falls through to that manifest for a byte window" refers to. startup_compute_mtbuf_window_check.py removes X2W_NATIVE_SHADERS, so this path is not tested. Suggested fix: set slots.back().requires_identity_dst_sel = view.requires_identity_dst_sel; and run the swapped case once with the variable set.

One-line mutations the tests do not catch:

  • src/startup_stubs/native_global_srv.h, global_srv_contract: view.dword_channels != 1 -> !view.dword_channels. There is no dword 3 2 case.
  • Same line: removing view.stride != 4 || or !view.bytes || view.bytes % 4 ||. No stride or size negative exists.
  • src/startup_stubs/d3d12_draw.inl: (words[3] & 0xfffu) != 0xfacu -> (words[3] & 0x3fu) != 0x2cu. Only an X/Y swap is tested, and the test load is _xy.

Checked and correct: 0xfac is identity DST_SEL. The decoder refuses typed heap loads with op > 3 (so no d16), offen, an immediate offset or a nonzero soffset. heap_typed_srv is appended last and the cache decode bound covers it. compute_heap_binding includes it, so the pipeline treats it as heap-indexed. The revision hash covers direct_compute_cache.cpp, so cached bindings in the old format do not decode under the new layout. git merge-tree against main 212d4b5f is clean.

Scope: the startup runtime still passes HeapViewContract::none (translate_compute hardcodes it at gfx1013_compute_native.cpp:2048; compile_dxil line 858 for runtime requests). So "direct resource-heap load requires the selected GPU slot and its view type" still refuses every runtime request. typed_dword applies only to compile_dxil with a .views file. In the runtime, the only change is that compute MTBUF loads through a table byte window are no longer refused with "non-contiguous resource descriptor".

The only build file is tests/cmake/startup_compute_mtbuf_window.cmake (add_test only). It is picked up by the existing glob, and CMakeLists.txt is unchanged.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100927874 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#pullrequestreview-6100927874). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T01:37:15Z. **Review:** CHANGES_REQUESTED --- Request changes at `d4d9af41`. Read from the diff only, not built here. **Blocking: the in-process path drops the DST_SEL check.** `translate_compute_natively` (`src/startup_stubs/d3d12_compute_dispatch.inl`, slot loop) accepts `byte_window_srv` through `accepts_cbv_window` and pushes the slot without copying `view.requires_identity_dst_sel`, so `record_translated_dispatch` calls `indirect_table_buffer(..., false)`. That path is tried before the published manifest. On `main` this program was refused at translation. With this PR and `X2W_NATIVE_SHADERS` set, a V# with swapped DST_SEL, a slot 18 SRV with a non-default mapping or a slot 17 CBV token binds without a check (the three checks in `d3d12_draw.inl` are all gated on that flag). The same drop applies when the pack returns a prepared program, not only on live translation. I could not find what the doc line "The in-process path falls through to that manifest for a byte window" refers to. `startup_compute_mtbuf_window_check.py` removes `X2W_NATIVE_SHADERS`, so this path is not tested. Suggested fix: set `slots.back().requires_identity_dst_sel = view.requires_identity_dst_sel;` and run the `swapped` case once with the variable set. **One-line mutations the tests do not catch:** - `src/startup_stubs/native_global_srv.h`, `global_srv_contract`: `view.dword_channels != 1` -> `!view.dword_channels`. There is no `dword 3 2` case. - Same line: removing `view.stride != 4 ||` or `!view.bytes || view.bytes % 4 ||`. No stride or size negative exists. - `src/startup_stubs/d3d12_draw.inl`: `(words[3] & 0xfffu) != 0xfacu` -> `(words[3] & 0x3fu) != 0x2cu`. Only an X/Y swap is tested, and the test load is `_xy`. **Checked and correct:** `0xfac` is identity DST_SEL. The decoder refuses typed heap loads with `op > 3` (so no d16), `offen`, an immediate offset or a nonzero `soffset`. `heap_typed_srv` is appended last and the cache decode bound covers it. `compute_heap_binding` includes it, so the pipeline treats it as heap-indexed. The revision hash covers `direct_compute_cache.cpp`, so cached bindings in the old format do not decode under the new layout. `git merge-tree` against `main` `212d4b5f` is clean. **Scope:** the startup runtime still passes `HeapViewContract::none` (`translate_compute` hardcodes it at `gfx1013_compute_native.cpp:2048`; `compile_dxil` line 858 for runtime requests). So "direct resource-heap load requires the selected GPU slot and its view type" still refuses every runtime request. `typed_dword` applies only to `compile_dxil` with a `.views` file. In the runtime, the only change is that compute MTBUF loads through a table byte window are no longer refused with "non-contiguous resource descriptor". The only build file is `tests/cmake/startup_compute_mtbuf_window.cmake` (`add_test` only). It is picked up by the existing glob, and `CMakeLists.txt` is unchanged.
JB2WIN commented 2026-11-29 02:10:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T02:10:30Z.


Thanks, all addressed in 30de88b6:

  • In-process DST_SEL: translate_compute_natively now copies requires_identity_dst_sel into the slot. startup_compute_mtbuf_window runs the identity and swapped X/Y cases a second time with X2W_NATIVE_SHADERS and X2W_NATIVE_SHADERS_ONLY set. With that line reverted, the swapped case writes the output (word 0 reads 01234567, not the sentinel). The doc sentence about the in-process route now says what the code does.

  • Mutations:

    • a Z/W swap with identity X/Y (0x0103edec) must refuse on the published route;
    • global_srv_contract gets dword 3 2, stride 8, an odd byte count and a zero byte count as compile refusals.

    I ran each of your four one-line mutations locally, and each now fails its test.

  • Scope: agreed, the runtime still passes no contract, so for a title run this only changes the MTBUF table byte window. The PR body says it is translator side only. #3023 has the measurement for the runtime side.

native_global_srv_heap_replay_hardware, startup_compute_mtbuf_window_*, native_mtbuf_* and native_direct_container*: 6/6 pass on an RTX 3080 (32.0.16.2124). The WARP wave32 cases skip with 77. #3415 has the same fix merged in (242 assertions on that branch).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7249257052 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#issuecomment-7249257052). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T02:10:30Z. --- Thanks, all addressed in `30de88b6`: - **In-process DST_SEL:** `translate_compute_natively` now copies `requires_identity_dst_sel` into the slot. `startup_compute_mtbuf_window` runs the identity and swapped X/Y cases a second time with `X2W_NATIVE_SHADERS` and `X2W_NATIVE_SHADERS_ONLY` set. With that line reverted, the swapped case writes the output (word 0 reads `01234567`, not the sentinel). The doc sentence about the in-process route now says what the code does. - **Mutations:** - a Z/W swap with identity X/Y (`0x0103edec`) must refuse on the published route; - `global_srv_contract` gets `dword 3 2`, stride 8, an odd byte count and a zero byte count as compile refusals. I ran each of your four one-line mutations locally, and each now fails its test. - **Scope:** agreed, the runtime still passes no contract, so for a title run this only changes the MTBUF table byte window. The PR body says it is translator side only. #3023 has the measurement for the runtime side. `native_global_srv_heap_replay_hardware`, `startup_compute_mtbuf_window_*`, `native_mtbuf_*` and `native_direct_container*`: 6/6 pass on an RTX 3080 (32.0.16.2124). The WARP wave32 cases skip with 77. #3415 has the same fix merged in (242 assertions on that branch). AI-assisted.
Leyukaka commented 2026-11-29 02:39:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T02:39:30Z.

Review: APPROVED


Approve at 30de88b6. Read from the diff only, not built or run here.

Blocking point fixed. src/startup_stubs/d3d12_compute_dispatch.inl:358 copies view.requires_identity_dst_sel into the slot, and line 789 passes it to indirect_table_buffer. The live translation (line 325) and the prepared pack program (line 317, decode reads the flag at direct_compute_cache.cpp:141) both reach that loop. startup_compute_mtbuf_window_check.py:117-123 runs identity and swapped X/Y with X2W_NATIVE_SHADERS and X2W_NATIVE_SHADERS_ONLY=1. load_compute_translation returns before reading the published manifest under _ONLY (line 130), so the identity readback can only come from the in-process route, and the refusal text is produced only by the binder (d3d12_draw.inl:2573).

The four mutations, by reading:

  • dword_channels != 1 -> !dword_channels: typed_dword_2 (native_global_srv_heap_replay_check.py:556) no longer gets the refusal text, so its require fails.
  • Removing view.stride != 4 ||: typed_stride_8 (line 557).
  • Removing !view.bytes || or view.bytes % 4 ||: typed_bytes_zero (561) and typed_bytes_odd (559, 256 + 2 bytes).
  • 0xfff/0xfac -> 0x3f/0x2c: SWAPPED_ZW = 0x0103edec (startup_compute_mtbuf_window_check.py:112-114) has 0xdec & 0x3f == 0x2c, so it binds and the guard compare fails.

Not blocking, follow-up (by reading): a byte window read through a GPU-selected heap descriptor still has no identity requirement. resource() returns from heap_resource (gfx1013_direct_compute.inl:411-412) before the flag is set (433), and the heap loop in the dispatch (d3d12_compute_dispatch.inl:934) passes no flag. translate_compute passes HeapViewContract::none (gfx1013_compute_native.cpp:2048), under which heap_resource refuses, so the runtime does not reach this today. It needs the same check when the contract is wired into the runtime.

CI does not run the changed tests: on a pull request the Windows job runs ctest --preset pr (windows.yml:493), and that filter matches neither startup_compute_mtbuf_window_* nor native_global_srv_heap_replay*. The inter-diff from d4d9af41 touches no build, CI or hook file. #3415 (e232e475) contains 30de88b6.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101105380 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#pullrequestreview-6101105380). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T02:39:30Z. **Review:** APPROVED --- Approve at `30de88b6`. Read from the diff only, not built or run here. **Blocking point fixed.** `src/startup_stubs/d3d12_compute_dispatch.inl:358` copies `view.requires_identity_dst_sel` into the slot, and line 789 passes it to `indirect_table_buffer`. The live translation (line 325) and the prepared pack program (line 317, `decode` reads the flag at `direct_compute_cache.cpp:141`) both reach that loop. `startup_compute_mtbuf_window_check.py:117-123` runs identity and swapped X/Y with `X2W_NATIVE_SHADERS` and `X2W_NATIVE_SHADERS_ONLY=1`. `load_compute_translation` returns before reading the published manifest under `_ONLY` (line 130), so the identity readback can only come from the in-process route, and the refusal text is produced only by the binder (`d3d12_draw.inl:2573`). **The four mutations, by reading:** - `dword_channels != 1` -> `!dword_channels`: `typed_dword_2` (`native_global_srv_heap_replay_check.py:556`) no longer gets the refusal text, so its `require` fails. - Removing `view.stride != 4 ||`: `typed_stride_8` (line 557). - Removing `!view.bytes ||` or `view.bytes % 4 ||`: `typed_bytes_zero` (561) and `typed_bytes_odd` (559, 256 + 2 bytes). - `0xfff`/`0xfac` -> `0x3f`/`0x2c`: `SWAPPED_ZW = 0x0103edec` (`startup_compute_mtbuf_window_check.py:112-114`) has `0xdec & 0x3f == 0x2c`, so it binds and the guard compare fails. **Not blocking, follow-up (by reading):** a byte window read through a GPU-selected heap descriptor still has no identity requirement. `resource()` returns from `heap_resource` (`gfx1013_direct_compute.inl:411-412`) before the flag is set (433), and the heap loop in the dispatch (`d3d12_compute_dispatch.inl:934`) passes no flag. `translate_compute` passes `HeapViewContract::none` (`gfx1013_compute_native.cpp:2048`), under which `heap_resource` refuses, so the runtime does not reach this today. It needs the same check when the contract is wired into the runtime. CI does not run the changed tests: on a pull request the Windows job runs `ctest --preset pr` (`windows.yml:493`), and that filter matches neither `startup_compute_mtbuf_window_*` nor `native_global_srv_heap_replay*`. The inter-diff from `d4d9af41` touches no build, CI or hook file. #3415 (`e232e475`) contains `30de88b6`.
JB2WIN commented 2026-11-29 02:41:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T02:41:05Z.


Thanks for the re-review. Noted the heap byte-window follow-up for #3023: in the raw-twin proposal there, a byte window read through a GPU-selected heap record needs the same identity requirement before the runtime passes any contract. Until then it stays refused.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7249582206 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3409#issuecomment-7249582206). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T02:41:05Z. --- Thanks for the re-review. Noted the heap byte-window follow-up for #3023: in the raw-twin proposal there, a byte window read through a GPU-selected heap record needs the same identity requirement before the runtime passes any contract. Until then it stays refused. AI-assisted.
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!3409
No description provided.