Skip to content

runtime: emulate missing Xbox boot interfaces for retail startup - #8831

Open
pawlickerr wants to merge 10 commits into
ItsNotRexed:mainfrom
pawlickerr:main
Open

pawlickerr wants to merge 10 commits into
ItsNotRexed:mainfrom
pawlickerr:main

Conversation

@pawlickerr

Copy link
Copy Markdown

Claimed in the coordination issue as:

Depends on: #7180, #7527

What and why

Adds missing Xbox runtime compatibility needed by the retail executable during startup, including CPU instruction emulation, DirectStorage support, Xbox D3D12 ABI handling, shader-library compute pipelines, TLS handling, and XG resource helpers.

The changes advance startup through DirectStorage and D3D12 initialization to the Xbox BVH builder. The title does not reach the main menu yet; the current stop is a C++ exception while creating the first BVH compute pipeline.

Tested

Tested on Windows 11 with the Xbox Series 1.0.2.1 package and a Vulkan-capable NVIDIA GPU.

  • Runtime build: passed
  • Selected CTest suite: 23/23 passed
  • No-game-data check: passed
  • Python compilation checks: passed
  • Retail startup test: 1,846 supplementary shaders loaded; startup reaches XboxBvhBuilder initialization

AI-assisted: yes

Checklist

  • No game data, keys or decryption, including in quoted logs or reports.
  • No new shader translator rule was introduced.

Integrate the measured Xbox ABI shims, memory and descriptor handling, command-object proxies, CPU instruction emulation, DirectStorage zlib requests, pipeline-library compute shader loading, and focused regression coverage used by the retail boot path.
# Conflicts:
#	docs/d3d12_vulkan.md
#	docs/runtime_imports.md
#	make_game.py
#	runtime/CMakeLists.txt
#	runtime/shims/xg_xs.cpp
#	runtime/shims/xmem.cpp
#	runtime/src/shader_library.h
@Digit4w

Digit4w commented Nov 23, 2026

Copy link
Copy Markdown

Review of ba5f3b26 (based on main 867d922f): changes needed. 25 runtime tests regress against main, all from one cause. The PR also carries code from three other open PRs without saying so.

Windows 11 build 26200.9974, MSVC (VS 2022 Build Tools), Vulkan SDK 1.4.363.0, AMD Radeon gfx1036 iGPU (driver 25.10.42) pinned with LEONIDA_VK_DEVICE. I did not run the retail boot. The blocker below shows up without game files.

1. ShaderLibrary::load() no longer reads <dir>/index.json (blocker)

runtime/src/shader_library.h: the new load() loops over {"fspx", "bvh", "library"} only. The load_index(dir, "", fail) call for the main index was removed, together with its try/fail("index.json could not be read"). So no translated game shader is ever found. Only the side-folder programs load, which would also explain the "1,846 supplementary shaders loaded" in the description.

ctest -C RelWithDebInfo: 247/274 pass, 27 fail. I built main in a separate worktree and ran the same 27 there: 25 pass, and only d3d12_depth_resolve and d3d12_vulkan_device fail on main too. The 25 regressions:

shader_library (line 388: library.load(...) && library.size() == 6), and the D3D12 tests that build a PSO from a temp shader folder, which print 0 translated shaders from ... and then fail Create{Compute,Graphics}PipelineState: d3d12_compute, d3d12_draw, d3d12_fspx_compute, d3d12_set0_compute, d3d12_descriptor, d3d12_bundle, d3d12_geometry, d3d12_msaa_draw, d3d12_depth24_draw, d3d12_f16_halves, d3d12_pso_validation, d3d12_typeless_families, d3d12_stores_atomics, d3d12_pipeline_library, d3d12_indirect_dispatch_count, d3d12_execute_indirect_validation, d3d12_conservative_raster, d3d12_conservative_tier2, d3d12_conservative_tier3, d3d12_inner_coverage_guards, d3d12_inner_coverage_native, d3d12_bindless_churn, d3d12_bindless_churn_validated.

Separately, xg_xs fails 4 checks (XGSuggestSwizzleMode / XGCreateTextureComputer returns E_NOTIMPL, ...). The PR changes that behaviour but not the test. The PR's "Selected CTest suite: 23/23" did not include these tests.

2. Code from other open PRs, not declared

3. Other findings (code read, each checked in the source)

  • D3D12 list CPU descriptor handles are not translated. translate_cpu_descriptor_handle (d3d12_xs_device.cpp:3524) has no caller outside xs_proxy_mock_test.cpp. The XMem-backed heaps hand the title custom_cpu_start addresses, but the list proxy forwards OMSetRenderTargets, ClearRenderTargetView / ClearDepthStencilView and ClearUAV* handles unchanged.
  • The upload arena only grows. In upload_alloc (~1720-1740), chunk->used is never reset per frame or fence, so steady AllocateUploadMemory traffic adds an 8 MiB UPLOAD chunk each time the last one fills, until the device dies.
  • The upload fallback hands a CPU address out as a GPU VA. In upload_chunk_new (~1683-1691), when CreateCommittedResource or Map fails, gpu_base = the VirtualAlloc pointer. The comment says this is for mocks, but the path is live in the real build.
  • Silent S_OK for unmodelled slots: list slots not forwarded (return 0, ~1954) and queue slots past the table (return hr_to_u64(S_OK), ~1474). Real commands (e.g. CopyTextureRegionX) vanish after a first-call log line. The project rule is "fix, don't disable", and the comment calls these a refusal while they return success.
  • DirectStorage:
    • describe() reads the title's r.Name without the guarded_move the other title pointers get (dstorage.cpp:897-898).
    • A status entry enqueued on a closed queue is set to E_PENDING (:535) and then dropped (:674-679), so it never completes. The log line says so.
  • TLS index-0 move: reserve_tls_index0 runs on every gta6rt start, writes a DLL copy to %TEMP%, and when it fails --run / --init of any EXE with TLS is now refused. Antivirus blocking a fresh DLL in TEMP (as AGENTS.md notes for loader_test) would stop runs that worked before. A fallback or a clear message would help.

Checked and fine

  • check_no_game_data.py on all 85 changed files is clean.
  • No keys, decryption or online services. The doc links are public GDK reference pages.
  • compileall passes, and tests/test_cpu_feature_scan.py gives 22/22.
  • tests/test_text_write_line_endings.py fails the same way on main (tools/leonida_tui.py, tools/wave_diff.py), so that failure is not this PR's.

AI-assisted (Claude).

@lohant27-netizen

Copy link
Copy Markdown

Tested ba5f3b26a merged alone onto main 867d922f0 (clean merge) on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101), MSVC with SDK 10.0.26100, Release: builds, but 26 tests that pass on main fail (full ctest: 28 failures, against 2 on main without this PR).

What the failures share:

  • Pipeline creation: CreateGraphicsPipelineState returns E_FAIL (0x80004005). d3d12_draw fails at line 169, and d3d12_pso_validation reports [gfx: baseline]: layer returned 0x80004005, expected 0x00000000. The compute slot 62 also fails (d3d12_compute line 354). This takes down the draw, compute, MSAA, mesh, geometry, conservative-raster, bundle and pipeline-library tests.
  • shader_library fails at line 388: library.load(dir.string(), &error) && library.size() == 6. That's probably the root of the PSO failures, since this PR changes shader-library loading.
  • xg_xs: FAIL XGSuggestSwizzleMode returns E_NOTIMPL. The PR implements it, but the test still expects the stub.
  • d3d12_vulkan_device now fails earlier, at line 5770 (CreateMetaCommand(unknown_command, ...) == E_INVALIDARG && meta == nullptr), instead of the known tiles == 1.
  • Also failing: d3d12_descriptor, d3d12_execute_indirect_validation, d3d12_typeless_families, d3d12_f16_halves, d3d12_fspx_compute, d3d12_set0_compute, d3d12_stores_atomics, d3d12_bindless_churn(_validated) and d3d12_indirect_dispatch_count (the last passes on main now).

The description's "selected CTest suite: 23/23" doesn't include these. Separately, the claim line is still the template placeholder, and the PR covers areas with their own open PRs (Xbox device slots, TLS index 0 in #8379/#8622, xmem). Splitting it would make each part reviewable and testable on its own.

@Digit4w

Digit4w commented Nov 23, 2026

Copy link
Copy Markdown

Update for the new head 007863e1, pushed while I was writing the review above (same machine and setup). It restores the main load_index(dir, "", fail) in ShaderLibrary::load() (shader_library.h:760), so finding 1 is fixed: 21 of the 25 regressions now pass.

ctest -C RelWithDebInfo on 007863e1: 267/274 pass. Against main, 4 still regress:

  • xg_xs: the same 4 E_NOTIMPL checks as before. The PR changes the behaviour, not the test.
  • d3d12_descriptor: line 509: FAILED(device->CreateCommittedResource(&default_heap, ..., nullptr)).
  • d3d12_bindless_churn and d3d12_bindless_churn_validated: SEGFAULT. On ba5f3b26 they failed at PSO creation instead, so the crash was hidden behind finding 1.

Not counted: d3d12_depth_resolve and d3d12_vulkan_device fail on main too. crt_timed_wait failed once in the parallel full run and passed 3/3 on its own, so it is timing under load.

I have not reviewed the new runtime/shims/acphal.cpp (+197) or the ExecuteCommandListsX changes. Findings 2 and 3 above are unchanged by these commits.

AI-assisted (Claude).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants