D3D12.X: two-pass ExecuteIndirect uses plain signatures, with Wine's barrier #3012

Open
voiceovarian1-max wants to merge 1 commit from upstream-pr/3012 into main
voiceovarian1-max commented 2026-11-27 12:14:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by voiceovarian1-max on 2026-11-27T12:14:09Z.


For nvidia-dev. The two-pass ExecuteIndirect of a mesh pipeline (#2092) replays the title's command signature for each pass. When that signature has an argument before the DispatchMesh, vkd3d-proton runs it through its state template (device generated commands, EXT_dgc). On NVIDIA's Linux driver a mesh pass then read its records before its compute pass wrote them, or read the next command's. In a retail title this lost the device: a run without those draws did not lose it.

Outside XCL, in plain D3D12 under vkd3d-proton: three commands, one ExecuteIndirect per pass, a UAV barrier after each. With the constant in the signature, the mesh passes read [[0, 0, 0], [2, 2], [1, 1, 1, 3]] or [[0, 0, 0], [2, 2], [3, 3, 3, 3]]. They should read [[1, 1, 1], [2, 2], [3, 3, 3, 3]]. This happened 6 of 6 times, on a compute and on a direct queue. With a signature of the Dispatch alone the result was right 6 of 6 times.

Now create_command_signature_x also makes a plain Dispatch and a plain DispatchMesh signature for each DispatchMesh signature, and both two-pass ExecuteIndirect paths use them, over the command's arguments alone. Only signatures without root arguments get a companion, so the passes read none of the arguments left out. XCL_TWO_PASS_PLAIN=0 uses the title's signature, as before. Where the title's signature is still used under Wine, the barriers between passes also get a global aliasing barrier (emit_two_pass_barrier); in that case the deferred path records at once.

What is in it

  • hle/d3d12x/device_x.rs: the two plain signatures, noted with note_plain_two_pass_signatures.
  • hle/d3d12x/bind.rs: plain_two_pass_signatures, used in execute_indirect and defer_execute_indirect; emit_two_pass_barrier in run_two_pass_plan. New GPU test gpu_two_pass_plain_signatures_keep_each_commands_records (the plain D3D12 case above, which has to read the right records on every driver).

Tested

  • Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04, i7-14700K. Rust 1.100.0, x86_64-pc-windows-gnu, release. Head 1d3d6187 on nvidia-dev 3f39671d.
  • Whole lib suite under Wine (cargo test -p xcl --lib -- --test-threads=4):
    • this head: 1693 passed, 7 failed, 28 ignored
    • nvidia-dev 3f39671d: 1691 passed, 8 failed, 28 ignored
    • The 7 also fail on nvidia-dev (Wine's D3DCompile, descriptor heap and XAudio2 tests under Wine). The 8th, #2092's gpu_two_pass_indirect_commands_keep_their_own_records, passes with this change.
  • cargo test -p xcl --lib two_pass -- --test-threads=1: 32 passed, 0 failed (1 SKIPPED: two_pass_binds_set_the_shared_view_heap, opt-in heap windows).
  • A retail title on our Linux tree, which carries this change, plays its world with two-pass mesh draws and no device loss. This branch was not run in the title.

Regression run

  • None: scripts/smoke.ps1 needs Windows, and we only have Linux. A Windows smoke run on nvidia-dev and on this head would be welcome.

Not tested

  • Windows and AMD. On those, the plain signatures are used too (they are on everywhere), and the aliasing barrier is Wine-only. The state-template issue itself was not reported to vkd3d-proton.

AI use

  • Claude Code with Claude Opus 5.5: found the out-of-order passes with the probe, wrote the change, the tests and this description, and ran the tests.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5526434785 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3012). Originally posted by [voiceovarian1-max](https://github.com/voiceovarian1-max) on 2026-11-27T12:14:09Z. --- For nvidia-dev. The two-pass ExecuteIndirect of a mesh pipeline (#2092) replays the title's command signature for each pass. When that signature has an argument before the DispatchMesh, vkd3d-proton runs it through its state template (device generated commands, `EXT_dgc`). On NVIDIA's Linux driver a mesh pass then read its records before its compute pass wrote them, or read the next command's. In a retail title this lost the device: a run without those draws did not lose it. Outside XCL, in plain D3D12 under vkd3d-proton: three commands, one ExecuteIndirect per pass, a UAV barrier after each. With the constant in the signature, the mesh passes read `[[0, 0, 0], [2, 2], [1, 1, 1, 3]]` or `[[0, 0, 0], [2, 2], [3, 3, 3, 3]]`. They should read `[[1, 1, 1], [2, 2], [3, 3, 3, 3]]`. This happened 6 of 6 times, on a compute and on a direct queue. With a signature of the Dispatch alone the result was right 6 of 6 times. Now `create_command_signature_x` also makes a plain Dispatch and a plain DispatchMesh signature for each DispatchMesh signature, and both two-pass ExecuteIndirect paths use them, over the command's arguments alone. Only signatures without root arguments get a companion, so the passes read none of the arguments left out. `XCL_TWO_PASS_PLAIN=0` uses the title's signature, as before. Where the title's signature is still used under Wine, the barriers between passes also get a global aliasing barrier (`emit_two_pass_barrier`); in that case the deferred path records at once. **What is in it** - `hle/d3d12x/device_x.rs`: the two plain signatures, noted with `note_plain_two_pass_signatures`. - `hle/d3d12x/bind.rs`: `plain_two_pass_signatures`, used in `execute_indirect` and `defer_execute_indirect`; `emit_two_pass_barrier` in `run_two_pass_plan`. New GPU test `gpu_two_pass_plain_signatures_keep_each_commands_records` (the plain D3D12 case above, which has to read the right records on every driver). **Tested** - Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04, i7-14700K. Rust 1.100.0, `x86_64-pc-windows-gnu`, release. Head `1d3d6187` on nvidia-dev `3f39671d`. - Whole lib suite under Wine (`cargo test -p xcl --lib -- --test-threads=4`): - this head: 1693 passed, 7 failed, 28 ignored - nvidia-dev `3f39671d`: 1691 passed, 8 failed, 28 ignored - The 7 also fail on nvidia-dev (Wine's `D3DCompile`, descriptor heap and XAudio2 tests under Wine). The 8th, #2092's `gpu_two_pass_indirect_commands_keep_their_own_records`, passes with this change. - `cargo test -p xcl --lib two_pass -- --test-threads=1`: 32 passed, 0 failed (1 SKIPPED: `two_pass_binds_set_the_shared_view_heap`, opt-in heap windows). - A retail title on our Linux tree, which carries this change, plays its world with two-pass mesh draws and no device loss. This branch was not run in the title. **Regression run** - None: `scripts/smoke.ps1` needs Windows, and we only have Linux. A Windows smoke run on nvidia-dev and on this head would be welcome. **Not tested** - Windows and AMD. On those, the plain signatures are used too (they are on everywhere), and the aliasing barrier is Wine-only. The state-template issue itself was not reported to vkd3d-proton. **AI use** - Claude Code with Claude Opus 5.5: found the out-of-order passes with the probe, wrote the change, the tests and this description, and ran the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Lum7nt commented 2026-11-27 14:49:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-27T14:49:54Z.


Native Windows 11 + NVIDIA RTX 3060 verification of PR #3012

Tested PR #3012 head \1d3d61879f\ on native Windows 11 with native D3D12 hardware execution on Ampere (RTX 3060 12 GB, native wave32).

Environment

  • GPU: NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver \32.0.15.8142\ (WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0)
  • Toolchain:
    ustc 1.100.0 (0ef1bc386 2026-11-09)\ x86_64-pc-windows-msvc, Windows SDK DXC \1.8.2502.11\ / dxil \1.8.2502.11\

GPU Test Results (\hle::d3d12x::bind::tests::gpu_two_pass)

Ran targeted two-pass tests on the physical NVIDIA D3D12 device:
\\powershell
cargo test -p xcl --lib hle::d3d12x::bind::tests::gpu_two_pass -- --nocapture
\\

  • \gpu_two_pass_pooled_scratch_respects_remaining_budget\ ? PASS
  • \gpu_two_pass_argument_scratch_is_shared_and_capped\ ? PASS
  • \gpu_two_pass_indirect_commands_keep_their_own_records\ ? PASS
  • \gpu_two_pass_plain_signatures_keep_each_commands_records\ ? PASS

Result: 4 passed; 0 failed; 0 ignored; 0 skipped (0.31s).

Observations

  1. The new test \gpu_two_pass_plain_signatures_keep_each_commands_records\ executed across both \D3D12_COMMAND_LIST_TYPE_COMPUTE\ and \D3D12_COMMAND_LIST_TYPE_DIRECT\ on the live RTX 3060 adapter.
  2. Verified that each command's records were read back correctly without cross-command corruption: exactly 1, 1, 1], [2, 2], [3, 3, 3, 3\ in both queues.
  3. Native Windows D3D12 device remained healthy with zero removals or driver errors.

AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.

<!-- greyfinch-sync:ivall/xcl:comment:7221283440 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3012#issuecomment-7221283440). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-27T14:49:54Z. --- ### Native Windows 11 + NVIDIA RTX 3060 verification of PR #3012 Tested PR #3012 head \1d3d61879f021871673324a75bf8982dc78cbb53\ on native Windows 11 with native D3D12 hardware execution on Ampere (RTX 3060 12 GB, native wave32). ### Environment - **GPU:** NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver \32.0.15.8142\ (WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0) - **Toolchain:** \ ustc 1.100.0 (0ef1bc386 2026-11-09)\ x86_64-pc-windows-msvc, Windows SDK DXC \1.8.2502.11\ / dxil \1.8.2502.11\ ### GPU Test Results (\hle::d3d12x::bind::tests::gpu_two_pass\) Ran targeted two-pass tests on the physical NVIDIA D3D12 device: \\\powershell cargo test -p xcl --lib hle::d3d12x::bind::tests::gpu_two_pass -- --nocapture \\\ - \gpu_two_pass_pooled_scratch_respects_remaining_budget\ ? **PASS** - \gpu_two_pass_argument_scratch_is_shared_and_capped\ ? **PASS** - \gpu_two_pass_indirect_commands_keep_their_own_records\ ? **PASS** - \gpu_two_pass_plain_signatures_keep_each_commands_records\ ? **PASS** **Result:** **4 passed; 0 failed; 0 ignored; 0 skipped** (0.31s). ### Observations 1. The new test \gpu_two_pass_plain_signatures_keep_each_commands_records\ executed across both \D3D12_COMMAND_LIST_TYPE_COMPUTE\ and \D3D12_COMMAND_LIST_TYPE_DIRECT\ on the live RTX 3060 adapter. 2. Verified that each command's records were read back correctly without cross-command corruption: exactly \[[1, 1, 1], [2, 2], [3, 3, 3, 3]]\ in both queues. 3. Native Windows D3D12 device remained healthy with zero removals or driver errors. *AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.*
imnicho commented 2026-11-27 15:10:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-27T15:10:48Z.


Windows measurement (native D3D12, NVIDIA): the plain signatures are chosen, and the device loss here is unchanged

Machine: RTX 5080 16 GB, driver 610.47 (32.0.16.1047), Windows 10 22H2 (19045), i7-7700K, 16 GB RAM. Tree: nvidia-dev d1be8103 with this PR's 1d3d6187 cherry-picked (it applied cleanly) on a local test tree that also carries other open nvidia-dev PRs and local test changes; release build. One binary for both runs, this PR's switch the only difference, Series S profile, 600 s limit, a retail title.

default (plain signatures) XCL_TWO_PASS_PLAIN=0
two-pass indirect calls that took the plain pair / the title's signature (a local counter in plain_two_pass_signatures) 65,536+ / 0 0 / 131,072+
world set-up at 216 s 198 s
device removed 0x887a0006 at 340 s 0x887a0006 at 346 s
frames presented after the set-up 137 (1.28 a second) 179 (1.31 a second)
  • Why it changes nothing on this machine: the only DispatchMesh command signature the title created in these runs is 12 bytes with the DispatchMesh argument alone (logged where create_command_signature_x notes the plain pair). The plain pair then describes the same call as the title's signature and its companion, so both arms record the same ExecuteIndirects. If the title you ran creates the same signature, the argument in front of the command that the PR's probe uses would not be what the title's draws went through; it may be worth logging the argument types on your side.
  • DRED, both runs (device state 3): the hung list stops at Dispatch, ResourceBarrier, SetMarker, ExecuteIndirect with the ExecuteIndirect not finished. The same four operations end 12 earlier state-3 losses on this machine without this change, with compute, mesh and vertex/pixel pipelines bound, so this loss is not specific to the two-pass mesh path.
  • No regression seen: frames a second and the time of the loss are within what this machine does without the change (losses 84 to 166 s after the set-up).

Not tested: scripts/smoke.ps1 on nvidia-dev and on this head (the machine is busy with world runs; I can add the two blocks later if that still helps), AMD, the Wine-only barrier.

AI use: Claude Code with Claude Fable 5.2 built the tree, ran both runs and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7221728635 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3012#issuecomment-7221728635). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-27T15:10:48Z. --- **Windows measurement (native D3D12, NVIDIA): the plain signatures are chosen, and the device loss here is unchanged** Machine: RTX 5080 16 GB, driver 610.47 (32.0.16.1047), Windows 10 22H2 (19045), i7-7700K, 16 GB RAM. Tree: `nvidia-dev` `d1be8103` with this PR's `1d3d6187` cherry-picked (it applied cleanly) on a local test tree that also carries other open nvidia-dev PRs and local test changes; release build. One binary for both runs, this PR's switch the only difference, Series S profile, 600 s limit, a retail title. | | default (plain signatures) | `XCL_TWO_PASS_PLAIN=0` | |---|---|---| | two-pass indirect calls that took the plain pair / the title's signature (a local counter in `plain_two_pass_signatures`) | 65,536+ / 0 | 0 / 131,072+ | | world set-up at | 216 s | 198 s | | device removed | `0x887a0006` at 340 s | `0x887a0006` at 346 s | | frames presented after the set-up | 137 (1.28 a second) | 179 (1.31 a second) | - **Why it changes nothing on this machine:** the only DispatchMesh command signature the title created in these runs is 12 bytes with the DispatchMesh argument alone (logged where `create_command_signature_x` notes the plain pair). The plain pair then describes the same call as the title's signature and its companion, so both arms record the same ExecuteIndirects. If the title you ran creates the same signature, the argument in front of the command that the PR's probe uses would not be what the title's draws went through; it may be worth logging the argument types on your side. - **DRED, both runs (device state 3):** the hung list stops at `Dispatch, ResourceBarrier, SetMarker, ExecuteIndirect` with the ExecuteIndirect not finished. The same four operations end 12 earlier state-3 losses on this machine without this change, with compute, mesh and vertex/pixel pipelines bound, so this loss is not specific to the two-pass mesh path. - **No regression seen:** frames a second and the time of the loss are within what this machine does without the change (losses 84 to 166 s after the set-up). **Not tested:** `scripts/smoke.ps1` on `nvidia-dev` and on this head (the machine is busy with world runs; I can add the two blocks later if that still helps), AMD, the Wine-only barrier. AI use: Claude Code with Claude Fable 5.2 built the tree, ran both runs and wrote this comment.
Foniass commented 2026-12-01 09:19:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:19:22Z.


Triage (#1607) – head 1d3d618

No open or merged PR makes this change. #2092 is the two-pass ExecuteIndirect this builds on, and main has no PLAIN_TWO_PASS_SIGS or emit_two_pass_barrier.
Notes from the diff:

  • The plain signatures are on by default on Windows too, and only Wine was tested.
  • forget_dispatch_mesh_signature does not drop the PLAIN_TWO_PASS_SIGS entry, so a signature created later at a freed address keeps a stale entry. This is harmless today because the two-pass path is gated on DISPATCH_MESH_SIGS.
  • The two plain signatures made for each title DispatchMesh signature are never released, like the existing companion signature.
    Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306532947 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3012#issuecomment-7306532947). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:19:22Z. --- **Triage (#1607)** – head 1d3d618 No open or merged PR makes this change. #2092 is the two-pass ExecuteIndirect this builds on, and main has no `PLAIN_TWO_PASS_SIGS` or `emit_two_pass_barrier`. Notes from the diff: - The plain signatures are on by default on Windows too, and only Wine was tested. - `forget_dispatch_mesh_signature` does not drop the `PLAIN_TWO_PASS_SIGS` entry, so a signature created later at a freed address keeps a stale entry. This is harmless today because the two-pass path is gated on `DISPATCH_MESH_SIGS`. - The two plain signatures made for each title DispatchMesh signature are never released, like the existing companion signature. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3012:upstream-pr/3012'
git switch 'upstream-pr/3012'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3012'
git switch 'upstream-pr/3012'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3012'
git switch 'upstream-pr/3012'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3012'
git switch 'main'
git merge --squash 'upstream-pr/3012'
git switch 'main'
git merge --ff-only 'upstream-pr/3012'
git switch 'main'
git merge 'upstream-pr/3012'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3012
No description provided.