D3D12.X: draws with untranslated pipelines get the title's root signature #144

Manually merged
github merged 1 commit from gh-pr/144/head into gh-pr/144/base 2026-11-26 04:12:25 +00:00
Owner

@⁠tiagonleal on GitHub · 2026-11-23 15:12 UTC · original
tiagonleal:fix/untranslated-draws-root-signature → main · +47 −1 · 2 files · 1 commits · merged 2026-11-23 20:51 UTC

Found while getting CI (#143) to run on a runner whose only GPU is WARP: the test title crashes inside d3d10warp.dll. With XCL_D3D12_DEBUG=1 the debug layer shows why, and it shows the same on an RTX 5070 Ti, where the driver just tolerates it:

D3D12 debug layer (error, id 200): ID3D12CommandList::DrawInstanced: No root signature has been set so calling Draw can lead to unexpected behavior.

13 times in one test-title run: 11× DrawInstanced, 2× DrawIndexedInstanced.

Why

bind::set_graphics_root_signature (console #34) only records the console layout and arguments. A translated draw then binds XCL's ABI root signature in bind_abi. A draw with an untranslated pipeline – PC shaders, a background build's stand-in, a fallback after the driver rejected the console shaders – went to the PC list as it was, with the comment "a PC pipeline: its own root signature and arguments". Nothing had ever bound that root signature on the PC list.

Change

bind::State keeps the title's graphics root signature (a PC object: dev_create_root_signature always returns one, an empty fallback at worst). It is cleared on Reset / ClearState. graphics_bound binds it before a draw with an untranslated pipeline. Stand-ins and fallbacks are made from a copy of the title's desc, pRootSignature included, so they match it. Translated draws are unchanged, and so is compute: untranslated dispatches are skipped already.

Test

e2e::test_title_draws_with_a_root_signature_under_the_debug_layer runs the test title with XCL_D3D12_DEBUG=1 and fails on any "No root signature has been set" in its log. Before: 13 draws without a root signature. After: none. It skips without d3d12SDKLayers.dll (Graphics Tools) or the system XGameRuntime, so it skips on the CI runner.

cargo test --workspace --no-fail-fast on main 484dd57 (RTX 5070 Ti): 561 passed, 0 failed, 39 ignored.

Not in this PR (seen in the same debug-layer run)

  • WARP still faults later: the unified memory cannot be made there (CreateReservedResource → E_OUTOFMEMORY), so IASetIndexBuffer gets a console address that is no GPU address (0x20010000 does not belong to any existing Resource or Heap). No title draws anything right without unified memory, so I left it.
  • One CopyBufferRegion on a resource in the wrong state (id 538), on the RTX 5070 Ti too.

AI-assisted.

🤖 Generated with Claude Code

**@⁠tiagonleal** on GitHub · 2026-11-23 15:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/144) `tiagonleal:fix/untranslated-draws-root-signature` → `main` · +47 −1 · 2 files · 1 commits · merged 2026-11-23 20:51 UTC Found while getting CI (#143) to run on a runner whose only GPU is WARP: the test title crashes inside `d3d10warp.dll`. With `XCL_D3D12_DEBUG=1` the debug layer shows why, and it shows the same on an RTX 5070 Ti, where the driver just tolerates it: ``` D3D12 debug layer (error, id 200): ID3D12CommandList::DrawInstanced: No root signature has been set so calling Draw can lead to unexpected behavior. ``` 13 times in one test-title run: 11× `DrawInstanced`, 2× `DrawIndexedInstanced`. ### Why `bind::set_graphics_root_signature` (console #34) only records the console layout and arguments. A **translated** draw then binds XCL's ABI root signature in `bind_abi`. A draw with an **untranslated** pipeline – PC shaders, a background build's stand-in, a fallback after the driver rejected the console shaders – went to the PC list as it was, with the comment "a PC pipeline: its own root signature and arguments". Nothing had ever bound that root signature on the PC list. ### Change `bind::State` keeps the title's graphics root signature (a PC object: `dev_create_root_signature` always returns one, an empty fallback at worst). It is cleared on `Reset` / `ClearState`. `graphics_bound` binds it before a draw with an untranslated pipeline. Stand-ins and fallbacks are made from a copy of the title's desc, `pRootSignature` included, so they match it. Translated draws are unchanged, and so is compute: untranslated dispatches are skipped already. ### Test `e2e::test_title_draws_with_a_root_signature_under_the_debug_layer` runs the test title with `XCL_D3D12_DEBUG=1` and fails on any "No root signature has been set" in its log. Before: `13 draws without a root signature`. After: none. It skips without `d3d12SDKLayers.dll` (Graphics Tools) or the system XGameRuntime, so it skips on the CI runner. `cargo test --workspace --no-fail-fast` on `main` 484dd57 (RTX 5070 Ti): 561 passed, 0 failed, 39 ignored. ### Not in this PR (seen in the same debug-layer run) - WARP still faults later: the unified memory cannot be made there (`CreateReservedResource` → `E_OUTOFMEMORY`), so `IASetIndexBuffer` gets a console address that is no GPU address (`0x20010000 does not belong to any existing Resource or Heap`). No title draws anything right without unified memory, so I left it. - One `CopyBufferRegion` on a resource in the wrong state (id 538), on the RTX 5070 Ti too. _AI-assisted._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Console SetGraphicsRootSignature only records the console layout (a
translated draw binds XCL's ABI root signature in bind_abi), so a draw
with an untranslated pipeline – PC shaders, a stand-in, a fallback, all
made with the title's root signature – ran with no root signature on the
PC list. The D3D12 debug layer reports it on every GPU (13 draws of the
test title on an RTX 5070 Ti, where the driver tolerates it); WARP
faults on it.

graphics_bound now binds the title's current graphics root signature
(kept per list, cleared on Reset / ClearState) before such a draw.

Test: e2e test_title_draws_with_a_root_signature_under_the_debug_layer
runs the test title with XCL_D3D12_DEBUG=1 and fails on "No root
signature has been set" (13 before, 0 after); skipped without the debug
layer or the system XGameRuntime.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:24 +00:00
github manually merged commit 87fe289438 into gh-pr/144/base 2026-11-26 04:12:25 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 20:52 UTC · original

Merged (main 2abc562). Checked on an RX 9070 (RDNA4) with the 11 PRs merged together on main 38b05b7: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 547 unit tests passed, 0 failed (19 ignored); the integration and e2e tests passed too.

**@⁠ivall** on GitHub · 2026-11-23 20:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/144#issuecomment-7113684155) Merged (main 2abc562). Checked on an RX 9070 (RDNA4) with the 11 PRs merged together on main 38b05b7: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 547 unit tests passed, 0 failed (19 ignored); the integration and e2e tests passed too.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-23 15:13 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-23 15:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/144#pullrequestreview-6024106620) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.