Skip to content

d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 - #6935

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Kam471:d3d12-xs-hle-device-slots
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Kam471:d3d12-xs-hle-device-slots

Conversation

@Kam471

@Kam471 Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #6910 (comment)

Depends on: none

What and why

The public HLE Freminet/ScarlettX records five Xbox device methods outside the PC vtable: CreateCommandQueueX at slot 48, CreateCommandListX at 73, SetFrameIntervalX at 78, ScheduleFrameEventX at 79 and WaitFrameEventX at 80 (a third-party observation, not Microsoft documentation). Today the proxy forwards those indices, so 78/79 reach CreateReservedResource2/CreateSampler2, 80 falls past an 80-slot ID3D12Device11 table, and 48/73 reach unrelated PC methods. A title that follows the public boot sequence stops there before it can create its first queue or list.

This routes the five slots in the generic device thunk before it indexes the PC vtable:

  • CreateCommandQueueX(desc, riid, out) uses the existing queue-proxy path (the first fields of the Xbox desc are D3D12_COMMAND_QUEUE_DESC's).
  • CreateCommandListX(desc, allocator, initialState, riid, out) calls PC CreateCommandList(0, type, allocator, initialState, riid, out): the type is the first word of the console desc, there is no node mask, and a Leonida allocator proxy is unwrapped first. The desc's second word is logged once, not interpreted, because its public layout is not established.
  • SetFrameIntervalX / ScheduleFrameEventX / WaitFrameEventX answer S_OK from a per-device token counter. WaitFrameEventX returns at once with a fresh non-zero token and E_POINTER for a null token pointer. There is no vblank source behind the device before a presenter exists, so these calls do not pace the title yet.

Because the indices are an observation rather than an ABI, each can be moved without a code change: LEONIDA_XS_QUEUE_X_SLOT, LEONIDA_XS_LIST_X_SLOT, LEONIDA_XS_FRAME_INTERVAL_SLOT, LEONIDA_XS_SCHEDULE_EVENT_SLOT and LEONIDA_XS_WAIT_EVENT_SLOT (3..127; an invalid value is logged once and ignored). The table is read once, on the first generic slot call.

Not in this PR: queue-side PresentX/SuspendX/ResumeX routing. That is separate work (see #6230 and #2490), and the queue slots are not guessed here.

docs/d3d12_vulkan.md §4.9 gains one row naming the five variables and the three caveats above.

Tested

Windows 11 26200, MSVC 19.44.35228, Ninja, RelWithDebInfo.

  • xs_proxy_mock (mock device answering ID3D12Device11, 80 PC slots): all five slots reach their handlers; none reaches the mock's own PC slot 48/73/78/79/80; the queue and command list are the created objects; WaitFrameEventX returns fresh non-zero tokens and E_POINTER for null; a null desc/allocator is E_INVALIDARG; device_slot_overridden returns true for the configured indices.
  • xs_proxy_mock --env-slots: all five routes move to 96-100 and the default 78 is then forwarded to the mock.
  • xs_proxy_mock --env-slots-invalid: values outside 3..127 are ignored and the five defaults still answer.
  • device_proxy (real PC device over WARP): slots 78/79/80 return S_OK and fresh tokens, 48 returns a queue proxy, and 73 creates a command list through PC CreateCommandList.
  • ctest -R "xs_proxy_mock|device_proxy": 8/8 passed (device_proxy, device_proxy_trace, xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots, _env_slots_invalid).
  • python -m pytest tests/test_docs_links.py tests/test_docs_table_rows.py tests/test_docs_table_ids.py tests/test_docs_list_items.py tests/test_docs_repo_paths.py tests/test_docs_pr_template.py tests/test_docs_design_rows.py tests/test_docs_env_vars.py tests/test_docs_cli_flags.py tests/test_docs_python_deps.py -q: 33 passed, 6 subtests passed.
  • python -I tests/test_check_no_game_data.py: OK. python -I tests/test_d3d12_xs_surface.py: OK (SCARAB cross-check skipped without SCARAB_REF).
  • python -I scripts/merge_check.py --main origin/main 0=HEAD: clean, 0/1 commit already on main.

Limitations, recorded rather than hidden: the Xbox desc layouts beyond their first fields, the frame-token semantics and the ScaleFilter/frame-statistics values are not measured; the frame calls do not pace; and the slots are the HLE's, so a trace that disagrees moves them with the variables above.

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. (No translator rule changed.)

The public HLE Freminet/ScarlettX puts CreateCommandQueueX at device slot
48, CreateCommandListX at 73, SetFrameIntervalX at 78, ScheduleFrameEventX
at 79 and WaitFrameEventX at 80. The generic device thunk now answers those
slots before it indexes the PC vtable, so a title that follows the public
boot sequence no longer reaches CreateReservedResource2/CreateSampler2
(slots 78/79), falls past an 80-slot ID3D12Device11 table (slot 80), or
reaches unrelated PC methods (48/73).

Queue and list creation use the existing create paths. The command-list
call takes the console shape (desc, allocator, initialState, riid, out):
the type is the first word of the desc and there is no node mask. The three
frame calls are a per-device token counter and return S_OK; WaitFrameEventX
returns at once with a fresh non-zero token, because there is no vblank
source behind the device before a presenter exists.

The slot numbers are a third-party observation, not Microsoft
documentation, so each route can be moved with LEONIDA_XS_QUEUE_X_SLOT,
LEONIDA_XS_LIST_X_SLOT, LEONIDA_XS_FRAME_INTERVAL_SLOT,
LEONIDA_XS_SCHEDULE_EVENT_SLOT and LEONIDA_XS_WAIT_EVENT_SLOT (3..127;
anything else is logged once and ignored).

Tests: xs_proxy_mock (mock device answering ID3D12Device11: the five slots
reach the handlers, none reaches the mock's own PC slots, null arguments
are refused, environment overrides move all five, out-of-range values are
ignored) and device_proxy (WARP: the same five slots, including a command
list and a queue proxy). 8/8 ctest targets pass: device_proxy,
device_proxy_trace, xs_proxy_mock, xs_proxy_mock_no_reserve,
xs_proxy_mock_no_protect, xs_proxy_mock_no_handler,
xs_proxy_mock_env_slots, xs_proxy_mock_env_slots_invalid.
@Vencite

Vencite commented Nov 23, 2026

Copy link
Copy Markdown

Independently tested 9e4da128f on Windows with Visual Studio 2022, MSVC 19.44.35230, x64 RelWithDebInfo. All 8 tests matched by ctest -R "xs_proxy_mock|device_proxy" passed, including the WARP device test and both environment-slot cases. No retail executable was used. AI-assisted.

@0klavair

Copy link
Copy Markdown
Contributor

Tested on the retail executable: two stops. 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., plus a local slot 26 stand-in (as #6964/#6973).

  1. Slot 48: the first CreateCommandQueueX passes, then the second one is refused with CreateCommandQueue refused (type, priority, flags or node mask), type 2, and the title hits int3 at +0x2478866. The four calls pass Flags 1, 2, 3 and then 0 (with NodeMask 1). 2 and 3 carry a console bit the PC runtime rejects. d3d12_xs: Xbox device slot 48 creates a command queue from its 32-byte description #6954 (@Pipodi) masks it and gets all four through on the same base.
  2. Slot 73, with the queue flags masked locally to get past 1: the description words are 0x0 0x2 (type 0, as you read it ✓). But the title asks for riid = {c3827890-4024-474c-98cf-645b51dc4874}, which the layer doesn't know (QueryInterface: unknown IID). So CreateCommandList returns E_NOINTERFACE and the title hits int3 at +0x2478b7b. That IID shares Data1 with the PC ID3D12GraphicsCommandList6 (c3827890-e548-…). Creating the list as the PC ID3D12GraphicsCommandList for that IID gets past it in my local run.

After both, the next stop is the new list's console slots 131/132, which @tedin7's command-list order item covers. Details are in #6750 (comment). AI-assisted (Claude Code).

@thehollowedone

Copy link
Copy Markdown

Independent native Windows WARP check of 49b2e792. The focused device_proxy test exercised all five Xbox routes. Queue and command-list creation succeeded, the frame interval and scheduling calls returned S_OK, and two frame-event wait calls produced distinct nonzero tokens. The run passed with zero skips.

This fixture checked the routing and return values using software D3D12.

AI-assisted.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary
runtime/shims/d3d12_xs_device.cpp installs XboxDeviceSlotRoutes that intercept device slots 48/73/78/79/80 before the PC vtable, via env_device_slot plus proxy_set_frame_interval_x, proxy_schedule_frame_event_x, proxy_wait_frame_event_x and proxy_create_command_list_x; env overrides and tests/docs are included.

Why merge
Restores Xbox-specific device calls that previously fell through to incompatible PC slots, with proxy outputs, hit counters and override coverage. Important for executable emulation fidelity.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary
runtime/shims/d3d12_xs_device.cpp installs XboxDeviceSlotRoutes that intercept device slots 48/73/78/79/80 before the PC vtable, via env_device_slot plus proxy_set_frame_interval_x, proxy_schedule_frame_event_x, proxy_wait_frame_event_x and proxy_create_command_list_x; env overrides and tests/docs are included.

Why merge
Restores Xbox-specific device calls that previously fell through to incompatible PC slots, with proxy outputs, hit counters and override coverage. Important for executable emulation fidelity.

Verdict: Approve

@shayderrr
shayderrr merged commit 2dbcb88 into ItsNotRexed:main Nov 23, 2026
0 of 5 checks passed
@LooperSalty

Copy link
Copy Markdown

Measured on the 1.0.2.1 executable (own copy, Windows 11, RTX 4070 SUPER, local gta6rt RelWithDebInfo from main 1cc6e3c1 + #6919 + this PR, LEONIDA_UNIMPLEMENTED=log). Counts, RVAs and descriptor values only.

CreateCommandQueueX (slot 48): Xbox-only bits in Flags. The title creates its compute queues through slot 48 at one call site (game+0x2478813 and the next two calls), with these {Type, Priority, Flags, NodeMask}:

queue Type Priority Flags NodeMask host result
1st slot-48 call 2 0 0x1 0 S_OK
2nd 2 0 0x2 0 E_INVALIDARG, the title asserts (int3 at game+0x2478866)
3rd 2 0 0x3 0 not reached before the fix

PC D3D12_COMMAND_QUEUE_FLAGS only accepts DISABLE_GPU_TIMEOUT (0x1), so the host rejects bit 0x2. With desc.Flags &= D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT before the host call (and the removed bits logged once), all three queues are created and the run goes past that assert. Suggestion: clear the Xbox-only Flags bits in the slot-48 path. TomBox's xone_queue.rs translates type, priority and node mask but leaves Flags alone, so it doesn't cover this case.

Next stop on the same routing, for information (I'm still checking it, not claiming it in this comment): slot 73 CreateCommandListX logs desc words 0x0 0x2 and the host throws a C++ exception right after, then the title asserts at game+0x2478b7b.

AI-assisted (Claude Code).

Stalkerino added a commit to Stalkerino/Leonida that referenced this pull request Nov 23, 2026
Route the Xbox GraphicsCommandList6 request from ItsNotRexed#6935 through ItsNotRexed#2490's list factory. Query the host's GraphicsCommandList6 capability, preserve public PC list requests and count the Xbox call at the device slot that was actually invoked.

The mock checks allocator unwrapping, COM identity, Close, capability refusal, a neighbouring unknown IID, and public PC-list compatibility. The retail IID was independently reported in ItsNotRexed#6935 (comment 7105882597) and ItsNotRexed#3918 (comment 7086980056). AI-assisted.
Stalkerino added a commit to Stalkerino/Leonida that referenced this pull request Nov 23, 2026
Route the Xbox GraphicsCommandList6 request from ItsNotRexed#6935 through ItsNotRexed#2490's list factory. Query the host's GraphicsCommandList6 capability, preserve public PC list requests and count the Xbox call at the device slot that was actually invoked.

The mock checks allocator unwrapping, COM identity, Close, capability refusal, a neighbouring unknown IID, and public PC-list compatibility. The retail IID was independently reported in ItsNotRexed#6935 (comment 7105882597) and ItsNotRexed#3918 (comment 7086980056). AI-assisted.
@sneylol

sneylol commented Nov 23, 2026

Copy link
Copy Markdown

Heads-up, @Kam471: since this merged, d3d12_vulkan_device fails on main (b66e184) at line 6564: tiles == 1. I checked on Windows 11 with an RX 9070 XT and a clean build of main. That check calls ID3D12Device10::CreateReservedResource2 through a device proxy made by create_device_proxy. PC slot 78 is now routed to SetFrameIntervalX, which answers S_OK without creating the resource, so two stays null and GetResourceTiling reports 0 tiles. Any runtime-side caller that uses d3d12.h's ID3D12Device10/11 methods on the proxy (slots 78–80: CreateReservedResource2, CreateSampler2, GetResourceAllocationInfo3) gets the same. The test could call those on the inner device instead, as xs_pc_list.h does for lists in #1325; or the routes could check the argument shape. Your call; I'm not claiming it.

For reference, the retail title does call 78 and 79 with HRESULT-checked console arguments (78 (0, 0x8235, 3, …), 79 (0, 0, 0, …) and (2, 0, 0, 0); #313 comment 7106487864), so routing them is right for the title.

AI-assisted (Claude Code).

sneylol added a commit to sneylol/Leonida that referenced this pull request Nov 23, 2026
ItsNotRexed#6935 routes device slot 48 to CreateCommandQueueX and passes the title's
description to the PC path unchanged. The retail executable creates its four
compute queues there with console Flags 1, 2 and 3 (node mask 0) and 0 (node
mask 1). 2 and 3 are no PC queue flag, so the Vulkan device refuses the second
queue with E_INVALIDARG and the title asserts.

CreateCommandQueueX now copies the description, drops Flags (each value
logged once) and takes slot 8's path; a null description is refused before
the PC device. xs_proxy_mock's mock keeps slot 8's description as received
(the forwarded one is a local copy), and both it and device_proxy_test check
the forwarded fields for console Flags 1, 2 and 3; device_proxy_test also
signals a fence from each compute queue on WARP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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