Skip to content

d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 (reopens #7201) - #219

Closed
Andretuta wants to merge 1 commit into
mainfrom
old-pr/9954
Closed

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9954

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

Carried over from old PR 9954 by justr4mzi in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9954, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
justr4mzi: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: the device slot 86/101/108 claim in #7049 (carried over from #7201)

Reopens #7201, which was closed in the PR reset, rebased onto current main.

What and why

Three Xbox device slots that sit past the PC vtable layout are routed to their PC counterparts on DeviceProxy:

  • Slot 86: CreatePipelineState(stream desc, riid, out) -> PC slot 47 (ID3D12Device2::CreatePipelineState). It refuses with E_NOINTERFACE on devices below Device2, zeroes *out and returns E_POINTER on a null IID.
  • Slot 101: CreateStateObject -> PC slot 62 (ID3D12Device5::CreateStateObject), with the same guards.
  • Slot 108: GetResourceAllocationInfo2 -> PC slot 68 (ID3D12Device8::GetResourceAllocationInfo2).
    • It accepts the console C-ABI order (return buffer in RCX, device in RDX) as well as the PC order.
    • It reads the title's 56-byte D3D12_RESOURCE_DESC entries and expands each one into a zeroed D3D12_RESOURCE_DESC1.
    • It normalizes Xbox layout words (0x101, 0x105) to ROW_MAJOR for buffers and UNKNOWN for everything else.
    • It masks flags to the PC set.
    • It refuses a count with a null array with {UINT64_MAX, 0}.

Retail evidence, from the #7201 thread:

  • Pipodi: without the PR, the first slot 108 call returns E_NOTIMPL and the title asserts. With it, that assert is gone.
  • Zunraz: slot 86 is reached, and 6 CreatePipelineState calls succeed through it.
  • LooperSalty: static evidence for the slot 86 call shape.
  • Cresceda's frame-loop measurement (#8554) used it.
  • Slot 101 has not been reached on retail yet, so it stays a hypothesis.

Changes from #7201 in this rebase:

  • Main's slot 133 (CreatePlacedResourceX) is kept alongside the new slots, in slot_name, device_slot_overridden, the dispatch and the mock test.
  • Slot 108 now masks flags with slot 133's PC set, 0x5FF: USE_TIGHT_ALIGNMENT is kept and 0x200 is dropped, instead of 0x1FF. This addresses tedin7's flag-mask note.

Open note (evansedeno): a console DEPTH_STENCIL | UNORDERED_ACCESS texture sizes through slot 25 but comes back {UINT64_MAX, 0} through slot 108. If #7679's pc_resource_desc lands, slot 108 should use it for each entry so that the two slots agree.

Tested

  • #7201 head 1d080f4 (the same code before the rebase):
    • evansedeno: native Windows 11, RTX 5080 / 621.24, 8/8 for device_proxy|device_proxy_trace|xs_proxy_mock.*.
    • tedin7: Wine, RTX 4090, mock test passes, negative control fails as expected.
    • Earlier heads: 12/12 on RX 6700 XT, RX 9070 XT, RX 7800 XT, RTX 4090, RTX 5070 Ti and RTX 5090, with and without LEONIDA_VK_VALIDATION=1.
  • This rebase: the conflicts with slot 133 were resolved by hand, and I have not built it on Windows yet. CI is the first build of this exact commit.

AI-assisted: yes (Claude)

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. (n/a: no translator change)

…evice8

Reopened from #7201 (closed in the PR reset), rebased on current main.

Slot 86 (CreatePipelineState stream) -> PC slot 47, slot 101
(CreateStateObject) -> PC slot 62, slot 108 (GetResourceAllocationInfo2)
-> PC slot 68. Slot 108 accepts the console C-ABI order (return buffer
first) and the PC order, reads the title's 56-byte D3D12_RESOURCE_DESC
entries, expands each into a zeroed D3D12_RESOURCE_DESC1, normalizes
Xbox layout words and flag bits, and refuses a count with a null array.

Rebase: kept main's slot 133 (CreatePlacedResourceX) next to the new
slots, and slot 108 now masks flags with slot 133's PC set (0x5FF, which
keeps USE_TIGHT_ALIGNMENT and drops 0x200) instead of 0x1FF.
@Mumogg

Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Measured on top of the stack of #349, #350, #356, #362, #369, #375, #377, #383 and #385 (plus #142 and #328), on main ece4ba5b3: Linux (Nobara 44), 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.

--run Traced D3D12 calls Ends with
the stack up to #385 11,916 a call through a null pointer in the host, right after the first call of device slot 108
+ this pull request 11,948 an access violation in the title, after command-queue slot 35 is refused as past the PC queue table

So the slot 108 stop is cleared here, and slot 86 is reached and routed: the log has device slot 86 (Xbox CreatePipelineState -> PC CreatePipelineState (slot 47)). All six ID3D12Device2::CreatePipelineState calls that follow fail, and the title goes on to WaitFrameEventX and to queue slot 35 regardless. I have not looked at why the six fail yet; that and queue slot 35 are the next two things on this path.

One note for whoever merges: on that stack this branch conflicts in d3d12_xs_device.cpp, its header and xs_proxy_mock_test.cpp, all of the neighbours kind (functions and slot-list entries added side by side). I resolved them by keeping both sides and gta6rt builds; I did not run this pull request's own tests on the merged tree.

AI-assisted; built and run on the machine above.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
@DesertGamer

Copy link
Copy Markdown
Contributor

Measured on main 21625bc + #142 + #427 + this PR + #602 (Windows 11, RTX 5070, driver 617.14, Vulkan backend with LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, translated shaders from LEONIDA_SHADERS).

Without this PR the title faults in the host at its first call of device slot 108 (proxy_slot<108>, d3d12_xs_device.cpp:2855), after 11,916 D3D12 calls with #142 + #427. At the fault RDX holds the device proxy and RCX is not an object, so the retail call is in the slot-26 shape (device in RDX); proxy_slot takes self from RCX and reads through garbage. With this PR the fault is gone, and the next stop is GetResourceAllocationInfo format not supported yet: 65 (A8_UNORM), which #602 clears. The run then went to 49,023 D3D12 calls, with the first PresentX ok at call 12,051 and no exception, until my 150 s limit.

One thing for the author: the PR no longer merges with current main. I resolved it locally by keeping both sides of three hunks in runtime/shims/d3d12_xs_device.cpp (the new proxy functions next to proxy_slot74, the Slot == 86 / 101 / 108 branches next to kCreateCommittedResource3X, and device_slot_overridden, where I added 86 || 101 || 108 to the current list) and the comment in d3d12_xs_device.h. runtime/test/xs_proxy_mock_test.cpp conflicts as well; I kept main's side there and did not build or run the tests.

No game data in this comment: only slot numbers, call counts and the format number.

AI-assisted: yes

@aslan2142

Copy link
Copy Markdown
Collaborator

This carry-over of old upstream PR 9954 has been taken over in #727, so I'm closing this draft as #17 describes. The branch old-pr/9954 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

@aslan2142 aslan2142 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants