gpu: run the translated compute-mesh-pixel chain from the shim EXE entry #676

Merged
grahamster2 merged 1 commit from upstream-pr/682 into main 2026-11-22 21:11:05 +00:00
grahamster2 commented 2026-11-22 19:54:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by grahamster2 on 2026-11-22T19:54:37Z.


Change

Fixes #671. Refs #560, #658 and #218.

The shim-startup EXE's draw contract from #560 now also runs the translated compute → mesh → pixel chain from #658, one frame per process. X2W_SHIM_DRAW_CASE gains three values, chain0, chain1 and chain-stale. draw_request maps each to a new mode, and draw_frame sends those modes to a new file, tests/cpu/shim_chain_gpu.cpp. On one direct queue that file:

  1. dispatches one or two translated gfx1013 producers, each writing two packed RGBA8 rows at byte offsets 0 and 256 of a default-heap raw UAV;
  2. transitions the UAV to copy source, copies the rows into a 2×2 texture and transitions it to pixel-shader-resource state;
  3. draws with the translated indexed mesh (TRACE_EXPORTS) and the image_sample_lz pixel stage into a 32×32 RGBA8 target. The root layout matches offscreen_check --compute-mesh-texture.

The provider publishes the whole observable result after the startup output: 4,096 RGBA bytes plus the 80-byte mesh export trace. draw_frame returns the mismatch count against the case reference, so the guest exits 42 on a match and 20 otherwise. The draw_request/draw_frame signatures, shim_startup.asm and the AOT import table are unchanged.

tests/cpu/shim_chain_check.py builds the translated mesh, pixel and producer shaders, and both case files, with the generators that compute_mesh_texture_check.py uses. It then runs the native EXE, pe_map and AOT for each case.

Case Producers Bound Exit Check
chain0 palette A A 42 all 1,024 pixels and the trace match A's Python reference
chain1 A, then B B 42 all 1,024 pixels and the trace match B's reference
chain-stale A, then B A 20 frame equals A's reference. Against B's reference exactly 276 covered pixels differ, while all 748 clear pixels and the trace match

For every case, the three runners must produce identical stderr: no diagnostics from the native and AOT runs, and the six explicit shim bindings plus mapped host returned from pe_map. They must also share the same exit status and all 4,176 published bytes. The references come from texture_case/fixture in Python and do not depend on D3D12.

Shared interfaces. The only shared file is #560's test-only tests/cpu/shim_draw_provider.cpp, which gets three new cases. The edit was announced on #218 (note) and claimed on #671 (claim). mesh_entry_draw.cpp, offscreen_check and shim_draw_gpu.cpp are untouched. The #658 helpers live in the offscreen_check executable, so the DLL keeps its own copy of the sequence. This doesn't overlap the persistent multi-frame draft in RonLogic/Xbox2Windows#1, which changes shim_draw_gpu.cpp.

Verification

Commit 543b951 (on main at 0a9cc04, which includes #560's merge 899785e). Windows 11 build 26200.9974, MSVC from tools/dev.ps1, Windows SDK 10.0.26100 DXC 1.8.2502.11, Python 3.12 venv.

foreach ($p in 'dev', 'release') {
    cmake --preset $p "-DINTAKE_PYTHON=$intakePython"
    cmake --build --preset $p
    ctest --preset $p --no-tests=error -R '^cpu_shim_chain_(warp|hardware)$' -V
    ctest --preset $p --no-tests=error -R '^cpu_shim_chain_(warp|hardware)$' --repeat until-fail:5
    ctest --preset $p --no-tests=error --timeout 300 -E '^(conditional_import_paths|static_exe_intake|bundled_export_forwarders)$'
}
$env:XBOX2WINDOWS_ADAPTER = 'NVIDIA'  # then 'AMD'
ctest --preset $p --no-tests=error -R '^cpu_shim_chain_hardware$' -V
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
Adapter dev (Debug) release (/O2)
WARP 10.0.26100.9818 pass: chain0 and chain1 match exactly; stale shows 276 differing pixels, 748 clear pixels and trace match pass, same result
NVIDIA GeForce RTX 3080, driver 32.0.16.1088 pass, same result pass, same result
AMD Radeon(TM) Graphics (1002:164e, RDNA2 iGPU), driver 32.0.13066.12 capability skip (77): mesh_shader_tier=unsupported same skip

The AMD skip matches the existing #658 harness on the same adapter: compute_mesh_texture_hardware also reports mesh_shader_tier=unsupported there. Example output:

chain0: producers=1 exit=42 native, pe_map and AOT agree on 4176 bytes; 1024/1024 pixels and trace match
chain1: producers=2 exit=42 native, pe_map and AOT agree on 4176 bytes; 1024/1024 pixels and trace match
chain-stale: producers=2 exit=20 native, pe_map and AOT agree on 4176 bytes; stale texture differs at 276 pixels; 748 clear pixels and trace match
  • Focused tests: pass in both presets. --repeat until-fail:5 was 5/5 for both tests in both presets.
  • Full serial suite (three intake tests excluded): 296/296 in dev and 296/296 in release. Three skips in both presets: bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp, unrelated to this change.
  • Docs link and bidi checks: pass.
  • Not run: the D3D12 debug layer. D3D12GetDebugInterface returns 0x887a002d (Graphics Tools not installed on this machine), so debug-layer errors and warnings were not checked. Also not run: Intel hardware and an AMD adapter with mesh shader support.

Evidence and follow-up

All inputs are source-built synthetic fixtures under the project's MIT license. The EXE is the MASM shim-startup fixture, and the shaders are generated from the gfx1013 programs already in the repository's #658 test. The test measures one frame per process. Persistent device and queue state across frames is the separate RonLogic/Xbox2Windows#1 follow-up. Nothing here exercises Xbox GPU command translation or title code, and no game startup or graphics compatibility is claimed. The reproduction command is in docs/experiments.md, under "EXE startup through the desktop runtime shims".

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture: the stale-texture binding.
  • I updated README/docs when a capability or build requirement changed (docs/experiments.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6547007598 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/682). Originally posted by [grahamster2](https://github.com/grahamster2) on 2026-11-22T19:54:37Z. --- ## Change Fixes #671. Refs #560, #658 and #218. The shim-startup EXE's draw contract from #560 now also runs the translated compute → mesh → pixel chain from #658, one frame per process. `X2W_SHIM_DRAW_CASE` gains three values, `chain0`, `chain1` and `chain-stale`. `draw_request` maps each to a new mode, and `draw_frame` sends those modes to a new file, `tests/cpu/shim_chain_gpu.cpp`. On one direct queue that file: 1. dispatches one or two translated gfx1013 producers, each writing two packed RGBA8 rows at byte offsets 0 and 256 of a default-heap raw UAV; 2. transitions the UAV to copy source, copies the rows into a 2×2 texture and transitions it to pixel-shader-resource state; 3. draws with the translated indexed mesh (`TRACE_EXPORTS`) and the `image_sample_lz` pixel stage into a 32×32 RGBA8 target. The root layout matches `offscreen_check --compute-mesh-texture`. The provider publishes the whole observable result after the startup output: 4,096 RGBA bytes plus the 80-byte mesh export trace. `draw_frame` returns the mismatch count against the case reference, so the guest exits 42 on a match and 20 otherwise. The `draw_request`/`draw_frame` signatures, `shim_startup.asm` and the AOT import table are unchanged. `tests/cpu/shim_chain_check.py` builds the translated mesh, pixel and producer shaders, and both case files, with the generators that `compute_mesh_texture_check.py` uses. It then runs the native EXE, `pe_map` and AOT for each case. | Case | Producers | Bound | Exit | Check | |---|---|---|---|---| | `chain0` | palette A | A | 42 | all 1,024 pixels and the trace match A's Python reference | | `chain1` | A, then B | B | 42 | all 1,024 pixels and the trace match B's reference | | `chain-stale` | A, then B | A | 20 | frame equals A's reference. Against B's reference exactly 276 covered pixels differ, while all 748 clear pixels and the trace match | For every case, the three runners must produce identical stderr: no diagnostics from the native and AOT runs, and the six explicit shim bindings plus `mapped host returned` from `pe_map`. They must also share the same exit status and all 4,176 published bytes. The references come from `texture_case`/`fixture` in Python and do not depend on D3D12. **Shared interfaces.** The only shared file is #560's test-only `tests/cpu/shim_draw_provider.cpp`, which gets three new cases. The edit was announced on #218 ([note](https://github.com/R0Y00/Xbox2Windows/issues/218#issuecomment-7084141442)) and claimed on #671 ([claim](https://github.com/R0Y00/Xbox2Windows/issues/671#issuecomment-7084139376)). `mesh_entry_draw.cpp`, `offscreen_check` and `shim_draw_gpu.cpp` are untouched. The #658 helpers live in the `offscreen_check` executable, so the DLL keeps its own copy of the sequence. This doesn't overlap the persistent multi-frame draft in RonLogic/Xbox2Windows#1, which changes `shim_draw_gpu.cpp`. ## Verification Commit `543b951` (on `main` at `0a9cc04`, which includes #560's merge `899785e`). Windows 11 build 26200.9974, MSVC from `tools/dev.ps1`, Windows SDK 10.0.26100 DXC 1.8.2502.11, Python 3.12 venv. ```powershell foreach ($p in 'dev', 'release') { cmake --preset $p "-DINTAKE_PYTHON=$intakePython" cmake --build --preset $p ctest --preset $p --no-tests=error -R '^cpu_shim_chain_(warp|hardware)$' -V ctest --preset $p --no-tests=error -R '^cpu_shim_chain_(warp|hardware)$' --repeat until-fail:5 ctest --preset $p --no-tests=error --timeout 300 -E '^(conditional_import_paths|static_exe_intake|bundled_export_forwarders)$' } $env:XBOX2WINDOWS_ADAPTER = 'NVIDIA' # then 'AMD' ctest --preset $p --no-tests=error -R '^cpu_shim_chain_hardware$' -V python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` | Adapter | dev (Debug) | release (/O2) | |---|---|---| | WARP 10.0.26100.9818 | pass: chain0 and chain1 match exactly; stale shows 276 differing pixels, 748 clear pixels and trace match | pass, same result | | NVIDIA GeForce RTX 3080, driver 32.0.16.1088 | pass, same result | pass, same result | | AMD Radeon(TM) Graphics (1002:164e, RDNA2 iGPU), driver 32.0.13066.12 | **capability skip (77)**: `mesh_shader_tier=unsupported` | same skip | The AMD skip matches the existing #658 harness on the same adapter: `compute_mesh_texture_hardware` also reports `mesh_shader_tier=unsupported` there. Example output: ```text chain0: producers=1 exit=42 native, pe_map and AOT agree on 4176 bytes; 1024/1024 pixels and trace match chain1: producers=2 exit=42 native, pe_map and AOT agree on 4176 bytes; 1024/1024 pixels and trace match chain-stale: producers=2 exit=20 native, pe_map and AOT agree on 4176 bytes; stale texture differs at 276 pixels; 748 clear pixels and trace match ``` - Focused tests: pass in both presets. `--repeat until-fail:5` was 5/5 for both tests in both presets. - Full serial suite (three intake tests excluded): **296/296 in dev and 296/296 in release**. Three skips in both presets: `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`, unrelated to this change. - Docs link and bidi checks: pass. - **Not run:** the D3D12 debug layer. `D3D12GetDebugInterface` returns `0x887a002d` (Graphics Tools not installed on this machine), so debug-layer errors and warnings were not checked. Also not run: Intel hardware and an AMD adapter with mesh shader support. ## Evidence and follow-up All inputs are source-built synthetic fixtures under the project's MIT license. The EXE is the MASM shim-startup fixture, and the shaders are generated from the gfx1013 programs already in the repository's #658 test. The test measures one frame per process. Persistent device and queue state across frames is the separate RonLogic/Xbox2Windows#1 follow-up. Nothing here exercises Xbox GPU command translation or title code, and no game startup or graphics compatibility is claimed. The reproduction command is in `docs/experiments.md`, under "EXE startup through the desktop runtime shims". ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture: the stale-texture binding. - [x] I updated README/docs when a capability or build requirement changed (`docs/experiments.md`). - [x] I did not include game files, dumps, distribution links or secrets. _AI-assisted (Claude Code)._
upstream-sync closed this pull request 2026-11-24 06:44:18 +00:00
thepatrickworld commented 2026-11-24 06:48:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T21:22:05Z.


Verification: #682 tests: run the compute -> mesh -> pixel chain from the shim EXE

Head 543b9519, merged with main. Five files, +564/−1: tests/cpu/shim_chain_gpu.cpp (387 lines,
new), tests/cpu/shim_chain_check.py (124 lines, new), changes to tests/cpu/shim_draw_provider.cpp,
tests/offscreen_check.cpp and CMakeLists.txt.

What it adds

A new test that drives the whole chain from the shim EXE's PE entry: translated gfx1013 compute
producers write a 2×2 texture, translated indexed mesh and image_sample_lz pixel stages sample it
into a 32×32 frame, and the provider publishes the frame plus an 80-byte mesh export trace after the
startup output. Three cases: chain0 (bind A), chain1 (bind B after dispatching both) and
chain-stale (dispatch both, bind the earlier texture A against B's reference, expected exit 20).

The reference is computed in Python without D3D12, then compared byte for byte, including the trace.
For chain-stale it additionally asserts that the frame equals palette A's frame and that every
differing pixel is a covered pixel whose palette entry changed, with all clear pixels still matching.

This is the most valuable shape in the suite so far: it is the only test I have run that exercises a
multi-stage chain end to end through the translation path, rather than one dispatch in isolation.

Environment

Windows 11 25H2 (build 26200.9711), MSVC 19.44.35230, DXC 1.9.2602.17, AMD RX 9070 XT
(vendor 1002, device 7550), driver 32.0.32029.2010, native wave64.

Commands and output

cmake --preset dev -DINTAKE_PYTHON=<venv>
cmake --build --preset dev --parallel 12
set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT
ctest --preset dev --no-tests=error -R "shim|cpu"
100% tests passed out of 131

131 tests, all green — the chain test plus the CPU suite it pulls in.

Negative control: I changed the stale case in shim_draw_provider.cpp to bind palette 1 instead of
palette 0 (if (!std::strcmp(mode, "chain-stale")) return 5; → return 4;), rebuilt
offscreen_check and re-ran -R "shim":

93% tests passed, 1 tests failed out of 15
193 - cpu_shim_chain_hardware (Failed)

So the stale assertion does discriminate: binding the wrong texture is caught, not absorbed by the
other two cases.

The reserve: an exit-code collision, and a coupling to seven modules

The failure path reuses the success code. This is the one real defect. shim_chain_gpu.cpp:591
returns false on failure, shim_draw_provider.cpp:58 turns that into 0xFFFFFFFF, and the guest reads
it as a mismatch → exit 20 (shim_chain_check.py:187). But 20 is also the expected exit for
chain-stale. A complete provider failure — PSO refused, mesh tier lost, unreadable case — therefore
looks exactly like the stale case doing its job. Only the published-length check in verify (l. 150)
catches it, and it is the only thing that does.

The import order is load-bearing. shim_chain_check.py:106 does from pixel_aot import lower
while sys.path only holds tests/ (l. 100). It works solely because mesh_entry_check.py:10 adds
tools/ as a side effect. Reordering the import block breaks the test with a ModuleNotFoundError
that points nowhere near the cause.

Coupling: seven modules, not eight. compute_mesh_texture_check, mesh_entry_check,
mesh_indexed_check, mesh_textured_check, pixel_aot, pixel_aot_check and shim_startup_check
(l. 102-108). None of them belongs to this PR, so a refactor in any of them breaks this test with a
message that points at the shim chain rather than at the change that caused it. That is the real cost.

Imprecision in my first pass, corrected here. I wrote that a palette drift would move this test
silently — that is wrong: STALE_MISMATCHES = 276 is asserted (l. 162), so a drift fails loudly. The
hardcode is therefore both fragile and load-bearing, and the thing worth fixing is the error message,
not the constant's existence. 276 is otherwise correct: recomputed independently from PALETTE, 276
pixels differ between A and B, 748 are clear in B, and no differing pixel is clear.

Scope: chain-stale does not cover the translator. Once chain1 is green, the stale case adds no
coverage of the translation path — it validates the fixture (that A and B produce discriminable
frames) and guards the Python reference model against regression. Worth stating as such.

What I would add

  • ExitProcess(24) when shim_chain_gpu fails, so a provider failure cannot masquerade as the
    expected stale result. The file already uses 21/22/23 in this style.
  • sys.path.insert(0, str(ROOT / "tools")) at the top, so the coupling is explicit instead of
    inherited from mesh_entry_check's import side effect.
  • Derive STALE_MISMATCHES (and the clear-pixel count, 748) from the two palettes, so the failure
    names the cause instead of the chain.

What this does not prove

  • Nothing about the same chain under a real title: this is a synthetic fixture, no original shader
    binaries.
  • Nothing about wave32 execution.
  • Nothing about chains longer than three stages, or about a compute producer that reads back a UAV
    written by the pixel stage.

AI-assisted; runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7085996735 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/682#issuecomment-7085996735). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-22T21:22:05Z. --- **Verification: #682 `tests: run the compute -> mesh -> pixel chain from the shim EXE`** Head `543b9519`, merged with `main`. Five files, +564/−1: `tests/cpu/shim_chain_gpu.cpp` (387 lines, new), `tests/cpu/shim_chain_check.py` (124 lines, new), changes to `tests/cpu/shim_draw_provider.cpp`, `tests/offscreen_check.cpp` and `CMakeLists.txt`. ### What it adds A new test that drives the whole chain from the shim EXE's PE entry: translated gfx1013 compute producers write a 2×2 texture, translated indexed mesh and `image_sample_lz` pixel stages sample it into a 32×32 frame, and the provider publishes the frame plus an 80-byte mesh export trace after the startup output. Three cases: `chain0` (bind A), `chain1` (bind B after dispatching both) and `chain-stale` (dispatch both, bind the earlier texture A against B's reference, expected exit 20). The reference is computed in Python without D3D12, then compared byte for byte, including the trace. For `chain-stale` it additionally asserts that the frame equals palette A's frame and that every differing pixel is a covered pixel whose palette entry changed, with all clear pixels still matching. This is the most valuable shape in the suite so far: it is the only test I have run that exercises a multi-stage chain end to end through the translation path, rather than one dispatch in isolation. ### Environment Windows 11 25H2 (build 26200.9711), MSVC 19.44.35230, DXC 1.9.2602.17, AMD RX 9070 XT (vendor `1002`, device `7550`), driver 32.0.32029.2010, native wave64. ### Commands and output ``` cmake --preset dev -DINTAKE_PYTHON=<venv> cmake --build --preset dev --parallel 12 set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT ctest --preset dev --no-tests=error -R "shim|cpu" ``` ``` 100% tests passed out of 131 ``` 131 tests, all green — the chain test plus the CPU suite it pulls in. Negative control: I changed the stale case in `shim_draw_provider.cpp` to bind palette 1 instead of palette 0 (`if (!std::strcmp(mode, "chain-stale")) return 5;` → `return 4;`), rebuilt `offscreen_check` and re-ran `-R "shim"`: ``` 93% tests passed, 1 tests failed out of 15 193 - cpu_shim_chain_hardware (Failed) ``` So the stale assertion does discriminate: binding the wrong texture is caught, not absorbed by the other two cases. ### The reserve: an exit-code collision, and a coupling to seven modules `The failure path reuses the success code.` This is the one real defect. `shim_chain_gpu.cpp:591` returns false on failure, `shim_draw_provider.cpp:58` turns that into `0xFFFFFFFF`, and the guest reads it as a mismatch → exit 20 (`shim_chain_check.py:187`). But 20 is also the *expected* exit for `chain-stale`. A complete provider failure — PSO refused, mesh tier lost, unreadable case — therefore looks exactly like the stale case doing its job. Only the published-length check in `verify` (l. 150) catches it, and it is the only thing that does. `The import order is load-bearing.` `shim_chain_check.py:106` does `from pixel_aot import lower` while `sys.path` only holds `tests/` (l. 100). It works solely because `mesh_entry_check.py:10` adds `tools/` as a side effect. Reordering the import block breaks the test with a `ModuleNotFoundError` that points nowhere near the cause. `Coupling: seven modules, not eight.` `compute_mesh_texture_check`, `mesh_entry_check`, `mesh_indexed_check`, `mesh_textured_check`, `pixel_aot`, `pixel_aot_check` and `shim_startup_check` (l. 102-108). None of them belongs to this PR, so a refactor in any of them breaks this test with a message that points at the shim chain rather than at the change that caused it. That is the real cost. `Imprecision in my first pass, corrected here.` I wrote that a palette drift would move this test silently — that is wrong: `STALE_MISMATCHES = 276` is asserted (l. 162), so a drift fails loudly. The hardcode is therefore both fragile and load-bearing, and the thing worth fixing is the error message, not the constant's existence. `276` is otherwise correct: recomputed independently from `PALETTE`, 276 pixels differ between A and B, 748 are clear in B, and no differing pixel is clear. `Scope: chain-stale does not cover the translator.` Once `chain1` is green, the stale case adds no coverage of the translation path — it validates the fixture (that A and B produce discriminable frames) and guards the Python reference model against regression. Worth stating as such. ### What I would add - `ExitProcess(24)` when `shim_chain_gpu` fails, so a provider failure cannot masquerade as the expected stale result. The file already uses 21/22/23 in this style. - `sys.path.insert(0, str(ROOT / "tools"))` at the top, so the coupling is explicit instead of inherited from `mesh_entry_check`'s import side effect. - Derive `STALE_MISMATCHES` (and the clear-pixel count, 748) from the two palettes, so the failure names the cause instead of the chain. ### What this does not prove - Nothing about the same chain under a real title: this is a synthetic fixture, no original shader binaries. - Nothing about wave32 execution. - Nothing about chains longer than three stages, or about a compute producer that reads back a UAV written by the pixel stage. _AI-assisted; runs executed locally._
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!676
No description provided.