D3D12: fix the slot-14 and acphal build breaks, report slot-133 texture GPU VAs #2

Manually merged
github merged 3 commits from gh-pr/2/head into gh-pr/2/base 2026-11-26 08:39:38 +00:00
Owner

@⁠ExCorvus on GitHub · 2026-11-24 00:33 UTC · original
ExCorvus:fix/d3d12-build-breaks-and-texture-va → main · +98 −34 · 8 files · 3 commits · merged 2026-11-24 00:37 UTC

D3D12: fix the slot-14 and acphal build breaks, report slot-133 texture GPU VAs

Claimed in the coordination issue as: none exists yet. ubiquitarianism/leonida had
0 issues and 0 pull requests when this was written (8eee35cfd); CONTRIBUTING.md still links
the "Coordinating who works on what" issue in the deleted ItsNotRexed/Leonida repository, which
now returns 404. This PR is the claim. If a coordination issue is recreated, I will move the claim
there; otherwise please treat this line as the claim record.

Depends on: none. Based on 8eee35cfd (continuation/main); the merge-base with the last
pre-continuation commit is 2d53a8055.

AI-assisted: yes (DeepSeek V4.1 Flash 1017 / Alibaba Token Plan; coordinated by Qwen4 Max
Preview).

What and why

Three independent fixes. The continuation delta (2d53a8055..8eee35cfd, 35 commits) touches
none of the files below, so this applies and behaves the same on 8eee35cfd as it did on the
base.

Commit Area Problem
1 runtime acphal.cpp does not compile: the GDK size asserts fail (60/28 vs 64/32).
2 d3d12_xs 3630610ca does not compile (C3083/C2039) and its test does not build.
3 d3d12 A slot-133 placed texture answers GetGPUVirtualAddress with 0, so the title's texture clear writes at address 0.

Recommended commit order is 1, 2, 3 (both build breaks first, then the behavior change). If you
prefer smaller changes, commits 1-2 can land as a build-fix PR before commit 3.

1. runtime: acphal SHAPE context sizes

ccd36246f added the GDK static asserts, but the published field lists leave
SHAPE_XMA_CONTEXT at 60 bytes and SHAPE_PCM_CONTEXT at 28, so the file fails its
static_assert checks (C2338) and gta6rt does not build. The GDK layouts have one trailing
reserved word that the lists omit: reserved[11] for XMA (64 bytes) and reserved[2] for PCM
(32 bytes). The words are unused; this only restores the ABI size.

File: runtime/shims/acphal.cpp.

3630610ca ("report console descriptor heap address on Xbox slot 14") called
rt::d3d12::create_console_descriptor_heap from runtime/shims/d3d12_xs_device.cpp without
including d3d12_com.h; the namespace is unknown there:

runtime/shims/d3d12_xs_device.cpp(1606): error C3083: 'd3d12': symbol to the left of '::' must be a type or namespace
runtime/shims/d3d12_xs_device.cpp(1606): error C2039: 'create_console_descriptor_heap': is not a member of 'rt'

Including d3d12_com.h is not an option: it pulls Vulkan types into xs_proxy_mock_test, which
compiles d3d12_xs_device.cpp alone and does not link the Vulkan layer. The fix uses the same
handler pattern as slot 133:

  • ConsoleDescriptorHeapHandler and set_console_descriptor_heap_handler in
    d3d12_xs_device.h, backed by an atomic in d3d12_xs_device.cpp;
  • every Vulkan device registers rt::d3d12::create_console_descriptor_heap in its constructor;
  • Device::create_console_descriptor_heap owns the heap construction, so the free helper only
    unwraps the proxy's real device and delegates.

The new test needed three repairs independent of the handler: Ref::operator->, correct
create_device_proxy reference ownership (the function takes one reference on success), and
reading the PC heap start through heap_proxy_real_heap() rather than the proxy's Xbox-ABI
GetCPUDescriptorHandleForHeapStart (which answers in RAX). 3630610ca's stated limitation is
unchanged: the console address is reported, but title-memory/section 3.3 aliasing is still TODO.

Files: runtime/shims/d3d12_xs_device.h/.cpp, runtime/shims/d3d12_vulkan_device.cpp,
runtime/test/d3d12_console_descriptor_heap_test.cpp.

3. d3d12: slot-133 textures report the title address as their GPU VA

The retail title places a 256x256 R32_FLOAT texture through Xbox device slot 133 and then uses
ID3D12Resource::GetGPUVirtualAddress as the CPU pointer for its clear. On the console every
resource has an address; D3D12 answers 0 for a texture and the title therefore wrote 256 KB at
address 0. XCL measured the same clear and its res_gpu_va_x returns the title's placed address
(XCL PR #168). Provenance: the behavior was independently reimplemented from our own measurement;
XCL (GPL-2.0-only) is cited as measured prior art only, per docs/related_projects.md — no XCL
code, tables or comments were copied.

A slot-133 texture still gets the existing committed fallback image, but records the title address
and reports it from GetGPUVirtualAddress. Ordinary textures still answer 0 (as on D3D12) and
buffers keep their console arena VA. Limitation, stated in the diff and docs: the image does
not alias the title's pages yet, so a write through the returned address does not reach the
texture. That needs the page mapper; it is not hidden by this change.

Files: runtime/shims/d3d12_vulkan_device.cpp, runtime/test/d3d12_existing_heap_test.cpp,
docs/d3d12_vulkan.md, docs/retail_boot_chain.md.

Not in this PR: rpf9-explorer pin

A fourth local change bumps third_party/rpf9-explorer from e293917 to c77f750. It is not
part of this PR: continuation/main still pins e293917, and bb75702bc explicitly reverted an
earlier bump to keep that pin. The bump is asset-view tooling and should be requested separately
if the maintainers want it. The rest of this PR does not depend on it.

Tested

Host: Windows 11, AMD Radeon RX 9070 XT, driver 32.0.32029.2010 (Vulkan backend of the D3D12
layer).

  • cmake --build runtime/build --target gta6rt -j 12 -> gta6rt.exe linked at 2026-11-24
    00:27:51, after all touched source files (newest 00:27:45).
  • On 2026-11-24 00:26 the following built and exited 0:
    • d3d12_existing_heap_test (covers both slot-133 texture paths and the new VA answer)
    • d3d12_xmem_placed_test
    • xs_proxy_mock_test (compiles the proxy without the Vulkan layer)
    • d3d12_console_descriptor_heap_test (console slot 14 and the proxy's PC ABI)
  • Patch verification against 8eee35cfd: each unit applies with git apply --check; applying the
    three included units reproduces the intended tree byte-for-byte (all file blob hashes match), and
    the combined check passes. No rebase was needed because the 35 continuation commits change none
    of these files.
  • The build/test run above was made on the 2d53a8055 working tree before the continuation ref
    was fetched. Since 8eee35cfd does not touch these files, the patched content is identical, but
    CI on this PR will be the first full build on 8eee35cfd.
  • Python suite (the .github/workflows/ci.yml selection, run locally with python -I -m pytest):
    1848 passed, 21 skipped, 3 failed. All three failures are pre-existing and unrelated to this
    diff (C++/docs only): two test_cf_diff cases hit a translator-unsupported instruction, and one
    test_user_sgpr_census case assumes case-sensitive paths, which Windows does not provide.
  • Not tested: a new retail boot. The title-side clear that motivates the third commit was measured
    in the earlier debugging session and is the same observation recorded by XCL PR #168.

Checklist

  • No game data, keys or decryption in the diff, tests, docs or this description.
  • No new translator rule (not applicable).
**@⁠ExCorvus** on GitHub · 2026-11-24 00:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2) `ExCorvus:fix/d3d12-build-breaks-and-texture-va` → `main` · +98 −34 · 8 files · 3 commits · merged 2026-11-24 00:37 UTC # D3D12: fix the slot-14 and acphal build breaks, report slot-133 texture GPU VAs Claimed in the coordination issue as: **none exists yet.** `ubiquitarianism/leonida` had 0 issues and 0 pull requests when this was written (`8eee35cfd`); `CONTRIBUTING.md` still links the "Coordinating who works on what" issue in the deleted `ItsNotRexed/Leonida` repository, which now returns 404. This PR is the claim. If a coordination issue is recreated, I will move the claim there; otherwise please treat this line as the claim record. Depends on: none. Based on `8eee35cfd` (`continuation/main`); the merge-base with the last pre-continuation commit is `2d53a8055`. AI-assisted: yes (DeepSeek V4.1 Flash 1017 / Alibaba Token Plan; coordinated by Qwen4 Max Preview). ## What and why Three independent fixes. The continuation delta (`2d53a8055..8eee35cfd`, 35 commits) touches none of the files below, so this applies and behaves the same on `8eee35cfd` as it did on the base. | Commit | Area | Problem | | --- | --- | --- | | 1 | `runtime` | `acphal.cpp` does not compile: the GDK size asserts fail (60/28 vs 64/32). | | 2 | `d3d12_xs` | `3630610ca` does not compile (`C3083`/`C2039`) and its test does not build. | | 3 | `d3d12` | A slot-133 placed texture answers `GetGPUVirtualAddress` with 0, so the title's texture clear writes at address 0. | Recommended commit order is 1, 2, 3 (both build breaks first, then the behavior change). If you prefer smaller changes, commits 1-2 can land as a build-fix PR before commit 3. ### 1. `runtime`: acphal SHAPE context sizes `ccd36246f` added the GDK static asserts, but the published field lists leave `SHAPE_XMA_CONTEXT` at 60 bytes and `SHAPE_PCM_CONTEXT` at 28, so the file fails its `static_assert` checks (C2338) and `gta6rt` does not build. The GDK layouts have one trailing reserved word that the lists omit: `reserved[11]` for XMA (64 bytes) and `reserved[2]` for PCM (32 bytes). The words are unused; this only restores the ABI size. File: `runtime/shims/acphal.cpp`. ### 2. `d3d12_xs`: console-extended slot 14 compiles and links again `3630610ca` ("report console descriptor heap address on Xbox slot 14") called `rt::d3d12::create_console_descriptor_heap` from `runtime/shims/d3d12_xs_device.cpp` without including `d3d12_com.h`; the namespace is unknown there: ``` runtime/shims/d3d12_xs_device.cpp(1606): error C3083: 'd3d12': symbol to the left of '::' must be a type or namespace runtime/shims/d3d12_xs_device.cpp(1606): error C2039: 'create_console_descriptor_heap': is not a member of 'rt' ``` Including `d3d12_com.h` is not an option: it pulls Vulkan types into `xs_proxy_mock_test`, which compiles `d3d12_xs_device.cpp` alone and does not link the Vulkan layer. The fix uses the same handler pattern as slot 133: - `ConsoleDescriptorHeapHandler` and `set_console_descriptor_heap_handler` in `d3d12_xs_device.h`, backed by an atomic in `d3d12_xs_device.cpp`; - every Vulkan device registers `rt::d3d12::create_console_descriptor_heap` in its constructor; - `Device::create_console_descriptor_heap` owns the heap construction, so the free helper only unwraps the proxy's real device and delegates. The new test needed three repairs independent of the handler: `Ref::operator->`, correct `create_device_proxy` reference ownership (the function takes one reference on success), and reading the PC heap start through `heap_proxy_real_heap()` rather than the proxy's Xbox-ABI `GetCPUDescriptorHandleForHeapStart` (which answers in RAX). `3630610ca`'s stated limitation is unchanged: the console address is reported, but title-memory/section 3.3 aliasing is still TODO. Files: `runtime/shims/d3d12_xs_device.h/.cpp`, `runtime/shims/d3d12_vulkan_device.cpp`, `runtime/test/d3d12_console_descriptor_heap_test.cpp`. ### 3. `d3d12`: slot-133 textures report the title address as their GPU VA The retail title places a 256x256 `R32_FLOAT` texture through Xbox device slot 133 and then uses `ID3D12Resource::GetGPUVirtualAddress` as the CPU pointer for its clear. On the console every resource has an address; D3D12 answers 0 for a texture and the title therefore wrote 256 KB at address 0. XCL measured the same clear and its `res_gpu_va_x` returns the title's placed address (XCL PR #168). Provenance: the behavior was independently reimplemented from our own measurement; XCL (GPL-2.0-only) is cited as measured prior art only, per `docs/related_projects.md` — no XCL code, tables or comments were copied. A slot-133 texture still gets the existing committed fallback image, but records the title address and reports it from `GetGPUVirtualAddress`. Ordinary textures still answer 0 (as on D3D12) and buffers keep their console arena VA. **Limitation, stated in the diff and docs:** the image does not alias the title's pages yet, so a write through the returned address does not reach the texture. That needs the page mapper; it is not hidden by this change. Files: `runtime/shims/d3d12_vulkan_device.cpp`, `runtime/test/d3d12_existing_heap_test.cpp`, `docs/d3d12_vulkan.md`, `docs/retail_boot_chain.md`. ### Not in this PR: rpf9-explorer pin A fourth local change bumps `third_party/rpf9-explorer` from `e293917` to `c77f750`. It is **not** part of this PR: `continuation/main` still pins `e293917`, and `bb75702bc` explicitly reverted an earlier bump to keep that pin. The bump is asset-view tooling and should be requested separately if the maintainers want it. The rest of this PR does not depend on it. ## Tested Host: Windows 11, AMD Radeon RX 9070 XT, driver `32.0.32029.2010` (Vulkan backend of the D3D12 layer). - `cmake --build runtime/build --target gta6rt -j 12` -> `gta6rt.exe` linked at 2026-11-24 00:27:51, after all touched source files (newest 00:27:45). - On 2026-11-24 00:26 the following built and exited 0: - `d3d12_existing_heap_test` (covers both slot-133 texture paths and the new VA answer) - `d3d12_xmem_placed_test` - `xs_proxy_mock_test` (compiles the proxy without the Vulkan layer) - `d3d12_console_descriptor_heap_test` (console slot 14 and the proxy's PC ABI) - Patch verification against `8eee35cfd`: each unit applies with `git apply --check`; applying the three included units reproduces the intended tree byte-for-byte (all file blob hashes match), and the combined check passes. No rebase was needed because the 35 continuation commits change none of these files. - The build/test run above was made on the `2d53a8055` working tree before the continuation ref was fetched. Since `8eee35cfd` does not touch these files, the patched content is identical, but CI on this PR will be the first full build on `8eee35cfd`. - Python suite (the `.github/workflows/ci.yml` selection, run locally with `python -I -m pytest`): 1848 passed, 21 skipped, 3 failed. All three failures are pre-existing and unrelated to this diff (C++/docs only): two `test_cf_diff` cases hit a translator-unsupported instruction, and one `test_user_sgpr_census` case assumes case-sensitive paths, which Windows does not provide. - Not tested: a new retail boot. The title-side clear that motivates the third commit was measured in the earlier debugging session and is the same observation recorded by XCL PR #168. ## Checklist - [x] No game data, keys or decryption in the diff, tests, docs or this description. - [x] No new translator rule (not applicable).
ccd36246f added the GDK size checks, but the published field lists leave
SHAPE_XMA_CONTEXT at 60 bytes and SHAPE_PCM_CONTEXT at 28, so acphal.cpp fails
its static_asserts (C2338) and the runtime does not build. Each context has one
trailing reserved word in the GDK layout that the list omits: reserved[11] takes
the XMA context to 64 bytes and reserved[2] the PCM context to 32.

Tests: gta6rt links.

AI-assisted: DeepSeek V4.1 Flash 1017 (Alibaba Token Plan); coordinated by Qwen4 Max Preview.
3630610ca made the Xbox device proxy call
rt::d3d12::create_console_descriptor_heap directly, but d3d12_xs_device.cpp does
not include d3d12_com.h, so the tree does not compile: C3083 ('d3d12' is not
a namespace) and C2039 at d3d12_xs_device.cpp:1606. Including the header would
pull Vulkan types into xs_proxy_mock_test, which compiles the proxy standalone
and does not link the layer.

The proxy now has set_console_descriptor_heap_handler, the same shape as slot
133's placed-at-VA handler: a ConsoleDescriptorHeapHandler typedef and an atomic
in d3d12_xs_device.h/.cpp, registered by every Vulkan device in its constructor.
Heap creation moves into a Device member so the free helper only unwraps the
device and delegates. The new test gets its own reference from
create_device_proxy, reads the PC heap's CPU start through heap_proxy_real_heap()
instead of the Xbox-ABI proxy, and Ref gains operator->.

Tests: xs_proxy_mock_test and d3d12_console_descriptor_heap_test build and exit
0; gta6rt links.

AI-assisted: DeepSeek V4.1 Flash 1017 (Alibaba Token Plan); coordinated by Qwen4 Max Preview.
A retail title places a 256x256 R32_FLOAT texture through Xbox device slot 133
and then clears it through the value GetGPUVirtualAddress returns, used as a CPU
pointer. The layer answers 0 for a texture, as D3D12 does, so the title wrote
256 KB at address 0. XCL measured the same clear and returns the address the
title placed the resource at (its PR #168).

A slot-133 placed texture still gets its committed fallback image, but records
the title address and reports it from GetGPUVirtualAddress. Ordinary textures
still answer 0 and buffers are unchanged. The pixels do not alias the title's
pages yet, so a write through the address is not uploaded; that is the
page-mapper work and is called out in docs/d3d12_vulkan.md.

Tests: d3d12_existing_heap_test checks that the RENDER_TARGET layout and the
COMMON retry both answer the title address; it exits 0, and gta6rt links.

AI-assisted: DeepSeek V4.1 Flash 1017 (Alibaba Token Plan); coordinated by Qwen4 Max Preview.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:39:37 +00:00
github manually merged commit f9c68577e3 into gh-pr/2/base 2026-11-26 08:39:38 +00:00
Author
Owner

@⁠ExCorvus on GitHub · 2026-11-24 00:42 UTC · original

Boot test of this PR's build — Windows 11, RX 9070 XT, driver 32.0.32029.2010

Ran the three loader stages against my own 1.0.2.1 package (108/108 files SHA-256 verified):

  • --dry-run: 5 modules mapped, 11 unimplemented imports served by the return policy.
  • --init: "5 module(s) initialised"; both TLS callbacks ran; the loader's index-0 TLS rewrite is active (53,246 reads served from the module's own TLS).
  • --run: a window appears; the title ends ~2.1 s after start at stop 5 of docs/retail_boot_chain.md — its fatal assert after xcrdapi.dll!DStorageGetFactory leaves the factory null. The trace shows all four DllMains returning 1, the five startup XMemVirtualAlloc attribute setups accepted (including the two 24 GiB title-memory arenas), and InitializeApiImplEx2 (offline) before the DStorage call. The runtime catches the guest breakpoint and exits with code 0 — the "crash" is the title's own assert, not a host fault.

So with these fixes the public tree clears stops 1–4 on AMD hardware too, and the first remaining blocker is a console DirectStorage implementation (IDStorageFactoryX), not a return-class detail: the retail import lives under xcrdapi.dll, and under either return class the factory pointer stays null and the title asserts. ivall/xcl's hle/dstorage.rs is measured prior art for that work (facts only, GPL-2.0-only).

Context: the full asset/shader build was still running at test time; this stop is import-level and independent of it. No writes to the game folder (--overlay on a separate drive). Happy to attach the full trace shape (export names, call shapes and counts only) if useful.

**@⁠ExCorvus** on GitHub · 2026-11-24 00:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2#issuecomment-7118347331) **Boot test of this PR's build — Windows 11, RX 9070 XT, driver 32.0.32029.2010** Ran the three loader stages against my own 1.0.2.1 package (108/108 files SHA-256 verified): - `--dry-run`: 5 modules mapped, 11 unimplemented imports served by the return policy. - `--init`: "5 module(s) initialised"; both TLS callbacks ran; the loader's index-0 TLS rewrite is active (53,246 reads served from the module's own TLS). - `--run`: a window appears; the title ends ~2.1 s after start at **stop 5 of `docs/retail_boot_chain.md`** — its fatal assert after `xcrdapi.dll!DStorageGetFactory` leaves the factory null. The trace shows all four DllMains returning 1, the five startup `XMemVirtualAlloc` attribute setups accepted (including the two 24 GiB title-memory arenas), and `InitializeApiImplEx2` (offline) before the DStorage call. The runtime catches the guest breakpoint and exits with code 0 — the "crash" is the title's own assert, not a host fault. So with these fixes the public tree clears stops 1–4 on AMD hardware too, and the first remaining blocker is a console DirectStorage implementation (`IDStorageFactoryX`), not a return-class detail: the retail import lives under `xcrdapi.dll`, and under either return class the factory pointer stays null and the title asserts. ivall/xcl's `hle/dstorage.rs` is measured prior art for that work (facts only, GPL-2.0-only). Context: the full asset/shader build was still running at test time; this stop is import-level and independent of it. No writes to the game folder (`--overlay` on a separate drive). Happy to attach the full trace shape (export names, call shapes and counts only) if useful.
This discussion has been locked. Commenting is limited to contributors.
No description provided.