Skip to content

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

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

Pipodi wants to merge 3 commits into
ProjectLeonida: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
Collaborator

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.

@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.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

checked: #6954 at 72ab762, merged onto main 867d922 (clean merge) | on: Wine 11 on RunPod RTX 4090 (Linux), clang-cl cross-build; not native Windows, host D3D12/WARP comparisons do not run | ran: xs_proxy_mock_test EXIT 0, xs_proxy_mock_test: PASS, including the new line "slot 48 makes a queue proxy from a 32-byte description, PC prefix and flags only" and the one-time log slot 48 queue: flags=0x8001 extra words=0x11 0x22 0x33 0x44; its five ctest modes (--fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid) run by hand, all EXIT 0. device_proxy_test builds, EXIT 77 SKIP: no WARP adapter (Wine has no WARP), so its edited slot-48 block did not run here. Negative control: with only d3d12_xs_device.cpp/.h reverted to main (PR tests kept), xs_proxy_mock_test exits 1; with the PR it exits 0.

diff review: the thunk branch Slot == routes.queue_x now calls proxy_create_command_queue_xbox, which copies the 16-byte PC prefix of the 32-byte description, keeps only DISABLE_GPU_TIMEOUT in Flags (the mock records exactly the kept flags), logs the four extra words once and reuses the slot-8 path. The static_assert on sizeof(D3D12_COMMAND_QUEUE_DESC) is useful. It reads 8 words from desc without a length, which matches the measured 32-byte shape; a shorter caller would read past it (the null case is handled). About the earlier comment that this branch is unreachable because #6935 routes slot 48 through route_xbox_device_slot() first: on current main 867d922f0 that function does not exist anywhere in the tree and the only slot-48 route is this routes.queue_x branch in proxy_slot, which the PR does edit, so I could not reproduce that concern on this base. No game files; docs changes (retail_boot_chain row 8, d3d12_vulkan.md, d3d12_command_objects.md) match the code. Scope is one slot. I found no defect.

Not verified: retail boot, native Windows, a real host device behind the proxy; the meaning of the four extra words (unknown, only logged).

agent: yes
AI-assisted.

@akimfomin

Copy link
Copy Markdown

Independent native WARP A/B of the production Xbox queue route at 72ab7623 vs base 108c36ef, Windows 11 28000.3501 with portable LLVM/MinGW. I wrapped a real Microsoft Basic Render Driver device and called slot 48 with synthetic descriptors for Direct, Compute and Copy, each with flags 0, 1, 2, 3 and 0x200. The base accepted 6/15, rejecting flags 2, 3 and 0x200 for every queue type with E_INVALIDARG. The PR accepted 15/15. Underlying queue descriptions retained type, priority and node and contained exactly the supported flag bit. The caller’s descriptor stayed unchanged. The null descriptor check rejected the request and cleared the output.

The stock proxy mock passed in all six process modes. The Device11-only subcase was skipped by the portable SDK. No command was submitted and no game files were used. AI-assisted (Codex).

@byPreaZy

Copy link
Copy Markdown

checked: #6954 | with: applied the diff on main 867d922, built xs_proxy_mock_test and device_proxy_test (MSVC, Ninja RelWithDebInfo) | on: Windows 11, RX 9060 XT | result: xs_proxy_mock_test PASS (incl. new check_slot48: 32-byte desc -> queue proxy via PC slot 8, flags masked to DISABLE_GPU_TIMEOUT, extra words logged once, E_INVALIDARG on null desc), device_proxy_test OK (0 failures)

Code read: the new proxy_create_command_queue_xbox copies only the 16-byte PC D3D12_COMMAND_QUEUE_DESC prefix, masks Flags to the single PC-known bit, and reuses the slot 8 wrap path; the retail_boot_chain.md stop-8 row now correctly credits this PR. Docs updates are consistent with the measured (desc, riid, out) shape.

AI-assisted check.

@Cryptoteep

Copy link
Copy Markdown
Contributor

checked: #6954086d49c | with: clean merge onto main@867d922f0, check_no_game_data.py | on: Windows 11 24H2, no game files | result: pass (merges cleanly onto main@867d922f0 with zero conflicts; diff review confirms slot 48 CreateCommandQueueX parses the 32-byte console desc, sanitizes D3D12_COMMAND_QUEUE_DESC flags, logs extra words, and returns proxy_create_command_queue; handles !desc with E_INVALIDARG; xs_proxy_mock_test.cpp and device_proxy_test.cpp updated; scripts/check_no_game_data.py clean).

@isfcrctfs

Copy link
Copy Markdown

checked: #695472ab762 | with: PR diff applied cleanly to origin/main 867d922f0 (the PR's own base is 108c36ef); clang-cl 23.1.5 + lld-link cross build against xwin SDK 10.0.26100 (cmake -S runtime -B build --toolchain runtime/cmake/clang-cl-xwin.cmake -DXWIN_DIR=<xwin-sdk> -DVulkan_INCLUDE_DIR=<vulkan-headers-1.4.363>/include -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG /Zc:threadSafeInit-" -DLEONIDA_SDL3=ON -DLEONIDA_SDL3_FETCH=ON -DSDL_HIDAPI_LIBUSB=OFF; cmake --build build -j8; ctest -R '^(xs_proxy_mock|device_proxy)' under Wine; xs_proxy_mock_test also run directly | on: Linux x86_64, clang-cl 23.1.5 + lld-link, xwin SDK 10.0.26100, Wine 11.22-staging, no GPU (llvmpipe only), no game copy — a cross-build + Wine data point, not an MSVC/Windows check | result: pass on the mock test — build exit 0; xs_proxy_mock 6/6 ctest modes passed (plain, --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid); direct run xs_proxy_mock_test: PASS (9 allocations refused on purpose), including slot 48 makes a queue proxy from a 32-byte description, PC prefix and flags only and the one-time log slot 48 queue: flags=0x8001 extra words=0x11 0x22 0x33 0x44. device_proxy / device_proxy_trace: not run, GPU-dependent (see below).

Audit: clean (audit tool exit 0) and the diff was read. Seven files, +70/−20: runtime/shims/d3d12_xs_device.cpp (slot-48 route through a filtered PC prefix), runtime/shims/d3d12_xs_device.h (comment), runtime/test/device_proxy_test.cpp, runtime/test/xs_proxy_mock_test.cpp, and the three docs/ rows. No network, process-spawn, file-removal, CI/workflow, submodule, binary or game-data change.

Already in the integration main? The project's integration main (git.notrexed.dev/enx/leonida) already carries it as commit 07920f32b "Upstream PR #6954: d3d12_xs: Xbox device slot 48 creates a command queue from its 32-byte description" (checked on forge main b5163905e). GitHub origin/main at 867d922f0 does not; the PR's diff applies cleanly there.

Negative control: with only runtime/shims/d3d12_xs_device.cpp and .h reverted to origin/main (the PR's tests kept), xs_proxy_mock_test exits 1 at the new slot-48 check: main forwards the 32-byte description as a 16-byte D3D12_COMMAND_QUEUE_DESC and does not mask the flags, so the mock sees Flags == 0x8001 instead of DISABLE_GPU_TIMEOUT. Restoring the PR gives PASS as above.

One note, no change requested: the extra-word log reads desc[4..7], so the route now assumes the caller supplies the 32-byte console description. A caller passing the old 16-byte D3D12_COMMAND_QUEUE_DESC shape would be read past the struct. The measured title call and the updated test both pass 32 bytes, so this is a note about the assumption, not a failure of the tested path.

Not run: device_proxy and device_proxy_trace — GPU-dependent, and this host has no GPU (Vulkan is llvmpipe only); the test stops at D3D12CreateDevice before reaching slot 48. The PR body's MSVC/RTX 4090 run and the retail-executable queue creation are not reproduced: no game copy, and none should be used.

agent: yes

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
… command queue from its 32-byte description

Squashed from ItsNotRexed#6954 by Pipodi, head 72ab762 (security scan PASS).

Conflicts with ItsNotRexed#6964: the header comment lists both slot 26 and slot 48 as measured exceptions; xs_proxy_mock_test main runs both check_slot48 and check_custom_heap_properties.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…wers console tile sizes for 2D render targets (slot 25 return-buffer form; sizes ItsNotRexed#7240 leases at stop 17)

Squashed from ItsNotRexed#7078 by tedin7, head 3ace986 (security scan PASS).

Conflicts with ItsNotRexed#6954 (slot 48): header comment, slot overview in d3d12_xs_device.h and the mock test's check list keep both PRs' slots; slot 25/26/56 text and device_slot_overridden take this PR's form (it contains ItsNotRexed#6964).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…x layout word and flag bits on a copy before the PC GetResourceAllocationInfo (retail boot chain stop 16)

Squashed from ItsNotRexed#7110 by tedin7, head 77878e3 (security scan PASS).

Conflicts with ItsNotRexed#6954 (slot 48): the header comment and d3d12_xs_device.h keep the slot 48 text, the mock test's check list keeps check_slot48; everything slot 25 takes this PR's version (it contains ItsNotRexed#7078).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…d by the proxy (a null SRV for now, its raw words logged), not the PC CreatePlacedResource1 (retail boot chain stop 14)

Squashed from ItsNotRexed#7066 by tedin7, head 1d8d1d3 (security scan PASS).

Conflicts with ItsNotRexed#6964/ItsNotRexed#7218/ItsNotRexed#6954: slot 26, slot 133 and this PR's route_xbox_device_slot helper all kept; the helper's queue route calls ItsNotRexed#6954's proxy_create_command_queue_xbox (32-byte description) instead of the slot-8 path it was written against. device_slot_overridden, the header and the mock test's check list take the union.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…_OK in the proxy and never reaches the PC ShaderCacheControl (retail boot, after stop 20)

Squashed from ItsNotRexed#7323 by tedin7, head a30e78e (security scan PASS).

This PR and ItsNotRexed#7066 each add route_xbox_device_slot; ItsNotRexed#7066's copy is kept (with its queue route on ItsNotRexed#6954's 32-byte path, as reviewers asked for both PRs) and this PR's copy is dropped. run_env_slots takes both on_slot70 and on_slot74; CMake keeps both env-slot tests; check_slot74 sits after ItsNotRexed#7066's slot-70 checks; slot lists take the union.
@nschlaepfer

Copy link
Copy Markdown
Contributor

One additional measurement for Pipodi’s #6954, following 0klavair’s retail test and Marukooh’s #7037 comparison. We instrumented the unchanged rejection path after #6964 on a full-input Wine 9.0/lavapipe retail run. This comparison did not apply the flag translation.

Two consecutive slot-48 calls requested the same queue interface with an output pointer. Under the pinned backend’s PC-prefix interpretation, both were COMPUTE, priority 0, node mask 0. Word 2 (zero-based) was 1 on the first call and 2 on the second. The first returned a real queue and proxy. On the second, the backend’s flags predicate alone rejected the descriptor. Both backend and wrapper returned E_INVALIDARG with a null output. A title breakpoint followed about 2.4 ms later; the timing does not establish why the title stopped.

Does anyone have a public, version-tagged Scarlett reference, or a permissible aggregate sizeof/offsetof result for Type, Flags, EngineOrPipeIndex and QueueIndex in D3D12XBOX_COMMAND_QUEUE_DESC? No headers, binaries or title data needed. Microsoft’s Series-capable sample uses those named members, while current PC headers assign PC flag 2 a dynamic-priority meaning. Neither source identifies what the observed console word means. A typed offset result would distinguish a field-layout issue from a flag translation and help define what the backend should preserve.

AI-assisted with Claude Opus and Gemini Neon.

@Digit4w

Digit4w commented Nov 23, 2026

Copy link
Copy Markdown

Hardening note from a security read of 72ab7623 (diff only, nothing executed), no malicious code found:

proxy_create_command_queue_xbox only null-checks the title's desc and then reads 32 bytes from it: the 16-byte PC prefix through memcpy, and words 4-7 only for the one-time log line. A caller that passes a plain 16-byte D3D12_COMMAND_QUEUE_DESC would be over-read by 16 bytes. The retail title passes 32 bytes as measured here, so this is about robustness; logging only the words that are needed, or reading the extra words only on the console route, would remove it.

Findings come from a static, AI-assisted review of this PR's diff (nothing was executed); they were read by the account owner. This comment text is AI-generated.

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.