Skip to content

d3d12_xs: device slot 25 takes the console's struct-return form too (RT-SLOT25) - #362

Merged
ubiquitarianism merged 6 commits into
ProjectLeonida:mainfrom
Mumogg:slot25-struct-return
Nov 24, 2026
Merged

ubiquitarianism merged 6 commits into
ProjectLeonida:mainfrom
Mumogg:slot25-struct-return

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-SLOT25. Depends on: #349, #350, #356 (their commits are the first three here; this pull request is the last two).

What and why

After #356 the retail boot stops with a host access violation at device slot 25, GetResourceAllocationInfo. It is slot 26's twin (#349): a method that returns a struct, called by the title with the buffer for the struct in RCX and the device in RDX, while main's forwarder takes RCX for the proxy.

  • Commit 5dbc30bed by sneylol (-x, authorship kept; an ancestor of main whose content is not in the tree) adds thunks for slots 25 and 26 that accept either form: whichever of the first two arguments is the device proxy is this. Slot 26 already has its thunk from d3d12_xs: device slot 26 takes the console's struct-return form, again (RT-SLOT26) #349, so only slot 25's is installed here; the commit message says so.
  • One commit of mine: xs_proxy_mock_test gets a case for slot 25 in both forms. The original commit tested it in device_proxy_test, which I cannot run (it stops at D3D12XboxCreateDevice returns a device under Wine, on main too).

Not included: the later guard for a stale vtable pointer in the title's return buffer (4154ab0a6, TreXito). It builds on this and can follow.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on main ece4ba5b3, with #142 and #328 applied on top for the boot runs (they are not in this branch).

--run Ends with
up to #356 host AV at device slot 25, right after its first call
+ this the title's own int3, after device slot 127 is refused as beyond the PC device table (E_NOTIMPL)

The D3D12 call count is 1,631 in both: GetResourceAllocationInfo is not one of the traced calls. The next stop is slot 127, the console's committed-resource creation.

xs_proxy_mock_test under Wine passes, with the new case: the buffer in RCX and the device in RDX reaches the PC method with the mask, count and descriptions, only the struct is written and the bytes around it stay; the PC form reaches it too.

Not built with MSVC and not run on Windows.

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

sennecools and others added 5 commits November 23, 2026 21:46
The retail executable calls GetCustomHeapProperties with the return buffer in RCX and the device in RDX. The forwarder took RCX for the proxy and faulted.

AI-assisted.

(cherry picked from commit 86b8e04)
…te Xbox description

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0cde63d)

Adapted to main by Mumogg: main already routes slot 48 through its Xbox slot table (LEONIDA_XS_QUEUE_X_SLOT),
so the route now calls proxy_create_command_queue_xbox instead of a fixed slot 48 branch, and xs_proxy_mock's
check_xbox_slots and the environment case pass the console's 32-byte description.
…ead of reaching PC CreatePlacedResource1 (retail boot chain stop 14)

(cherry picked from commit 3073250)
The retail executable calls GetCustomHeapProperties (device slot 26) with the
C convention: the hidden return buffer in RCX and the device in RDX. The
proxy's generic forwarder assumed the PC C++ form (this in RCX, buffer in
RDX), took the buffer for the device and crashed on its vtable right after
D3D12XboxCreateDevice.

Slots 25 (GetResourceAllocationInfo, same rule, inferred) and 26 (measured)
now get thunks that accept either form: whichever of the first two arguments
is the device proxy is `this`. The runtime's own code still calls the proxy
through d3d12.h in the PC form. device_proxy_test calls both slots in both
forms against WARP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5dbc30b)

Adapted to main by Mumogg: slot 26 keeps the thunk it already has (86b8e04), so of this commit's two thunks
only slot 25's is installed.
The mock device answers GetResourceAllocationInfo, and the new case calls slot 25 with the return buffer in RCX
and the device in RDX, then in the PC form: both reach the PC method with the mask, count and descriptions, and
only the struct is written.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@BadgersMC

Copy link
Copy Markdown
Contributor

I reproduced a slot 26 test regression on native Windows and tested the small patch below on this PR's head 9bc1f8f1. device_proxy passes at f9d20bf9 and first fails at 91575fda, with slot 26 hit counter is 3 and slot 26 PC form still forwards GetCustomHeapProperties.

The new WARP coverage calls slot 26 four times before the existing block reaches its absolute hit-count checks. Measuring the increase from the start of that block preserves the routing checks. Checking the returned heap properties separately also keeps a counter failure from being reported as a forwarding failure.

After applying the patch, all 8 device_proxy and xs_proxy_mock tests passed, including trace mode. Windows 11 build 26100, MSVC 19.44.35228, Windows SDK 10.0.26100, RelWithDebInfo, WARP and synthetic fixtures. No game files were used. AI-assisted with Codex.

Test-only patch for 9bc1f8f
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp
index 3fb0ba1d..b3b3f0fc 100644
--- a/runtime/test/device_proxy_test.cpp
+++ b/runtime/test/device_proxy_test.cpp
@@ -255,6 +255,7 @@ int main(int argc, char** argv) {
         D3D12_HEAP_PROPERTIES*(WINAPI*)(D3D12_HEAP_PROPERTIES*, void*, UINT, D3D12_HEAP_TYPE);
     auto get_custom_heap = reinterpret_cast<XboxGetCustomHeapPropertiesFn>(proxy_vtbl[26]);
     const D3D12_HEAP_TYPE heap_types[] = {D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_HEAP_TYPE_READBACK};
+    const auto slot26_hits_before = rt::d3d12_xs::device_slot_hits(26);
     bool console_returns_buffer = true, console_matches_pc = real != nullptr, console_writes_only_struct = true;
     for (const D3D12_HEAP_TYPE type : heap_types) {
         struct Padded {
@@ -272,15 +273,18 @@ int main(int argc, char** argv) {
     check(console_returns_buffer, "slot 26 console form returns the buffer's address");
     check(console_matches_pc, "slot 26 console form writes the PC device's DEFAULT, UPLOAD and READBACK properties");
     check(console_writes_only_struct, "slot 26 console form writes nothing past the struct");
-    check(rt::d3d12_xs::device_slot_hits(26) == 3, "slot 26 hit counter is 3");
+    check(rt::d3d12_xs::device_slot_hits(26) == slot26_hits_before + 3,
+          "slot 26 hit counter increases by three for the console calls");
     check(rt::d3d12_xs::is_device_proxy(device.Get()) && rt::d3d12_xs::device_proxy_real_device(device.Get()) == real,
           "the proxy is intact after the console-form calls");
     // A PC C++ call through the proxy (the proxy in RCX, the buffer in RDX) is still forwarded.
     const D3D12_HEAP_PROPERTIES pc_form = device->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD);
     const D3D12_HEAP_PROPERTIES pc_want = real ? real->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD)
                                                : D3D12_HEAP_PROPERTIES{};
-    check(real && std::memcmp(&pc_form, &pc_want, sizeof(pc_want)) == 0 && rt::d3d12_xs::device_slot_hits(26) == 4,
+    check(real && std::memcmp(&pc_form, &pc_want, sizeof(pc_want)) == 0,
           "slot 26 PC form still forwards GetCustomHeapProperties");
+    check(rt::d3d12_xs::device_slot_hits(26) == slot26_hits_before + 4,
+          "slot 26 hit counter also includes the PC call");
 
     // Slot 14: descriptor heap through the proxy. The proxy wraps the real PC heap for the handle ABI.
     D3D12_DESCRIPTOR_HEAP_DESC heap_desc{};

…t of their block

The slot 25/26 cases added before this block call slot 26 four times, so its absolute counts (3, then 4) failed
on Windows. The counts are now increases from the block's start, and the forwarding check no longer shares a
line with a counter, so a counter failure is not reported as a forwarding failure.

Patch by BadgersMC, from the review of ProjectLeonida#362 (found and tested on native Windows with WARP; device_proxy_test
does not run under Wine here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@Mumogg

Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, that is exactly the kind of failure I cannot see from here: device_proxy_test does not get past device creation under Wine.

Your patch is applied as its own commit on this branch (992b19bd4, credited to you in the message), and the pull requests stacked above this one (#369, #375, #377, #383) are rebased onto it, so they carry the fix too. I rebuilt device_proxy_test, xs_proxy_mock_test and gta6rt with clang-cl after the rebase and xs_proxy_mock_test passes under Wine; the device_proxy result is yours.

AI-assisted.

@ubiquitarianism
ubiquitarianism merged commit 2a2b168 into ProjectLeonida:main Nov 24, 2026
6 of 11 checks passed
SwavyJayden pushed a commit to SwavyJayden/leonida that referenced this pull request Nov 24, 2026
…t of their block

The slot 25/26 cases added before this block call slot 26 four times, so its absolute counts (3, then 4) failed
on Windows. The counts are now increases from the block's start, and the forwarding check no longer shares a
line with a counter, so a counter failure is not reported as a forwarding failure.

Patch by BadgersMC, from the review of ProjectLeonida#362 (found and tested on native Windows with WARP; device_proxy_test
does not run under Wine here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants