gpu: run the translated compute-mesh-pixel chain from the shim EXE entry #676
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/682"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_CASEgains three values,chain0,chain1andchain-stale.draw_requestmaps each to a new mode, anddraw_framesends those modes to a new file,tests/cpu/shim_chain_gpu.cpp. On one direct queue that file:TRACE_EXPORTS) and theimage_sample_lzpixel stage into a 32×32 RGBA8 target. The root layout matchesoffscreen_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_framereturns the mismatch count against the case reference, so the guest exits 42 on a match and 20 otherwise. Thedraw_request/draw_framesignatures,shim_startup.asmand the AOT import table are unchanged.tests/cpu/shim_chain_check.pybuilds the translated mesh, pixel and producer shaders, and both case files, with the generators thatcompute_mesh_texture_check.pyuses. It then runs the native EXE,pe_mapand AOT for each case.chain0chain1chain-staleFor 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 returnedfrompe_map. They must also share the same exit status and all 4,176 published bytes. The references come fromtexture_case/fixturein 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_checkandshim_draw_gpu.cppare untouched. The #658 helpers live in theoffscreen_checkexecutable, so the DLL keeps its own copy of the sequence. This doesn't overlap the persistent multi-frame draft in RonLogic/Xbox2Windows#1, which changesshim_draw_gpu.cpp.Verification
Commit
543b951(onmainat0a9cc04, which includes #560's merge899785e). Windows 11 build 26200.9974, MSVC fromtools/dev.ps1, Windows SDK 10.0.26100 DXC 1.8.2502.11, Python 3.12 venv.mesh_shader_tier=unsupportedThe AMD skip matches the existing #658 harness on the same adapter:
compute_mesh_texture_hardwarealso reportsmesh_shader_tier=unsupportedthere. Example output:--repeat until-fail:5was 5/5 for both tests in both presets.bvh_wave64_hardware,bvh_wave64_warpandwave_shuffle_warp, unrelated to this change.D3D12GetDebugInterfacereturns0x887a002d(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
docs/experiments.md).AI-assisted (Claude Code).
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 EXEHead
543b9519, merged withmain. Five files, +564/−1:tests/cpu/shim_chain_gpu.cpp(387 lines,new),
tests/cpu/shim_chain_check.py(124 lines, new), changes totests/cpu/shim_draw_provider.cpp,tests/offscreen_check.cppandCMakeLists.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_lzpixel stages sample itinto 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) andchain-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-staleit additionally asserts that the frame equals palette A's frame and that everydiffering 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, device7550), driver 32.0.32029.2010, native wave64.Commands and output
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.cppto bind palette 1 instead ofpalette 0 (
if (!std::strcmp(mode, "chain-stale")) return 5;→return 4;), rebuiltoffscreen_checkand re-ran-R "shim":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:591returns false on failure,
shim_draw_provider.cpp:58turns that into0xFFFFFFFF, and the guest readsit as a mismatch → exit 20 (
shim_chain_check.py:187). But 20 is also the expected exit forchain-stale. A complete provider failure — PSO refused, mesh tier lost, unreadable case — thereforelooks 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:106doesfrom pixel_aot import lowerwhile
sys.pathonly holdstests/(l. 100). It works solely becausemesh_entry_check.py:10addstools/as a side effect. Reordering the import block breaks the test with aModuleNotFoundErrorthat 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_checkandshim_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 testsilently — that is wrong:
STALE_MISMATCHES = 276is asserted (l. 162), so a drift fails loudly. Thehardcode is therefore both fragile and load-bearing, and the thing worth fixing is the error message,
not the constant's existence.
276is otherwise correct: recomputed independently fromPALETTE, 276pixels differ between A and B, 748 are clear in B, and no differing pixel is clear.
Scope: chain-stale does not cover the translator.Oncechain1is green, the stale case adds nocoverage 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)whenshim_chain_gpufails, so a provider failure cannot masquerade as theexpected 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 ofinherited from
mesh_entry_check's import side effect.STALE_MISMATCHES(and the clear-pixel count, 748) from the two palettes, so the failurenames the cause instead of the chain.
What this does not prove
binaries.
written by the pixel stage.
AI-assisted; runs executed locally.