diff --git a/README.md b/README.md
index fab7eb14b..b73800119 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ work on booting can start as soon as one is available to a developer.
| Audio banks (AWC: Opus, XMA2) | ✅ Exported whole. Opus repackaged **losslessly** as Ogg Opus; PCM (codec 0/2) as WAV; XMA2 decoded with ffmpeg. `--wav` adds 16-bit PCM WAV ([notes](docs/audio.md)) |
| Music/radio config | ? Measured. **1,589** audio-config records with exact durations and AWC stream ids; station grouping and content-id lists; no per-track start offsets ([notes](docs/audio_config.md)) |
| PE loader and import shims | ⚠️ Runs a stand-in executable end to end (`gta6rt --run`: CRT startup, statics, heap, files, threads, GDK imports through the shims, exit code back). Controllers through a GameInput shim on SDL3 (any controller SDL supports, rumble, DualSense trigger effects and lightbar; built when SDL3 is installed or with `-DLEONIDA_SDL3_FETCH=ON`, [notes](docs/gameinput.md)). `--trace-d3d12` logs every D3D12 call and its outcome for the first boot. Untested against the real executable |
-| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists, fences, descriptor heaps, committed, placed and reserved resources, render-target and depth views (3D targets included), texture views and samplers (2D, cube, 1D and 3D views, the depth and stencil planes of depth-stencil textures, packed formats such as B5G6R5, B4G4R4A4 and R9G9B9E5, buffer SRVs — raw, structured and typed; they go into the bindless set), root signatures, pipelines and query heaps, and draws run on Vulkan. Barriers, clears, uploads, copies (BC included), colour resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, checked on one GPU. The console-shaped command-list proxy, the measured `PresentX` queue slots (30/32, layout-detected) wired to the presentation core, and `AllocateUploadMemory` (list slot 148, a mapped-upload arena whose addresses translate to buffer device addresses in root descriptors and IA/SO views) cover the console-ABI surface the package measures. Still open: the console list tail and the descriptor-table record model ([plan](docs/d3d12_vulkan.md), [console ABI](docs/d3d12_xs_console_abi.md)) |
+| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists, fences, descriptor heaps, committed, placed and reserved resources, render-target and depth views (3D targets included), texture views and samplers (2D, cube, 1D and 3D views, the depth and stencil planes of depth-stencil textures, packed formats such as B5G6R5, B4G4R4A4 and R9G9B9E5, buffer SRVs — raw, structured and typed; they go into the bindless set), root signatures, pipelines and query heaps, and draws run on Vulkan. Barriers, clears, uploads, copies (BC included), colour resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, checked on one GPU. The console-shaped command-list proxy, the measured `PresentX` queue slots (30/32, layout-detected) wired to the presentation core, and `AllocateUploadMemory` (list slot 148, a mapped-upload arena whose addresses translate to buffer device addresses in root descriptors and IA/SO views) cover the console-ABI surface the package measures. Still open: the console list tail and the descriptor-table record model ([plan](docs/d3d12_vulkan.md)) |
| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists and bundles, fences, descriptor heaps, committed, placed and reserved resources (1D, 2D, 3D and cube textures), render-target and depth views, texture views and samplers (they go into the bindless set), buffer UAVs (written as address descriptors), root signatures, graphics (vertex, pixel, geometry) and compute pipelines, pipeline libraries, command signatures and query heaps. Draws (MSAA included), dispatches and indirect dispatches, barriers, clears, uploads, copies (BC included), colour and depth resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, as do DXGI swapchains and `PresentX` planes. Tested by contributors on NVIDIA, AMD and Intel GPUs ([#166](https://github.com/ItsNotRexed/Leonida/issues/166)). Not yet: mesh-shader draws, the draw state of indirect draws, stream output, and anything checked against the real executable ([plan](docs/d3d12_vulkan.md)) |
| Ray tracing (BVH) | ⚠️ In progress. `BuildRaytracingAccelerationStructure` builds BLASes and TLASes on the GPU in the console's XDXR BVH4 layout (the default; `LEONIDA_RT_AS=khr` uses Vulkan's own acceleration structures instead), which the translated shaders walk themselves through `image_bvh_intersect_ray` (all four triangle node types, TRI0-TRI3, with the barycentric remap byte); the GPU builder writes TRI0 leaves. Updates refit instead of rebuilding, and clone, compaction and the compacted/current postbuild sizes work; checked against a CPU reference on synthetic scenes. The build descriptions are recovered from the package's `XboxBvhBuilder.dll` ([notes](docs/xdxr.md)). The game's `*_bvh4.rpf` packs are measured: offline-built, dehydrated BLASes that rehydrate through that DLL with their geometry from the drawables in `levels.rpf` (measured on 8 of the 10 sampled BLAS; [notes](docs/bvh.md)). Not done in the builder: TRI1 pairing, BOX16 nodes, serialization. Open: whether the game rehydrates the packs or rebuilds them ([#313](https://github.com/ItsNotRexed/Leonida/issues/313)) |
| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists and bundles, fences, descriptor heaps, committed, placed and reserved resources (1D, 2D, 3D and cube textures), render-target and depth views, texture views, buffer UAVs and samplers (they go into the bindless set), root signatures, graphics (vertex, pixel, geometry) and compute pipelines, pipeline libraries, command signatures and query heaps. Draws (MSAA included), dispatches and indirect dispatches, barriers, clears, uploads, copies (BC included), colour and depth resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, as do DXGI swapchains and `PresentX` planes. Tested by contributors on NVIDIA, AMD and Intel GPUs ([#166](https://github.com/ItsNotRexed/Leonida/issues/166)). Not yet: mesh-shader draws, the draw state of indirect draws, stream output, and anything checked against the real executable ([plan](docs/d3d12_vulkan.md)) |
diff --git a/docs/README.md b/docs/README.md
index f9695b486..1fe20c5bf 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -66,11 +66,8 @@ method, scope and caveats. No game data is included.
| [d3d12_xs_surface.md](d3d12_xs_surface.md) | The 116-slot `d3d12_xs.dll` export surface; 83/83 standard GUIDs match the PC SDK. |
| [xdxr.md](xdxr.md) | `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) from `XboxBvhBuilder.dll`'s reads; stream records' offsets and defaults; offline statistics not in the package. |
| [d3d12_command_objects.md](d3d12_command_objects.md) | Measured command queue/list/fence/`PresentX` surface; verified vs prior art vs open. |
-| [d3d12_xs_console_abi.md](d3d12_xs_console_abi.md) | The D3D12.X console ABI the `d3d12_xs` shim must reproduce: device/queue/list vtable slots, command-list object fields and record encodings, root-argument SGPR rules, unified memory; sibling-layer measurements marked unverified here. |
| [xbox_d3d12_xs.md](xbox_d3d12_xs.md) | The `d3d12_xs` graphics ABI quoted from Microsoft's public GDK reference: root signatures, state objects, DXIL libraries, hit groups, shader cache sessions; which pages are missing or NDA-gated. |
| [runtime_imports.md](runtime_imports.md) | The 16 shipped modules' measured imports and shim/host/unimplemented split. |
-| [console_libraries.md](console_libraries.md) | The console-DLL surface a title can import (`d3d12_xs`, `xgameruntime`, `xmem`, `gameinput`, `xaudio2_9`, `dstorage_xs`, `xg_xs`, `AcpHal`, `chad`/`xapu`/`xcrdapi`): which are shimmed, classified or unbound. |
-| [import_routing.md](import_routing.md) | The bind order (shim → bundled → host → unimplemented), `owns_dll` and the pseudo-handle path, per-DLL outcome. |
| [xcl_compare.md](xcl_compare.md) | XCL's synthetic test title under `gta6rt --run` and under XCL (`tools/xcl_compare.py`): 5 of 50 checks pass here, both hangs are the documented manual-queue terminate deadlock, and each other difference mapped to an open item or a lead. |
| [gameinput.md](gameinput.md) | The GameInput shim on SDL3: `GameInputCreate` and the v0 `IGameInput`/`IGameInputDevice`/`IGameInputReading`/`IGameInputDispatcher` surface on any SDL gamepad, DualSense adaptive-trigger approximation and lightbar, force-feedback motors and trigger haptics through SDL's haptic API; 261 checks on virtual joysticks and a fake haptic backend; by hand on an Xbox Series X pad (Bluetooth) and a DualSense (USB). 261 checks on virtual joysticks and a fake haptic backend, not yet tried on a real pad. |
| [saves.md](saves.md) | Save containers: `JSAV` (index + JSON story save, byte-exact rebuild), `ASAV` header, `SLAYER1` packed copy (not decoded); `tools/saves.py` and import into the offline `XGameSave` folder; key hashes are case-sensitive joaat (`tools/save_keys.py`). |
@@ -87,7 +84,6 @@ method, scope and caveats. No game data is included.
| [embedded_shaders.md](embedded_shaders.md) | DXBC containers embedded in the package's DLLs: 52 in `XboxBvhBuilder.dll` (console `FSSM` via the `XDAT`/`XBCH` record; 51/52 pass `spirv-val` today) and 29 `ACCC`/`FSPX` in the FidelityFX upscaler; the scan/extract tool and the one rule still missing. |
| [shader_library.md](shader_library.md) | The pipeline library in `shaders.rpf`'s zlib part, which the carve doesn't read: 25,471 graphics and 2,693 compute pipeline records (stage slots: PS, VS, MS) and 21,522 native programs, 21,509 of them pipeline builds of 6,522 carved shaders (named by their `HASH` digest); `tools/shader_library.py`. |
| [shader_inputs.md](shader_inputs.md) | Inputs that specific game shaders need to be right, as a first check for a black frame or a device-lost: the studio-shot lighting shader's 512-byte light records, eight-light loop, plane count at +0x4C (#1892 said +0x40), profile table and shadow-strength byte; the ACES LUT bakes' two tone-curve splines (reference order at +0x00, points-first at +0x70 behind the +0x118 switch), the +0x13C luminance mode and the quasi-log addressing (#1896); the sky LUT order and the +0xD0 dword that picks RGB9E5 or float outputs (#1897); the shared atmosphere constant buffer, its table slots (+0x220, +0xC60) and the layout with the two scale-height dwords no pass consumes (#3990). |
-| [hello_pixels.md](hello_pixels.md) | The package-free sibling: a synthetic quad drawn through the same `vk_harness` mesh mode, shaders hand-written in SPIR-V assembly; `tools/hello_pixels.py` checks coverage and probe pixels against a closed form. |
| [sandbox.md](sandbox.md) | Placed world props through one translated VS/PS pair with a real camera, TTPF albedo and the game's sampler: 442 of 446 draws textured; fly/walk/drive window, `tools/sandbox.py --check`. |
| [coder.md](coder.md) | The compressed mass in `story000_script.rpf`: entry framing (`align16(entry+8)` payload), the 32-value tag alphabet, deflate-shaped but proprietary, variable-length 7/8-bit LSB-first codes with no stored table, and the `n7 = 116..127` search that finishes it. |
| [mission_logic.md](mission_logic.md) | Mission state tables: 0x20 record layout (band counter, byte offsets), the 64-byte pool element with world transforms, case-folding joaat keys, 53.5 % of states named, 113 state-set clusters covering 82.4 % of files. |
diff --git a/docs/boot.md b/docs/boot.md
index 62824b588..b6708fdc3 100644
--- a/docs/boot.md
+++ b/docs/boot.md
@@ -1,23 +1,8 @@
# First boot: the runbook and the two traces
-**Status: first run done, on the only executable obtained so far.** A `game_scarlett_master.exe` (2,725,424 bytes)
-reached the loader from outside the test corpus and ran end to end: dry-run mapped it at its preferred base with
-every import bound (11 shim / 164 host, 0 unimplemented), `--init` ran its three TLS callbacks, and `--run` ran its
-entry point to a clean `exit 0`. Its debug output identifies it as a **packaging verification probe, not the
-engine** — it scans a payload root and compares file/byte/archive counts against a manifest. With the probe's own
-`GetModuleFileNameW` answered for the mapped image (see below), run against the 1.0.2.1 payload it verified
-104/104 files, 223,534,748,018 bytes, rpf 22/22, ttpf 57/57, png 5/5, dll 16/16, bad magic 0: **verdict PASS**.
-The engine binary itself still is not in the corpus (RT-5), so the D3D12 half of this page is unexercised. Nothing
-here quotes game data; a real trace stays on the player's machine.
-
-The package's own metadata agrees: `MicrosoftGame.Config` declares `Identity Name="GTA6.Probe.PC"` and its
-`ExecutableList` names `game_scarlett_master.exe` as the **only** executable, so this payload is a packaging
-verification build that carries the real payload's shape (its counts match the probe's manifest exactly) rather
-than a retail dump missing its engine. All eleven bundled DLLs also initialise cleanly through `gta6rt --init`.
-
-One shim gap the probe exposed, now closed: `GetModuleFileName` was host-bound, so a mapped image asking for its
-own path got `gta6rt.exe`'s; the bundled-module ops now expose the main image and each module's load path, and
-`GetModuleHandle(nullptr)`/`GetModuleFileNameA/W` answer for mapped images first.
+**Status: prepared, not yet run against the retail executable.** The package in the repository's test corpus does
+not contain `game_scarlett_master.exe` (RT-5), so this page is the procedure and the trace tool for the day it
+arrives. Nothing here quotes game data; a real trace stays on the player's machine.
## 1. What the first boot produces
diff --git a/docs/console_libraries.md b/docs/console_libraries.md
deleted file mode 100644
index cce2facef..000000000
--- a/docs/console_libraries.md
+++ /dev/null
@@ -1,224 +0,0 @@
-# Console libraries: what the console build can import, and how the loader answers
-
-Status: catalogue, sourced. This page lists the console-only or console-flavoured DLLs an Xbox
-Series title's imports can name, what is measured about each one's export surface, and what
-`gta6rt` does with each today. It is the module-level counterpart to
-[runtime_imports.md](runtime_imports.md) (what the 16 shipped DLLs import) and to
-[d3d12_vulkan.md §7](d3d12_vulkan.md#7-prior-art-and-measured-xbox-abi) (the measured ABI inside
-the main one, `d3d12_xs.dll`).
-
-Basis tags:
-
-- **This repo** — verifiable in this tree: a `SHIM_TABLE` in `runtime/shims/*.cpp`, the
- `classify()` list in `runtime/shims/registry.cpp`, the binding order in
- `runtime/src/pe_loader.cpp`, or a measurement recorded in another page here.
-- **Sibling-layer measurement** — a fact folded in from `d3d12_vulkan.md` §7, measured elsewhere
- by running the console DLLs or a retail title behind a compatibility layer. Paraphrased, not
- re-measured here; no external repository is named on this page.
-
-Scope limit: the game executable is not in the package, so its own import table is unmeasured.
-The list below is the surface a console title *can* name — from sibling-layer inventories of the
-console DLLs and from one retail title's run — not a claim about what this title does.
-
-## 1. How an import binds today
-
-`Loader::resolve` in `runtime/src/pe_loader.cpp` binds each import in a fixed order (**this
-repo**):
-
-1. **Shim registry** — `rt::shims::find(dll, name)`. Ordinal imports look up `"#N"`, so a shim
- serves an ordinal import only if its table carries the `"#N"` spelling.
-2. **Bundled module** — a DLL of the same name in `--game-dir`, mapped by the same loader (the
- `module` count of the dry run; the CRT families are deliberately excluded and always take the
- host copy).
-3. **Host** — `LoadLibraryEx` on `System32` plus `GetProcAddress`, by name or ordinal.
-4. **Unimplemented thunk** — a generated stub whose behaviour `LEONIDA_UNIMPLEMENTED` sets
- (`log`/`fail`/`stop`; see
- [runtime_imports.md](runtime_imports.md#when-an-unimplemented-import-is-called)). Under `fail`,
- `classify()` in `runtime/shims/registry.cpp` decides by DLL and name which imports return
- `E_NOTIMPL`.
-
-A module the registry serves at all and that is not a host DLL is **owned** (`owns_dll`): a
-title's `LoadLibrary`/`GetModuleHandle` on it gets a pseudo-handle and its `GetProcAddress`
-resolves through the registry by name or `"#N"`, with unknown names returning
-`ERROR_PROC_NOT_FOUND`
-([runtime_imports.md](runtime_imports.md#run-time-loaded-modules)). Owned today:
-`d3d12_xs.dll`, `xgameruntime.dll`, `xmem.dll` and `gameinput.dll` — the modules with a
-`SHIM_TABLE` entry.
-
-The registry also holds tables under `kernel32.dll`, `kernelbase.dll`, the `api-ms-*` sets,
-`msvcrt.dll` and `ucrtbase*.dll` (file system, library loader, process entry/exit). Those are
-host DLLs a few functions are replaced on, not owned console modules, so they are not in the
-list below.
-
-## 2. The modules
-
-| Module | What it is | Leonida today | Status |
-|---|---|---|---|
-| `d3d12_xs.dll` | Console D3D12 runtime front end | 4 names registered | partial shim |
-| `xgameruntime.dll` | GDK runtime (task queues, users, store, packaging) | 39 names registered; 2 impl classes | partial shim |
-| `xmem.dll` | Console tracked allocator / virtual-memory API | all 4 measured imports implemented | shimmed |
-| `gameinput.dll` | GameInput v0, controller input | `GameInputCreate` registered (SDL3 build) | shimmed |
-| `xaudio2_9.dll` | Console XAudio2 2.9 | no table; host binds it by ordinal | classified only |
-| `dstorage_xs.dll` | Console DirectStorage | no table; `DStorageGetFactory` classified | classified only |
-| `xg_xs.dll` | Texture layout helpers | nothing | unhandled |
-| `AcpHal.dll` | Audio co-processor HAL | nothing | unhandled |
-| `chad`, `xapu`, `xcrdapi`, `*legacy` | DSP, APU and card-API modules; names only | nothing | unhandled |
-
-### `d3d12_xs.dll`
-
-The console D3D12 runtime's front end: a thin DLL that loads the user-mode driver, which owns the
-device and command objects (**sibling-layer measurement**;
-[d3d12_xs_surface.md](d3d12_xs_surface.md) records the reported 116-export surface — 23 functions
-plus 93 GUID data exports — and which of the 83 standard GUIDs match the PC SDK). Beyond the
-standard `D3D12*` names its exports include `D3D12XboxCreateDevice` — the device entry point, call
-shape `(adapter, params, riid, out)` with a 24-word params block that is only logged —
-`D3D12XboxCreateSyntheticDevice` and `D3D12XboxSetProcessDebugFlags` (**sibling-layer
-measurement**).
-
-Leonida registers four names (**this repo**, `runtime/shims/d3d12_xs.cpp`):
-`D3D12SerializeVersionedRootSignature`, `D3D12SerializeRootSignature` and
-`D3D12CreateRootSignatureDeserializer`, each forwarded to the host `d3d12.dll` after the Xbox
-high flag byte is cleared on a copy; and `D3D12XboxCreateDevice`, which returns an Xbox-ABI proxy
-over the PC `ID3D12Device` — or over the Vulkan-backed device with `LEONIDA_D3D12=vulkan` — with
-the measured slot overrides (device slot 62 as compute-PSO creation, slot 76 as texture creation,
-descriptor-heap start handles returned in RAX). The other 19 function exports, including
-`D3D12XboxCreateSyntheticDevice` and `D3D12XboxSetProcessDebugFlags`, are not registered.
-`classify()` marks the `D3D12Create*`/`D3D12Serialize*` families, the two debug entries and both
-`D3D12XboxCreate*Device` names as HRESULT; `D3D12XboxSetProcessDebugFlags` is deliberately left
-out because its return was not measured (**this repo**, `registry.cpp`).
-
-The COM surface behind the device — queue, command list, fence, `PresentX` — is vtable work, not
-an import problem; it is tracked in [d3d12_vulkan.md](d3d12_vulkan.md),
-[d3d12_command_objects.md](d3d12_command_objects.md) and
-[d3d12_xs_console_abi.md](d3d12_xs_console_abi.md). The presentation core
-(`runtime/shims/xbox_present.h`) is wired to the measured `PresentX` queue slots (30, or 32 on the
-newer layout) in `d3d12_xs_device.cpp`; the plane and parameter struct layouts are still provisional.
-
-### `xgameruntime.dll`
-
-The GDK runtime. Not in the package; GDK titles reach it either by import or by `LoadLibraryW` +
-`GetProcAddress` of `InitializeApiImpl`, `InitializeApiImplEx`, `InitializeApiImplEx2`,
-`QueryApiImpl` and `UninitializeApiImpl`, which is how the package's `libHttpClient.GDK.dll` and
-`XCurl.dll` do it (**this repo**,
-[runtime_imports.md](runtime_imports.md#run-time-loaded-modules)).
-
-Leonida registers 38 names plus `GameInputCreate` (**this repo**,
-`runtime/shims/xgameruntime.cpp`): the five loader entry points,
-`XGameRuntimeInitialize`/`Uninitialize`, five `XSystem*` queries, three `XPackage*` queries, the
-15-function `XTaskQueue*` set and the 8-function `XAsync*` set, both on the vendored
-`third_party/xtaskqueue`. `QueryApiImpl` serves `XThreadingImpl` and `XErrorImpl` and answers
-every other class with the documented "not provided" error so the first boot lists what is
-missing. `classify()` marks the `XAsync*`/`XTaskQueue*`/`XUser*`/`XStore*`/`XGameSave*`/
-`XPackage*`/`XGameUi*` families as HRESULT except the members the public pages document as
-`void`/`bool`/`int` (**this repo**, `registry.cpp`).
-
-### `xmem.dll`
-
-The console's tracked allocator. The only console module whose whole measured import surface is
-implemented (**this repo**, `runtime/shims/xmem.cpp`): `XMemAlloc`/`XMemFree` on the 64-byte
-aligned CRT heap, `XMemVirtualQuery(process, address, out64)` filling the
-`MEMORY_BASIC_INFORMATION` prefix and zeroing the rest of the measured 64-byte output, and
-`XMemGetWorkingSetStatistics(kind, out)` writing the process working set at +8 of the measured
-output. All four names are exactly the set the package's DLLs import
-([runtime_imports.md](runtime_imports.md)).
-
-A sibling layer additionally measured a title's physical-page calls on this module: 64 KiB pages,
-with runs of consecutive pages mapping contiguously inside one unified region and scattered or
-explicitly addressed mappings refused (**sibling-layer measurement**). Nothing in the package
-imports them and no such names are registered; see section 3.
-
-### `gameinput.dll`
-
-GameInput v0. The console build's ordinal 1 is `GameInputCreate` (**sibling-layer
-measurement**).
-
-Leonida registers `GameInputCreate` by name under both `gameinput.dll` and `xgameruntime.dll`:
-the PC API lives in the former, the GDK links it through the latter, and which the executable
-imports is unknown until it exists (**this repo**, `runtime/shims/gameinput.cpp`; the shim's API
-surface is [gameinput.md](gameinput.md)). The registration is a name only — no `"#1"` entry — so
-an ordinal-1 import would not hit the table (section 3). The shim is optional and built only with
-SDL3; without it the import falls through to the host DLL or the unimplemented thunk as before.
-
-### `xaudio2_9.dll`
-
-Console XAudio2 2.9. Ordinal 1 is `XAudio2Create` (**sibling-layer measurement**). Voices accept
-the console formats — XMA/XMA2 and an Opus format tag `0x704F` — and a `CO_E_NOTINITIALIZED`
-from the system XAudio2 is retried after `CoInitializeEx` on the calling thread; forwarding to
-the system XAudio2 2.9 works with those two quirks (**sibling-layer measurement**).
-
-Leonida has no table for it (**this repo**). The package's `Bink2Scarlett.dll` imports
-`XAudio2_9.dll` ordinal 1 and the dry run binds it to the host copy by ordinal — 57 host, 0
-unimplemented ([movies.md](movies.md), [runtime_imports.md](runtime_imports.md)) — so creation by
-ordinal resolves today, but the console voice formats and the retry quirk are not reproduced: a
-voice created with XMA/XMA2 or `0x704F` would reach the host unremapped. `classify()` marks
-`xaudio2_9.dll`/`xaudio2_9redist.dll` `XAudio2Create` as HRESULT — by name; the ordinal lookup
-classifies as Other (**this repo**, `registry.cpp`).
-
-### `dstorage_xs.dll`
-
-Console DirectStorage; named in the sibling export inventory with no export list measured
-(**sibling-layer measurement**). Leonida has no table; `DStorageGetFactory` is classified HRESULT
-under both `dstorage.dll` and `dstorage_xs.dll` (**this repo**, `registry.cpp`).
-
-### `xg_xs.dll`
-
-Texture layout helpers. The sibling export inventory names `XGCreateTexture2DComputer` and
-`XGComputeOptimalSwizzleMode` (**sibling-layer measurement**); prior-art text folded into
-[d3d12_vulkan.md](d3d12_vulkan.md#35-root-signature-to-user-sgprs) also names
-`XGComputeTexture2DLayout` as the module's untiling reference. Leonida has no table and no
-classification (`xg_xs.dll!XGCreateTexture2DComputer` is pinned as Other in
-`unimplemented_policy_test`; **this repo**). Nothing in the package imports it.
-
-### `AcpHal.dll`
-
-The audio co-processor HAL. The sibling export inventory names `ApuAlloc`, `ApuFree`,
-`ApuMapVirtualAddress`, `ApuIsVirtualAddressValid`, `AcpHalCreate`,
-`AcpHalAllocateShapeContexts` and `AcpHalReleaseShapeContexts` (**sibling-layer measurement**).
-Leonida has nothing for it (`acphal.dll!AcpHalCreate` is pinned as Other in
-`unimplemented_policy_test`; **this repo**).
-
-### `chad`, `xapu`, `xcrdapi`, `*legacy` variants
-
-A retail title booted to its menu and lobby through console-library stand-ins, and its
-console-only library set added `chad` (`XDsp*` exports), `xapu` (`XApu*` exports), `xcrdapi` and
-`*legacy` DLL variants to the modules above (**sibling-layer measurement**). These are names
-only: no export list, call shape or argument is measured, and Leonida has nothing for them.
-
-### Not console modules
-
-`d3d12.dll`, `dxgi.dll` and the `api-ms-*` sets are ordinary host bindings, not console modules.
-The package's own middleware (`Bink2Scarlett.dll`, `XboxBvhBuilder.dll`, the FidelityFX pair,
-`libHttpClient.GDK.dll`, `XCurl.dll`, the CRT set) binds as `module`, with the CRT families
-deliberately host-bound; their imports are catalogued in
-[runtime_imports.md](runtime_imports.md), not here. `xgs12_10.dll`, the user-mode driver a real
-`d3d12_xs.dll` loads (recorded in [d3d12_vulkan.md](d3d12_vulkan.md) from prior-art text), is not
-an import target a title names; Leonida replaces the whole stack rather than providing it.
-
-## 3. Gaps
-
-What a real title is known to call that Leonida does not yet cover (**sibling-layer
-measurement** unless noted):
-
-- **The whole `xg_xs`, `AcpHal`, `dstorage_xs`, `chad`, `xapu`, `xcrdapi` and `*legacy`
- surface.** No table, no classification. A retail run reached its menu and lobby with stand-ins
- for them; for this title, whether any is imported at all is unknown until the executable exists.
-- **The `xaudio2_9` quirks.** Creation by ordinal already binds to the host (**this repo**), but
- the XMA/XMA2 and Opus `0x704F` voice formats and the `CoInitializeEx` retry would need a shim
- that wraps or remaps — the host sees console format tags it does not know.
-- **The unregistered `d3d12_xs` functions.** 4 of the 23 function exports are registered; the
- rest — `D3D12XboxCreateSyntheticDevice`, `D3D12XboxSetProcessDebugFlags`, the `DXGIX*`
- present/frame-notification functions, `D3D12UploadCustomMicrocodeX`-type console entries —
- would hit the unimplemented thunk. Two are at least classified (`D3D12XboxCreate*Device` →
- HRESULT under `fail`).
-- **`xmem` physical-page calls.** A title's physical-page API uses 64 KiB pages and contiguous
- mappings inside one unified region; the shim covers only the four allocator/query names the
- package measured.
-- **Ordinal-only registrations.** The shim tables serve names; an ordinal import is looked up as
- `"#N"`. `gameinput.dll` and `xaudio2_9.dll` ordinal 1 are the measured console entry points,
- and neither has a `"#1"` entry — a static ordinal import therefore skips the shim and binds to
- the host DLL where one exists (as `xaudio2_9.dll!#1` does today; **this repo**), and a
- `GetProcAddress` for ordinal 1 on an owned module returns `ERROR_PROC_NOT_FOUND`.
-- **Run-time loading of bundled middleware.** A title that `LoadLibrary`s a package DLL such as
- `Bink2Scarlett.dll` gets the host loader, which maps the Xbox build without the registry's
- bindings for its own console imports — recorded as an open item in
- [runtime_imports.md](runtime_imports.md#run-time-loaded-modules) (**this repo**).
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index 00056e2da..5a214e325 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -375,10 +375,9 @@ section 3.5a), and the console list has methods well past the PC tail: 71, 73, 8
FSR DLL.
Slot 148 matters beyond the builder: the address it returns is written by the CPU and passed unchanged to the GPU
-as a root SRV address, so console upload memory has the same address for the CPU and the GPU. On a PC the two
-address spaces differ, so `d3d12_xs_device.cpp` carves a bump arena out of persistently-mapped UPLOAD-heap
-buffers: the title writes the mapped memory and the six root descriptor setters and the IA/SO view setters
-translate the CPU pointer to the chunk's buffer device address before forwarding.
+as a root SRV address, so console upload memory has the same address for the CPU and the GPU. A replacement must
+return memory whose CPU pointer is also a valid GPU address (for this layer: inside the arena of
+[d3d12_vulkan.md §3.3](d3d12_vulkan.md)).
The function at `0xd580` uses the 71/73 pair instead of the slot-146 barrier when the byte at RVA `0xd773c` is set.
That byte is one of seven bools at `0xd7738`–`0xd773e` in zero-initialised `.bss`. The only accesses to them in
diff --git a/docs/d3d12_xs_console_abi.md b/docs/d3d12_xs_console_abi.md
deleted file mode 100644
index 39f570b28..000000000
--- a/docs/d3d12_xs_console_abi.md
+++ /dev/null
@@ -1,271 +0,0 @@
-# The D3D12.X console ABI: vtable slots, object fields and record encodings
-
-Status: measured-facts note, sourced. This page collects the Xbox Series (`d3d12_xs`) ABI facts a
-replacement runtime must reproduce — vtable slot numbers, object field layouts and the inline
-record encodings the console SDK writes into a command-list object — for the layers that are still
-missing: command lists, root arguments, descriptor heaps and present. It complements
-[d3d12_vulkan.md](d3d12_vulkan.md) (the Vulkan layer plan) and
-[d3d12_command_objects.md](d3d12_command_objects.md) (what this package's own DLLs measure).
-
-Provenance rules for this page, stated once:
-
-- **Sibling layer** — measured by a sibling open-source layer on retail Series titles and
- published as findings. Not independently reproduced here; treat every such claim as unverified
- on this package.
-- **Package** — measured on this package's shipped DLLs (`XboxBvhBuilder.dll`,
- `amd_fidelityfx_upscaler_xbox.dll`); see
- [d3d12_command_objects.md](d3d12_command_objects.md) §§3.3–3.5a.
-- **SDK** — the public Windows SDK `d3d12.h` order, for contrast.
-- **Unconfirmed** — consistent with the surrounding facts but not yet measured anywhere we can
- check.
-
-All slot numbers below are absolute vtable indices including `IUnknown` (0–2) and the
-`ID3D12Object`/`ID3D12DeviceChild`/`ID3D12Pageable` base slots, as in
-[d3d12_command_objects.md](d3d12_command_objects.md) §2.
-
-## 1. Device (`ID3D12DeviceX` over the PC `ID3D12Device` layout)
-
-The console device keeps the PC slot order where measured, with extra console methods placed in
-slots the PC chain uses for newer interfaces, plus a tail of console-only methods. Slots marked
-**Package** were called by the shipped upscaler or BVH-builder DLLs with the stated shapes; the
-rest are **Sibling layer** measurements.
-
-| Slot | Method | Evidence |
-|---:|---|---|
-| 8, 48 | `CreateCommandQueue` variants | Sibling layer |
-| 9 | `CreateCommandAllocator` | Sibling layer |
-| 10, 60 | `CreateGraphicsPipelineState` variants | Sibling layer |
-| 12 | `CreateCommandList` | Sibling layer |
-| 14 | `CreateDescriptorHeap` | Package + sibling layer |
-| 15 | `GetDescriptorHandleIncrementSize` | Package + sibling layer |
-| 17, 18, 19 | `CreateConstantBufferView` / `CreateShaderResourceView` / `CreateUnorderedAccessView` | Package + sibling layer |
-| 22 | `CreateSampler` | Sibling layer |
-| 23, 24 | `CopyDescriptors` / `CopyDescriptorsSimple` | Package + sibling layer |
-| 25 | `GetResourceAllocationInfo` | Sibling layer |
-| 29, 44 | `CreatePlacedResource` variants | Sibling layer |
-| 38 | `GetCopyableFootprints` | Package + sibling layer |
-| 41 | `CreateCommandSignature` | Sibling layer |
-| 52 | `SetDebugFlags` | Sibling layer |
-| 55 | derived pipeline state | Sibling layer |
-| 56, 57, 66, 67 | serialize / deserialize pipeline state | Sibling layer; the package's upscaler calls 67 as `DeserializeComputePipelineStateX` (console desc, `IID_ID3D12PipelineState`) — Package |
-| 61 | `CreateSamplerX` | Sibling layer |
-| 62 | `CreateComputePipelineState` with two extra args: `(desc, NULL, NULL, riid, ppv)`; the PC interface presents `CreateStateObject` at this slot | **Confirmed here**: Package ([d3d12_vulkan.md](d3d12_vulkan.md) §7) + sibling layer |
-| 73 | `CreateCommandListX` | Sibling layer |
-| 74, 75 | register / unregister page pool | Sibling layer |
-| 76 | `CreateCommittedResource`, same signature family as PC slot 27 | **Confirmed here**: Package ([d3d12_vulkan.md](d3d12_vulkan.md) §7) + sibling layer |
-| 78–81 | frame pacing: `SetFrameIntervalX`, `ScheduleFrameEventX`, `WaitFrameEventX`, `GetFrameStatisticsX` | Sibling layer |
-| 86 | `CreatePipelineStateX` | Sibling layer |
-
-The slot-76 console resource descriptor is **larger than 52 bytes** (sibling layer); the package's
-upscaler DLL writes a 3 at offset +52 (Package). The `Layout` field sits at +44; value `0x101`
-denotes a 2D texture ([d3d12_vulkan.md](d3d12_vulkan.md) §7; a sibling layer measured the same on
-retail titles).
-
-### 1.1 Two runtime layouts
-
-Two console runtime layouts exist: an older game-OS layout and a newer one in which the queue and
-list slots shift **+2** (sibling layer). Detection rule (sibling layer): if a fence object is
-passed to queue slot 16/17, the layout is newer — on the older layout those slots are
-`GetTimestampFrequency`/`GetClockCalibration`. Which layout this package's titles were built
-against is **unverified here**.
-
-## 2. Descriptor heap
-
-| Slot | Fact | Evidence |
-|---:|---|---|
-| 9, 10 | `GetCPUDescriptorHandleForHeapStart` / `GetGPUDescriptorHandleForHeapStart` return the 8-byte handle in `rax` on console; the PC convention is a hidden out-pointer | **Confirmed here**: Package + sibling layer |
-
-Descriptor contents (sibling layer): CBV/SRV/UAV heaps use **32-byte slots** in unified memory — a
-T# is 8 dwords, a V# 4 dwords, inside the 32-byte slot; sampler heaps use **16-byte slots**. The
-CPU handle, GPU handle and the address in title memory are the same value.
-
-## 3. Resource
-
-| Slot | Fact | Evidence |
-|---:|---|---|
-| 11 | `GetGPUVirtualAddress` returns the title-memory address | Sibling layer; consistent with the package measurement that a CPU pointer from list slot 148 is passed unchanged as a root SRV GPU address ([d3d12_command_objects.md](d3d12_command_objects.md) §3.3a) |
-
-## 4. Command queue
-
-Measured queue slots (sibling layer); the queue follows the two-layout rule of §1.1:
-
-| Method | Older layout | Newer layout |
-|---|---:|---:|
-| `Signal` | 14 | 16 |
-| `Wait` | 15 | 17 |
-| `GetTimestampFrequency` | 16 | 18 |
-| `GetClockCalibration` | 17 | — (shifted) |
-| `GetDesc` | 18 | — (shifted) |
-| `SignalX` | 23 | 25 |
-| `PresentX` | 30 | 32 |
-
-Console-only queue methods the layer does not model should return `S_OK` and log the call:
-title frame pacing flows through some of them (sibling layer).
-
-## 5. Command list object
-
-Measured by a sibling layer with a fake list — a 600-slot vtable of logging thunks — that let the
-console SDK's inline writers record into the object (sibling layer; the package's BVH builder and
-upscaler independently measured `+0x18`, `+0x28`, `+0x30`, `+0x140`, `+0x141`, `+0x344` and
-`+0x544` — Package, [d3d12_command_objects.md](d3d12_command_objects.md) §§3.4–3.5a).
-
-### 5.1 Object fields
-
-| Offset | Field | Evidence |
-|---:|---|---|
-| +0x00 | vtable pointer | Package + sibling layer |
-| +0x18 | inline write pointer | Package + sibling layer |
-| +0x28 | dispatch-record limit | Package + sibling layer |
-| +0x30 | buffer end | Package + sibling layer |
-| +0x140 | dirty flag byte, set when record header bits 31:30 are 0 | Package + sibling layer |
-| +0x141 | pipeline flag byte, taken from bit 20 of the pipeline's record word at +0x20 | Package + sibling layer |
-| +0x143 | flag byte; read by titles, written only by the runtime | Package (read 31+1 sites, never written) + sibling layer |
-| +0x344 + 4·i | header word of root parameter *i* | Package + sibling layer |
-| +0x544 | current pipeline record, 16 bytes | Package + sibling layer |
-
-### 5.2 Inline record encodings
-
-The console SDK's inline writers emit a record only while the write pointer is below the buffer
-end; on a full buffer they call the vtable method the record stands for (Package + sibling layer).
-
-| Record | Encoding | Evidence |
-|---|---|---|
-| Pipeline | 28 B: `[PSO ptr][D3D12Core ptr][8 B flags][4 B]` | Package + sibling layer |
-| Root parameter *i* | header at +0x344+4·i = `0xC0000000 \| i<<10` + const-offset·4 (bits 9:2) + `(count-1)<<16` | Sibling layer; header table itself confirmed Package |
-| Root descriptor | header + 64-bit address = 12 B | Package + sibling layer |
-| Root constants | one constant = 8 B; *n* constants = 4+4·*n* B | Package + sibling layer |
-| Descriptor table | header + one 32-bit word = the 32-bit GPU address of the first descriptor | Sibling layer |
-| `Dispatch` | `0x4002C400` (or `(0x1000BA00 \| flag) << 2`) followed by x, y, z = 16 B | Package + sibling layer |
-| Indirect dispatch | `0x4003CC00`, 20 B total | Package (five-word form with W `0x8020`/`0x20`) + sibling layer |
-| `IASetPrimitiveTopology` | `0xC000B600 \| topology` | Sibling layer |
-
-### 5.3 Method slots
-
-| Slot | Method | Evidence |
-|---:|---|---|
-| 9 | `Close` | Sibling layer |
-| 10 | `Reset` | Sibling layer |
-| 12 | `DrawInstanced` | Sibling layer |
-| 13 | `DrawIndexedInstanced` | Sibling layer |
-| 14 | `Dispatch` | Package + sibling layer |
-| 15 | `CopyBufferRegion` | Package + sibling layer |
-| 16 | `CopyTextureRegion` | Sibling layer |
-| 17 | `CopyResource` | Sibling layer |
-| 19 | `ResolveSubresource` | Sibling layer |
-| 20 | `IASetPrimitiveTopology` | Sibling layer |
-| 25 | `SetPipelineState` | Package + sibling layer |
-| 26 | `ResourceBarrier` | Package + sibling layer |
-| 32 | `SetDescriptorHeaps` | Package + sibling layer |
-| 33 | `SetComputeRootSignature` | Package + sibling layer |
-| 37, 39 | `Set*RootConstant(s)` | Package + sibling layer |
-| 41, 43, 45 | `Set*RootDescriptor*` / table | Package + sibling layer |
-| 48 | `IASetVertexBuffers` | Sibling layer |
-| 51 | `ClearDepthStencilView` | Sibling layer |
-| 80 | `ExecuteIndirect` | Sibling layer (note: the package measured slot 80 as a console-only call, a `Dispatch`-with-extra-word shape; slot assignments past 61 differ between the two sources — unconfirmed) |
-| 83 | `CopyTextureRegionX` (older layout) | Sibling layer; the package measured a `CopyTextureRegion`-shaped call at slot 85 — consistent with the newer layout (+2) |
-| 108 | `ResolveSubresourceRegion` | Sibling layer |
-| 146 | enhanced `Barrier` | **Confirmed here**: Package (console slot 146 takes one `D3D12_BARRIER_GROUP`; PC equivalent is GCL7 slot 80) |
-| 148 | `AllocateUploadMemory` `(size, alignment)`; the returned CPU pointer is the GPU address in unified memory | Package + sibling layer |
-
-Layout shift on the list tail (sibling layer): from `CopyTextureRegionX` on, methods sit two slots
-later in the newer layout — newer→older pairs 85→83, 86→84, 87→85, 90→88, 91→89, 92→90, 95→93,
-96→94.
-
-### 5.4 DMA command list
-
-| Slot | Method | Evidence |
-|---:|---|---|
-| 9 | `Close` | Sibling layer |
-| 10 | `Reset` | Sibling layer |
-| 11 | `CopyBufferRegion` | Sibling layer |
-| 12 | `CopyTextureRegion` | Sibling layer |
-| 13 | `CopyResource` | Sibling layer |
-
-## 6. Root arguments
-
-Sibling-layer measurements on retail titles:
-
-- **Compute.** The root arguments are a packed argument array in title memory; `io[0:1]` of the
- dispatch record carries its address.
-- **Graphics.** VS and PS receive root arguments in user SGPRs `s8..s31` — `s0..s7` are
- driver-reserved; `s[4:5]` of a VS holds the fetch shader — 24 user SGPRs in total. Arguments
- past those go through a table whose address is in `s[0:1]`.
-- **Descriptor tables** take 4 bytes in the packed array: the record is the parameter header plus
- one 32-bit word, the 32-bit GPU address of the first descriptor.
-- **Root CBV.** The shader builds its own V#; a measured example sets `DST_SEL xyzw` plus the
- format word from `s11`.
-
-## 7. Resource barriers (list slot 26)
-
-Sibling layer: console aliasing barriers behave as "any resource" barriers — both resource
-pointers are null — where the PC API only allows those between placed or reserved resources.
-Console-only state bits must be dropped before forwarding, or `Close` fails `E_INVALIDARG`.
-
-## 8. Unified memory
-
-Titles expect graphics memory where the CPU address equals the GPU address (sibling layer;
-consistent with the package's slot-148 measurement in §3).
-
-- The sibling layer backs this with a fully-committed sub-4 GiB region at a 4 GiB-aligned virtual
- address, opened via `ID3D12Device3::OpenExistingHeapFromAddress`. Measured limits: a partial
- commit is rejected; a full 4 GiB is rejected; 4095 MiB works.
-- For reservations above 4 GiB the measured technique is: reserve with `VirtualAlloc2`
- `MEM_RESERVE_PLACEHOLDER`, split chunks with `VirtualFree` `MEM_PRESERVE_PLACEHOLDER`, back each
- chunk with a `SEC_COMMIT` section mapped via `MapViewOfFile3` `MEM_REPLACE_PLACEHOLDER`. Each
- chunk opens as its own heap with GPU/CPU coherence at the title's address. `SEC_RESERVE`
- sections are refused even when fully committed.
-- Buffers in unified memory are placed resources at 64 KiB alignment. A buffer at a
- non-64 KiB-aligned console address is placed from the 64 KiB boundary below it and the copy
- paths add the delta.
-- `Map` of a unified-memory resource returns its console address.
-- GPU-owned textures (resources with RT/DS/UAV flags) go into "arenas" — default heaps standing
- for ranges of title addresses — because titles alias several textures at one address.
-
-## 9. `PresentX`
-
-Sibling layer: one frame is presented per console queue method call (`PresentX`, §4). The
-presented back buffer is detected by tracking render-target binds (RTV creation and
-`OMSetRenderTargets`) and `ExecuteCommandLists`.
-
-## 10. Shader-interface facts
-
-Measured on real console shaders by a sibling layer; where the claims overlap this repository's
-translator docs they are mostly confirmed here.
-
-- An FSSM stage descriptor at +0x110 looks like `RSRC2`: `USER_SGPR` sits in bits 5:1 (e.g.
- `0x18` → 12 SGPRs). A PS header carries an export-variant patch table from about +0x25C.
-- User SGPRs (a compute example with 14 per `RSRC2`): `s4` = descriptor table 0, `s5` = table 1,
- `s[6:7]` and `s[8:9]` = root CBVs; `s14`/`s15` = thread-group id x/y.
-- Mesh-shader interface: `s3[27:24]` = wave index in the group, `v5` = group·128 + thread,
- `s16..s24` = user data.
-- Console GS runs on-chip: the ES writes vertices to LDS and `s_setpc`s to the GS. The GS writes
- vertices to LDS at 64 B per vertex, base = `s2 + ([s8 + 0xB8] << 8)`, and uses `s_sendmsg`
- emit/cut/done. No copy shader is present in the pack.
-- `IASetPrimitiveTopology` value 17 is rectangle lists, drawn as two triangles on PC.
-- Derivatives: console code computes cross-quad derivatives manually (DPP `quad_perm`,
- `ds_swizzle`) and reads helper lanes. On PC, reads across quads need quad-aware lane reads:
- `WaveReadLaneAt` leaves helper lanes out before SM 6.7, and enabling
- `WaveOpsIncludeHelperLanes` caused a device hang in the sibling layer — whole-wave ballots then
- never let helper lanes exit.
-- A pixel shader doing `v_readfirstlane` after `s_wqm` can read a helper lane's value; the read
- must take the value with a quad read inside its own quad plus a wave read from a live lane of
- that quad.
-- Memory model: a shared "mem" buffer used for flat accesses must be coherent
- (`globallycoherent` on D3D12). Bottom-up BVH builds with atomics produce wrong child pointers
- otherwise; console code relies on GLC/cache-invalidation semantics.
-- ISG1 inputs a VS never reads get no fetch-shader VGPRs.
-
-## 11. Unverified here
-
-The sibling-layer measurements above were made on retail Series titles and that project's own
-host runtime, not on this package or this layer. Still to be measured on this package:
-
-- **which runtime layout this title uses** — the older/newer detection rule of §1.1 needs a queue
- call trace;
-- **draw-record encodings for graphics** — only compute dispatches and copies were measured; the
- graphics draw records and their sizes are unknown;
-- the `PresentX` signature and plane struct (no signature is recovered anywhere;
- [d3d12_command_objects.md](d3d12_command_objects.md) §4);
-- queue/fence/allocator slots and the device creation slots 8/9/12/36 for the layout this title
- uses ([d3d12_command_objects.md](d3d12_command_objects.md) §5.3);
-- the exact newer→older slot pairs on the command-list tail beyond the measured set.
diff --git a/docs/design.md b/docs/design.md
index d7b62c212..3744aca2f 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -1,9 +1,7 @@
# Design notes
Groundwork for running the Xbox Series build of GTA VI natively on Windows. The work that does not need the
-executable is in place; booting can start as soon as the engine image is available (the
-`game_scarlett_master.exe` obtained so far is a packaging verification probe, not the engine — see
-docs/boot.md).
+executable is in place; booting can start as soon as `game_scarlett_master.exe` is available.
## Ground rules
diff --git a/docs/fssm_crosscheck.md b/docs/fssm_crosscheck.md
index 072576a6f..9cc5f5a13 100644
--- a/docs/fssm_crosscheck.md
+++ b/docs/fssm_crosscheck.md
@@ -44,8 +44,7 @@ The short version:
### The duplicate-XBCH exception (the important one)
-`tools/fssm_unpack.py` read the entries last-wins, dropping all but the last payload of a
-repeated tag:
+`tools/fssm_unpack.py` does:
```python
ents = {}
diff --git a/docs/hello_pixels.md b/docs/hello_pixels.md
deleted file mode 100644
index 8df0f4229..000000000
--- a/docs/hello_pixels.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# Hello pixels: a package-free draw through vk_harness
-
-**Status: measured** on Mesa llvmpipe (LLVM 20.1.2, Vulkan 1.3.275, Linux). This is a synthetic complement to
-[first_light.md](first_light.md): where that page draws a real game model with real translated shaders, this one
-draws a quad built entirely in the repository — hand-written SPIR-V assembly, a generated mesh — so anyone with
-a Vulkan device can check the pipeline without the game package.
-
-## What it draws
-
-`tools/hello_pixels.py --run --check` assembles two tiny shaders (no GLSL compiler needed, `spirv-as` only):
-
-- **VS** (`vs.asm`): `Location 0` float3 position already in NDC, `Location 1` float2 uv; stores the position
- into `gl_Position` and forwards uv to the interpolating varying. This is the same shape as the first_light VS.
-- **PS** (`ps.asm`): `rgb = (u, v, (u+v)/2)` dimmed to 20% on every other cell of a 16×16 checker, computed with
- core instructions only (`OpFMod` cell coordinate, `OpFOrdLessThan`/`OpSelect` parity). `OriginUpperLeft`.
-
-The mesh is a generated fullscreen indexed quad (`u32` counts, `5f` vertices, `u32` indices — the
-`VKH_DRAW_MESH` format with `VKH_VERTEX_LAYOUT=0:3f,1:2f`), drawn into the RGBA32F attachment, read back, and
-written as `image.raw`, `image.ppm` and a zlib-only `image.png`.
-
-## What --check verifies
-
-Same style as the first_light oracle, so the image has to be *right*, not just non-clear:
-
-- the buffer is exactly `w*h*16` bytes of RGBA32F;
-- coverage is 100% — a quad that misses the image fails, and so does an all-clear image;
-- seven probe pixels match `expected_pixel`, the closed form of the same pattern (u, v, (u+v)/2 with cell
- parity) computed at pixel centres, within 0.04. A flipped axis, a swapped u/v or a mirrored checker moves
- probe values out of tolerance.
-
-`tests/test_hello_pixels.py` runs the oracle on synthetic buffers without a GPU or vk_harness: the accepted
-image, a truncated buffer, a wrong probe pixel and a coverage loss away from every probe.
-
-## Why it matters
-
-first_light needs `shaders.rpf`, `data.rpf` and an OBJ export. This needs nothing but the built harness and
-`spirv-as`, so it is the fastest way to tell a fresh machine "your Vulkan path prints pixels": vertex fetch →
-interpolation → fragment → readback, exercised end to end. It also serves as the smallest reproducer for
-VKH_DRAW_MESH bugs — the file format and layout string are spelled out in one generated mesh.
-
-## Reproduce it
-
-```sh
-cmake -S runtime -B runtime/build -G Ninja
-cmake --build runtime/build --target vk_harness
-python -I tools/hello_pixels.py --work
--size 512 --run --check
-# /image.png: a u/v gradient dimmed on alternating 16x16 cells
-```
-
-On Windows the same command works against `runtime/build/windows/vk_harness.exe`; on a machine without
-`spirv-as`, drop the `vs.spv`/`ps.spv` that `--emit-only` produced on a machine that has one into the `--work`
-directory; the tool uses the prebuilt pair when `spirv-as` is absent (fresh assembly always wins when it is
-present).
diff --git a/docs/import_routing.md b/docs/import_routing.md
deleted file mode 100644
index 6be8d31eb..000000000
--- a/docs/import_routing.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Import routing: shim, bundled, host or unimplemented
-
-How `gta6rt` binds an import, per DLL. The code paths are `Loader::resolve` for the import table
-(`runtime/src/pe_loader.cpp`), `Loader::resolve_forwarder` for a forwarded export, and the `LoadLibrary*` /
-`GetProcAddress` shims for run-time loads (`runtime/shims/library_loader.cpp`). Measured against the 16 shipped
-modules in [runtime_imports.md](runtime_imports.md): every import binds, 0 unimplemented.
-
-## The bind order
-
-The lookup key is the DLL name normalised the way `LoadLibrary` resolves a file name (`dll_key`,
-`pe_loader.cpp`): lower-case, a trailing `.` dropped, and `.dll` added when the name has no extension —
-so a descriptor naming `GameInput` or `gameinput.dll.` keys the same as `gameinput.dll`, matching the
-host `LoadLibraryExA` it can fall through to.
-
-`resolve(dll, name)` tries, in order:
-
-1. **Shim** — `rt::shims::find("dll!name")`, the clean-room tables registered by `SHIM_TABLE` in
- `runtime/shims/*.cpp`. The registry is searched first even for host DLLs, which is how `kernel32!CreateFileW`
- or `ExitProcess` get redirected without losing the rest of `kernel32`.
-2. **Bundled** — `/` mapped by the same loader, unless the name is in `prefer_host_copy`
- (the `vcruntime140`/`msvcp140`/`concrt140`/`vccorlib140`/`vcomp140` family: the host CRT is always used, so a
- mapped image's `RtlPcToFileHeader` can be redirected, `pe_loader.cpp`). A bundled export that is itself a
- forwarder string is followed by `resolve_forwarder` (8 deep, then a loop is declared).
-3. **Host** — `LoadLibraryExA(dll, LOAD_LIBRARY_SEARCH_SYSTEM32)` + `GetProcAddress`. System32 only, so the game
- folder is never in the search. API-set names (`api-ms-*`, `ext-ms-*`) resolve here through the host's API-set
- schema; the measured run binds every api-ms import the package asks for.
-4. **Unimplemented** — `shims::make_unimplemented_thunk`: a 32-byte stub per import that calls `rt_unimplemented`
- with `"dll!name"` and the argument registers; `LEONIDA_UNIMPLEMENTED` = log (default) / fail / stop picks the
- answer (`runtime/shims/registry.cpp`, policy documented in `runtime/README.md` and
- [runtime_imports.md](runtime_imports.md#when-an-unimplemented-import-is-called)).
-
-Step 3 is skipped when `shims::owns_dll(dll)` is true. `xgameruntime.dll` and `gameinput.dll` are real PC names
-(Gaming Services installs `xgameruntime.dll` in System32); without the skip, an import the registry doesn't serve
-would bind to the live service runtime while a run-time `GetProcAddress` for the same name returns NULL, and the
-process would be online-capable. `resolve_forwarder` applies the same order, so a forwarder string naming a
-shimmed module resolves to the shim.
-
-## `owns_dll`: whole-module shims
-
-`owns_dll` (registry.cpp) is false for `api-ms-*`/`ext-ms-*` prefixes and for the eight host DLLs that the tables
-partially override — `kernel32`, `kernelbase`, `msvcrt`, `ucrtbase`, `ucrtbased`, `vulkan-1`, `ntdll`, `user32` —
-and otherwise true exactly when the registry holds at least one `dll!` entry. Owned today: `d3d12_xs.dll`,
-`xgameruntime.dll`, `gameinput.dll`, `xmem.dll`.
-
-A title's `LoadLibrary*`/`GetModuleHandle*` for an owned module returns a pseudo-handle
-(`library_loader.cpp`); `GetProcAddress` on it resolves through the registry only — an unserved name is NULL with
-`ERROR_PROC_NOT_FOUND`, never the host. `FreeLibrary` on a pseudo-handle is a no-op. Every other module goes to
-the real `LoadLibrary*`/`GetProcAddress`.
-
-## Per-DLL outcome
-
-| DLL | Registry entries | Static import | Run-time load |
-|---|---|---|---|
-| `d3d12_xs.dll` | 4: `D3D12XboxCreateDevice`, `D3D12Serialize{,Versioned}RootSignature`, `D3D12CreateRootSignatureDeserializer` | those → shim; any other → unimplemented (no host namesake) | owned → pseudo-handle |
-| `xgameruntime.dll` | ~40: `*ApiImpl*` entry points, `XGameRuntime*`, `XSystem*`, `XPackage*`, `XTaskQueue*`, `XAsync*`, `GameInputCreate` | registered → shim; unregistered → unimplemented | owned → pseudo-handle (the path `xgameruntime.lib` thunks use) |
-| `gameinput.dll` | `GameInputCreate` | registered → shim; unregistered → unimplemented | owned → pseudo-handle |
-| `xmem.dll` | `XMemAlloc`, `XMemFree`, `XMemVirtualQuery`, `XMemGetWorkingSetStatistics` | registered → shim; unregistered → unimplemented | owned → pseudo-handle |
-| `d3d12.dll`, `dxgi.dll` | none | host (the real PC DLLs; the console surface rides on them through the `d3d12_xs` device proxy and the DXGI COM wrappers) | real host DLL |
-| `xaudio2_9.dll`, `xaudio2_9redist.dll` | none | host if installed, else unimplemented | real host DLL |
-| `dstorage.dll`, `dstorage_xs.dll` | none | `dstorage.dll` host if the DirectStorage redist is installed, else unimplemented; `dstorage_xs.dll` unimplemented | real host DLL / fails |
-| `xg_xs.dll`, `acphal.dll`, `chad*`/`xapu*`/`xcrdapi*` (legacy Xbox names) | none | unimplemented | fails (host can't load them) |
-| `kernel32`, `kernelbase` | file (`CreateFile*`, `FindFirstFile*`, `GetFileAttributes*`, `DeleteFile*`), loader (`LoadLibrary*`, `GetModuleHandle*`, `GetProcAddress`, `FreeLibrary`), process (`ExitProcess`, `GetCommandLine*`) | registered → shim; everything else → host | real host DLL (not owned) |
-| `msvcrt`, `ucrtbase`, `ucrtbased` | exit/`abort`/argv/command-line overrides | registered → shim; everything else → host | real host DLL |
-| `ntdll`, `user32`, `vulkan-1` | none | host | real host DLL |
-| `api-ms-*`, `ext-ms-*` | only the sets a GDK title links: `core-file-l1-1-0/l1-2-0/l2-1-0`, `core-libraryloader-l1-1-0/l1-1-1/l1-2-0/l1-2-1/l1-2-2`, `core-processthreads-l1-1-0`, `core-processenvironment-l1-1-0`, `crt-runtime-l1-1-0` | registered names → shim; all other names and sets → host API-set schema (this is what covers every UCRT `api-ms-win-crt-*` variant without a table entry) | real host resolution |
-| `vcruntime140*`, `msvcp140*`, `concrt140`, `vccorlib140`, `vcomp140` | none | host, even when a bundled copy exists (`prefer_host_copy`) | real host DLL |
-| the package's own DLLs (`Bink2Scarlett.dll`, `XCurl.dll`, …) | none | bundled module, mapped by the loader | host `LoadLibrary` — see the caveat in [runtime_imports.md](runtime_imports.md#run-time-loaded-modules) |
-| anything else | none | unimplemented | host or failure |
-
-## Edge cases
-
-- **`d3d12.dll`/`dxgi.dll` can never hit the unimplemented thunk** for a name the PC DLL exports: no registry
- entries exist for them, and they are real System32 DLLs. A name they don't export ends unimplemented, which is
- the wanted answer.
-- **Ordinals**: registry keys are `dll!#N` in `Entry.name`, but no shipped table registers an ordinal; an
- ordinal-only import from a shimmed or console-only DLL lands unimplemented. Host DLLs bind ordinals through
- `GetProcAddress` normally.
-- **No console DLL matches the host list.** The `owns_dll` host list holds only names that also exist on the PC
- and have partial table overrides. A console-only name (`d3d12_xs`, `xmem`, `xg_xs`, …) can't be owned by
- accident and can't be excluded from the tables by accident.
-- **Owned ≠ bundled-blocked.** A bundled copy of an owned name would still map through the bundled step before
- the unimplemented fallback; nothing in the package ships one.
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index e47bb9ad9..73326b838 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -2499,7 +2499,7 @@ if(TARGET Vulkan::Headers)
# The loader can create this device instead of the host's (D3D12XboxCreateDevice, LEONIDA_D3D12=vulkan).
if(TARGET gta6rt)
- target_link_libraries(gta6rt PRIVATE gta6rt_d3d12_com user32) # user32: the PresentX window
+ target_link_libraries(gta6rt PRIVATE gta6rt_d3d12_com)
target_compile_definitions(gta6rt PRIVATE LEONIDA_VULKAN_DEVICE)
# A stand-in title that imports d3d12_xs.dll!D3D12XboxCreateDevice and runs a clear and a readback on the
diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp
index 0286a6876..590f86bd7 100644
--- a/runtime/shims/d3d12_xs_device.cpp
+++ b/runtime/shims/d3d12_xs_device.cpp
@@ -20,12 +20,6 @@
#include "d3d12_trace.h"
#include "../src/shader_library.h" // leonida::fspx_payload_from_parts for slot 67
-#ifdef LEONIDA_VULKAN_DEVICE
-// PresentX wiring: the queue's console slots land on the Xbox presentation core, which needs the Vulkan layer's
-// WindowPresenter. Other builds of this file (mock and COM tests) keep the refused-slot behaviour.
-#include "xbox_present.h"
-#endif
-
#include
#include
@@ -34,11 +28,9 @@
#include
#include
#include
-#include
#include
#include
#include
-#include
namespace rt::d3d12_xs {
namespace {
@@ -56,19 +48,6 @@ struct DeviceProxy {
void** real_vtable;
unsigned slot_count; // number of valid entries in real_vtable
std::atomic refs;
- // The PresentX state (window, presenter, XboxPresentation) the first queue PresentX builds on this device,
- // under LEONIDA_VULKAN_DEVICE; always null elsewhere. Opaque: PresentState is defined with the queue proxy.
- void* present_state = nullptr;
- // The upload-memory arena console list slot 148 (AllocateUploadMemory) carves from; always null until the
- // first call. Opaque: UploadArena is defined with the list proxy. Atomic: lists record on several threads
- // at once, so the first AllocateUploadMemory installs the arena by compare-exchange.
- std::atomic upload_state{nullptr};
- // The console runtime layout this title was built against (docs/d3d12_xs_console_abi.md §4): the queue proxy
- // writes it on detection and every object shares it — the queue/list slot tails shift +2 under the newer one.
- std::atomic console_layout{0}; // 0 unknown, 1 older, 2 newer
- // Set by create_device_proxy: false hands real (PC-shaped) lists back from CreateCommandList for callers
- // compiled against the PC headers.
- bool console_lists = true;
// The device's IDXGIDevice1 (see "IDXGIDevice1 on the device" below): a title's IDXGIDevice1* points here.
void** dxgi_vtable;
DxgiAdapterProvider adapter_provider;
@@ -76,10 +55,6 @@ struct DeviceProxy {
std::atomic max_frame_latency;
};
-// Freed in proxy_release; defined where the states are complete.
-void destroy_present_state(void* present_state);
-void destroy_upload_state(void* upload_state);
-
constexpr unsigned kHeapSlots = 11; // IUnknown + ID3D12Object + DeviceChild + Pageable + GetDesc + 2 handles
struct HeapProxy {
@@ -203,8 +178,6 @@ unsigned long proxy_release(DeviceProxy* self) {
note_slot(2);
const unsigned long refs = self->refs.fetch_sub(1, std::memory_order_acq_rel) - 1;
if (refs == 0) {
- destroy_present_state(self->present_state);
- destroy_upload_state(self->upload_state.load(std::memory_order_relaxed));
ID3D12Device* real = self->real;
delete self;
if (real) real->Release();
@@ -554,16 +527,10 @@ HRESULT create_heap_proxy(ID3D12DescriptorHeap* real, DeviceProxy* device, REFII
//
// Device slots 8 (CreateCommandQueue), 75 (CreateCommandQueue1), 36 (CreateFence) and 32 (OpenSharedHandle, for a
// fence) wrap what they create, so a title never holds a PC or Vulkan-layer queue or fence. The proxies forward
-// the public chain in PC order, exactly like the device proxy; on a fence a slot past the PC vtable is logged and
-// refused with E_NOTIMPL. PresentX, SuspendX and ResumeX are queue methods past the public chain
-// (docs/d3d12_command_objects.md §5.3). A sibling layer measured two queue layouts on retail titles
-// (docs/d3d12_xs_console_abi.md §4, unverified here): the older has Signal 14, Wait 15,
-// GetTimestampFrequency 16, GetClockCalibration 17, GetDesc 18, SignalX 23, PresentX 30; a newer game
-// OS inserts two methods before Signal, shifting to Signal 16, Wait 17, frequency 18, SignalX 25,
-// PresentX 32 — a fence passed to slot 16 or 17 marks the newer layout, and the detection is shared
-// across queues through the device. PresentX is wired to the Vulkan layer's Xbox presentation,
-// SignalX forwards as Signal, and the unmodelled console-only slots answer S_OK (the PresentX
-// section below); the first run of the executable confirms which layout.
+// the public chain in PC order, exactly like the device proxy, and a slot past the PC vtable is logged and refused
+// with E_NOTIMPL. PresentX, SuspendX and ResumeX are queue methods past the public chain
+// (docs/d3d12_command_objects.md §5.3). Their slots are not known and nothing is guessed: the first run of the
+// executable names them in the log.
//
// Slot numbers are those of the Windows SDK 10.0.26100 d3d12.h: ID3D12CommandQueue has 19, ID3D12Fence 11 and
// ID3D12Fence1 12. That the console keeps these public slots, and keeps device slots 8/32/36/75, is an assumption
@@ -581,10 +548,11 @@ HRESULT create_heap_proxy(ID3D12DescriptorHeap* real, DeviceProxy* device, REFII
// passed there: queue Signal/Wait (14/15) take a fence; device CreateSharedHandle (31) a device child,
// MakeResident/Evict (34/35), SetResidencyPriority (46) and EnqueueMakeResident (50) pageables, and
// SetEventOnMultipleFenceCompletion (45) and EnqueueMakeResident fences. The heap proxies of slot 14 are pageables
-// and device children too and are unwrapped in the same places. Command lists from device slot 12 come back
-// console-shaped (the list proxy below): queue ExecuteCommandLists (10) unwraps the list array, the list's own
-// Reset and ExecuteBundle unwrap allocator and bundle proxies, and its SetDescriptorHeaps unwraps heap proxies —
-// all through proxy_real_object, so any object kind added later unwraps in every place at once.
+// and device children too and are unwrapped in the same places. Command lists are not wrapped yet, so
+// ExecuteCommandLists passes them through, and a heap proxy still reaches the real runtime through the list's
+// SetDescriptorHeaps. A command-list proxy (docs/d3d12_command_objects.md §3.5a) adds its vtable to
+// proxy_real_object, which every unwrap goes through, and a queue slot 10 branch in child_slot that unwraps the list
+// array (UnwrappedArray) before forwarding, and unwraps heap proxies in its own SetDescriptorHeaps.
//
// QueryInterface answers only the interfaces the proxy models (the base chain and its own interface, Fence1 when
// the real fence has it), like the device and heap proxies, so the COM identity holds and no real object leaks to
@@ -622,14 +590,6 @@ struct ChildProxy {
void** real_vtable;
unsigned slot_count; // public slots the real object implements; the rest of the table is refused
std::atomic refs;
- // Queues only: the console runtime layout this title was built against (docs/d3d12_xs_console_abi.md §4),
- // detected by a fence reaching slot 16/17 or SignalX slot 25. Unused on fences and allocators. A queue is
- // used from many threads, so the cache of the device's shared detection is atomic like the shared flag
- // itself.
- static constexpr unsigned char kQueueLayoutUnknown = 0;
- static constexpr unsigned char kQueueLayoutOlder = 1; // PC order; PresentX 30, SignalX 23
- static constexpr unsigned char kQueueLayoutNewer = 2; // +2 shift; PresentX 32, SignalX 25
- std::atomic queue_layout{kQueueLayoutUnknown};
};
template
@@ -823,10 +783,6 @@ HRESULT child_get_device(ChildProxy* self, const IID* riid, void** out) {
template
void** get_child_vtable();
-// The command-list proxy's helpers (defined with the list proxy below): proxy_real_object checks lists through
-// list_real_or_null, since the ListProxy type is complete only there.
-IUnknown* list_real_or_null(const void* object);
-
template
bool is_child_proxy(const void* object) {
return object && *reinterpret_cast(object) == reinterpret_cast(get_child_vtable());
@@ -841,7 +797,6 @@ IUnknown* proxy_real_object(const void* object) {
vtable == reinterpret_cast(get_child_vtable()) ||
vtable == reinterpret_cast(get_child_vtable()))
return static_cast(object)->real;
- if (IUnknown* real = list_real_or_null(object)) return real;
return nullptr;
}
@@ -922,91 +877,6 @@ LONG CALLBACK table_overrun_handler(EXCEPTION_POINTERS* info) {
return EXCEPTION_CONTINUE_SEARCH; // diagnostics only: the fault goes on to the title's handlers or the crash
}
-// ---- PresentX on the queue (LEONIDA_VULKAN_DEVICE) ---------------------------------------------------------
-//
-// The measured console queue slots (docs/d3d12_xs_console_abi.md §4): the older runtime keeps the PC order —
-// Signal 14, Wait 15, frequency 16, calibration 17, GetDesc 18 — and presents at slot 30, with SignalX at 23. A
-// newer game OS inserts two methods before Signal: Signal 16, Wait 17, frequency 18, calibration 19, GetDesc 20,
-// SignalX 25, PresentX 32. The layout is detected once, by a fence object reaching slot 16 or 17 (the older
-// layout's frequency and calibration getters take no object argument) or by a fence reaching SignalX slot 25 —
-// a title that signals only through SignalX would otherwise stay undetected and lose every signal.
-//
-// Every other console-only queue method answers S_OK (sibling layer: title frame pacing flows through them, and a
-// refusal wedges the present loop), still recorded by note_child_slot. Slot 148's AllocateUploadMemory is a list
-// method, not a queue method, so it is not part of this table.
-
-#ifdef LEONIDA_VULKAN_DEVICE
-
-struct PresentState {
- ~PresentState() {
- if (window) DestroyWindow(window); // the presentation and its window die with the device proxy
- }
- HWND window = nullptr;
- std::unique_ptr xbox;
- bool tried = false; // creation is attempted once; a null xbox means this device cannot present
-};
-
-void destroy_present_state(void* present_state) {
- delete static_cast(present_state);
-}
-
-LRESULT CALLBACK present_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
- return DefWindowProcW(window, message, wparam, lparam);
-}
-
-// Lazily builds the window, presenter and XboxPresentation a console PresentX needs, once per device. Returns the
-// state even when `xbox` stays null (no presentation support): the failure is logged once, not retried.
-PresentState* present_state_for(DeviceProxy* device) {
- if (auto* state = static_cast(device->present_state)) return state;
- auto* state = new (std::nothrow) PresentState;
- if (!state) return nullptr;
- device->present_state = state;
- state->tried = true;
- WNDCLASSW window_class{};
- window_class.lpfnWndProc = present_window_proc;
- window_class.hInstance = GetModuleHandleW(nullptr);
- window_class.lpszClassName = L"LeonidaPresentX";
- if (!RegisterClassW(&window_class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
- std::fprintf(stderr, "[rt] d3d12_xs: PresentX window class failed (error %lu)\n", GetLastError());
- return state;
- }
- state->window = CreateWindowExW(0, window_class.lpszClassName, L"Leonida", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr,
- window_class.hInstance, nullptr);
- if (!state->window) {
- std::fprintf(stderr, "[rt] d3d12_xs: PresentX window failed (error %lu)\n", GetLastError());
- return state;
- }
- auto presenter = rt::d3d12::create_window_presenter(device->real, state->window);
- if (!presenter) {
- std::fprintf(stderr, "[rt] d3d12_xs: no window presenter on this device; PresentX is a no-op\n");
- return state;
- }
- state->xbox = std::make_unique(std::move(presenter));
- std::fprintf(stderr, "[rt] d3d12_xs: PresentX ready (window %p)\n", static_cast(state->window));
- return state;
-}
-
-std::uint64_t queue_present_x(ChildProxy* self, std::uint64_t plane_count, std::uint64_t planes,
- std::uint64_t params) {
- PresentState* state = self->device ? present_state_for(self->device) : nullptr;
- if (!state || !state->xbox) return hr_to_u64(S_OK); // a title still runs with nothing presented
- return hr_to_u64(state->xbox->PresentX(
- static_cast(plane_count),
- reinterpret_cast(planes),
- reinterpret_cast(params)));
-}
-
-#else // !LEONIDA_VULKAN_DEVICE: this translation unit stands alone (mock and COM tests)
-
-void destroy_present_state(void*) {}
-
-std::uint64_t queue_present_x(ChildProxy*, std::uint64_t, std::uint64_t, std::uint64_t) {
- return hr_to_u64(S_OK);
-}
-
-#endif
-
template
std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3,
std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7,
@@ -1026,100 +896,6 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_
reinterpret_cast(a2)));
} else {
note_child_slot(Slot);
- if constexpr (K == ChildKind::queue) {
- // Layout detection (the comment at the PresentX section): a fence reaching slot 16 or 17 is the newer
- // layout's Signal/Wait; anything else there is the older layout's frequency/calibration getter. A
- // fence at slot 14 or 15 is the older Signal/Wait; a non-fence argument there is one of the newer
- // layout's two inserted console methods.
- // A queue made after another one detected the layout inherits it from the device; undetected queues
- // assume the older layout, whose unshifted slots are also the PC chain. A fence reaching SignalX
- // slot 25 while the layout is still unknown is itself the newer-layout evidence: a title that
- // signals only through SignalX never reaches Signal/Wait at 16/17, and an unanswered SignalX
- // returns S_OK having signalled nothing, leaving a waiter on that fence value hanging.
- const bool newer = [&] {
- const unsigned char own = self->queue_layout.load(std::memory_order_relaxed);
- if (own == ChildProxy::kQueueLayoutNewer) return true;
- const unsigned char shared =
- self->device->console_layout.load(std::memory_order_relaxed);
- return own == ChildProxy::kQueueLayoutUnknown && shared == ChildProxy::kQueueLayoutNewer;
- }();
- if (Slot == 16 || Slot == 17) {
- if (IUnknown* fence = proxy_real_object(reinterpret_cast(a1))) {
- self->queue_layout.store(ChildProxy::kQueueLayoutNewer, std::memory_order_relaxed);
- self->device->console_layout.store(ChildProxy::kQueueLayoutNewer,
- std::memory_order_relaxed);
- using Fn = HRESULT(WINAPI*)(IUnknown*, IUnknown*, UINT64);
- return hr_to_u64(reinterpret_cast(self->real_vtable[kQueueSignal + (Slot - 16)])(
- self->real, fence, a2));
- }
- if (newer) return hr_to_u64(S_OK); // proven newer: a non-fence Signal/Wait arg is malformed,
- // not evidence of the older layout — do not downgrade the shared detection on it
- if (self->queue_layout.load(std::memory_order_relaxed) ==
- ChildProxy::kQueueLayoutUnknown) {
- self->queue_layout.store(ChildProxy::kQueueLayoutOlder, std::memory_order_relaxed);
- self->device->console_layout.store(ChildProxy::kQueueLayoutOlder,
- std::memory_order_relaxed);
- }
- } else if ((Slot == 14 || Slot == 15) && !proxy_real_object(reinterpret_cast(a1)) &&
- newer) {
- return hr_to_u64(S_OK); // the newer layout's two inserted console methods, unmeasured
- }
- if (newer && Slot >= 18 && Slot <= 20) {
- // Newer layout: frequency 18, calibration 19, GetDesc 20 are the PC slots 16-18 shifted.
- d3d12_trace::record(child_trace_name(Slot));
- using ForwardFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t);
- auto fn = reinterpret_cast(self->real_vtable[Slot - 2]);
- return fn(self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
- }
- // Slot 18 while the layout is still unknown is ambiguous: the older GetDesc (a struct-return
- // write of a whole desc) or the newer frequency getter (an 8-byte out). Answering it as GetDesc
- // writes far past the 8 bytes a frequency caller passes, so the call goes to the frequency
- // getter — the only interpretation that cannot overrun its argument, and a title often queries
- // the frequency before its first fence call. A proven-older queue keeps the generic GetDesc
- // path below; slots 19 and 20 stay no-ops, since their newer interpretations write through
- // caller pointers an unmodelled older method might not supply.
- if (Slot == 18 && !newer && self->queue_layout == ChildProxy::kQueueLayoutUnknown &&
- self->device->console_layout.load(std::memory_order_relaxed) !=
- ChildProxy::kQueueLayoutOlder) {
- d3d12_trace::record(child_trace_name(Slot));
- using Fn = HRESULT(WINAPI*)(IUnknown*, UINT64*);
- return hr_to_u64(reinterpret_cast(self->real_vtable[16])(
- self->real, reinterpret_cast(a1)));
- }
- if (Slot == (newer ? 25u : 23u) ||
- (Slot == 25u && self->queue_layout.load(std::memory_order_relaxed) ==
- ChildProxy::kQueueLayoutUnknown &&
- self->device->console_layout.load(std::memory_order_relaxed) ==
- ChildProxy::kQueueLayoutUnknown)) {
- // SignalX: console Signal (older 23, newer 25); the extra X word is dropped. The slot-25
- // alternative is the fence itself carrying the layout evidence, per the comment above; a
- // proven-older queue still leaves slot 25 to the console-only no-op, since its fence-taking
- // methods sit at 14/15/23 there.
- if (IUnknown* fence = proxy_real_object(reinterpret_cast(a1))) {
- if (Slot == 25u && !newer) {
- self->queue_layout.store(ChildProxy::kQueueLayoutNewer,
- std::memory_order_relaxed);
- self->device->console_layout.store(ChildProxy::kQueueLayoutNewer,
- std::memory_order_relaxed);
- }
- static std::atomic logged{false};
- if (!logged.exchange(true, std::memory_order_relaxed))
- std::fprintf(stderr, "[rt] d3d12_xs: SignalX (queue slot %u) forwarded as Signal\n", Slot);
- using Fn = HRESULT(WINAPI*)(IUnknown*, IUnknown*, UINT64);
- return hr_to_u64(reinterpret_cast(self->real_vtable[kQueueSignal])(self->real, fence, a2));
- }
- return hr_to_u64(S_OK);
- }
- if (Slot == (newer ? 32u : 30u)) return queue_present_x(self, a1, a2, a3); // PresentX
- if (Slot >= self->slot_count || (newer && (Slot == 14 || Slot == 15))) {
- d3d12_trace::record(child_trace_name(Slot), "console-only");
- return hr_to_u64(S_OK); // unmodelled console queue methods: frame pacing flows through them
- }
- }
if (Slot >= self->slot_count) {
bool expected = false;
if (ChildStats::beyond_warned[Slot].compare_exchange_strong(expected, true,
@@ -1137,14 +913,6 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_
d3d12_trace::record(child_trace_name(Slot)); // "called": the real object's result is not inspected
if constexpr (K == ChildKind::queue && (Slot == kQueueSignal || Slot == kQueueWait)) a1 = unwrap_object(a1);
- // Queue slot 10: ExecuteCommandLists(count, lists). The array is copied with each list proxy replaced by
- // its real list; a bundle on the list side unwraps the same way at the console's ExecuteBundle.
- UnwrappedArray unwrapped;
- if constexpr (K == ChildKind::queue && Slot == 10) {
- if (!unwrapped.fill(a2, a1)) return hr_to_u64(E_OUTOFMEMORY);
- if (unwrapped.data()) a2 = unwrapped.data();
- }
-
// The PC vtable entry with the real object as `this`; integer/pointer arguments, the hidden struct-return
// pointer and stack arguments keep their positions, as in the device proxy.
using ForwardFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std::uint64_t,
@@ -1246,498 +1014,6 @@ HRESULT wrap_child(IUnknown* created, DeviceProxy* device, const IID* riid, void
return S_OK;
}
-// ---- Command list proxy ---------------------------------------------------------------------------------
-//
-// Device slot 12 (CreateCommandList) hands the title a console-shaped command list: the console vtable order, a
-// 160-slot table, and the object fields the console SDK's inline writers touch (docs/d3d12_xs_console_abi.md
-// §5). The write cursor (+0x18) is pinned at both limits (+0x28, +0x30), so a title always finds the record
-// buffer full and takes the vtable path for every command — the proxy never has to interpret inline records.
-// The flag bytes (+0x140..+0x143), the root-parameter header table (+0x344) and the pipeline record (+0x544)
-// stay zeroed: they are only read while writing a record, which never happens at the limit.
-//
-// The console slot order keeps the PC order through slot 26 (measured: 9, 10, 12-17, 19, 20, 25, 26), places
-// four console-only methods at 27-30, then the PC chain resumes shifted +4 — confirmed at console 32->PC 28
-// (SetDescriptorHeaps), 33->29, 41->37, 43->39, 45->41, 48->44, 51->47 and 53->49, and the same shift fills the
-// block through console 59 -> PC 55. The console has no PIX markers: console 60 is EndEvent (PC 58) and 61 is
-// ExecuteIndirect (PC 59, package-measured). Console 146 is the enhanced Barrier taking one D3D12_BARRIER_GROUP
-// (package-confirmed; PC equivalent is GCL7 slot 80). Console-only slots — the 27-30 extras, AllocateUploadMemory
-// (148), the disputed tail past 61 and the newer-layout +2 tail — are recorded with their first argument words
-// and return 0 without a PC call: a wrong forward is worse than a clean refusal.
-
-constexpr unsigned kListSlots = 160;
-// ---- Upload memory (console list slot 148, AllocateUploadMemory) ----
-//
-// On the console the CPU and GPU share one address space: the pointer AllocateUploadMemory(size, alignment)
-// returns is written by the CPU and handed to the GPU unchanged — the package measures it going straight into a
-// root SRV (docs/d3d12_xs_console_abi.md §5.3, d3d12_command_objects.md §3.3a). A PC has two address spaces, so
-// each arena chunk is a persistently-mapped UPLOAD-heap buffer: the title gets the CPU pointer and writes the
-// very memory the GPU samples, and the root-descriptor setters translate a chunk address to the buffer's device
-// address (the same backing memory) before forwarding. Translation covers the six root VA setters (console
-// 41-46); VAs inside view structs (IASetVertexBuffers/IASetIndexBuffer) and ExecuteIndirect arguments are not
-// rewritten yet and stay title addresses.
-
-struct UploadChunk {
- UploadChunk* next;
- ID3D12Resource* resource; // the mapped buffer; released with the chunk
- std::uint8_t* cpu_base;
- D3D12_GPU_VIRTUAL_ADDRESS gpu_base;
- std::size_t size;
- std::size_t used;
-};
-
-struct UploadArena {
- UploadChunk* chunks = nullptr;
- std::mutex lock;
-};
-
-constexpr std::size_t kUploadChunkMin = 8 << 20; // one chunk serves a title's whole frame of uploads
-
-UploadChunk* upload_chunk_new(DeviceProxy* device, std::size_t size) {
- auto* chunk = new (std::nothrow) UploadChunk{};
- if (!chunk) return nullptr;
- chunk->size = size;
-
- D3D12_HEAP_PROPERTIES heap = {};
- heap.Type = D3D12_HEAP_TYPE_UPLOAD;
- D3D12_RESOURCE_DESC desc = {};
- desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
- desc.Width = size;
- desc.Height = 1;
- desc.DepthOrArraySize = 1;
- desc.MipLevels = 1;
- desc.SampleDesc.Count = 1;
- desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
- ID3D12Resource* resource = nullptr;
- const HRESULT hr = device->real->CreateCommittedResource(
- &heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
- __uuidof(ID3D12Resource), reinterpret_cast(&resource));
- void* cpu = nullptr;
- if (SUCCEEDED(hr) && resource && SUCCEEDED(resource->Map(0, nullptr, &cpu)) && cpu &&
- resource->GetGPUVirtualAddress() != 0) {
- chunk->resource = resource;
- chunk->cpu_base = static_cast(cpu);
- chunk->gpu_base = resource->GetGPUVirtualAddress();
- return chunk;
- }
- if (resource) resource->Release();
- // A device that cannot hand out a mapped buffer (a mock, or an older layer without buffer device
- // addresses) still gets memory to write; upload_translate leaves its addresses alone.
- auto* cpu_fallback = static_cast(
- VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE));
- if (!cpu_fallback) {
- delete chunk;
- return nullptr;
- }
- chunk->cpu_base = cpu_fallback;
- chunk->gpu_base = reinterpret_cast(cpu_fallback);
- return chunk;
-}
-
-std::uint64_t upload_alloc(DeviceProxy* device, std::uint64_t size, std::uint64_t alignment) {
- if (!device || !size) return 0;
- alignment = alignment < 16 ? 16 : alignment; // every measured call asked for 16
- auto* arena = static_cast(device->upload_state.load(std::memory_order_acquire));
- if (!arena) {
- auto* fresh = new (std::nothrow) UploadArena;
- if (!fresh) return 0;
- void* expected = nullptr; // a concurrent first call loses its arena but keeps the winner's chunks
- if (device->upload_state.compare_exchange_strong(expected, fresh, std::memory_order_acq_rel))
- arena = fresh;
- else {
- delete fresh;
- arena = static_cast(expected);
- }
- }
- std::lock_guard lock(arena->lock);
- const std::size_t need = static_cast(size);
- for (UploadChunk* chunk = arena->chunks; chunk; chunk = chunk->next) {
- const std::size_t aligned = (chunk->used + (alignment - 1)) & ~(static_cast(alignment) - 1);
- if (aligned + need <= chunk->size) {
- chunk->used = aligned + need;
- return reinterpret_cast(chunk->cpu_base + aligned);
- }
- }
- const std::size_t chunk_size = need + alignment > kUploadChunkMin ? need + alignment : kUploadChunkMin;
- UploadChunk* chunk = upload_chunk_new(device, chunk_size);
- if (!chunk) {
- std::fprintf(stderr, "[rt] d3d12_xs: AllocateUploadMemory(%llu, %llu) failed\n",
- static_cast(size), static_cast(alignment));
- return 0;
- }
- chunk->next = arena->chunks;
- arena->chunks = chunk;
- const std::size_t aligned = (alignment - 1) & ~(static_cast(alignment) - 1); // 0-based
- chunk->used = aligned + need;
- return reinterpret_cast(chunk->cpu_base + aligned);
-}
-
-// An address inside an upload chunk becomes the chunk's device address plus the offset; anything else — a
-// real resource VA the title already holds — passes through.
-std::uint64_t upload_translate(DeviceProxy* device, std::uint64_t va) {
- auto* arena = static_cast(
- device ? device->upload_state.load(std::memory_order_acquire) : nullptr);
- if (!arena) return va;
- std::lock_guard lock(arena->lock);
- for (UploadChunk* chunk = arena->chunks; chunk; chunk = chunk->next) {
- const std::uint64_t base = reinterpret_cast(chunk->cpu_base);
- if (va >= base && va < base + chunk->size) return chunk->gpu_base + (va - base);
- }
- return va;
-}
-
-void destroy_upload_state(void* upload_state) {
- auto* arena = static_cast(upload_state);
- if (!arena) return;
- for (UploadChunk* chunk = arena->chunks; chunk;) {
- UploadChunk* next = chunk->next;
- if (chunk->resource) {
- chunk->resource->Unmap(0, nullptr);
- chunk->resource->Release();
- } else {
- VirtualFree(chunk->cpu_base, 0, MEM_RELEASE);
- }
- delete chunk;
- chunk = next;
- }
- delete arena;
-}
-
-constexpr unsigned kListNotForwarded = ~0u;
-constexpr unsigned kConsoleSetDescriptorHeaps = 32;
-constexpr unsigned kConsoleExecuteBundle = 31;
-constexpr unsigned kConsoleBarrier = 146;
-constexpr unsigned kConsoleAllocateUpload = 148;
-
-constexpr unsigned console_to_pc_list_slot(unsigned slot) {
- if (slot <= 26) return slot; // PC order, measured
- if (slot <= 30) return kListNotForwarded; // console-only extras
- if (slot <= 59) return slot - 4; // PC chain, shifted +4
- if (slot == 60) return 58; // EndEvent (no console SetMarker/BeginEvent)
- if (slot == 61) return 59; // ExecuteIndirect (Package)
- if (slot == kConsoleBarrier) return 80; // D3D12_BARRIER_GROUP (Package; PC GCL7)
- return kListNotForwarded;
-}
-
-struct ListProxy {
- void** vtable; // +0x00
- ID3D12GraphicsCommandList* real; // +0x08
- DeviceProxy* device; // +0x10: keeps the Xbox-ABI device alive; GetDevice returns it
- // +0x18..: the console object body a title's inline writers read. +0x18 holds the write cursor, +0x28 and
- // +0x30 the record limits; the rest is room for the measured flags, header table and pipeline record.
- alignas(8) std::uint8_t console_fields[0x600];
- std::atomic refs; // past the console body
- unsigned pc_slot_count; // slots the real list implements; mapped slots past it are refused
- std::vector vb_scratch; // slot-48 views with their VAs translated
- std::vector so_scratch; // slot-49 views, same treatment
-
- void pin_cursor_at_limit() {
- const std::uint64_t at_limit = static_cast(
- reinterpret_cast(this) + 0x18 + 0x500);
- for (const size_t offset : {0x18, 0x28, 0x30})
- std::memcpy(reinterpret_cast(this) + offset, &at_limit, sizeof(at_limit));
- }
-};
-static_assert(offsetof(ListProxy, console_fields) == 0x18, "the console fields start at +0x18");
-
-struct ListStats {
- static inline std::atomic hits[kListSlots];
- static inline std::atomic first[kListSlots];
-};
-
-// The list tail (D3D-445). From CopyTextureRegionX on, the newer console layout sits two slots later than the older
-// one (docs/d3d12_xs_console_abi.md 5.3). The table is keyed by the older-layout slot. Only CopyTextureRegionX has a
-// measured name; the other measured pairs are named by their older slot, so that both layouts print the same text
-// for the same method.
-struct ListTailName {
- unsigned older_slot;
- const char* name;
-};
-constexpr ListTailName kListTailNames[] = {
- {83, "CopyTextureRegionX"}, {84, "tail method, older slot 84"}, {85, "tail method, older slot 85"},
- {88, "tail method, older slot 88"}, {89, "tail method, older slot 89"}, {90, "tail method, older slot 90"},
- {93, "tail method, older slot 93"}, {94, "tail method, older slot 94"},
-};
-constexpr unsigned kListTailShift = 2;
-static_assert(kConsoleLayoutOlder == ChildProxy::kQueueLayoutOlder &&
- kConsoleLayoutNewer == ChildProxy::kQueueLayoutNewer,
- "the list tail names use the queue proxy's layout values");
-
-// Null while the layout is unknown, and for a slot that is not a measured tail slot of that layout: a slot number
-// never gets the other layout's name.
-const char* list_tail_name(unsigned slot, unsigned char console_layout) {
- if (console_layout != kConsoleLayoutOlder && console_layout != kConsoleLayoutNewer) return nullptr;
- const unsigned shift = console_layout == kConsoleLayoutNewer ? kListTailShift : 0;
- if (slot < shift) return nullptr;
- for (const ListTailName& entry : kListTailNames)
- if (entry.older_slot == slot - shift) return entry.name;
- return nullptr;
-}
-
-void note_list_slot(unsigned slot, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, std::uint64_t a4,
- unsigned char console_layout = 0) {
- if (slot >= kListSlots) return;
- ListStats::hits[slot].fetch_add(1, std::memory_order_relaxed);
- bool expected = false;
- if (ListStats::first[slot].compare_exchange_strong(expected, true, std::memory_order_relaxed)) {
- const char* name = list_tail_name(slot, console_layout);
- std::fprintf(stderr, "[rt] d3d12_xs: list slot %u%s%s%s first call (args 0x%llx 0x%llx 0x%llx 0x%llx)\n", slot,
- name ? " (" : "", name ? name : "", name ? ")" : "", static_cast(a1),
- static_cast(a2), static_cast(a3),
- static_cast(a4));
- }
-}
-
-// The interfaces the console list answers: the base chain, ID3D12CommandList and every graphics-command-list
-// interface the real list implements — on the console the list is a single object, so any of them returns the
-// proxy.
-bool is_list_iid(const IID& iid) {
- return IsEqualIID(iid, __uuidof(IUnknown)) || IsEqualIID(iid, __uuidof(ID3D12Object)) ||
- IsEqualIID(iid, __uuidof(ID3D12DeviceChild)) || IsEqualIID(iid, __uuidof(ID3D12CommandList)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList1)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList2)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList3)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList4)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList5)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList6)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList7)) ||
- IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList8));
-}
-
-unsigned long list_add_ref(ListProxy* self) { return self->refs.fetch_add(1, std::memory_order_relaxed) + 1; }
-
-void destroy_list(ListProxy* self) {
- IUnknown* real = self->real;
- DeviceProxy* device = self->device;
- delete self;
- if (real) real->Release();
- if (device) proxy_release(device);
-}
-
-unsigned long list_release(ListProxy* self) {
- const unsigned long refs = self->refs.fetch_sub(1, std::memory_order_acq_rel) - 1;
- if (refs == 0) destroy_list(self);
- return refs;
-}
-
-HRESULT list_query_interface(ListProxy* self, const IID* riid, void** out) {
- note_list_slot(0, reinterpret_cast(riid), reinterpret_cast(out), 0, 0);
- if (!out) return E_POINTER;
- *out = nullptr;
- if (!riid) return E_POINTER;
- if (!is_list_iid(*riid)) {
- if (supports_iid(self->real, *riid)) log_refused_iid("list", *riid);
- return E_NOINTERFACE;
- }
- if (!supports_iid(self->real, *riid)) return E_NOINTERFACE;
- *out = self;
- list_add_ref(self);
- return S_OK;
-}
-
-// Highest list interface the real object implements; its cumulative slot count bounds mapped forwards
-// (ID3D12GraphicsCommandList8 ends at slot 81, OMSetFrontAndBackStencilRef).
-unsigned detect_list_slot_count(IUnknown* real) {
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList8))) return 82;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList7))) return 81;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList6))) return 78;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList5))) return 75;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList4))) return 69;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList3))) return 67;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList2))) return 66;
- if (supports_iid(real, __uuidof(ID3D12GraphicsCommandList1))) return 65;
- return 60;
-}
-
-template
-std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3,
- std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7,
- std::uint64_t a8, std::uint64_t a9, std::uint64_t a10, std::uint64_t a11,
- std::uint64_t a12, std::uint64_t a13, std::uint64_t a14) {
- if constexpr (Slot == 0) {
- return hr_to_u64(list_query_interface(self, reinterpret_cast(a1),
- reinterpret_cast(a2)));
- } else if constexpr (Slot == 1) {
- return list_add_ref(self);
- } else if constexpr (Slot == 2) {
- return list_release(self);
- } else if constexpr (Slot == 7) { // GetDevice: the Xbox-ABI device, as on the other proxies
- note_list_slot(7, a1, a2, 0, 0);
- if (a2) *reinterpret_cast(a2) = nullptr;
- if (!a1) return hr_to_u64(E_POINTER);
- if (!a2) { // no output: the real object's own answer
- using Fn = HRESULT(WINAPI*)(IUnknown*, const IID*, void**);
- return hr_to_u64(reinterpret_cast((*reinterpret_cast(self->real))[7])(
- self->real, reinterpret_cast(a1), nullptr));
- }
- return hr_to_u64(proxy_query_interface(self->device, reinterpret_cast(a1),
- reinterpret_cast(a2)));
- } else {
- note_list_slot(Slot, a1, a2, a3, a4, self->device->console_layout.load(std::memory_order_relaxed));
- constexpr unsigned pc = console_to_pc_list_slot(Slot);
- if constexpr (pc == kListNotForwarded) {
- if constexpr (Slot == kConsoleAllocateUpload) {
- return upload_alloc(self->device, a1, a2); // (size, alignment); the comment at UploadChunk
- }
- return 0; // unmodelled console slot: recorded above, never a PC call
- } else {
- if (pc >= self->pc_slot_count) {
- static std::atomic beyond_warned[kListSlots];
- bool expected = false;
- if (beyond_warned[Slot].compare_exchange_strong(expected, true, std::memory_order_relaxed))
- std::fprintf(stderr,
- "[rt] d3d12_xs: list slot %u maps to PC slot %u, beyond the real list's %u "
- "slots; returning E_NOTIMPL\n",
- Slot, pc, self->pc_slot_count);
- return hr_to_u64(E_NOTIMPL);
- }
- using ForwardFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t, std::uint64_t,
- std::uint64_t, std::uint64_t);
- auto** const real_vtable = *reinterpret_cast(self->real);
- if constexpr (Slot == 10) {
- // Reset(allocator, pso): the title hands its allocator proxy; the real list takes the real one.
- a1 = unwrap_object(a1);
- } else if constexpr (Slot == kConsoleExecuteBundle) {
- a1 = unwrap_object(a1); // the bundle is a list proxy too
- } else if constexpr (Slot >= 41 && Slot <= 46) {
- // The six root descriptor setters (index, GPU VA): an upload-arena CPU pointer becomes the
- // chunk's device address (d3d12_xs_console_abi.md §5.3 measures slots 41/43/45 for the compute
- // side; the graphics setters interleave on even slots).
- a2 = upload_translate(self->device, a2);
- } else if constexpr (Slot == 47) {
- // IASetIndexBuffer(pView): the view's BufferLocation is a GPU VA; translate in a copy so the
- // title's struct is not written.
- if (a1) {
- auto view = *reinterpret_cast(a1);
- view.BufferLocation = upload_translate(self->device, view.BufferLocation);
- return reinterpret_cast(real_vtable[pc])(
- self->real, reinterpret_cast(&view), a2, a3, a4, a5, a6, a7, a8, a9,
- a10, a11, a12, a13, a14);
- }
- } else if constexpr (Slot == 48) {
- // IASetVertexBuffers(start, count, views): each view's BufferLocation is a GPU VA. The views are
- // translated in the proxy's scratch array for the same reason as the index view.
- if (a3 && a2) {
- const auto* in = reinterpret_cast(a3);
- self->vb_scratch.assign(in, in + a2);
- for (auto& view : self->vb_scratch)
- view.BufferLocation = upload_translate(self->device, view.BufferLocation);
- return reinterpret_cast(real_vtable[pc])(
- self->real, a1, a2, reinterpret_cast(self->vb_scratch.data()), a4, a5,
- a6, a7, a8, a9, a10, a11, a12, a13, a14);
- }
- } else if constexpr (Slot == 49) {
- // SOSetTargets(start, count, views): BufferLocation and BufferFilledSizeLocation are both VAs.
- if (a3 && a2) {
- const auto* in = reinterpret_cast(a3);
- self->so_scratch.assign(in, in + a2);
- for (auto& view : self->so_scratch) {
- view.BufferLocation = upload_translate(self->device, view.BufferLocation);
- view.BufferFilledSizeLocation =
- upload_translate(self->device, view.BufferFilledSizeLocation);
- }
- return reinterpret_cast(real_vtable[pc])(
- self->real, a1, a2, reinterpret_cast(self->so_scratch.data()), a4, a5,
- a6, a7, a8, a9, a10, a11, a12, a13, a14);
- }
- } else if constexpr (Slot == kConsoleSetDescriptorHeaps) {
- UnwrappedArray heaps;
- if (!heaps.fill(a2, a1)) return 0; // void on the PC side; the call simply does not happen
- const std::uint64_t real_heaps = heaps.data() ? heaps.data() : a2;
- return reinterpret_cast(real_vtable[pc])(self->real, a1, real_heaps, a3, a4, a5, a6,
- a7, a8, a9, a10, a11, a12, a13, a14);
- }
- return reinterpret_cast(real_vtable[pc])(self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9,
- a10, a11, a12, a13, a14);
- }
- }
-}
-
-template
-void fill_list_vtable(void** vtable, std::index_sequence) {
- ((vtable[I] = reinterpret_cast(&list_slot(I)>) ), ...);
-}
-
-void** get_list_vtable() {
- static void** vtable = [] {
- static void* storage[kListSlots];
- fill_list_vtable(storage, std::make_index_sequence{});
- return storage;
- }();
- return vtable;
-}
-
-bool is_list_proxy_impl(const void* list) {
- return list && *reinterpret_cast(list) == reinterpret_cast(get_list_vtable());
-}
-
-IUnknown* list_real_or_null(const void* object) {
- return is_list_proxy_impl(object) ? static_cast(static_cast(object)->real)
- : nullptr;
-}
-
-// Wraps `created` (one reference, owned by the proxy on success, released on failure) and returns `riid` from the
-// proxy through `out`.
-HRESULT wrap_list(IUnknown* created, DeviceProxy* device, const IID* riid, void** out) {
- if (!created) return E_FAIL;
- ListProxy* proxy = new (std::nothrow) ListProxy(); // (): the console body starts zeroed
- if (!proxy) {
- created->Release();
- return E_OUTOFMEMORY;
- }
- proxy->vtable = get_list_vtable();
- proxy->real = static_cast(created);
- proxy->device = device;
- proxy->refs.store(1, std::memory_order_relaxed);
- proxy->pc_slot_count = detect_list_slot_count(created);
- proxy->pin_cursor_at_limit();
- proxy_add_ref(device); // the list keeps its Xbox-ABI device alive for GetDevice
-
- const HRESULT hr = list_query_interface(proxy, riid, out);
- if (FAILED(hr)) {
- destroy_list(proxy); // no reference escaped
- return hr;
- }
- static std::atomic logged{false};
- if (!d3d12_trace::enabled() && (!logged.exchange(true, std::memory_order_relaxed) || trace_enabled()))
- std::fprintf(stderr, "[rt] d3d12_xs: list proxy %p wraps %p (%u PC vtable slots)\n",
- static_cast(proxy), static_cast(created), proxy->pc_slot_count);
- proxy->refs.fetch_sub(1, std::memory_order_relaxed); // drop the creation reference; `out` holds the caller's
- return S_OK;
-}
-
-// Device slot 12: CreateCommandList(node_mask, type, allocator, initial_pso, riid, out). The title hands its
-// allocator proxy, which the real device unwraps to the real allocator; the created list goes back console-shaped.
-HRESULT proxy_create_command_list(DeviceProxy* self, std::uint64_t node_mask, std::uint64_t type,
- std::uint64_t allocator, std::uint64_t pso, const IID* riid, void** out) {
- note_slot(12);
- if (out) *out = nullptr; // as slot 8
- if (!riid) return E_POINTER;
- if (!out) return self->real->CreateCommandList(static_cast(node_mask),
- static_cast(type),
- reinterpret_cast(unwrap_object(allocator)),
- reinterpret_cast(pso), *riid, nullptr);
- if (!self->console_lists) {
- // PC caller (create_device_proxy's console_lists=false): the real list answers every PC slot, and the
- // console-only pieces (slot 148, the shifted tail) are simply not there for this caller to reach.
- return self->real->CreateCommandList(static_cast(node_mask),
- static_cast(type),
- reinterpret_cast(unwrap_object(allocator)),
- reinterpret_cast(pso), *riid, out);
- }
- void* created = nullptr;
- const HRESULT hr = self->real->CreateCommandList(
- static_cast(node_mask), static_cast(type),
- reinterpret_cast(unwrap_object(allocator)),
- reinterpret_cast(pso), __uuidof(ID3D12GraphicsCommandList), &created);
- if (FAILED(hr)) return hr;
- if (!created) return E_FAIL;
- return wrap_list(static_cast(created), self, riid, out);
-}
-
// Calls the real device's slot `Slot` with these five words in the positions the thunk received them (see "A thunk
// declares 14 argument words" at the top: no word may move to another stack position on the way).
template
@@ -2060,9 +1336,6 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64
} else if constexpr (Slot == 9) {
return hr_to_u64(proxy_create_command_allocator(self, a1, reinterpret_cast(a2),
reinterpret_cast(a3)));
- } else if constexpr (Slot == 12) {
- return hr_to_u64(proxy_create_command_list(self, a1, a2, a3, a4, reinterpret_cast(a5),
- reinterpret_cast(a6)));
} else if constexpr (Slot == 36) {
return hr_to_u64(proxy_create_fence(self, a1, a2, reinterpret_cast(a3),
reinterpret_cast(a4)));
@@ -2165,7 +1438,7 @@ unsigned detect_slot_count(ID3D12Device* real) {
} // namespace
-HRESULT create_device_proxy(ID3D12Device* real, REFIID riid, void** out, bool console_lists) {
+HRESULT create_device_proxy(ID3D12Device* real, REFIID riid, void** out) {
if (!real) return E_POINTER;
if (!out) return E_POINTER;
*out = nullptr;
@@ -2176,7 +1449,6 @@ HRESULT create_device_proxy(ID3D12Device* real, REFIID riid, void** out, bool co
proxy->real = real;
proxy->real_vtable = *reinterpret_cast(real);
proxy->slot_count = detect_slot_count(real);
- proxy->console_lists = console_lists;
proxy->refs.store(1, std::memory_order_relaxed);
proxy->dxgi_vtable = get_dxgi_vtable();
proxy->adapter_provider = nullptr;
@@ -2243,26 +1515,12 @@ ID3D12Device* device_proxy_real_device(const void* device) {
}
bool device_slot_overridden(unsigned slot) {
- return slot <= 2 || slot == 8 || slot == 9 || slot == 12 || slot == 14 || slot == 31 || slot == 32 ||
- slot == 34 || slot == 35 || slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 ||
- slot == 67 || slot == 75 || slot == 76;
+ return slot <= 2 || slot == 8 || slot == 9 || slot == 14 || slot == 31 || slot == 32 || slot == 34 || slot == 35 ||
+ slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 || slot == 67 ||
+ slot == 75 || slot == 76;
}
bool is_queue_proxy(const void* queue) { return is_child_proxy(queue); }
-
-bool is_list_proxy(const void* list) { return is_list_proxy_impl(list); }
-
-ID3D12CommandList* list_proxy_real_list(const void* list) {
- if (!is_list_proxy_impl(list)) return nullptr;
- return static_cast(list)->real;
-}
-
-const char* list_tail_slot_name(unsigned slot, unsigned char console_layout) {
- return list_tail_name(slot, console_layout);
-}
-std::uint64_t list_slot_hits(unsigned slot) {
- return slot < kListSlots ? ListStats::hits[slot].load(std::memory_order_relaxed) : 0;
-}
bool is_fence_proxy(const void* fence) { return is_child_proxy(fence); }
bool is_allocator_proxy(const void* allocator) { return is_child_proxy(allocator); }
diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h
index 33f38a2c4..8ff508e6f 100644
--- a/runtime/shims/d3d12_xs_device.h
+++ b/runtime/shims/d3d12_xs_device.h
@@ -24,23 +24,14 @@
// Command queues and fences (device slots 8, 75, 36, and 32 for a shared fence) come back wrapped in queue and fence
// proxies of the same kind: the public chain (19 queue slots, 11 or 12 fence slots in SDK 10.0.26100) is forwarded
// in PC order, and a slot past it, up to the end of the proxy's table (128 queue, 64 fence slots), is logged with its
-// first four argument words and answered S_OK on a queue or refused with E_NOTIMPL on a fence or allocator. A slot
-// past the table faults on the vtable read inside a
+// first four argument words and refused with E_NOTIMPL. A slot past the table faults on the vtable read inside a
// reserved, never-committed region, and the fault is logged with the slot. That is where the console's queue methods
-// (PresentX, SuspendX, ResumeX) will show up; the sibling-layer measurement puts PresentX at queue slot 30 or 32
-// and SignalX at 23 or 25 by runtime layout (docs/d3d12_xs_console_abi.md §4, unverified here). The proxy detects
-// the layout from a fence reaching slot 16/17, forwards SignalX as PC Signal, routes PresentX to the presentation
-// core under LEONIDA_VULKAN_DEVICE and answers the remaining console-only queue methods S_OK (frame pacing flows
-// through them) without forwarding, and that
-// the console keeps the public slots is an assumption (docs/d3d12_command_objects.md §5.2). Heap, queue and fence proxies are
+// (PresentX, SuspendX, ResumeX) will show up; their slots are not known and are not guessed, and that the console
+// keeps the public slots is an assumption (docs/d3d12_command_objects.md §5.2). Heap, queue and fence proxies are
// unwrapped wherever a device or queue method hands them to the real runtime: queue Signal/Wait (14/15), device
// CreateSharedHandle (31), MakeResident/Evict (34/35), SetEventOnMultipleFenceCompletion (45), SetResidencyPriority
-// (46) and EnqueueMakeResident (50). Command lists come back from device slot 12 behind a console-shaped list
-// proxy: console vtable order (PC order through slot 26, four console-only extras at 27-30, the PC chain shifted
-// +4 through console 59, measured tail slots at 60/61/146), the write cursor pinned at the record limits so a
-// title's inline writers always take the vtable path, unmodelled slots recorded and refused. Queue
-// ExecuteCommandLists unwraps the list array; the list's own Reset, ExecuteBundle and SetDescriptorHeaps unwrap
-// allocator, list and heap proxies. QueryInterface answers only the
+// (46) and EnqueueMakeResident (50). Command lists are not wrapped, so ExecuteCommandLists passes them through and a
+// heap proxy given to a list's SetDescriptorHeaps reaches the real list as it is. QueryInterface answers only the
// modelled interfaces; one the real object has but the proxy does not model is logged once and refused.
#pragma once
@@ -53,10 +44,7 @@ namespace rt::d3d12_xs {
// Wraps `real` and returns the requested device interface through `out`. Takes ownership of one reference to
// `real` on success; on failure the caller keeps its reference. Returns E_NOINTERFACE if `riid` is not a D3D12
// device interface the PC device implements.
-// `console_lists` shapes the command lists CreateCommandList returns: true (the title path) gives the
-// console-shaped object the Xbox ABI calls; false hands the real list back for callers compiled against
-// the PC headers (the GPU test harnesses), whose vtable indices past slot 26 do not exist in console order.
-HRESULT create_device_proxy(ID3D12Device* real, REFIID riid, void** out, bool console_lists = true);
+HRESULT create_device_proxy(ID3D12Device* real, REFIID riid, void** out);
// True when `device` points at a proxy created by create_device_proxy. Used by the tests.
bool is_device_proxy(const void* device);
@@ -131,20 +119,6 @@ bool command_object_tables_guarded();
inline constexpr GUID kLeonidaCommandAllocatorTag{
0x7d0e6b51, 0x34a2, 0x4f0c, {0x9a, 0x61, 0x0c, 0x5b, 0x2e, 0x8f, 0x4a, 0x10}};
bool is_allocator_proxy(const void* allocator);
-// Command-list proxies (device slot 12): the console-shaped object. is_list_proxy / list_proxy_real_list give the
-// same access as the queue, fence and allocator helpers; list_slot_hits counts calls per console slot.
-bool is_list_proxy(const void* list);
-ID3D12CommandList* list_proxy_real_list(const void* list);
-std::uint64_t list_slot_hits(unsigned slot);
-// The diagnostic name of a command-list slot on the list tail, where the newer console layout sits two slots later
-// than the older one from CopyTextureRegionX on (docs/d3d12_xs_console_abi.md 5.3: newer->older pairs 85->83,
-// 86->84, 87->85, 90->88, 91->89, 92->90, 95->93, 96->94). `console_layout` is the device-wide layout the queue
-// proxy detects (kConsoleLayoutOlder or kConsoleLayoutNewer). Null when the layout is not known yet or the slot is
-// not a measured tail slot of that layout, so that a slot number is never given the other layout's name. Naming
-// only: no slot is forwarded because of it.
-inline constexpr unsigned char kConsoleLayoutOlder = 1;
-inline constexpr unsigned char kConsoleLayoutNewer = 2;
-const char* list_tail_slot_name(unsigned slot, unsigned char console_layout);
// The wrapped allocator (no reference added), or null when `allocator` is not an allocator proxy.
ID3D12CommandAllocator* allocator_proxy_real_allocator(const void* allocator);
unsigned allocator_proxy_slot_count(const void* allocator);
diff --git a/runtime/shims/library_loader.cpp b/runtime/shims/library_loader.cpp
index 9d3810705..2fa04c75f 100644
--- a/runtime/shims/library_loader.cpp
+++ b/runtime/shims/library_loader.cpp
@@ -14,9 +14,7 @@
#include
#include
-#include
#include
-#include
#include