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.

@kormocicsaba

Copy link
Copy Markdown

Tested 72ab7623e, merged alone into main 8575d36: pass. 257/259, baseline only.
Main already routes slot 48 since #6935, but it passes the title's Flags through, and the Vulkan layer refuses any flag except DISABLE_GPU_TIMEOUT (d3d12_vulkan_device.cpp:5385). So this fix matters. #7037 does the same and says it measured a 16-byte D3D12_COMMAND_QUEUE_DESC (the four compute queues, Flags 1/2/3/0). Is your 32-byte size measured? If the description is 16 bytes, the log line reads 16 bytes past the caller's struct. This PR also conflicts with #6964 (the comment block and xs_proxy_mock_test.cpp).

Setup: RTX 4070 (driver 621.01), Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo with Ninja, Vulkan SDK 1.4.363.0. The PR head was merged alone into main 8575d36 and runtime/ was built. I ran the full ctest -j8 --timeout 300; no game files were used.
Baseline on main: d3d12_vulkan_device and d3d12_indirect_dispatch_count fail on main 8575d36 as well. d3d12_bindless_churn fails now and then under -j8 on main too: it failed in main's -j8 run and passed 3 of 3 times run alone there.

AI-assisted review (Claude Code). How this compares with the other boot-chain PRs: #7333 (comment)

@lunarminus

Copy link
Copy Markdown

Tested 72ab7623e against my own 1.0.2.1 retail executable on an AMD Radeon 760M (RDNA3 iGPU), RADV Mesa 26.3.1, Wine 11.22 on CachyOS Linux, network off. gta6rt was cross-built with clang-cl 23.1.5 and xwin SDK 10.0.26100 (RelWithDebInfo, LEONIDA_D3D12=vulkan): pass

Outcomes and counts only, no game data. 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