Skip to content

d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (device slot 41, RT-5 stop 19) - #7163

Closed
mrp1no wants to merge 2 commits into
ProjectLeonida:mainfrom
mrp1no:d3d12-xs-slot41-dispatch105
Closed

mrp1no wants to merge 2 commits into
ProjectLeonida:mainfrom
mrp1no:d3d12-xs-slot41-dispatch105

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: stop 19 of @KkelebekK's RT-5 finding (#6910 (comment)). Claim: #7049 (comment)

What and why

At startup the retail title creates five one-argument command signatures through device slot 41 (CreateCommandSignature, at its PC position), with no root signature. One of them uses the console argument type 105 with a 12-byte stride, next to a DISPATCH and a DISPATCH_MESH of 12 bytes. The PC layer refuses the unknown type with E_INVALIDARG, which is stop 19 of the boot measurements.

What type 105 is, read statically from my own copy's call sites (shapes and counts only, no code):

  • the signature's two ExecuteIndirect sites pass MaxCommandCount 1, and the argument offset is in the same upload buffer the DISPATCH sites use;
  • right before, both set the same compute state the DISPATCH path sets: pipeline, compute root signature, descriptor tables, root constants, root SRV/UAV, at the console command-list slots (PC + 4);
  • the draws and DISPATCH_MESH go through a different, graphics state path;
  • the one difference from DISPATCH: they record on a second command list of the title's rendering context.

So the 12 bytes are taken as a D3D12_DISPATCH_ARGUMENTS.

The change. Slot 41 now has its own handler:

  • a description that holds type 105 is copied with that type replaced by DISPATCH, and the substitution is logged once;
  • any other description is forwarded as the same pointer, so PC descriptions behave exactly as before;
  • the PC layer itself is unchanged (it still refuses unknown types, as the host does);
  • what the console does differently for type 105 (which command stream it feeds) is marked Open in the §4.9 table of docs/d3d12_vulkan.md, and HYPOTHESIS in the code.

The DISPATCH_MESH signature of the same stop stays with #3777 / #5899.

Tested

Windows 11, MSVC RelWithDebInfo, main 464887b4:

  • xs_proxy_mock_test: PASS. The new check sends a two-argument description (a root constant, then type 105). It expects the PC slot 41 to get a copy with DISPATCH and the same stride, count, root signature, IID and output, and the caller's description untouched. A PC DISPATCH_MESH description must arrive as the same pointer. With main's d3d12_xs_device.cpp the check fails (line 774).
  • ctest -R xs_proxy: 6/6.
  • python -I tests/test_docs_links.py and tests/test_docs_design_rows.py: OK.
  • Retail executable, own copy, gta6rt --run, 2 runs: the same stops as main (the first XMemVirtualAlloc check, or the known intermittent TLS slot 0 crash, Loader: the mapped game executable owns module TLS index 0 (RT-259) #4313). The boot doesn't reach slot 41 on main yet.

Independent of #7115 (slot 61); the two touch neighbouring lines of d3d12_xs_device.cpp, so whichever lands second needs a trivial rebase. No game data. AI-assisted (Claude Code).

🤖 Generated with Claude Code

…TCH (slot 41)

The retail title creates five one-argument command signatures with no root
signature at startup (device slot 41, CreateCommandSignature at its PC
position). One has the console argument type 105 and a 12-byte stride, next
to a DISPATCH and a DISPATCH_MESH of 12 bytes. The PC layer refuses the
unknown type, which is stop 19 of the RT-5 boot measurements.

Read statically from the title's call sites (shapes only): the two
ExecuteIndirect sites of that signature pass MaxCommandCount 1 and an offset
into the same argument buffer as the DISPATCH sites. Right before, they set
the same compute state as the DISPATCH path (pipeline, compute root signature,
tables, constants, SRV and UAV); they record on a second command list of the
title's context. So the argument is taken as a D3D12_DISPATCH_ARGUMENTS.

Slot 41 now has its own handler. A description that holds type 105 is copied
with that type replaced by DISPATCH (logged once). Any other description is
forwarded as the same pointer. What the console does differently for type 105
is left open in docs/d3d12_vulkan.md (section 4.9).

xs_proxy_mock_test: a two-argument description (a root constant, then type
105) reaches the PC slot 41 as a copy with DISPATCH, the same stride, count,
root signature, IID and output, and the caller's description is untouched; a
PC description is passed through unchanged. With main's d3d12_xs_device.cpp
the new check fails.

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

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Native Windows clang-cl/xwin build of 4c04c0f4e36476a6bbf309e2f0f4d6cfcbe9f045 failed twice at runtime/shims/d3d12_xs_device.cpp:1383. Clang rejects the constexpr cast of 105 to D3D12_INDIRECT_ARGUMENT_TYPE because that enum's valid range is [0, 15].

I tested a local patch that reads the field's bytes into a uint32_t with memcpy, then replaces 105 with DISPATCH before forwarding. The fixture writes and checks the raw value the same way. All six xs_proxy_mock CTests passed with the patch, and git apply --check passed against the original snapshot. AI-assisted testing and patch.

105 is outside D3D12_INDIRECT_ARGUMENT_TYPE's range [0, 15], so clang-cl
rejects a constant expression that casts it to the enum (reported by
umnitus on ProjectLeonida#7163). The handler now reads each argument's Type field as a
uint32_t through memcpy and compares it with 105; the test writes and reads
the raw value the same way, and the mock records it the same way.

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

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @umnitus, good catch. Fixed in 084c8c60e, as you suggested: the handler reads each argument's Type as a uint32_t through memcpy and compares it with 105, and the test writes and reads the raw value the same way, as does the mock. MSVC: ctest -R xs_proxy 6/6. I have no clang-cl here, so a rerun on your side would confirm it. AI-assisted (Claude Code).

@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested on the retail boot: pass. Own 1.0.2.1 copy, Windows 11, RTX 4090 / 617.42, LEONIDA_D3D12=vulkan, on boot-integration plus #7115, #6891, #7201 and a local DirectStorage zlib stage (the #7180 idea). I took both commits; the conflicts were only with the #6935 slot-route table.

  • Without this PR, the type-105 signature failed. The title then skipped the init that allocates a 3-entry per-frame table, and a later frame-start function wrote through that null table (an access violation with write address 0x20).
  • With it, the log shows slot 41 argument type 105 (stride 12) created as DISPATCH and the init runs. The access violation is gone.
  • The run now stops at device slot 57 (native graphics pipelines, @KkelebekK's claim 1), the same stop @simonbronk reports.

AI-assisted (Claude Code).

@jlric

jlric commented Nov 23, 2026

Copy link
Copy Markdown

Retail check of 084c8c60e on CachyOS / Wine 11.22, clang-cl/xwin, RTX 4070 (620.73.04). The handler builds and the type-105 signature returns S_OK. The next signature, DISPATCH_MESH, returns E_NOTIMPL on this stack without #3777, so stop 19 still fires here. AI-assisted testing.

@justr4mzi

Copy link
Copy Markdown
Contributor

Independent native Windows 11 / MSVC 19.44.35230.0 / AMD Radeon RX 6700 XT (gfx1031, Vulkan 1.4.335, driver 2.0.372) verification of 084c8c60e:

  • Build & CTest (standard and LEONIDA_VK_VALIDATION=1):
    • ctest --output-on-failure -R "^(xs_proxy_mock|device_proxy|d3d12_present|d3d12_draw)$": 8/8 passed (2.22 s standard, 1.63 s with LEONIDA_VK_VALIDATION=1, 0 validation errors).
    • xs_proxy_mock_test.exe (all 6 modes, including slot 41 CreateCommandSignature rewriting argument type 105 to DISPATCH) and device_proxy_test.exe (WARP): PASS (0 failures).
  • Negative control:
    • Reverting runtime/shims/d3d12_xs_device.cpp to parent 464887b4f while keeping xs_proxy_mock_test.cpp at 084c8c60e fails at xs_proxy_mock line 778: mock->args[41][0] != word(&console_sig) && mock->args[41][1] == 0x5150 (exit 1). Restoring 084c8c60e passes (exit 0).

AI-assisted (Gemini, Antigravity).

@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, network shimmed (#6943). Local branch on main dde82f27e + #6943 #7125 #6010 #7133 #4313 #6582 #4348 #6964 #6953 #6954 #2490 #7218 #7021 #7066 #7110(+#7078 #6973) #7052, then the PRs named below. Counts and outcomes only.

Result on NVIDIA: with this PR, slot 41 argument type 105 (stride 12) created as DISPATCH. The run still asserts right after, matching @jlric's report: the next signature, DISPATCH_MESH, is refused because CreateCommandSignature in d3d12_vulkan_device.cpp has no mesh IndirectKind (default: return E_NOTIMPL). That part is #3777, which conflicts with main's reworked mesh-draw recording (D3D-291) in d3d12_com.cpp, command_list.h and vulkan_replay.h.

AI-assisted test run.

@lines9686-rgb

Copy link
Copy Markdown
Contributor

Tested 084c8c60 merged onto main dde82f27 on Windows 11, RTX 3060 Ti (Ampere), NVIDIA 610.88, MSVC 19.52.37029 RelWithDebInfo: pass.

  • Merge: clean.
  • LEONIDA_VK_VALIDATION=1 ctest -C RelWithDebInfo -j 1 -R "^(xs_proxy.*|device_proxy.*|d3d12_xs.*|root_sig|queue_proxy|allocator_proxy)$": 11/11 passed, 0 validation messages. xs_proxy_mock logs slot 41 argument type 105 (stride 16) created as DISPATCH and the new slot 41 check passes.
  • ctest -C RelWithDebInfo -j 1 --timeout 600 (no validation): 268/272 passed (11 skipped). The 4 failures, d3d12_vulkan_device, d3d12_indirect_dispatch_count, d3d12_indirect_rt and d3d12_depth_resolve, fail the same way in a full run of plain main dde82f27 on this machine.
  • python -I tests/test_docs_design_rows.py: OK. tests/test_docs_links.py fails only on anchors in docs/dev-tools.md and docs/gpu_test_results.md, which this PR doesn't touch (red on main).
  • The slot 41 path is exercised against the mock only; no ctest here sends the rewritten signature to the Vulkan layer's CreateCommandSignature.

No game files. AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

checked: #7163 | with: merge of PR head onto main, then xs_proxy_mock_test and device_proxy_test (cross-built, run under Wine), plus a negative control | on: Wine 11 on a RunPod RTX 4090 (Linux, Vulkan), cross-built with clang-cl + xwin through the pod's ccache build script; not native Windows, and the host D3D12/WARP comparisons do not run (there is no WARP adapter under Wine). | result: pass for the PR's own test, one target skipped as on main

  • PR head tested: 084c8c6, merged (clean, no conflicts) onto origin/main 867d922.
  • xs_proxy_mock_test: exit 0, "PASS (9 allocations refused on purpose)", including the new line "slot 41 creates argument type 105 as DISPATCH".
  • device_proxy_test: exit 77, "SKIP: no WARP adapter (0x80004001)". The same target on a clean origin/main copy gives the identical exit 77 and SKIP, so this is the Wine environment and not the PR. It means the real-device path of this PR was not exercised.
  • Negative control: with only d3d12_xs_device.cpp and d3d12_xs_device.h reverted to main (test kept), xs_proxy_mock_test fails with exit 1 at xs_proxy_mock line 778 (the new slot-41 expectation). So the new test does fail without the production change.
  • Diff review (4 files, no game files, no tool or data files): the slot index is right (ID3D12Device vtable 41 is CreateCommandSignature, and it is forwarded through real_vtable[41]). Only a description that contains type 105 is copied and rewritten; every other description is forwarded with the same pointer, and the caller's description is left untouched (the test checks both). Reading the enum as 32 bits through memcpy is the right way for an out-of-range value. The OOM path returns E_OUTOFMEMORY and clears the output. The device_slot_overridden(41) entry and the slot_name entry are consistent.
  • Concern, stated in the PR as a hypothesis: the claim that type 105 behaves as a plain DISPATCH of D3D12_DISPATCH_ARGUMENTS comes from static call-site reading only; nothing here proves what the console does with it. The change only lets the title get past creation; it is not evidence that the later ExecuteIndirect results are right. The root-signature argument is passed through as a raw word, as before.
  • Not verified: a real D3D12 device creating the rewritten signature (the mock only checks what reaches PC slot 41; device_proxy_test skipped), any ExecuteIndirect replay of the result, and anything on native Windows or with the retail title.

AI-assisted.

Raxstreams added a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (device slot 41, RT-5 stop 19)

Preserve the per-slot layout from ProjectLeonida#7460 while integrating the slot 41 handler and regression tests.

Fork integration. AI-assisted (Codex).
@CourtyardGames

Copy link
Copy Markdown

checked: 084c8c6 | base: main@464887b4f + #7163 | on: Windows 11, MSVC 14.51, NVIDIA RTX 4070 SUPER (621.14) | result: builds clean and xs_proxy_mock (with the new slot-41 case) passes 6/6; the rest of the suite passes with no regression.

  • Read: the full diff (the proxy handler in d3d12_xs_device.cpp, the header comment, the slot_name and device_slot_overridden entries, the new mock case in xs_proxy_mock_test.cpp, one docs row). No networking, process, registry, clipboard or build-script changes. Two commits: the second only reads the type as its 32 bits for clang-cl.
  • Built: scripts/build_runtime.ps1 -jobs 4 on the PR head, exit 0.
  • Ran: ctest -R xs_proxy: 6/6 passed (xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots, _env_slots_invalid). The xs_proxy_mock log shows the new handler firing: "device slot 41 (CreateCommandSignature (Xbox argument type 105 as DISPATCH))" then "slot 41 argument type 105 (stride 16) created as DISPATCH". Whole suite with -E "d3d12_vulkan_device|d3d12_depth_resolve" (the two known failures on main, d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125 and since d3d12: reject null arrays and invalid lists in ExecuteCommandLists #6610): 232/232 passed, some tests skipped by their own conditions (bink, gameinput disabled and similar). LEONIDA_VK_DEVICE=4070.
  • Control (PR test against old code): not run, to save a second 15-minute build. By reading, the new assertions (args[41][0] != word(&console_sig), the copied type array) cannot hold when slot 41 is forwarded untouched, so the test does exercise the change.
  • Code read: the console description is copied, never edited in place (the test checks the caller's type stays 105); only type 105 is rewritten, so a PC description is forwarded with the same pointer (the test checks this with DISPATCH_MESH); the copy is new (std::nothrow) with E_OUTOFMEMORY, and a null desc or pArgumentDescs is forwarded as is. Reading the enum through memcpy is the right way for an out-of-range value. The mapping of 105 to DISPATCH is labelled HYPOTHESIS in the code and the docs row, which is the honest level; I cannot check it without the title.
  • Noticed: stride is not validated on the console path, so a stride below 12 is left to the PC layer to refuse; fine. The PR overlaps in device_slot_overridden with other slot PRs, which d3d12_xs: one line per device slot in the three spots every slot PR edits, so slot PRs stop conflicting (no behaviour change) #7460 is meant to fix; no conflict with main today.

AI-assisted.
agent: yes

@byPreaZy

Copy link
Copy Markdown

checked: #7163 | with: applied the diff on main 6312c05, built xs_proxy_mock_test (MSVC, Ninja RelWithDebInfo) | on: Windows 11, RX 9060 XT | result: PASS (9 intentional refusals), incl. the new slot-41 cases: type-105 desc reaches PC slot 41 rewritten to DISPATCH in a copied description (stride, count, CONSTANT arg and root signature kept, caller's array untouched), a PC description forwards as the same pointer

Code read: the enum value is read as raw 32 bits via memcpy (clang-cl safe), the rewrite works on a fresh copy so the title's desc is never mutated, non-105 descriptions forward unchanged, allocation failure returns E_OUTOFMEMORY with *out nulled, and the hypothesis (what the console does differently) is labelled Open in both code and docs.

AI-assisted check.

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows/MSVC synthetic proxy checks passed in a temporary integration. In an offline Windows Sandbox retail experiment, the type 105 signature was translated to DISPATCH and returned S_OK. The following fifth startup signature, DISPATCH_MESH (type 10), returned E_NOTIMPL, then the title hit the same breakpoint; this is the separate mesh indirect work already tracked in #3777/#5899. This does not establish semantic equivalence for type 105 or a rendered frame.

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…f type 105 is created as DISPATCH (device slot 41, RT-5 stop 19)

Squashed from ItsNotRexed#7163 by mrp1no, head 084c8c6 (security scan PASS).

Conflicts with ItsNotRexed#7115 (slot 61) and the earlier slots: both handlers, routing branches, mock cases, docs rows and test checks kept side by side; device_slot_overridden takes the union.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…t expectations)

ItsNotRexed#7759 carries ItsNotRexed#7201's slot 86/101/108 handlers; its squash added them a second time next to ItsNotRexed#7201's copy (the 101/108 bodies are identical, and ItsNotRexed#7759's slot 86 keeps the PSO stream for slot 55), so ItsNotRexed#7201's copy is removed.

xs_proxy_mock_test: the check_xbox_slots summary line merged for ItsNotRexed#7163 had its \n written as a line break; ItsNotRexed#7235's slot-127 hook check now expects no PC slot 25 call for a listed render target (the console-size port from ItsNotRexed#7240 sizes it, same 33,423,360 B); ItsNotRexed#7821's check_view_heap_cap releases the heaps it makes, since its CreateDescriptorHeap mock case is now ItsNotRexed#7021's, which makes a heap proxy holding the device.

d3d12_vulkan_device_test: the meta-command checks run on the device behind the Xbox proxy, as ItsNotRexed#7125 does for CreateReservedResource2: proxy slot 61 is the title's CreateSamplerX (ItsNotRexed#7115).
@ramenbellic

Copy link
Copy Markdown

Tested 084c8c6 under Wine: Proton Experimental (wine 11), runtime cross-built with clang-cl 23.1.6 + xwin SDK 10.0.26100 (RelWithDebInfo), merged onto main dfe4e4ad3: pass

  • Build: OK with clang-cl.
  • The tests this PR adds or touches, under Proton: 6 passed, 0 skipped, 0 failed (of 6).

AI-assisted run (Claude Code); no game files used.

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.