[PR #2] [MERGED] D3D12: fix the slot-14 and acphal build breaks, report slot-133 texture GPU VAs #62

Closed
opened 2026-11-26 20:16:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2
Author: @ExCorvus
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fix/d3d12-build-breaks-and-texture-va


📝 Commits (3)

  • db761be runtime: give acphal's SHAPE contexts their GDK trailing words
  • a7ffc53 d3d12_xs: route console slot-14 heap creation through a registered handler
  • f9c6857 d3d12: slot 133 textures answer GetGPUVirtualAddress with the title address

📊 Changes

8 files changed (+98 additions, -34 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+10 -1)
📝 docs/retail_boot_chain.md (+6 -4)
📝 runtime/shims/acphal.cpp (+2 -2)
📝 runtime/shims/d3d12_vulkan_device.cpp (+37 -15)
📝 runtime/shims/d3d12_xs_device.cpp (+14 -4)
📝 runtime/shims/d3d12_xs_device.h (+9 -0)
📝 runtime/test/d3d12_console_descriptor_heap_test.cpp (+13 -5)
📝 runtime/test/d3d12_existing_heap_test.cpp (+7 -3)

📄 Description

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).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2 **Author:** [@ExCorvus](https://github.com/ExCorvus) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fix/d3d12-build-breaks-and-texture-va` --- ### 📝 Commits (3) - [`db761be`](https://github.com/ubiquitarianism/leonida/commit/db761be31041e1f9985d920a687e9e6952779fe9) runtime: give acphal's SHAPE contexts their GDK trailing words - [`a7ffc53`](https://github.com/ubiquitarianism/leonida/commit/a7ffc53c152aa725d9823655661a9e8cfd2d2a63) d3d12_xs: route console slot-14 heap creation through a registered handler - [`f9c6857`](https://github.com/ubiquitarianism/leonida/commit/f9c68577e3c640f2f1dbd4c7b19036eaf3cbd2a4) d3d12: slot 133 textures answer GetGPUVirtualAddress with the title address ### 📊 Changes **8 files changed** (+98 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+10 -1) 📝 `docs/retail_boot_chain.md` (+6 -4) 📝 `runtime/shims/acphal.cpp` (+2 -2) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+37 -15) 📝 `runtime/shims/d3d12_xs_device.cpp` (+14 -4) 📝 `runtime/shims/d3d12_xs_device.h` (+9 -0) 📝 `runtime/test/d3d12_console_descriptor_heap_test.cpp` (+13 -5) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+7 -3) </details> ### 📄 Description # 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:16:40 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#62
No description provided.