Skip to content

d3d12_xs: device slot 26 takes the return buffer in RCX and the device in RDX, as the retail executable calls it (RT-5) - #6964

Open
sennecools wants to merge 4 commits into
ItsNotRexed:mainfrom
sennecools:d3d12-xs-slot26-console-form
Open

sennecools wants to merge 4 commits into
ItsNotRexed:mainfrom
sennecools:d3d12-xs-slot26-console-form

Conversation

@sennecools

@sennecools sennecools commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: D3D-669 (claim)

Depends on: none. Text conflicts with #6954 and #6935; the second to land rebases. #6973, opened later, makes the same slot 26 change.

What and why

gta6rt --run on the retail executable crashes in the loader right after device creation: 0xC0000005 in proxy_slot<26>.

The title calls device slot 26 (GetCustomHeapProperties) with the return buffer in RCX and the device in RDX. The proxy assumed the PC C++ order and took the buffer for the device.

Fix: slot 26 takes that form when RDX holds the device proxy. A PC-style call is forwarded as before. Slots 25 and 43 are not changed.

Tested

Windows 11, MSVC 14.44, RX 9070 XT (driver 32.0.32029.2010).

  • New checks in xs_proxy_mock_test and device_proxy_test pass. Against main's proxy, device_proxy_test ends with the same 0xC0000005.
  • Runtime ctest: 235 pass, 11 skip, 4 fail. The 4 also fail on main here: vk_queue_query_sync, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_pipeline_library_host.
  • Retail executable, own copy, with the open startup PRs merged locally: 3 runs of 3 get past slot 26 and reach slot 48.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not a translator change)

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.
@0klavair

Copy link
Copy Markdown
Contributor

Tested on the retail executable: pass. Own 1.0.2.1 copy (exe sha256 e95020b2…08993), Windows 11 23H2, RTX 5060 / 621.01, Ryzen 9 5950X, LEONIDA_D3D12=vulkan, LEONIDA_UNIMPLEMENTED=stop, MSVC 19.44. Base: main 1cc6e3c1 with #4313, #6792, #6709, #6582, #6733, #3390, #6814, #4348 and #6803 merged, plus local stand-ins for the 2 MiB pages and the physical pages. Exit codes, module+RVA and flag words only.

  • Without this PR: 0xC0000005 in the proxy right after D3D12XboxCreateDevice.
  • With it: slot 26 is served (GetCustomHeapProperties). The title then creates its queue (slot 8) and fence (slot 36) and stops at the next known item, device slot 48 (OpenExistingHeapFromAddress unsupported, then int3 at +0x2478826).

#6973 gives the same result on the same base. Slot 25 isn't called before slot 48 in this run, so only the slot 26 half can be compared on the retail boot so far. AI-assisted (Claude Code).

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardware & Environment

  • Host: Windows 11 Build 26300 x64
  • GPU: AMD Radeon RX 7900 GRE (16 GB VRAM)
  • Toolchain: MSVC 19.44 (Visual Studio 2022), CMake 4.4

Verification Summary

Targets compiled with MSVC 19.44 and executed natively:

  1. xs_proxy_mock_test.exe:

    • Passed with 0 failures (xs_proxy_mock_test: PASS (9 allocations refused on purpose)).
    • Validated that check_custom_heap_properties exercises slot 26 (GetCustomHeapProperties) with console C-ABI struct-return calling convention (padded.value buffer in RCX, device in RDX), writing exact D3D12_HEAP_PROPERTIES output without buffer overrun or corruption of surrounding guard bytes, while also verifying PC C++ ABI caller forwarding.
  2. device_proxy_test.exe:

    • Passed with 0 failures across live WARP adapter testing.
  3. CTest Suite:

    • device_proxy: Passed (0.03s)
    • device_proxy_trace: Passed (0.03s)
    • xs_proxy_mock: Passed (0.01s)
    • xs_proxy_mock_no_reserve: Passed (0.01s)
    • xs_proxy_mock_no_protect: Passed (0.01s)
    • xs_proxy_mock_no_handler: Passed (0.01s)
    • Total: 6/6 passed (100%).
  4. Overlap Note:

    • Note for maintainers: PR #6973 covers both slot 25 and slot 26. Whichever PR merges first, the other can be rebased or consolidated accordingly.
  5. Hygiene & Compliance:

    • Clean-room compliant: pure synthetic unit tests; zero game assets or proprietary code.
    • git diff origin/main..HEAD --check: Clean (0 whitespace/formatting defects).

LGTM!

@Kam471

Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Note for the rebase: the #6935 conflict you listed is now on main (merged as 2dbcb882c, slot 48/73/78/79/80). Rebase on current main and keep your slot 26 handler and its device_slot_overridden(26)/test additions; the only overlap should be the header comment list and the test's main() call chain. No duplicate from my side: slot 26 is independent of the merged routes.

@sennecools

Copy link
Copy Markdown
Author

Merged current main (with #6935) into the branch; the conflicts were the slot list comment, device_slot_overridden and the mock test's check list, as @Kam471 said. ctest -R "xs_proxy|device_proxy": 8 of 8 pass (MSVC 14.44). AI-assisted.

@Marukooh

Copy link
Copy Markdown
Contributor

Independent before/after test of 23e9c953 on CachyOS x86-64, Wine 11.22, clang-cl 23.1.5/xwin SDK 10.0.26100, Release, RTX 5070 Ti (NVIDIA 620.73.04), Vulkan. Offline with my local 1.0.2.1 package.

Local stack: #4313 + #6792 + #6919 + #6582 + #4348 + #3410 with static SDL 3.4.20. The GameInput ordinal is bound to the shim, and the game opens its first DirectStorage file, calls the physical-page allocator and creates a Vulkan device on the 5070 Ti. Without this slot 26 patch the first forwarded call produced a read access violation. With this patch it reaches the device's Xbox queue creation at slot 48, where this build still forwards the call. The synthetic xs_proxy_mock passes with the Xbox and PC calling forms. Both synthetic GameInput CTests also passed.

Only call outcomes are reported. AI-assisted (Codex).

@zohaiblazuli

zohaiblazuli commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested 23e9c9535 on the retail executable: pass. (The PR head has since moved to 0d73e8b95, which I have not run.)

Retail Xbox Series 1.0.2.1 package + executable (sizes match game/xbox-1.0.2.1.json), Windows 11 10.0.26300, MSVC (VS 2022), GeForce RTX 3060 (driver 32.0.16.1742). Host D3D12 backend (LEONIDA_D3D12=vulkan not compiled in: no Vulkan SDK on this machine). gta6rt --run with --overlay to a scratch folder, outbound network blocked, LEONIDA_UNIMPLEMENTED=stop. Base: main 9b72d0d2c + #6582, #6919, #4313, #4348, #6792, #6810, #6885, #6891 merged locally (conflicts resolved locally).

Outcomes only; no game data.

@sneylol

sneylol commented Nov 23, 2026

Copy link
Copy Markdown

Closing my #6973 as a duplicate of this one: same measurement, same fix for slot 26, and yours came first.

One point from #6973 for a possible follow-up, not a blocker here: slot 25 (GetResourceAllocationInfo) returns a 16-byte struct, so by the same C-ABI rule the title would pass the return buffer in RCX and the device in RDX there too. I didn't see a call site for it on the retail executable before the boot stops, so it stays an inference; #6973's dual-form thunk handled both slots the same way if you want to compare.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 0d73e8b merged with main b66e184 on Windows 11 / RTX 4080 SUPER against own copy of the retail exe: pass

  • Build: MSVC 14.51 (VS 18), Ninja, RelWithDebInfo, gta6rt + device_proxy_test + xs_proxy_mock_test. The merge is clean. (The previous head 23e9c95 conflicted with d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 #6935 in d3d12_xs_device.cpp/.h and xs_proxy_mock_test.cpp; this head doesn't.)
  • ctest -R "device_proxy|xs_proxy_mock": 8/8 passed.
  • Negative control: main's runtime/shims/d3d12_xs_device.cpp and .h with the PR's tests make device_proxy and device_proxy_trace crash (SegFault) and xs_proxy_mock fail; the other 5 still pass. With the PR's files restored, all 8 pass again.
  • gta6rt --dry-run (LEONIDA_D3D12=vulkan, fresh --trace, --trace-d3d12, --overlay to a scratch folder): main b66e184 and the PR both have 29 unimplemented imports (shim 54), with the same list (expected, since the change is in the proxy).
  • gta6rt --run with LEONIDA_UNIMPLEMENTED=stop: the PR stops where main b66e184 does. Now that d3d12_xs: D3D12ConfigureVirtualMemoryX shim (first unimplemented call of the title) #6792 is in, it gets past D3D12ConfigureVirtualMemoryX and ends with 0x80000003 (an int3 in the title) after 3 xmem_attributes events, before D3D12XboxCreateDevice. Slot 26 is not reached in a main-only run yet, so this checks that nothing regresses; it doesn't exercise the fix on the exe. Main sometimes crashes (C0000005/C0000374) before that point too, so it took repeated runs to see the stop.

@Zunraz

Zunraz commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows check of 0d73e8b95d9af460227efbce4b7ec182764abe2d, merged locally onto the current-main startup integration (main 8575d36ed plus #4313, #6919, #4348, #6991 and the RT-488 cache change). clang-cl 21.1.8 + xwin SDK 10.0.26100, static CRT, Windows build 26300; NVIDIA RTX 5090, driver 32.0.16.2124 for the retail Vulkan run.

  • xs_proxy_mock_test: PASS, including its slot-26 dual calling-convention / struct-only-write check.
  • device_proxy_test: OK, zero failures.
  • Before this PR, the bounded retail run faults in proxy_slot<26> after Vulkan device creation.
  • With it, the slot-26 fault disappears. The trace advances through CreateFence and one successful CreateCommandQueue. A subsequent queue is refused (type 2); execution stops after that failure. I have not diagnosed the additional queue parameters, so this is not a claim that the queue failure belongs to this PR.

The run has not produced a frame/menu. Socket creation, DNS and transmission remain debugger-guarded; local Winsock initialization is permitted. Outcomes only: no game files, raw trace, title offsets or register contents attached. AI-assisted (Codex).

tedin7 added a commit to tedin7/Leonida that referenced this pull request Nov 23, 2026
@ramenbellic

Copy link
Copy Markdown

Tested 0d73e8b9 against the retail executable. Linux under Proton Experimental (wine 11.0), RTX 3070 (driver 620.70.06), Ryzen 5 5600X; gta6rt cross-built with clang-cl 23.1.6 + xwin SDK 10.0.26100 (RelWithDebInfo), LEONIDA_D3D12=vulkan, own 1.0.2.1 executable, gta6rt --run. Base: main 8575d36ed + #4313 + #6582 + #4348 (what it takes on Wine to get past the static initializers and XGameRuntimeInitialize). Plus #6919 and #3410.

AI-assisted (Claude Code); outcomes only, no game data.

@sneylol

sneylol commented Nov 23, 2026

Copy link
Copy Markdown

Tested on the retail executable: pass. slot 26 is called right after device creation; no fault, and the title moves on to its queues.

Setup: own Xbox 1.0.2.1 copy (exe 120,181,760 bytes), Windows 11 26200, RX 9070 XT (AMD Windows driver), MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan, gta6rt --run with --overlay, --trace and --trace-d3d12. Integration branch: main 8575d36 + #6919 (36936f3) + #6964 + #4313 + #6582 + #4348 + #7076 + #7183, plus the console-flags drop from #7037 (now closed in favour of #6954, which does the same for these calls). No local stand-ins: every stop below is the PRs' own behaviour. Counts and API names only.

Result (one run): the device is created; 5 queues (4 through slot 48), 5 fences and 7 allocators; 581 command lists created and closed through slot 73 (list slots 132 and 131 reached on the console-IID lists); slots 78/79 answered; then the xmem placeholder window, its 2 MiB commits and the physical-page maps all succeed (xmem_attributes x7, xmem_physical_pages); the title then calls device slot 133 (a buffer at a title address: unified memory, #313 (comment)), which is refused with E_NOTIMPL, and the title stops on its own assert. That is the next blocker; it is not in any of these PRs.

AI-assisted (Claude Code).

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.

10 participants