cpu: render one EXE-entry raster draw across native, mapped and AOT runners #554

Merged
yummancito merged 2 commits from upstream-pr/560 into main 2026-11-22 19:31:14 +00:00
yummancito commented 2026-11-22 12:12:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by yummancito on 2026-11-22T12:12:33Z.


The shim-startup EXE now owns a draw phase after the compute dispatch. draw_request selects the case and draw_frame (new cpu_shim_draw provider) renders the repository's 64x64 test triangle offscreen on D3D12: direct queue, fence-waited copy to a readback buffer, raw RGBA bytes published after the startup output.

The native EXE, the pe_map mapping (6 explicit shim bindings + mapped host returned, exit 42) and the AOT-lifted build (which calls draw_request/host_draw_frame from the lifted entry) agree byte for byte: 16,384 bytes, sha256 58d9236355d2cc98, 1176 green pixels per the CPU rule (x >= 8 && y >= 8 && x + y <= 63).

Negative controls: a mirrored-X shader variant must exit 20 with a frame that differs from the rule (be42c453…) but still agrees across runners; an unknown draw case must exit 21 with no frame. Deleting cpu_shim_draw.dll fails at the Windows loader (STATUS_DLL_NOT_FOUND), proving the import is load-bearing and nothing is bypassed.

Refs #218 as motivation (one connected vertical slice through loader, runtime, CPU and GPU paths). This does not resolve #218 and does not implement Xbox GPU command translation; no game startup or graphics compatibility is claimed.

Validation: fork CI run https://github.com/yummancito/Xbox2Windows/actions/runs/45020077723 — Windows dev 217/217, Windows /O2 217/217 (both include cpu_shim_draw_warp), plus both Linux jobs green. Local Release /O2 frame hashes match Development exactly.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6542218659 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/560). Originally posted by [yummancito](https://github.com/yummancito) on 2026-11-22T12:12:33Z. --- The shim-startup EXE now owns a draw phase after the compute dispatch. `draw_request` selects the case and `draw_frame` (new `cpu_shim_draw` provider) renders the repository's 64x64 test triangle offscreen on D3D12: direct queue, fence-waited copy to a readback buffer, raw RGBA bytes published after the startup output. The native EXE, the `pe_map` mapping (6 explicit shim bindings + `mapped host returned`, exit 42) and the AOT-lifted build (which calls `draw_request`/`host_draw_frame` from the lifted entry) agree byte for byte: 16,384 bytes, sha256 `58d9236355d2cc98`, 1176 green pixels per the CPU rule (`x >= 8 && y >= 8 && x + y <= 63`). Negative controls: a mirrored-X shader variant must exit 20 with a frame that differs from the rule (`be42c453…`) but still agrees across runners; an unknown draw case must exit 21 with no frame. Deleting `cpu_shim_draw.dll` fails at the Windows loader (`STATUS_DLL_NOT_FOUND`), proving the import is load-bearing and nothing is bypassed. Refs #218 as motivation (one connected vertical slice through loader, runtime, CPU and GPU paths). This does not resolve #218 and does not implement Xbox GPU command translation; no game startup or graphics compatibility is claimed. Validation: fork CI run https://github.com/yummancito/Xbox2Windows/actions/runs/45020077723 — Windows dev 217/217, Windows /O2 217/217 (both include `cpu_shim_draw_warp`), plus both Linux jobs green. Local Release /O2 frame hashes match Development exactly.
upstream-sync closed this pull request 2026-11-24 06:43:41 +00:00
roansystemlabs commented 2026-11-24 06:48:32 +00:00 (Migrated from github.com)

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


Physical-GPU run for this PR (the fork CI covers cpu_shim_draw_warp only).

Commit: 0472851 (PR head), dev preset.

ctest --preset dev --no-tests=error -R '^cpu_shim_draw_|^cpu_shim_compute_|^cpu_native_shim_startup$' -V

5/5 pass, including cpu_shim_draw_hardware (3.4 s) and cpu_shim_compute_hardware. On both adapters: draw frame: 64x64 RGBA (16384 bytes); CPU rule holds 1176 green pixels, and the draw, flip (exit 20) and bogus (exit 21) cases are checked across the native, pe_map and AOT runners. ctest -R '^cpu_shim_draw_' --repeat until-fail:10: 10/10 runs green on RTX 3070 and WARP.

Debug layer: the draw provider does not enable it, so I made a local, temporary change to create_device() in tests/cpu/shim_draw_gpu.cpp: behind an environment variable, it calls EnableDebugLayer() and sets ID3D12InfoQueue::SetBreakOnSeverity for CORRUPTION and ERROR. With it on, cpu_shim_draw_warp and _hardware still pass, so no error or corruption message is raised during the draw. As a control for the instrumentation itself, an extra invalid CreateRootSignature(0, nullptr, 0, …) call makes both tests fail (draw publishes a full frame: expected 16384, got 0). The change was reverted and the PR rebuilt before the repeat run. Debug-layer warnings were not checked.

Environment: Windows 11 build 26200.9974, NVIDIA GeForce RTX 3070 (10de:2484), driver 32.0.16.2101, Graphics Tools debug layer; WARP 10.0.26100.9818.

Not tested: AMD or Intel hardware, the /O2 release preset, debug-layer warnings, the cpu_shim_draw.dll-deletion control, and the full suite.

AI-assisted: prepared with an AI coding agent and reviewed by a human before posting.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7079761718 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/560#issuecomment-7079761718). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-22T13:22:22Z. --- Physical-GPU run for this PR (the fork CI covers `cpu_shim_draw_warp` only). **Commit:** `0472851` (PR head), `dev` preset. ```powershell ctest --preset dev --no-tests=error -R '^cpu_shim_draw_|^cpu_shim_compute_|^cpu_native_shim_startup$' -V ``` 5/5 pass, including `cpu_shim_draw_hardware` (3.4 s) and `cpu_shim_compute_hardware`. On both adapters: `draw frame: 64x64 RGBA (16384 bytes); CPU rule holds 1176 green pixels`, and the draw, flip (exit 20) and bogus (exit 21) cases are checked across the native, `pe_map` and AOT runners. `ctest -R '^cpu_shim_draw_' --repeat until-fail:10`: 10/10 runs green on RTX 3070 and WARP. **Debug layer:** the draw provider does not enable it, so I made a local, temporary change to `create_device()` in `tests/cpu/shim_draw_gpu.cpp`: behind an environment variable, it calls `EnableDebugLayer()` and sets `ID3D12InfoQueue::SetBreakOnSeverity` for CORRUPTION and ERROR. With it on, `cpu_shim_draw_warp` and `_hardware` still pass, so no error or corruption message is raised during the draw. As a control for the instrumentation itself, an extra invalid `CreateRootSignature(0, nullptr, 0, …)` call makes both tests fail (`draw publishes a full frame: expected 16384, got 0`). The change was reverted and the PR rebuilt before the repeat run. Debug-layer warnings were not checked. **Environment:** Windows 11 build 26200.9974, NVIDIA GeForce RTX 3070 (10de:2484), driver 32.0.16.2101, Graphics Tools debug layer; WARP 10.0.26100.9818. **Not tested:** AMD or Intel hardware, the `/O2` release preset, debug-layer warnings, the `cpu_shim_draw.dll`-deletion control, and the full suite. AI-assisted: prepared with an AI coding agent and reviewed by a human before posting.
rwZephyr commented 2026-11-24 06:48:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T18:43:13Z.


Independent Windows verification of PR head 04728512d8e87933c3e8fb7cfe6bb0d012d80dd5. AI-assisted report, tests run locally from unmodified PR source.

Windows 11 25H2 x64 build 26200.9974, MSVC 19.44.35230, Windows SDK 10.0.26100, DXC 1.8.2502.8, Python 3.12.10. A separate DXGI probe using the draw provider’s high-performance adapter selection returned AMD Radeon RX 9070 XT (1002:7550), driver 32.0.32029.2010. The draw provider ran without the D3D12 debug layer.

With the workspace-local toolchain loaded, $intakePython set to the local virtual environment’s Python executable, and the debug CRT DLLs staged alongside the dev binaries:

foreach ($preset in 'dev', 'release') {
    cmake --preset $preset "-DINTAKE_PYTHON=$intakePython"
    cmake --build --preset $preset --target pe_map cpu_shim_startup cpu_shim_startup_lifted
    ctest --preset $preset --no-tests=error -R '^cpu_shim_draw_(warp|hardware)$' -V
}

Both tests passed in both presets (4/4, zero skips). Native, pe_map, and AOT matched the CPU reference byte for byte for the 64×64 frame (16,384 RGBA bytes, 1,176 green pixels, exit 42). The mirrored control agreed across the three runners, differed from the CPU reference, and exited 20. The unknown draw case exited 21 and published no frame.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7083817737 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/560#issuecomment-7083817737). Originally posted by [rwZephyr](https://github.com/rwZephyr) on 2026-11-22T18:43:13Z. --- Independent Windows verification of PR head `04728512d8e87933c3e8fb7cfe6bb0d012d80dd5`. AI-assisted report, tests run locally from unmodified PR source. Windows 11 25H2 x64 build `26200.9974`, MSVC `19.44.35230`, Windows SDK `10.0.26100`, DXC `1.8.2502.8`, Python `3.12.10`. A separate DXGI probe using the draw provider’s high-performance adapter selection returned AMD Radeon RX 9070 XT (`1002:7550`), driver `32.0.32029.2010`. The draw provider ran without the D3D12 debug layer. With the workspace-local toolchain loaded, `$intakePython` set to the local virtual environment’s Python executable, and the debug CRT DLLs staged alongside the `dev` binaries: ```powershell foreach ($preset in 'dev', 'release') { cmake --preset $preset "-DINTAKE_PYTHON=$intakePython" cmake --build --preset $preset --target pe_map cpu_shim_startup cpu_shim_startup_lifted ctest --preset $preset --no-tests=error -R '^cpu_shim_draw_(warp|hardware)$' -V } ``` Both tests passed in both presets (4/4, zero skips). Native, `pe_map`, and AOT matched the CPU reference byte for byte for the 64×64 frame (16,384 RGBA bytes, 1,176 green pixels, exit 42). The mirrored control agreed across the three runners, differed from the CPU reference, and exited 20. The unknown draw case exited 21 and published no frame.
R0Y00 commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)

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


Maintainer review at 17e82dc. I added two harness assertions. The native hardware probe's exact no-adapter diagnostic now reaches CTest as a capability skip, and the three runner comparisons also check the expected startup bytes before the frame.

On Windows 11 build 26200 with MSVC 19.51.36244, I tested the patched tree integrated with main ff7f68a. In both the dev and release presets, ctest --preset <preset> --no-tests=error -R '^cpu_(shim_(draw|compute)_warp|native_shim_startup)$' -V passed 3/3, with no skips. The normal and mirrored draws each published 16,384 bytes and the unknown case published none. A mocked child verified the no-adapter 77, rejection of an unrelated 77 diagnostic, rejection of 77 on WARP, and rejection of corrupted startup output. The earlier independent GPU reports remain linked above. The new head is awaiting both Windows jobs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084344423 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/560#issuecomment-7084344423). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T19:22:31Z. --- Maintainer review at `17e82dc`. I added two harness assertions. The native hardware probe's exact no-adapter diagnostic now reaches CTest as a capability skip, and the three runner comparisons also check the expected startup bytes before the frame. On Windows 11 build 26200 with MSVC 19.51.36244, I tested the patched tree integrated with main `ff7f68a`. In both the `dev` and `release` presets, `ctest --preset <preset> --no-tests=error -R '^cpu_(shim_(draw|compute)_warp|native_shim_startup)$' -V` passed 3/3, with no skips. The normal and mirrored draws each published 16,384 bytes and the unknown case published none. A mocked child verified the no-adapter 77, rejection of an unrelated 77 diagnostic, rejection of 77 on WARP, and rejection of corrupted startup output. The earlier independent GPU reports remain linked above. The new head is awaiting both Windows jobs.
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!554
No description provided.