Skip to content

d3d12_xs: the device and queue proxies follow the console method order, not the PC one, so a console method no longer lands on a wrong PC method (XValkyrie B4/B5) - #7490

Open
tedin7 wants to merge 7 commits into
ItsNotRexed:mainfrom
tedin7:xv-b4b5

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in #6750 (comment)

@ItsNotRexed: an exe PR, as you asked.

What

The device and queue proxies follow the console vtable order instead of the PC one.

  • runtime/shims/d3d12_xs_console_slots.h (new): the console device order (0-42 public; console methods at 43-82 and 104;
    the public ID3D12Device1..5 at 83-103 and Device6..8 at 105-112, forwarded 39 or 40 slots lower) and the two known
    queue layouts (kit2020 and the later kit, which moves everything from Signal on by 2).
  • Device: 43 GetAdapterLuid with the LUID in RAX; 44 CreatePlacedResourceX (committed stand-in, every call logged);
    60 CreateGraphicsPipelineStateX (console flag bits removed); 61 CreateSamplerX (84-byte console sampler); 68
    GetGpuHardwareConfigurationX; 74/75 Register/UnregisterPagePoolX; 81 GetFrameStatisticsX (count 0, S_FALSE);
    111 the feedback UAV with the console argument order; 49-54, 58, 69, 72 accepted with no effect. Anything else
    is refused with E_NOTIMPL and never reaches a PC method.
  • d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 #6935's routes (48/73/78-80) run first, unchanged; the table refuses those slots only when LEONIDA_XS_*_SLOT
    moves a route away.
  • Queue: the layout is decided once, from the first Signal/Wait/SignalX given a fence proxy (14/15/23 vs 16/17/25)
    or a call at 32/33; the word is checked with VirtualQuery first. Until then a layout-dependent slot does nothing.
  • Diagnostics: every slot not forwarded is counted, and its first call is logged with the caller as module+RVA and
    four argument words, so the first boot names every console method the exe uses.

Why

In PC order, console methods at 44-82 land on PC Device1..14 methods (#6498: slot 78 reached
CreateReservedResource2). The queue sent 16-18 to GetTimestampFrequency/GetClockCalibration/GetDesc, which the
console queue does not have there. This gets the exe past device and queue calls that went to the wrong method.

Tested

Pod p2 (RTX 4090), clang-cl + xwin, Wine, DISPLAY=:99.

  • xs_console_slots_test (new), 3 modes (default, --later, --present-32): pass. On origin/main's proxy it fails
    at line 257 (a console slot reached a PC Device1+ method), and the two layout modes exit 5. Negative controls:
    26 public Device1..8 slots must reach PC 44-72, and 44-82, 104 and 113-127 must reach none.
  • 40 ctest tests over the proxy: 32 pass, 7 skip (need host D3D12 or the package), 1 fails the same way on main
    (d3d12_fence_timing check_luid: the test device's LUID is zero, line 248 on main).
  • Fixed to call the real objects or the console slots, checks kept: d3d12_vulkan_device, d3d12_debug_markers,
    d3d12_fence_timing, dxgi_device, d3d12_mesh, queue_proxy, device_proxy, xs_proxy_mock (d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 #6935's env tests now
    expect the console order: a moved route leaves 78 refused; a public method at 86 reaches PC 47).
    Shared helper: runtime/test/xs_console_call.h.
  • Timeouts on main too, not from this PR: queue_proxy and xbox_present time out at 600 s on main under Wine
    (queue_proxy's child-runner check hangs). With that one check skipped locally, queue_proxy's Vulkan run passes
    on this branch (31 differential cases, all 128 queue and 64 fence slots covered); on main it stops at its guard
    check. device_proxy skips on both (no host D3D12 under Wine).
  • Merges cleanly with d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0 #6953 (git merge-tree): the merged tree, with 192 slots and its slot-133 check, passes
    xs_proxy_mock (6 modes) and xs_console_slots (3 modes).

What xvalkyrie gave

Facts only, from sammwyy/xvalkyrie (GPL-3.0) at commit 53af7df77c10: src/runtime/modules/d3d12x/device.cpp:4196-4262
(device order, names and argument shapes of 43, 44, 48, 49-55, 58, 60, 61, 68, 69, 72-75, 78-81 and the
Device1..8 positions), device.cpp:2036-2186 (the two queue layouts) and docs/research/d3d12x.md. The sampler
layout is the kit's as xvalkyrie read it. No code was copied. Checked against Leonida's own measurements
(docs/d3d12_vulkan.md §7, docs/d3d12_command_objects.md §3.5a): device slots 1, 14-16, 18, 19, 27, 38 in PC order
and 62/67/76 console-only all fit. Where they differ, ours is kept: xvalkyrie leaves 67 unknown, and its
CreateCommandQueueX has three arguments where docs/d3d12_xs_surface.md inferred a shader-queue parameter (recorded,
not used). docs/d3d12_command_objects.md §5.2a has the full table.

Overlaps

Open PRs touching the same dispatcher: #7201 (86/101/108 to PC Device2/5/8: the same mapping, a subset of this
one), #7115 (61), #7187 (caller logging), #7066 (70), #7235 (127), #7218/#7075/#7183 (133). Slots 70, 127 and 133
stay refused here for their owners. #7218 names 133 CreatePlacedResourceX; xvalkyrie puts that method at 44.

Known limits

  • Until the title's queue layout is detected, GetDesc (queue slots 26/28) answers S_OK without writing the return buffer. Those slots are a different method in the other console layout, so writing through the first argument could corrupt memory; this PR leaves it open on purpose.
  • Slot 44 (CreatePlacedResourceX) is a committed stand-in, as its comment and the first-call log line say: the title's memory at that address is not shared with the resource.

AI-assisted: yes

Device slots 43-82 and 104 are console methods (handled, accepted or refused,
every call counted and reported with its caller); ID3D12Device1..8 are
forwarded from 83-103 and 105-112. The queue proxy decides between the two
known console layouts from the first fence call. Facts from xvalkyrie
53af7df77c10, checked against docs/d3d12_vulkan.md section 7.

WIP: tests that use the proxy as a PC device still need moving.
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.

1 participant