Skip to content

d3d12_xs: Xbox device slot 48 creates a command queue from its 32-byte description - #6954

Open
Pipodi wants to merge 3 commits into
ItsNotRexed:mainfrom
Pipodi:xs-slot48-queue
Open

Pipodi wants to merge 3 commits into
ItsNotRexed:mainfrom
Pipodi:xs-slot48-queue

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #6750 (comment) (item 2, from the RT-5 boot measurement in #6915)

What and why

Measured on the retail executable: Xbox device slot 48 is (desc, riid, out) with riid = IID_ID3D12CommandQueue. The desc is a PC D3D12_COMMAND_QUEUE_DESC (16 bytes) followed by four more 32-bit Xbox words. On the PC, slot 48 is OpenExistingHeapFromAddress, so the proxy forwarded the call by number and it failed. The title creates four of its five queues this way, and it can't continue without them.

proxy_create_command_queue_xbox copies the 16-byte PC prefix and keeps only D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT among the flags. It logs the four extra words once and takes the existing slot 8 path, so the title gets a queue proxy. A null desc returns E_INVALIDARG. The slot_name entry, the file header and the device row in docs/d3d12_vulkan.md say the same.

Tested

  • xs_proxy_mock_test (new case: a 32-byte desc through slot 48 → the mock's CreateCommandQueue sees the PC prefix with the unknown flag bit dropped, and a queue proxy comes back; a null desc gives E_INVALIDARG and a null output). PASS. MSVC 2022 RelWithDebInfo, Windows 11, RTX 4090 (driver 617.42).
  • On my own 1.0.2.1 copy under gta6rt --run (with the PRs listed in docs: the retail boot chain, what stops gta6rt --run in order (RT-5 measurement) #6915), all five queues are created and the title goes on to fences, allocators and command lists.

AI-assisted: yes (Claude Code)

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: runtime only)

🤖 Generated with Claude Code

…te Xbox description

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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., plus a local slot 26 stand-in (as #6964/#6973).

  • All four slot 48 calls create their queue. The descriptions carry Flags 1, 2, 3 and then 0 with NodeMask 1, with console words 1 0 0x40000000 1 each time. A plain PC CreateCommandQueue refuses Flags 2/3, and this PR handles them.
  • The run then gets to slot 9 (allocator, type 0) and stops at device slot 73, which is still forwarded to the PC slot 73 (CreateShaderCacheSession). That gives 0xC0000005, a read of 0x4f at +0x2478b96. Slot 73 is CreateCommandListX: @Kam471's d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 #6935 covers it, but see my note there about its IID.

AI-assisted (Claude Code).

@jlric

jlric commented Nov 23, 2026

Copy link
Copy Markdown

Tested 0cde63d6 on CachyOS, Wine 11.22, RTX 4070 (620.73.04), Vulkan. With the same boot stack, adding this PR's queue handler changed the result from 1 to 5 successful CreateCommandQueue calls and let startup reach the command-list path. xs_proxy_mock_test also passed. AI-assisted.

@Kam471

Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Heads-up: #6935 (the public-HLE slot 48/73/78/79/80 route) merged as 2dbcb882c, so main now routes device slot 48 by taking the desc pointer and calling the PC CreateCommandQueue. That reads the 16-byte D3D12_COMMAND_QUEUE_DESC prefix and passes the flags word through unchanged.

Your change is still distinct and likely needed: you measured a 32-byte console desc and found the extra flag bits that the PC runtime must not see (DISABLE_GPU_TIMEOUT kept). main's slot 48 does not copy the prefix or filter the flags. So this is not a duplicate in behaviour, but it does overlap slot 48's handler and the slot-name/header text in runtime/shims/d3d12_xs_device.cpp.

Suggestion: rebase on current main, keep proxy_create_command_queue_xbox as the slot 48 handler, and drop whatever part of the old slot-48 patch is now redundant. I can run xs_proxy_mock_test/device_proxy_test on the rebased head if that helps. No separate PR from my side.

Slot 48 goes through proxy_create_command_queue_xbox (filtered 16-byte prefix) via main's
queue_x route; the explicit slot 48 branch and the duplicate note_slot are gone. The
slot-48 header, slot name and tests follow, and device_proxy_test passes a 32-byte desc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quackottu

Copy link
Copy Markdown
Contributor

Tested the current head f20e99a5 (after the 15:56 push): merged onto main d2c2ab778 cleanly, Windows 11, MSVC 19.44, RelWithDebInfo. These results do not depend on the boot. The full gta6rt --run boot test is on hold until the game copy here is complete.

  • device_proxy_test: OK, 0 failures.
  • xs_proxy_mock_test: passes.
  • gta6rt --dry-run on the retail engine exe (1.0.2.1): 5 modules mapped and 29 unimplemented imports, the same as main. This is expected: slot 48 is a device vtable call, not an import, so the dry-run only shows that nothing regressed. Exercising slot 48 itself needs the --run boot.

@NJ1912

NJ1912 commented Nov 23, 2026

Copy link
Copy Markdown

Code read of f20e99a5 (merges cleanly onto main 829e5ede): the merge with #6935 is clean; one test passes a desc that is too short for the new handler.

  • d3d12_xs: route the public HLE's Xbox device slots 48/73/78/79/80 #6935 interaction: OK. Slot 48 now has a single path: main's routes.queue_x branch calls proxy_create_command_queue_xbox (runtime/shims/d3d12_xs_device.cpp:1570-1574) where main called proxy_create_command_queue on the raw pointer, the explicit Slot == 48 branch from 0cde63d6 is gone (so LEONIDA_XS_QUEUE_X_SLOT still moves the route), and the mock now records the slot 8 desc (runtime/test/xs_proxy_mock_test.cpp:191), so check_slot48 checks the filtered copy.
  • Out-of-bounds read in a test: the handler's one-time log reads desc[4]..desc[7] (d3d12_xs_device.cpp:1162-1165). run_env_slots(true) sends &kQueueDesc to the moved queue route (xs_proxy_mock_test.cpp:821), and kQueueDesc is a 16-byte D3D12_COMMAND_QUEUE_DESC (:296). --env-slots runs in its own process (runtime/CMakeLists.txt:842), so that is the first call there and the log reads 16 bytes past kQueueDesc. The test still passes, but an ASan build should flag it. check_xbox_slots makes the same call at :746 and is only safe because check_slot48 runs earlier in main (:976). Suggestion: one shared 32-byte const std::uint32_t kXboxQueueDesc[8]{} for both calls.
  • Docs (optional): docs/retail_boot_chain.md:24 still credits stop 8 to "Local, §3.2" and could name this PR; docs/d3d12_command_objects.md:833 still says CreateCommandQueueX has "No slot or parameter layout", and the measured (desc, riid, out) shape differs from the (pDesc, pShaderQueueParams, riid, out) shape inferred at :680, so a sentence there may be better than treating them as the same method.

Not run: code read only, no tests run. AI-assisted review.

…d#6954

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, all three points applied in a follow-up commit.

  • xs_proxy_mock_test.cpp: added one shared 32-byte kXboxQueueDesc[8] and use it for the slot 48 call in check_xbox_slots and the moved-slot call in run_env_slots(true), so the one-time log reading desc[4]..desc[7] stays inside the buffer.
  • docs/retail_boot_chain.md: stop 8 now credits d3d12_xs: Xbox device slot 48 creates a command queue from its 32-byte description #6954 instead of "Local, §3.2".
  • docs/d3d12_command_objects.md: added a sentence that the retail title calls device slot 48 as (desc, riid, out) with a 32-byte desc, which differs from the inferred (pDesc, pShaderQueueParams, riid, out) shape.

Tested: runtime rebuilt, ctest -R "xs_proxy_mock|device_proxy" 8/8 passed (MSVC, mock device, no GPU).

AI-assisted (Claude Code).

@ramenbellic

Copy link
Copy Markdown

Tested f20e99a5 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, #3410 and #6964.

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

@MiguelMachado-dev

Copy link
Copy Markdown

Tested 72ab7623e on Windows 11 build 26300 with MSVC 19.51, x64 RelWithDebInfo. All 6 xs_proxy_mock CTest cases passed, including the slot 48 command queue case. Synthetic CPU tests. AI-assisted.

@dandasma

Copy link
Copy Markdown
Contributor

Retail on AMD (own 1.0.2.1 copy, Windows 11, RX 9070 / AMD 26.10.1, Ryzen 9 9900X, LEONIDA_D3D12=vulkan, MSVC RelWithDebInfo): past stop 8, 3/3 (5 queues, 5 fences), on main 042c5f3 + #4313 #6582 #4348 #6964; 13/13 proxy, TLS, xmem, dstorage and xgameruntime ctests pass with it merged.

AI-assisted (Claude Code).

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

Tested on the retail boot (head 72ab7623e). Before: device slot 48 forwards the 32-byte Xbox desc and the Vulkan device refuses the queue (CreateCommandQueue refused …, type 2), and the title asserts. After: the slot-48 log shows flags=0x1, and the four compute/copy queues are created. The boot continues to slot 73 (1,181 D3D12 calls ok). Conflicts against current main are comments only (d3d12_xs_device.cpp/.h). Note for whoever merges #7066 after this: #7066 moves the slot 48/73 routing into route_xbox_device_slot, which still calls proxy_create_command_queue with the PC desc. That merge has to keep proxy_create_command_queue_xbox, or stop 8 comes back.

Setup: native Windows 11, RTX 5060 Ti (NVIDIA), Ryzen 7 8700F, MSVC RelWithDebInfo, LEONIDA_D3D12=vulkan, my own 1.0.2.1 copy with the full package as --game-dir. Local integration tree: main + #4313, #6582, #4348, #3410 (+SDL3), #6885, #6981, #6891, #7009, #4531, #6964, #6953, #7110, #7078, #7403, #7330, then the PRs below, one at a time.

Counts and stop numbers only, no game files. AI-assisted (Claude Code).

rndrmu added a commit to rndrmu/Leonida that referenced this pull request Nov 23, 2026
…iption)

Conflict notes: the stack routes Xbox slots through route_xbox_device_slot
(ItsNotRexed#7066/ItsNotRexed#7323); its CreateCommandQueueX branch now calls ItsNotRexed#6954's
proxy_create_command_queue_xbox instead of ItsNotRexed#6954's inline routing copy.

Measured here (Wine, own 1.0.2.1 copy): the title's second compute queue
passes Flags=2, which the Vulkan layer refused before this merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KevinPratap

Copy link
Copy Markdown

Tested 72ab7623e on RTX 4050 Laptop (NVIDIA 592.82), Windows 11, MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, gta6rt --run with outbound network blocked: pass.

Merged onto main dde82f27e with #4313, #6582, #4348, #2490, #4531 and #6964. Before it, slot 48 was routed with the raw 32-byte description and refused (CreateCommandQueue refused (type, priority, flags or node mask), type 2), and the title asserted. With it, the queues are created and the D3D12 trace grows to 1,181 calls, 1,180 ok: queues, fences, allocators, the command lists created and closed, XboxIDXGIDevice::GetAdapter, and SetFrameIntervalX/ScheduleFrameEventX. The run then calls through a null pointer at device slot 133 (#6953/#7075).

Conflicts: the slot comment in d3d12_xs_device.cpp, and main()'s check list in xs_proxy_mock_test.cpp.

Traces stay local; no addresses or game data here. AI-assisted (Claude Code).

@bobcatchris

Copy link
Copy Markdown
Contributor

Review finding from assembling the RT-5 stack on current main (posted in #7694 too): this PR's proxy_slot<48> branch is unreachable now. #6935 (merged) routes the Xbox slots through route_xbox_device_slot() before the thunk's own branches, and that route forwards the raw 32-byte desc to PC CreateCommandQueue. Measured on the retail 1.0.2.1 executable with the Vulkan backend on an RX 7900 XTX: [rt] d3d12: CreateCommandQueue refused (type, priority, flags or node mask), type 2, then the title asserts in its device-init function; routing routes.queue_x to proxy_create_command_queue_xbox as well clears it (two queues come through slot 48 with flags 0x1, extra words logged, and the boot goes on to slot 73 and past it).

So a rebase onto #6935 wants the route patched as well as the thunk; the mock test's check_slot48() passes through the thunk directly and would not catch it. Outcomes and slot numbers only; AI-assisted.

@XIIYAZ

XIIYAZ commented Nov 23, 2026

Copy link
Copy Markdown

Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF, RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, gta6rt --run with the network shimmed by #6943. Local integration branch on main dde82f27e with, in order: #6943, #7125, #6010, #7133, #4313, #6582, #4348, #6964, #6953, #6954, #2490, #7218, #7021, #7066, #7110 (+#7078, #6973), #7052. Each PR was merged, rebuilt and the game rerun; the stop named below is the first failure without it and is gone with it. With all of them the run reaches stop 17 of docs/retail_boot_chain.md (#6982) after 1,640 D3D12 calls. Counts and outcomes only; nothing from the executable is quoted.

Result: clears stop 8. Without it the second queue (type 2, compute) is refused: CreateCommandQueue refused (type, priority, flags or node mask), type 2. Current main already routes slot 48 but passes the description as a PC D3D12_COMMAND_QUEUE_DESC; with this PR all queues are created.

Heads-up: #7066 adds route_xbox_device_slot() whose queue_x branch calls proxy_create_command_queue with the PC desc, so landing #7066 after this PR silently brings stop 8 back unless that branch calls proxy_create_command_queue_xbox.

AI-assisted test run.

tibzejoker added a commit to tibzejoker/Leonida that referenced this pull request Nov 23, 2026
Slot 74 stand-in added beside slot 70; one route_xbox_device_slot (the auto-merge left two; the kept one has ItsNotRexed#6954's 32-byte queue path); env-slot test has both the 70 and 74 modes.

Co-Authored-By: Claude Fable 5.2 <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.