Skip to content

d3d12_xs: retry slot 41 DISPATCH_MESH as DISPATCH when the PC device returns E_NOTIMPL - #9222

Closed
Shnimlz wants to merge 3 commits into
ProjectLeonida:mainfrom
Shnimlz:fix/xs-slot41-dispatch-mesh-fallback
Closed

Shnimlz wants to merge 3 commits into
ProjectLeonida:mainfrom
Shnimlz:fix/xs-slot41-dispatch-mesh-fallback

Conversation

@Shnimlz

@Shnimlz Shnimlz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new RT/D3D item (RT-5 stop 19 follow-up), #9065 (comment)
Depends on: #7163

Summary

When the Xbox title's renderer initialization creates its five 1-argument command signatures through d3d12_xs device slot 41 (CreateCommandSignature), the fifth signature uses D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH (type 9, 12-byte {ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ} argument buffer).

On GPUs or drivers without VK_EXT_mesh_shader (such as AMD RDNA1 under --mesh-compute), the underlying PC ID3D12Device::CreateCommandSignature returns E_NOTIMPL for D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH (matching the PC D3D12 runtime contract and d3d12_mesh_test). Because the caller checks the HRESULT of all five command signatures and hits an assertion (int3) if any fails, failing the fifth signature aborts the rest of that renderer initialization function and leaves its per-frame query ring buffer unallocated, causing a null-dereference fault on frame 1 (write 0x20).

This PR teaches proxy_create_command_signature (device slot 41 in runtime/shims/d3d12_xs_device.cpp) to retry once with a local copy of D3D12_COMMAND_SIGNATURE_DESC replacing D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH with D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH (which shares the same 12-byte {ThreadGroupCountX, Y, Z} indirect argument layout) when the underlying PC device returns E_NOTIMPL, and logs the fallback once.

Note: This branch is stacked on #7163 (084c8c60e7e839d0caefaaeccf41a6348b062cf1); the slot 41 DISPATCH_MESH -> DISPATCH fallback is commit 07f6da074.

Changes

  • runtime/shims/d3d12_xs_device.cpp: in proxy_create_command_signature (device slot 41), if the description contains D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH and the PC device returns E_NOTIMPL, retry once with a copy replacing DISPATCH_MESH with DISPATCH and log a one-time diagnostic.
  • runtime/test/xs_proxy_mock_test.cpp: add a test verifying that when the mock PC device refuses DISPATCH_MESH with E_NOTIMPL, slot 41 retries once with DISPATCH, succeeds, and leaves the caller's input description unmodified.
  • docs/d3d12_vulkan.md: document the slot 41 DISPATCH_MESH -> DISPATCH fallback on E_NOTIMPL in §4.9.

Testing

  • Hardware / OS / Driver: AMD Radeon RX 5500M (RDNA1, no VK_EXT_mesh_shader), Mesa RADV, Linux 7.3.5-2-cachyos, Wine 11.22, cross-compiled with clang-cl 23.1.5 + lld-link against Windows SDK 10.0.26100.
  • Unit tests: xs_proxy_mock_test.exe across all 6 modes ("", --env-slots, --env-slots-invalid, --fail-virtualalloc, --fail-virtualprotect, --fail-veh) -> PASS (9 allocations refused on purpose).
  • Retail verification: On RDNA1 (RX 5500M with --mesh-compute SPIR-V corpus) combined with the ladder-frame stack + xmem: map consecutive physical pages as one view, so the retail boot's 100,000-page XMemMapPhysicalPages fits the title's hang watchdog under Wine #7584, all five renderer-init CreateCommandSignature calls succeed (0 int3_skipped), reaching 349,385 D3D12 calls over 60 s (19,134 Close ok, 18,509 Signal ok, 0 exceptions).
  • Policy & doc checks:
    • python3 -I scripts/check_no_game_data.py docs/d3d12_vulkan.md runtime/shims/d3d12_xs_device.cpp runtime/test/xs_proxy_mock_test.cpp (exit 0)
    • python3 -I tests/test_check_no_game_data.py
    • python3 -I tests/test_docs_list_items.py
    • python3 -I tests/test_docs_repeated_lines.py
    • python3 -I tests/test_docs_table_ids.py
  • AI-assisted: yes.

mrp1no and others added 3 commits November 23, 2026 17:05
…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>
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 ItsNotRexed#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>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Grimkaaah Grimkaaah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent Linux CPU review

What changed: d3d12_xs slot 41 maps Xbox indirect type 105 → DISPATCH, and retries DISPATCH_MESH as DISPATCH on E_NOTIMPL (no mesh shaders). Docs row added.

Checked: diff + xs_proxy_mock_test.cpp present. Logic matches the documented retail startup signatures.

No game files. Full Windows mock test not run on this Linux host.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo), PR head 07f6da074 merged onto main (6312c057f):

  • python -I scripts/check_no_game_data.py docs/d3d12_vulkan.md runtime/shims/d3d12_xs_device.cpp runtime/shims/d3d12_xs_device.h runtime/test/xs_proxy_mock_test.cpp: clean (exit 0).
  • cmake --build runtime/build --target xs_proxy_mock_test --parallel: built cleanly.
  • ctest --test-dir runtime/build -R xs_proxy_mock --output-on-failure -V: 6/6 passed (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).

AI-assisted.

@dracbat

dracbat commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

A measurement on this PR's premise that E_NOTIMPL "matches the PC D3D12 runtime contract". On an AMD RX 5700 (MeshShaderTier 0, AMD driver 32.0.21045.29003, D3D12Core 10.0.26100.9818), the host runtime answers CreateCommandSignature with S_OK for a single 12-byte DISPATCH_MESH argument, with the debug layer on and storing no message. WARP gives the same answer. Stride 8 is E_INVALIDARG on both. The posts: #7330 (comment) and #7913 (comment)

Retrying the description as DISPATCH gets past init. But ExecuteIndirect with that signature would then run a compute dispatch with whatever compute pipeline is bound, where the title meant a mesh dispatch. I have a local follow-up to #7330 that instead creates the DISPATCH_MESH signature on every device, as the host does; ExecuteIndirect with it records nothing. It also checks it like the host does: 15 parity rows against WARP and the RX 5700 agree. I'll open it shortly, so the two approaches can be compared. AI-assisted (Claude Code).

@Shnimlz

Shnimlz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the RX 5700 / WARP measurement, @dracbat — that's a great catch. I had inferred E_NOTIMPL was the intended PC contract from #7330 / d3d12_mesh_test rather than measuring D3D12Core directly on a MeshShaderTier 0 GPU.

Your point about ExecuteIndirect is also right: rewriting the command signature to DISPATCH at creation time unblocks renderer init (and matches --mesh-compute only when a mesh-as-compute pipeline is actually bound), whereas if an unrelated compute pipeline is bound at ExecuteIndirect time it would dispatch that instead of a mesh draw.

Handling DISPATCH_MESH in the PC layer so CreateCommandSignature returns S_OK on all devices (matching D3D12Core and WARP) and deciding what ExecuteIndirect does based on the bound pipeline / device capability is definitely cleaner. Feel free to link your #7330 follow-up here once it's open — if that lands, slot 41 won't see E_NOTIMPL from our Vulkan device anyway (and I'm happy to close this PR in favor of it if maintainers prefer not to keep the E_NOTIMPL retry in d3d12_xs).

Also thanks @smowlyy for verifying 6/6 xs_proxy_mock tests on native Windows 11 / MSVC and @Grimkeh for the review.

AI-assisted.

@Yoshi-OOF

Copy link
Copy Markdown

The Intel UHD 770 retail stop reproduces here: after warming all 52 actual BVH PSOs, startup gets past cold compilation, then reaches this signature boundary and the title reports E_NOTIMPL. One semantic concern with retrying as DISPATCH: ExecuteIndirect records its kind from the returned signature, so DISPATCH takes the compute-pipeline/user-data path, whereas mesh_compute is still a graphics PSO that needs both the compute pass and the slot draw. Identical 12-byte arguments do not make those commands interchangeable. #5899 implements the actual indirect mesh path: on my physical no-extension Intel its 30 indirect records and six compute-written records have zero mismatches, though its direct multi-dispatch fixture still has a separate 256-pixel failure. Could this use the real backend support instead of changing the signature kind?

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.

8 participants