native: read GPU-selected heap slots raw and typed in one program #3063

Closed
JB2WIN wants to merge 3 commits from upstream-pr/3063 into cpp-migration
JB2WIN commented 2026-11-27 13:21:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T13:21:44Z.


Change

Target branch cpp-migration. Refs #3023. Follow-up to #3042 (merged as a0f67731).

Programs that read some GPU-selected heap slots raw and others with a one-channel typed load were refused under both heap view contracts: raw_buffer refuses the typed load ("a GPU-selected heap slot is read as a raw buffer SRV only"), typed_dword the raw load ("… read as a typed dword buffer SRV only"). This adds a third contract class for that mixed case.

  • src/gfx1013_compute_native.h: HeapViewContract::raw_and_typed_dword, with its caller guarantee in the comment. The old clause "a program with two heap loads from different selectors is outside what one captured selection covers" is replaced by an explicit limit for every contract.
  • src/gfx1013_direct_compute.inl, heap_resource: under the new contract the kind of each heap load picks the path. buffer_load_format_* (typed_buffer_srv) follows the typed_dword rules, including the one-channel limit. Every other kind, tbuffer_load_format_* through a plain or rewritten descriptor included, follows the raw_buffer rules: raw handle, byte windows and the loop guard. One line of logic changed; refusal texts are unchanged.
  • src/gfx1013_compute_native.cpp: the byte-address rewrite of a heap descriptor is tracked under raw_buffer and raw_and_typed_dword.
  • src/direct_compute_cache.cpp: cache identity /heap-view/raw_and_typed_dword.
  • src/startup_stubs/native_global_srv.h:
    • .views gains zero or more also <slot> <type> lines, each a further selection of the same dispatch. Selector word k is selection k (select/need first). The header stays version 2; an older decoder refuses such a file with unknown line 'also'.
    • A slot may be named again with the same view type (each selector word that names it gets it). A slot named with two view types is refused (slot N selected with two view types).
    • refuse_global_srv_selections() checks every selection in order.
    • global_srv_contract() returns raw_and_typed_dword when raw and typed selections are both present.
  • tools/startup/compile_dxil.cpp: maps the contract with a switch and uses the plural check at both sites. The report line gains also=<slot>:<type>.
  • tests/native_global_srv_heap_replay.cpp:
    • record … [--also SELECTOR TYPE] writes selector word 1.
    • record and replay dispatch every selected slot and compare against the sum of the slot data (N+M reference in replay).
    • replay uses the plural check.
    • A small type_from_argument helper is shared by --need and --also.

Why this step: on a local start-up capture (compile_dxil --refusals, 2,689 slot 67 requests, counts only), 895 of the 906 programs with a typed heap load also read another heap slot raw. With this contract forced by an uncommitted switch, compiled requests go from 392 to 397. The others now stop at general refusals: 717 unbound numeric SGPR sN, 460 direct indexed descriptor load shape, 291 direct descriptor address outside bound table. That is an upper bound for what translation allows. No runtime produces also lines or binds heap slots under a contract yet; that is stage 3 of #3023.

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. Base cpp-migration a0f67731.

cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^native_global_srv_heap_replay_hardware$" -V
ctest --preset dev --no-tests=error -R "native_|startup_compute_dispatch|compute_heap" -j 6
ctest --preset dev --no-tests=error -R "^(compute_heap_view_controls|startup_gfx2hlsl_heap_record|docs_links|bidi_controls)$"
  • native_global_srv_heap_replay_hardware: passed, 196 assertions (122 before), 12.5 s (11.25 s before). New section 11 uses a source-built mixed program: two selector words, a raw buffer_load_dword through one heap descriptor and a buffer_load_format_x idxen through another, with the sum stored.
    • Record for raw slots 0 and 1 with typed slot 3: output equals the sum of the slot data, and .views has also 3 typed_buffer.
    • compile_dxil --requests with a fresh frontend cache: compiled with frontend_cache_hit=0, then =1 with the same .cso.
    • Replay equals the sum. Replay against slots 1+3 for the slot-0 shader reports a mismatch.
    • A typed selection of a raw slot is refused before the dispatch.
    • Three replay refusals, no dispatch: wrong type, unknown slot, texture.
    • Thirteen compile refusals, no .cso: the mixed program under the raw-only and the typed-only .views; also with a texture, wrong type, unknown slot, unreadable line, or a trailing field; a slot named with two types (the selected slot and an also slot); a second also of another type than its slot; a texture second also; a missing dword line; a two-channel typed load.
    • Six compile-only cases under the mixed contract: a second also, an also naming the selected slot again with the same type, the same also twice, a byte window by buffer_load_dword, one by tbuffer_load_format_x, and a tbuffer_load_format_x through a plain heap descriptor.
  • Discrimination:
    • The new check run with compile_dxil and the fixture built at a0f67731 passes the 122 earlier assertions and fails at the first mixed record (the old fixture has no --also).
    • The old compile_dxil refuses a mixed .views with unknown line 'also'; the new one compiles it.
    • Mutation 1 (mixed clause of typed set to false): the first mixed record fails.
    • Mutation 2 (mixed contract dropped from the heap-window tracking): the byte-window case under the mixed contract fails.
    • Both mutations were reverted afterwards.
  • Regression set: 147 tests, 3 failed, the same three as at the base on this machine (native_cvt_pk_u8_hardware, native_sdwa_f16_ir, native_sdwa_f16_hardware).
  • compile_dxil --refusals on the local capture without a contract: identical to the base.
  • The four Python checks pass.

Evidence and follow-up

  • Instruction words 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 translator cannot tell which heap index feeds which load and does not limit the number of heap loads.
    • The caller guarantees the raw_buffer conditions for every slot a raw load can select, and the typed_dword conditions for every slot a typed load can select.
    • A swapped pairing (typed slot read through the raw handle) is undefined and not run on the GPU.
    • tbuffer counts as raw.
  • Next on #3023: stage 3, the runtime contract (produce the selections and bind the heap slots).

Checklist

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

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5527351135 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T13:21:44Z. --- ## Change Target branch `cpp-migration`. Refs #3023. Follow-up to #3042 (merged as `a0f67731`). Programs that read some GPU-selected heap slots raw and others with a one-channel typed load were refused under both heap view contracts: `raw_buffer` refuses the typed load ("a GPU-selected heap slot is read as a raw buffer SRV only"), `typed_dword` the raw load ("… read as a typed dword buffer SRV only"). This adds a third contract class for that mixed case. - `src/gfx1013_compute_native.h`: `HeapViewContract::raw_and_typed_dword`, with its caller guarantee in the comment. The old clause "a program with two heap loads from different selectors is outside what one captured selection covers" is replaced by an explicit limit for every contract. - `src/gfx1013_direct_compute.inl`, `heap_resource`: under the new contract the kind of each heap load picks the path. `buffer_load_format_*` (`typed_buffer_srv`) follows the `typed_dword` rules, including the one-channel limit. Every other kind, `tbuffer_load_format_*` through a plain or rewritten descriptor included, follows the `raw_buffer` rules: raw handle, byte windows and the loop guard. One line of logic changed; refusal texts are unchanged. - `src/gfx1013_compute_native.cpp`: the byte-address rewrite of a heap descriptor is tracked under `raw_buffer` and `raw_and_typed_dword`. - `src/direct_compute_cache.cpp`: cache identity `/heap-view/raw_and_typed_dword`. - `src/startup_stubs/native_global_srv.h`: - `.views` gains zero or more `also <slot> <type>` lines, each a further selection of the same dispatch. Selector word k is selection k (`select`/`need` first). The header stays version 2; an older decoder refuses such a file with `unknown line 'also'`. - A slot may be named again with the same view type (each selector word that names it gets it). A slot named with two view types is refused (`slot N selected with two view types`). - `refuse_global_srv_selections()` checks every selection in order. - `global_srv_contract()` returns `raw_and_typed_dword` when raw and typed selections are both present. - `tools/startup/compile_dxil.cpp`: maps the contract with a `switch` and uses the plural check at both sites. The report line gains `also=<slot>:<type>`. - `tests/native_global_srv_heap_replay.cpp`: - `record … [--also SELECTOR TYPE]` writes selector word 1. - record and replay dispatch every selected slot and compare against the sum of the slot data (`N+M` reference in replay). - replay uses the plural check. - A small `type_from_argument` helper is shared by `--need` and `--also`. Why this step: on a local start-up capture (`compile_dxil --refusals`, 2,689 slot 67 requests, counts only), 895 of the 906 programs with a typed heap load also read another heap slot raw. With this contract forced by an uncommitted switch, compiled requests go from 392 to 397. The others now stop at general refusals: 717 `unbound numeric SGPR sN`, 460 `direct indexed descriptor load shape`, 291 `direct descriptor address outside bound table`. That is an upper bound for what translation allows. No runtime produces `also` lines or binds heap slots under a contract yet; that is stage 3 of #3023. ## 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. Base `cpp-migration` `a0f67731`. ``` cmake --build --preset dev ctest --preset dev --no-tests=error -R "^native_global_srv_heap_replay_hardware$" -V ctest --preset dev --no-tests=error -R "native_|startup_compute_dispatch|compute_heap" -j 6 ctest --preset dev --no-tests=error -R "^(compute_heap_view_controls|startup_gfx2hlsl_heap_record|docs_links|bidi_controls)$" ``` - `native_global_srv_heap_replay_hardware`: passed, 196 assertions (122 before), 12.5 s (11.25 s before). New section 11 uses a source-built mixed program: two selector words, a raw `buffer_load_dword` through one heap descriptor and a `buffer_load_format_x idxen` through another, with the sum stored. - Record for raw slots 0 and 1 with typed slot 3: output equals the sum of the slot data, and `.views` has `also 3 typed_buffer`. - `compile_dxil --requests` with a fresh frontend cache: compiled with `frontend_cache_hit=0`, then `=1` with the same `.cso`. - Replay equals the sum. Replay against slots 1+3 for the slot-0 shader reports a mismatch. - A typed selection of a raw slot is refused before the dispatch. - Three replay refusals, no dispatch: wrong type, unknown slot, texture. - Thirteen compile refusals, no `.cso`: the mixed program under the raw-only and the typed-only `.views`; `also` with a texture, wrong type, unknown slot, unreadable line, or a trailing field; a slot named with two types (the selected slot and an `also` slot); a second `also` of another type than its slot; a texture second `also`; a missing `dword` line; a two-channel typed load. - Six compile-only cases under the mixed contract: a second `also`, an `also` naming the selected slot again with the same type, the same `also` twice, a byte window by `buffer_load_dword`, one by `tbuffer_load_format_x`, and a `tbuffer_load_format_x` through a plain heap descriptor. - Discrimination: - The new check run with `compile_dxil` and the fixture built at `a0f67731` passes the 122 earlier assertions and fails at the first mixed record (the old fixture has no `--also`). - The old `compile_dxil` refuses a mixed `.views` with `unknown line 'also'`; the new one compiles it. - Mutation 1 (mixed clause of `typed` set to false): the first mixed record fails. - Mutation 2 (mixed contract dropped from the heap-window tracking): the byte-window case under the mixed contract fails. - Both mutations were reverted afterwards. - Regression set: 147 tests, 3 failed, the same three as at the base on this machine (`native_cvt_pk_u8_hardware`, `native_sdwa_f16_ir`, `native_sdwa_f16_hardware`). - `compile_dxil --refusals` on the local capture without a contract: identical to the base. - The four Python checks pass. ## Evidence and follow-up - Instruction words 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 translator cannot tell which heap index feeds which load and does not limit the number of heap loads. - The caller guarantees the `raw_buffer` conditions for every slot a raw load can select, and the `typed_dword` conditions for every slot a typed load can select. - A swapped pairing (typed slot read through the raw handle) is undefined and not run on the GPU. - `tbuffer` counts as raw. - Next on #3023: stage 3, the runtime contract (produce the selections and bind the heap slots). ## 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)
R0Y00 commented 2026-11-27 13:27:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T13:27:33Z.


Thanks for documenting the dependency on #3042. New translator PRs target main, but changing this base today would pull #3034 and #3042 into the same diff. At main ff04a75e, the typed-dword heap contract from #3042 is still absent. Please leave the base here while those prerequisites are carried to main in order, then we can retarget this PR and verify the mixed raw/typed fixture against the new base. The pending runtime capture work stays tracked in #3023.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7219502281 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7219502281). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T13:27:33Z. --- Thanks for documenting the dependency on #3042. New translator PRs target `main`, but changing this base today would pull #3034 and #3042 into the same diff. At `main` `ff04a75e`, the typed-dword heap contract from #3042 is still absent. Please leave the base here while those prerequisites are carried to `main` in order, then we can retarget this PR and verify the mixed raw/typed fixture against the new base. The pending runtime capture work stays tracked in #3023.
JB2WIN commented 2026-11-27 13:28:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T13:28:38Z.


Understood, leaving the base on cpp-migration. Once #3034 and #3042 are on main, I will retarget, rebase and rerun the mixed raw/typed fixture (native_global_srv_heap_replay_hardware) plus the regression set against the new base, and report the results here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7219524062 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7219524062). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T13:28:38Z. --- Understood, leaving the base on `cpp-migration`. Once #3034 and #3042 are on `main`, I will retarget, rebase and rerun the mixed raw/typed fixture (`native_global_srv_heap_replay_hardware`) plus the regression set against the new base, and report the results here. AI-assisted.
JohnConnorNPC commented 2026-11-27 17:27:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T17:27:51Z.


Thanks, the contract split by load kind reads cleanly, and the limits are written down. I checked this from Linux
only: a header harness over native_global_srv.h with mutants, llvm-mc over the new words, and the affected Python
checks on the head and on a merge with current main (clean, all pass). I did not run the GPU fixture.

  1. Duplicate slots vs selector-word order. Selection k is selector word k, but the decoder refuses a slot named
    twice even with the same type, and the doc says "a producer deduplicates". A dispatch whose two words pick the
    same raw slot then has no valid .views. Deduplicating drops word 1, and replay writes 0 there, so it replays a
    different selection. record writes such a file without complaint: its in-memory request passes
    refuse_global_srv_selections, and decode_global_srv_request refuses what it wrote ("duplicate selected slot
    0"). Could the decoder accept a repeated slot when the type is the same (and refuse only a slot named with two
    types)? Or could the doc say the capture refuses such a dispatch, with record refusing it too?

  2. Untested rules. With native_global_srv.h mutated, each of the following still gives the same outcome on
    every .views that section 11 feeds the decoder:

    • duplicates refused only when the types differ;
    • no duplicate check between two also lines;
    • refuse_global_srv_selections or global_srv_contract checking only the first also.

    Four negatives would pin them: also 0 raw_buffer, a second also 3 typed_buffer, also 2 raw_buffer as the
    second also, and also 2 texture as the second also.

  3. Coverage note. PR CI builds the pr preset, which does not include this fixture, and the _warp variant
    skips by design. So the green checks don't execute section 11. Could you add the head commit you tested and the
    debug-layer status to the GPU report?

  4. Small items.

    • The rewritten stride-read comment in gfx1013_direct_compute.inl names two contracts. typed_dword also admits
      the heap descriptor load and reaches that refusal.
    • A bad --also selector throws before the try (exit 3 under MSVC); returning 2 would match the usage path.
    • The new also line accepts trailing fields.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7224434259 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7224434259). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-27T17:27:51Z. --- Thanks, the contract split by load kind reads cleanly, and the limits are written down. I checked this from Linux only: a header harness over `native_global_srv.h` with mutants, llvm-mc over the new words, and the affected Python checks on the head and on a merge with current `main` (clean, all pass). I did not run the GPU fixture. 1. **Duplicate slots vs selector-word order.** Selection k is selector word k, but the decoder refuses a slot named twice even with the same type, and the doc says "a producer deduplicates". A dispatch whose two words pick the same raw slot then has no valid `.views`. Deduplicating drops word 1, and `replay` writes 0 there, so it replays a different selection. `record` writes such a file without complaint: its in-memory request passes `refuse_global_srv_selections`, and `decode_global_srv_request` refuses what it wrote ("duplicate selected slot 0"). Could the decoder accept a repeated slot when the type is the same (and refuse only a slot named with two types)? Or could the doc say the capture refuses such a dispatch, with `record` refusing it too? 2. **Untested rules.** With `native_global_srv.h` mutated, each of the following still gives the same outcome on every `.views` that section 11 feeds the decoder: - duplicates refused only when the types differ; - no duplicate check between two `also` lines; - `refuse_global_srv_selections` or `global_srv_contract` checking only the first `also`. Four negatives would pin them: `also 0 raw_buffer`, a second `also 3 typed_buffer`, `also 2 raw_buffer` as the second `also`, and `also 2 texture` as the second `also`. 3. **Coverage note.** PR CI builds the `pr` preset, which does not include this fixture, and the `_warp` variant skips by design. So the green checks don't execute section 11. Could you add the head commit you tested and the debug-layer status to the GPU report? 4. **Small items.** - The rewritten stride-read comment in `gfx1013_direct_compute.inl` names two contracts. `typed_dword` also admits the heap descriptor load and reaches that refusal. - A bad `--also` selector throws before the `try` (exit 3 under MSVC); returning 2 would match the usage path. - The new `also` line accepts trailing fields. This comment was AI-assisted.
JB2WIN commented 2026-11-27 22:47:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T22:47:05Z.


Thanks. Working on all four points now; update with a new commit soon.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229614992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7229614992). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T22:47:05Z. --- Thanks. Working on all four points now; update with a new commit soon. AI-assisted.
JB2WIN commented 2026-11-27 22:54:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T22:54:02Z.


Done in 64513f26.

  1. Duplicates: a slot named again with the same view type is accepted; a slot with two types is refused ("slot N selected with two view types"). record output now always decodes. New raw+raw case: record --also 0 raw_buffer, compile, replay 0+0 matches, replay 0+1 mismatches.
  2. New negatives: second also 2 raw_buffer (selection refusal), second also 2 texture (contract refusal), also 0 typed_buffer and also 3 raw_buffer after also 3 typed_buffer (two types). Positives: also 0 raw_buffer, second also 3 typed_buffer. Mutation check: refuse_global_srv_selections stopping after the first also fails the second-also case.
  3. GPU report: head 64513f26, RTX 3080 (driver 32.0.16.2124), native_global_srv_heap_replay_hardware 196 checks pass, 12.5 s. Debug layer not enabled in the fixture. Regression (native_|startup_compute_dispatch|compute_heap): 147 tests, the same 3 failures as the base.
  4. Stride-read comment names all three contracts; bad --also selector returns 2; also with trailing fields is unreadable.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229709480 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7229709480). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T22:54:02Z. --- Done in 64513f26. 1. Duplicates: a slot named again with the same view type is accepted; a slot with two types is refused ("slot N selected with two view types"). `record` output now always decodes. New raw+raw case: `record --also 0 raw_buffer`, compile, `replay 0+0` matches, `replay 0+1` mismatches. 2. New negatives: second `also 2 raw_buffer` (selection refusal), second `also 2 texture` (contract refusal), `also 0 typed_buffer` and `also 3 raw_buffer` after `also 3 typed_buffer` (two types). Positives: `also 0 raw_buffer`, second `also 3 typed_buffer`. Mutation check: `refuse_global_srv_selections` stopping after the first `also` fails the second-`also` case. 3. GPU report: head 64513f26, RTX 3080 (driver 32.0.16.2124), `native_global_srv_heap_replay_hardware` 196 checks pass, 12.5 s. Debug layer not enabled in the fixture. Regression (`native_|startup_compute_dispatch|compute_heap`): 147 tests, the same 3 failures as the base. 4. Stride-read comment names all three contracts; bad `--also` selector returns 2; `also` with trailing fields is unreadable. AI-assisted.
R0Y00 commented 2026-11-27 23:17:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T23:17:19Z.

Review: COMMENTED


Independently tested 64513f26 on cpp-migration a0f67731 (clean trial tree 80c5c815). I built compile_dxil native_global_srv_heap_replay and ran ctest --test-dir <build> --no-tests=error -j1 -V -R '^native_global_srv_heap_replay_(warp|hardware)$' in Debug and Release /O2. Each build passed all 196 assertions on RTX 4060 Laptop (driver 32.0.16.1656, Windows 11 26200.9974, debug layer off). Inbox WARP 10.0.26100.9818 returned 77 for lack of wave32. The repeated 0+0 selector round-trips, 0+1 gives the required mismatch, and the second also and conflicting-type controls refuse. Please update the old duplicate-slot wording in the PR body to reflect the new same-type behavior. The typed_dword contract still lives on the migration branch, so the previously agreed #3034/#3042 port order still determines when this can target main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094210376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#pullrequestreview-6094210376). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T23:17:19Z. **Review:** COMMENTED --- Independently tested `64513f26` on `cpp-migration` `a0f67731` (clean trial tree `80c5c815`). I built `compile_dxil native_global_srv_heap_replay` and ran `ctest --test-dir <build> --no-tests=error -j1 -V -R '^native_global_srv_heap_replay_(warp|hardware)$'` in Debug and Release /O2. Each build passed all 196 assertions on RTX 4060 Laptop (driver 32.0.16.1656, Windows 11 26200.9974, debug layer off). Inbox WARP 10.0.26100.9818 returned 77 for lack of wave32. The repeated `0+0` selector round-trips, `0+1` gives the required mismatch, and the second `also` and conflicting-type controls refuse. Please update the old duplicate-slot wording in the PR body to reflect the new same-type behavior. The `typed_dword` contract still lives on the migration branch, so the previously agreed #3034/#3042 port order still determines when this can target `main`.
pigalot commented 2026-11-27 23:18:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:18:11Z.

Review: APPROVED


Independently reviewed 64513f26 integrated over cpp-migration a0f67731 (tree 80c5c815), the PR's base. The merge is clean and git diff --cached --check origin/cpp-migration is clean.

What I traced.

  • In native_global_srv.h, selection 0 is select/need and selection k is the k-th also line, in file order.
  • The decoder now refuses only a slot named with two view types. A slot repeated with one type is accepted, so a dispatch whose two selector words pick the same slot has a valid .views.
  • refuse_global_srv_selections checks every selection, and the first refusal wins.
  • global_srv_contract returns raw_and_typed_dword only when at least one selection is raw and one is typed. Every captured typed slot must still be a one-channel 32-bit buffer.
  • In heap_resource, raw_and_typed_dword takes the typed path only for typed_buffer_srv loads. Every other kind stays raw, and the byte-window tracking applies as under raw_buffer.

JohnConnorNPC's findings, checked at this head.

  1. Duplicate slots: addressed.
    • The raw+raw case records with --also 0 raw_buffer, decodes and compiles.
    • The comparison with slot 0+0 matches. The comparison with slot 0+1 reports mismatch word 0: got 0x40000000 expected 0x50000000 (reference slot 0+1).
  2. Untested rules: addressed. Each rule now has a case that fails when the rule is mutated (table below).
  3. Coverage note: the GPU report now gives the head and the debug-layer status. My run below covers section 11 on a second GPU.
  4. Small items: addressed.
    • The stride-read comment and the other heap comments name all three contracts.
    • A non-numeric --also selector exits 2.
    • An also line with a trailing field is refused.

What I ran. I built native_global_srv_heap_replay compile_dxil in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_(hardware|warp)$'
  • native_global_srv_heap_replay_hardware passes in Debug and Release /O2 on the RTX 5090 ("all checks passed", about 11 s). The output includes mixed_also_same_slot, mixed_also_twice and "record with a non-numeric --also selector exits 2".
  • native_global_srv_heap_replay_warp reports a capability skip (77) in both presets, by design.
  • Regression set, the selection from JB2WIN's GPU report: ctest --test-dir out/build/dev --no-tests=error -j 1 -R '(native_|startup_compute_dispatch|compute_heap)'. 147 tests in Debug.
    • 140 pass.
    • 4 report capability skips (77): native_comparison_pso_warp, native_heap_handle_probe_warp, native_global_srv_heap_replay_warp and startup_compute_dispatch_native_warp.
    • 3 fail: native_cvt_pk_u8_hardware, native_sdwa_f16_ir and native_sdwa_f16_hardware. All three also fail on cpp-migration a0f67731 built alone, so they come from the base, not from this PR.

Mutants in src/startup_stubs/native_global_srv.h. Each was applied alone, the targets rebuilt in dev, the _hardware test run, and the source restored afterwards (git diff --quiet clean).

Mutant First failure
a repeated slot refused even with the same type mixed_also_same_slot: refused instead of compiled
the two-types check removed mixed_two_types: not refused with "slot 0 selected with two view types"
the duplicate check covers only select/need mixed_two_types_also: not refused with "slot 3 selected with two view types"
refuse_global_srv_selections checks only the first also mixed_second_also_wrong_type: not refused with "slot 2 has view type texture"
global_srv_contract checks only the first also mixed_second_also_texture: not refused with "view type texture is not raw_buffer or typed_buffer"
trailing fields on an also line accepted mixed_trailing_field: not refused with "unreadable also line"

Verdict: approve on 64513f26. The base is cpp-migration, so this is a review only. I am not merging, and R0Y00's plan to retarget after #3034 and #3042 reach main stands.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029; the debug layer is off in the fixture.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 64513f26.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094214011 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#pullrequestreview-6094214011). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T23:18:11Z. **Review:** APPROVED --- Independently reviewed `64513f26` integrated over `cpp-migration` `a0f67731` (tree `80c5c815`), the PR's base. The merge is clean and `git diff --cached --check origin/cpp-migration` is clean. **What I traced.** - In `native_global_srv.h`, selection 0 is `select`/`need` and selection k is the k-th `also` line, in file order. - The decoder now refuses only a slot named with two view types. A slot repeated with one type is accepted, so a dispatch whose two selector words pick the same slot has a valid `.views`. - `refuse_global_srv_selections` checks every selection, and the first refusal wins. - `global_srv_contract` returns `raw_and_typed_dword` only when at least one selection is raw and one is typed. Every captured typed slot must still be a one-channel 32-bit buffer. - In `heap_resource`, `raw_and_typed_dword` takes the typed path only for `typed_buffer_srv` loads. Every other kind stays raw, and the byte-window tracking applies as under `raw_buffer`. **JohnConnorNPC's findings, checked at this head.** 1. **Duplicate slots:** addressed. - The raw+raw case records with `--also 0 raw_buffer`, decodes and compiles. - The comparison with slot 0+0 matches. The comparison with slot 0+1 reports `mismatch word 0: got 0x40000000 expected 0x50000000 (reference slot 0+1)`. 2. **Untested rules:** addressed. Each rule now has a case that fails when the rule is mutated (table below). 3. **Coverage note:** the GPU report now gives the head and the debug-layer status. My run below covers section 11 on a second GPU. 4. **Small items:** addressed. - The stride-read comment and the other heap comments name all three contracts. - A non-numeric `--also` selector exits 2. - An `also` line with a trailing field is refused. **What I ran.** I built `native_global_srv_heap_replay compile_dxil` in `dev` and `release`, then ran: ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_(hardware|warp)$' ``` - `native_global_srv_heap_replay_hardware` passes in Debug and Release `/O2` on the RTX 5090 ("all checks passed", about 11 s). The output includes `mixed_also_same_slot`, `mixed_also_twice` and "record with a non-numeric --also selector exits 2". - `native_global_srv_heap_replay_warp` reports a capability skip (77) in both presets, by design. - Regression set, the selection from JB2WIN's GPU report: `ctest --test-dir out/build/dev --no-tests=error -j 1 -R '(native_|startup_compute_dispatch|compute_heap)'`. 147 tests in Debug. - 140 pass. - 4 report capability skips (77): `native_comparison_pso_warp`, `native_heap_handle_probe_warp`, `native_global_srv_heap_replay_warp` and `startup_compute_dispatch_native_warp`. - 3 fail: `native_cvt_pk_u8_hardware`, `native_sdwa_f16_ir` and `native_sdwa_f16_hardware`. All three also fail on `cpp-migration` `a0f67731` built alone, so they come from the base, not from this PR. **Mutants** in `src/startup_stubs/native_global_srv.h`. Each was applied alone, the targets rebuilt in `dev`, the `_hardware` test run, and the source restored afterwards (`git diff --quiet` clean). | Mutant | First failure | |---|---| | a repeated slot refused even with the same type | `mixed_also_same_slot`: refused instead of compiled | | the two-types check removed | `mixed_two_types`: not refused with "slot 0 selected with two view types" | | the duplicate check covers only `select`/`need` | `mixed_two_types_also`: not refused with "slot 3 selected with two view types" | | `refuse_global_srv_selections` checks only the first `also` | `mixed_second_also_wrong_type`: not refused with "slot 2 has view type texture" | | `global_srv_contract` checks only the first `also` | `mixed_second_also_texture`: not refused with "view type texture is not raw_buffer or typed_buffer" | | trailing fields on an `also` line accepted | `mixed_trailing_field`: not refused with "unreadable also line" | **Verdict:** approve on `64513f26`. The base is `cpp-migration`, so this is a review only. I am not merging, and R0Y00's plan to retarget after #3034 and #3042 reach `main` stands. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029; the debug layer is off in the fixture. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `64513f26`. This reply was AI-assisted.
RonLogic commented 2026-11-28 00:20:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-28T00:20:38Z.


I tested a clean local trial of 64513f26 on a main-based stack: 7fcde81f, #3034 as 6fb2316c (now #3232), #3042 as 43312821, then both #3063 commits through d484785f. The carry keeps main’s raw-address CPU-reference cases and the optional expected-word input to the replay tool.

Release on Windows 11 26300.10075, DXC 1.9.2602.17, RTX 4070 (32.0.16.2124) and app-local WARP 1.0.22 with Agility 1.620.2:

cmake --build --preset release --target compile_dxil native_store_replay native_global_srv_heap_replay
ctest --preset release --no-tests=error -R '^(native_mtbuf_hardware|native_global_srv_heap_replay_(hardware|warp)|native_direct_container)$' -V

All four tests passed. Each heap replay emitted 217 passing assertions including the raw+typed selections 0+3 and 1+3, repeated 0+0, cold/warm identical DXIL, and the metadata refusals. On both adapters, the deliberate 0+1 reference for the 0+0 dispatch failed at word 0 (0x40000000 vs 0x50000000). This verifies the source-built compiler/replay stack on a main-based tree. The live heap contract remains tracked in #3023.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230837600 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7230837600). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-28T00:20:38Z. --- I tested a clean local trial of `64513f26` on a main-based stack: `7fcde81f`, #3034 as `6fb2316c` (now #3232), #3042 as `43312821`, then both #3063 commits through `d484785f`. The carry keeps main’s raw-address CPU-reference cases and the optional expected-word input to the replay tool. Release on Windows 11 26300.10075, DXC 1.9.2602.17, RTX 4070 (32.0.16.2124) and app-local WARP 1.0.22 with Agility 1.620.2: ```powershell cmake --build --preset release --target compile_dxil native_store_replay native_global_srv_heap_replay ctest --preset release --no-tests=error -R '^(native_mtbuf_hardware|native_global_srv_heap_replay_(hardware|warp)|native_direct_container)$' -V ``` All four tests passed. Each heap replay emitted 217 passing assertions including the raw+typed selections 0+3 and 1+3, repeated 0+0, cold/warm identical DXIL, and the metadata refusals. On both adapters, the deliberate 0+1 reference for the 0+0 dispatch failed at word 0 (0x40000000 vs 0x50000000). This verifies the source-built compiler/replay stack on a main-based tree. The live heap contract remains tracked in #3023.
JohnConnorNPC commented 2026-11-28 08:05:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:05:29Z.


Thanks for the quick turnaround on 64513f26. All four points from my earlier comment are addressed, and I think this is ready to merge into cpp-migration. It is a fast-forward there: git rev-list --count 64513f26..a0f67731 → 0. I found nothing blocking, only one body fix and three small notes.

It can't target main yet. git merge-tree --write-tree --name-only 1f07b2c1 64513f26 exits 1 with 6 conflicting files. The base a0f67731 already conflicts in 5 of them, and this PR adds src/gfx1013_compute_native.cpp. #3232 (the #3034 port) is open with changes requested, and no #3042 port is open yet.

Should fix: the duplicate-slot wording that R0Y00 asked to update on the review is still in the body ("The decoder refuses a slot named twice, even with the same type"). GraphQL lastEditedAt is still null. The body's counts are also behind the doc: "174 assertions", "Nine compile refusals" and "Four compile-only cases", where the doc now says 196 assertions, thirteen refusals and six compile-only cases.

Notes, none blocking:

  1. The top comment of src/startup_stubs/native_global_srv.h says the dispatch is refused "when the selected slot holds another type than the one the shader reads". Under raw_and_typed_dword, each word's type comes from the capture (need/also), not from the shader. From reading the code (not run), select 3 need typed_buffer with also 0 raw_buffer on the MIXED program passes the guard, and the typed view is then read through the raw handle. The HeapViewContract comment and the doc's Limits already call this a caller guarantee. One sentence in the header saying the guard is necessary but not sufficient would match them.
  2. No mutant is reported for the contract's return raw ? GlobalSrvContract::raw_and_typed_dword : GlobalSrvContract::typed_dword or for the new /heap-view/raw_and_typed_dword cache-identity line. From reading the code, section 10's typed refusals and mixed_raw_views/mixed_typed_views should catch both, but that is not measured.
  3. Pre-existing, not from this PR: the other refusal in src/gfx1013_direct_compute.inl, "is not raw_buffer; only raw buffer heap reads are translated", has been out of date since #3042 added typed_dword.

Opcodes: the diff adds no DXIL op (grep -cE '^\+.*(dx\.op|createHandleFromHeap|annotateHandle)' → 0). Loads reuse raw ? 139 : 68, and handles reuse kinds 11 and 10 (5 + 1 * 256), chosen per instruction. llvm-mc-19 --disassemble -mcpu=gfx1013 of the MIXED words matches each comment (LLVM 19 prints the zero SMEM offset as null). CI's Windows job ran ctest --preset pr (100% tests passed out of 41) with no native_global_srv test. So section 11 rests on the GPU runs posted here: RTX 3080, RTX 4060 Laptop and RTX 5090 on this base, and RTX 4070 plus WARP on a main-based stack. The three runs that report the debug layer had it off.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7236356628 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7236356628). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-28T08:05:29Z. --- Thanks for the quick turnaround on 64513f26. All four points from my earlier comment are addressed, and I think this is ready to merge into `cpp-migration`. It is a fast-forward there: `git rev-list --count 64513f26..a0f67731` → `0`. I found nothing blocking, only one body fix and three small notes. It can't target `main` yet. `git merge-tree --write-tree --name-only 1f07b2c1 64513f26` exits 1 with 6 conflicting files. The base a0f67731 already conflicts in 5 of them, and this PR adds `src/gfx1013_compute_native.cpp`. #3232 (the #3034 port) is open with changes requested, and no #3042 port is open yet. Should fix: the duplicate-slot wording that R0Y00 asked to update on the review is still in the body ("The decoder refuses a slot named twice, even with the same type"). GraphQL `lastEditedAt` is still `null`. The body's counts are also behind the doc: "174 assertions", "Nine compile refusals" and "Four compile-only cases", where the doc now says 196 assertions, thirteen refusals and six compile-only cases. Notes, none blocking: 1. The top comment of `src/startup_stubs/native_global_srv.h` says the dispatch is refused "when the selected slot holds another type than the one the shader reads". Under `raw_and_typed_dword`, each word's type comes from the capture (`need`/`also`), not from the shader. From reading the code (not run), `select 3 need typed_buffer` with `also 0 raw_buffer` on the MIXED program passes the guard, and the typed view is then read through the raw handle. The `HeapViewContract` comment and the doc's Limits already call this a caller guarantee. One sentence in the header saying the guard is necessary but not sufficient would match them. 2. No mutant is reported for the contract's `return raw ? GlobalSrvContract::raw_and_typed_dword : GlobalSrvContract::typed_dword` or for the new `/heap-view/raw_and_typed_dword` cache-identity line. From reading the code, section 10's typed refusals and `mixed_raw_views`/`mixed_typed_views` should catch both, but that is not measured. 3. Pre-existing, not from this PR: the `other` refusal in `src/gfx1013_direct_compute.inl`, "is not raw_buffer; only raw buffer heap reads are translated", has been out of date since #3042 added `typed_dword`. Opcodes: the diff adds no DXIL op (`grep -cE '^\+.*(dx\.op|createHandleFromHeap|annotateHandle)'` → `0`). Loads reuse `raw ? 139 : 68`, and handles reuse kinds 11 and 10 (`5 + 1 * 256`), chosen per instruction. `llvm-mc-19 --disassemble -mcpu=gfx1013` of the MIXED words matches each comment (LLVM 19 prints the zero SMEM offset as `null`). CI's Windows job ran `ctest --preset pr` (`100% tests passed out of 41`) with no `native_global_srv` test. So section 11 rests on the GPU runs posted here: RTX 3080, RTX 4060 Laptop and RTX 5090 on this base, and RTX 4070 plus WARP on a main-based stack. The three runs that report the debug layer had it off. This comment was AI-assisted.
JB2WIN commented 2026-11-28 14:32:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T14:32:24Z.


Thanks. Done:

  • Body: the duplicate-slot line now says a slot may be named again with the same type and is refused with two types. The counts match the doc (196 assertions, thirteen compile refusals, six compile-only cases).
  • Note 1: 2534937a adds the sentence to the top of native_global_srv.h (comment only).
  • Notes 2 and 3: left as they are. The stale other refusal text predates this PR and would be its own small change.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7240745927 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7240745927). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-28T14:32:24Z. --- Thanks. Done: - Body: the duplicate-slot line now says a slot may be named again with the same type and is refused with two types. The counts match the doc (196 assertions, thirteen compile refusals, six compile-only cases). - Note 1: `2534937a` adds the sentence to the top of `native_global_srv.h` (comment only). - Notes 2 and 3: left as they are. The stale `other` refusal text predates this PR and would be its own small change. AI-assisted.
JB2WIN commented 2026-11-28 23:51:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T23:51:14Z.


Carried to main in #3415, stacked on #3409 (which brings #3034 and #3042 over, taking over #3232).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7247706624 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7247706624). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-28T23:51:14Z. --- Carried to `main` in #3415, stacked on #3409 (which brings #3034 and #3042 over, taking over #3232). AI-assisted.
JB2WIN commented 2026-11-29 09:33:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T09:33:21Z.


Closing: the same three commits reached main through #3415 (merged as 1341bd6b). AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7253841056 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3063#issuecomment-7253841056). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T09:33:21Z. --- Closing: the same three commits reached `main` through #3415 (merged as 1341bd6b). AI-assisted.

Pull request closed

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!3063
No description provided.