startup: experimental runtime stand-ins for console executables #1128
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1135"
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 denn0x on 2026-11-24T01:45:14Z.
Change
Adds experimental, opt-in desktop stand-ins under
src/startup_stubs/and a debugger launcher undertools/startup/. With them, an x64 console executable can start on desktop Windows under a debugger, so itsstartup path can be studied one missing piece at a time. Nothing changes unless the
X2W_*_PERMISSIVE/feature switches are set; without them, every unimplemented export traps with a named exit code.
This is not a port and does not make any executable playable.
docs/startup-runtime.mddescribes the build,run, switches and findings, and the shortcuts that are known to be wrong. A README row was added under
"Choose an experiment".
What it adds:
X2W_XMEM_GPU_MIRRORpairs a no-access graphicsreservation with the read-write reservation before it and maps each page's section into both views.
path through translated pipelines (
X2W_D3D12_RENDER,X2W_SHADER_CACHE).Submit, in order with status and fence entries.Page-array entries that are 0 at enqueue are re-read at run time. zlib is inflated on the CPU; BCPack is
zero-filled (shortcut).
call. The proxy answers the user and gamertag interfaces and the save API for one local user.
tools/startup/gfx2hlsl.py: a translator for pipeline requests, with constant-foldeds_bfm_b32inlinesamplers and 3D image resources.
tests/startup_stub_check.py(cteststartup_stubs): checks the stand-ins' exports, traps and permissiveanswers with a source-built consumer. No executable is needed.
Overlap with
main: the trap entries forXMemTransferMemory/D3D12ConfigureVirtualMemoryXwere dropped,because
mainnow implements them.d3d12_xs_shimgains the stand-in device source.Open problems are split into issues that can be picked up independently (listed below).
Verification
Commit
e658fe24on top ofmaina7710b73. Built with a release configuration (MSVC 14.50, Windows SDK 10.0.26100.0,Ninja, Python from
requirements-dev.txt). Environment: AMD Radeon RX 9070 XT, driver 32.0.32015.7029,Windows 11 build 26300, D3D12 debug layer off.
startup_stubs: pass.xmem|era_|startup: 43/43 pass. This includescpu_native_xmem_default_pair; the stand-ins' switch readernow preserves the last-error value.
main:dxr_opacity_hardware,gpu_alias_lookup_writes_hardwareandpixel_aot_comparisons_hardware(
offscreen_check, which links only the system D3D12; adapter-specific);pe_package_import_closure(WinError 1314: the symlink privilege is missing).xg_swizzle*,bvh_wave64_warp,wave_shuffle_warp,spirv_*andbc7_mode6_multiblock.End-to-end check (local, no files from it are included): I ran
tools/startup/run.ps1 -Render -FakeUser -GpuMirror -ContinueAsserts 5000 -Seconds 150on one console executable in offline mode, where 4 network opens were refused.Evidence and follow-up
All fixtures are source-built (
tests/startup_stub_consumer.cpp, MIT). The findings in the doc are measured on oneexecutable and are stated as hypotheses for others. Open issues:
Suggested repository changes (also filed as an issue):
startup_stubsin the Windows CI job (no GPU or game files needed);tools/startup/;pe_package_import_closurewhen the symlink privilege is missing;Checklist
It is large; I can split it per DLL if reviewers prefer.
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:15:46Z.
Review: COMMENTED
Reviewed at
e658fe24a0bf80adb6f5c62275945010a3538df3.X2W_XMEM_PERMISSIVE,X2W_D3D12_PERMISSIVE,X2W_AUDIO_PERMISSIVE). Default behavior is preserved:d3d12_xs_XboxCreateDevicestill returnsE_INVALIDARGfor non-null parameters withoutX2W_D3D12_PERMISSIVE,XMemAlloconly falls back tolocal_allocwhenera_heap::allocatereturns null withX2W_XMEM_PERMISSIVE,xmem_mapped_pages.cppgates permissive paths onlocal_permissive(), and unimplemented stub exports trap withx2w-trapby default.docs/startup-runtime.mdclearly documents the experimental scope, switches, findings, and known shortcuts in title-neutral terms.python3 -B tests/docs_links_check.py(16 files, 253 links),python3 -B tests/bidi_controls_check.py(965 files),python3 -B tests/gpu_report_format_check.py(10 tests),python3 -B tests/xgameruntime_table_check.py, andpython3 -m py_compile tools/startup/*.py tests/startup_stub_check.py— all passed (startup_stub_check.pyexecution requires built Windows DLLs).Assemble and translate gfx1013 fixturespassed, whileBuild and test on Windowsis currentlyFAILUREandBuild and test on Windows at /O2isIN_PROGRESS; Windows MSVC/DLL verification relies on CI.Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T02:04:49Z.
Verification on a second machine (NVIDIA, Windows 10). The source-built checks pass. The end-to-end run needed two changes to get past the first seconds here and then stops at a new fault; details and issues below.
Environment: commit
e658fe24, release preset (Ninja, MSVC from the Visual Studio developer shell), NVIDIA GeForce RTX 3060, driver 32.0.15.9636, Windows 10 22H2 build 19045.6466, D3D12 debug layer off. Package on a slow volume (about 27 MB/s sequential).Source-built checks (unmodified
e658fe24)startup_stubs: pass (all 8 stand-ins load with their exports;chadandxg_xstraps return their named exit codes; both controls exit 0).xmem|era_|startup: 48/48 pass, no skips. (The PR reports 43; this build has the Python environment configured, which registers more tests.)End-to-end, one console executable, offline (
tools/startup/run.ps1 -Render -FakeUser -GpuMirror -ContinueAsserts 5000 -Seconds 240, package in a folder on another drive)e658fe24CreateDescriptorHeapfor a shader-visible view heap of 1,245,184 descriptors returns0x8007000Eon this adapter; the executable reads through the null result. #1159Measured in runs 3 and 4 before the stop:
gfx2hlsl.py --pendingtranslated both, and run 4 then recorded 1,182 translated draws;0x80070057(#1140);X2W_D3D12_DUMP_SURFACE) is black. I did not see the intro video before the stop, so I cannot confirm that part.One more local experiment was active in runs 3 and 4 and should be read as a caveat: a debugger-side byte patch that disables a 30 s stall self-check in the executable. On this storage, start-up without it sometimes ends in that self-check before the first present. I have not measured runs 3 and 4 without it.
Not established here: anything after 75 s, the video, the first-run prompt, and the soft assert in #1136.
The two changes (drive mapping in
debug_launch.py/run.ps1, and the capped view heap ind3d12_xs_device.cpp) are local for now. I can open them against this branch or wait for it to merge, whichever you prefer. I am also taking #1141, #1142 and #1147 (claims on the issues).AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-24T02:05:39Z.
NVIDIA retest of this branch at
e658fe24, and one NVIDIA-specific blocker with a small fix.Environment: RTX 3090 (
10de:2204), driver 32.0.16.1664, Windows 11 Pro build 26300, MSVC 19.44.35207.1,releasepreset, D3D12 debug layer off.ctest --preset release -R '^startup_stubs$'passes.Run setup:
tools/startup/run.ps1 -Render -FakeUser -GpuMirror -ContinueAsserts 5000, with the package root mapped asG:and-StoragePathset to a local folder. WithoutG:, the title cannot open its package files and fails early with a large clear to a null allocation, so it may be worth a line indocs/startup-runtime.mdthat-DataDirshould be the drive the title expects.Blocker on NVIDIA: the title creates its main shader-visible CBV/SRV/UAV heap with 1,245,184 descriptors over title memory. On the RTX 3090, desktop
CreateDescriptorHeaprefuses that size withE_INVALIDARG(the adapter reports 1,000,000 for shader-visible view heaps). The stand-in returns the failure, the title gets a null heap and stops at a null read about 2 s in. On the RX 9070 XT the same size is accepted, which explains why it did not show up there.Local fix (
src/startup_stubs/d3d12_xs_device.cpp, 38 lines):E_INVALIDARGfor a shader-visible CBV/SRV/UAV heap, readD3D12_OPTIONS19.MaxViewDescriptorHeapSize(default 1,000,000), create the desktop heap at that size and log the cap. The title's CPU side keeps its full size.DescriptorRangegainsdesktop_bytes.desktop_cpu_handlemaps title handles past the cap to one CPU-only sink slot, so view writes there are absorbed rather than landing past the desktop heap.note_heapgets the capped count, so shadow and GPU table lookups stay inside the desktop heap.Descriptors past index 1,000,000 are not bound on such adapters. I did not see any binding reach that range. I can push this as a commit to your branch, or a follow-up PR against
mainonce this merges. Tell me which you prefer.Result with the fix (local, no files attached):
gfx2hlsl.py --pendinground, both recorded pipelines translated and about 3,000 translated draws ran per run. The output window stays black.The black output has two parts on this machine:
no translation for stream shader). That is #1142, and it is probably the pass that reaches the window. No textures are uploaded in this phase.I have not established what it waits for. Possibilities on my side are the heap cap (if something binds above index 1,000,000) and input timing. If your run passes a specific screen with a known input at a known time, that would help me tell them apart.
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:07:56Z.
I ran the source-built Release fixture on
e658fe24(Windows x64, MSVC 19.51):ctest --preset release --no-tests=error -R '^startup_stubs$' -Vpassed. All eight DLL export checks, the two trap exits and the permissive controls matched. This result is for the generated fixture. The independent startup observations stay in #870.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:08:56Z.
Independently rebuilt the startup DLLs and consumer from
e658fe24in Release on Windows 11 build 26200.9974 (MSVC 19.51).ctest --test-dir <release-build> --no-tests=error -R '^startup_stubs$' -Vpassed. The consumer loaded eight DLLs, observed the two expected named trap exits, and passed both control paths.I also ran a source-built EXE through this PR's
tools/startup/debug_launch.pywith rendering and the permissive device enabled. On the RTX 4060 Laptop (616.56) and on WARP, it created the wrapped D3D12 device, direct queue and fence, observed the fence move from 0 to 7 after queue Signal, and exited with code 0. Debug layer off. With the device switch disabled, the same non-null creation parameters returned E_INVALIDARG with a null device. This checks the launcher/device/queue path. The intro playback observation in the PR description is still the author's separate run.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:11:30Z.
Thanks for the RTX 3090 retest. Please submit the descriptor heap changes as a focused follow-up against main after this PR merges. #874 already tracks paging work. Please keep an explicit diagnostic for the first GPU-visible binding that crosses the physical limit, and include a synthetic case that reaches that range so an absorbed write cannot silently count as a pass.
For the black-window retest on the 3090, there is now a stream request translation candidate on top of this exact PR head:
github.com/R0Y00/Xbox2Windows@72acbf0df7. If you can run the same setup with that change and your local heap fix, the most useful comparison for #1137 is whether the third draw acquires a translated pipeline and whether the output changes. Please report those two observations separately; aggregate results are sufficient.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:22:17Z.
Both Windows jobs on
e658fe24reported startup_stubs as Not Run because a fresh configure registered the test before INTAKE_PYTHON was initialized. I retested5691fe81from a fresh Release build directory with the preset default Python path and no INTAKE_PYTHON override. The DLLs and consumer built, and ctest --preset release --no-tests=error -R "^startup_stubs$" passed 1/1. GitHub is rerunning the full matrix.Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-24T02:47:20Z.
@mumba17, on input timing. These are measured on the RX 9070 XT with the same switches; on this adapter the UI reaches the window, so each step was confirmed from presented-surface dumps, not from a fixed schedule:
Two fixes from this testing are now on the branch:
5691fe81registersstartup_stubsafterINTAKE_PYTHONis defined. It was "Not Run" in CI.5e775ddastops an allocation failure on the DirectStorage worker from ending the process. It was a fast fail inXCRDAPI.dllabout six minutes in, after the loading screen.The zlib failures in #1144 turned out to be multi-page streams; the layout table is in https://github.com/R0Y00/Xbox2Windows/issues/1144#issuecomment-7120470386.
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T03:12:07Z.
Tested on Windows 10 22H2
19045.6456with MSVC 19.44.35230, a GTX 1060 6 GB (10de:1c03, driver32.0.15.6094,XBOX2WINDOWS_ADAPTER=1060) and in-box WARP (1414:008c,10.0.19041.5794). This was a Debug (dev) build with the D3D12 debug layer enabled. Only the source-built ctest checks ran; no console executable was loaded.da5884af(current head):ctest --preset dev --no-tests=error -R '^startup_stubs$' -Vpasses. The consumer loads all eight stand-ins (acphal 9/9, chad 5/5, xapu 5/5, xcrdapi 1/1, xg_xs 2/2, gameinput 1/1, xmem 7/7, d3d12_xs 1/1 exports). It sees the two expected trap codes (0xe2570200,0xe2570501), and both controls exit 0.-R 'xmem|era_|startup'passes 48/48. This ran in the build directory from my earlier configure, so it doesn't add to your fresh-configure check of the registration fix.e658fe24, full suite (ctest --preset dev --no-tests=error): 557 passed, 70 capability skips (exit 77, mostly mesh shaders and newer shader-model or wave features this adapter and WARP build don't expose), 8 failed.startup_stubswas Not Run (the registration-order issue, already fixed). The other 7 failures don't involve this PR:e658fe24main645b9697, same hostgpu_alias_lookup_writes_warparray_atomics … expected=64 actual=256,256,256,256(the #369 symptom, on this WARP build)pixel_aot_title_loads_warpcompressed_scene_metadata,shader_metadata_probe,dxil_retarget_probe,dxil_retarget_probe_hardwareroot_probe.exe --containerexits 4 (it can't load or use the SDK DXIL validator on this host)pe_package_import_closureWinError 1314creating a symlink (no symlink privilege)mainalready has the #1126 handling, so a rebase picks it upEvery
_hardwaretest that ran on the 1060, rather than skipping, passed. The DXIL-validator and WARP failures are local to this host and also occur onmain; I'll look at them separately.AI-assisted (Claude Code).