Skip to content

Runtime: refuse multi-argument command signatures with E_NOTIMPL until #2077, instead of replaying the constant as the action - #5129

Closed
tedin7 wants to merge 3 commits into
ProjectLeonida:mainfrom
tedin7:d3d12-signature-stopgap
Closed

tedin7 wants to merge 3 commits into
ProjectLeonida:mainfrom
tedin7:d3d12-signature-stopgap

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #5032 (comment)

What and why

ExecuteIndirect with a command signature that has an argument before its draw or dispatch
([CONSTANT, DRAW], [CONSTANT, DRAW_INDEXED], [CONSTANT, DISPATCH], and the same with views) was accepted by
CreateCommandSignature, but the list kept only the last argument's kind, the stride and the record offset, and
the replay handed that offset to Vulkan. So Vulkan read the record from its first byte: the constant became the
first draw or dispatch argument, and the constant itself never reached the shader.

Measured on main (3faac55) with the new test, record {constant 7, then the draw or dispatch}, the root
constant set to 100 directly before the call:

  • [CONSTANT, DISPATCH], record {7, 1, 1, 1}: 7 groups ran, and they saw the constant 100. D3D12 runs 1 group
    with constant 7. The plain [DISPATCH] control in the same test runs 1 group, so the harness is right.
  • [CONSTANT, DRAW] (stride 20) and [CONSTANT, DRAW_INDEXED] (stride 24): accepted (S_OK). The API dump shows
    vkCmdDrawIndirect / vkCmdDrawIndexedIndirect called at the record's start (offset 131072, a 64 KiB boundary,
    not +4), so Vulkan reads {7, 3, 1, 0}: 7 vertices, 3 instances, first vertex 1. The draw itself doesn't render
    on main anyway: an ExecuteIndirect draw is recorded outside rendering and without a pipeline (validation:
    VUID-vkCmdDrawIndirect-renderpass, -None-08606), and the submission didn't finish in 20 s. That part is Runtime: milestone M5 synthetic gate (without mesh) — ExecuteIndirect draws render now, multi-threaded lists, 5,120-SRV bindless table, pipeline cache #1865
    (M5, "ExecuteIndirect draws render now"); once it lands, these signatures would draw the wrong vertex count.

The real fix is #2077 (multi-argument signatures). Until it lands, this makes such a signature fail clearly
instead of drawing wrong:

With #3929. #3929 changes the same function. The code merges cleanly (git merge-tree with #3929's head), and the
doc item sits apart from #3929's. One semantic point: d3d12_command_signature_root_test compares the layer's
HRESULT with the host's. For a valid signature with a root argument, the host gives S_OK and the layer now gives
E_NOTIMPL. Whichever lands second needs the exemption #3929 already makes for mesh dispatch (#3777): not compared
while the layer answers E_NOTIMPL.

Tested

RunPod: NVIDIA GeForce RTX 5080, Linux, driver 580.65.06. Windows build cross-compiled with clang-cl 21 and xwin
(RelWithDebInfo), run through Wine 11.0 under xvfb-run. Validation is the host's VK_LAYER_KHRONOS_validation
(SDK 1.4.363.1, VK_INSTANCE_LAYERS). LEONIDA_VK_VALIDATION=1 doesn't work under Wine, because winevulkan doesn't
list the layer. The host layer does report errors here: it flagged the draws above.

Not covered

No game files.

AI-assisted (Claude Code).

…dispatch until they execute

ExecuteIndirect keeps only a signature's final argument and reads it at the start of each record, so a
[CONSTANT, DISPATCH] record {7, 1, 1, 1} ran 7 groups without the constant, and [CONSTANT, DRAW] passed the
record's start to vkCmdDrawIndirect (the constant became the vertex count). Until ProjectLeonida#2077 executes such
signatures, a valid one with any argument before its draw or dispatch is refused with E_NOTIMPL and one log
line. d3d12_indirect_signature_test checks [CONSTANT, DISPATCH/DRAW/DRAW_INDEXED]: refused, or run as D3D12 says.
…ning them until ProjectLeonida#1865

A draw ExecuteIndirect is replayed without the list's pipeline, render targets and root arguments until ProjectLeonida#1865,
so a correct ProjectLeonida#2077 would have turned the draw cases red. They now pass when refused with E_NOTIMPL or accepted,
and only the dispatch runs; the dependency is in the test and docs/d3d12_vulkan.md 4.7. The points VS/PS go.
The doc also says the refusal logs one line per distinct argument count, not once.
@searyecheesepeaceful

Copy link
Copy Markdown

Tested dbac43d on NVIDIA GeForce RTX 4080 (driver 617.42), Windows 11, clang-cl cross-build: the targets that ran pass; d3d12_command_signature_root_test did not run.

  • d3d12_indirect_signature_test: exit 0. The control [DISPATCH] ran 1 group (constant + 1 = 101); [CONSTANT, DISPATCH], [CONSTANT, DRAW] and [CONSTANT, DRAW_INDEXED] are each refused with E_NOTIMPL.
  • d3d12_vulkan_device_test: exit 0 (it prints no check summary on a pass).
  • d3d12_command_signature_root_test, which the PR says compares the layer's HRESULT with the host's for root-argument signatures, was not built: the target name I used does not exist, so it never ran on this GPU.

AI-assisted.

@milas6669

Copy link
Copy Markdown

Tested dbac43da on NVIDIA GeForce RTX 3070 (Ampere, driver 32.0.16.2124), Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo, Vulkan SDK 1.4.363, llvm-mc 21.1.8, with LEONIDA_VK_VALIDATION=1: pass. Same head as @gertify's RTX 4080 run above, with validation layers on here.

  • d3d12_indirect_signature_test: exit 0, 0 validation errors, 1 translated shaders. [ok] control [DISPATCH]: 1 group(s), constant + 1 = 101; [ok] [CONSTANT, DISPATCH], [CONSTANT, DRAW] and [CONSTANT, DRAW_INDEXED]: refused with E_NOTIMPL.
  • d3d12_vulkan_device_test: exit 0, 0 mismatches (195 FORMAT_INFO queries, 94 FORMAT_SUPPORT formats, 46 feature queries).

On the d3d12_command_signature_root_test that did not run in the RTX 4080 report: it is not in this branch. git grep command_signature_root at dbac43da finds nothing, and the PR body says that test belongs to #3929 ("With #3929"), so no target of that name exists on this head and it cannot be built here. I did not test the combination with #3929.

Not run: #3929's tests on top of this change (the PR body notes they need the Microsoft runtime), AMD and Intel adapters, and the rest of CTest.

AI-assisted. Synthetic tests only; no game data.

@searyecheesepeaceful

Copy link
Copy Markdown

Tested dbac43d on Intel UHD 770, driver 32.0.101.7088, Windows 11, MSVC: d3d12_indirect_signature_test exits 0 on two runs with LEONIDA_VK_VALIDATION=1. The DISPATCH control runs 1 group, and [CONSTANT, DISPATCH], [CONSTANT, DRAW] and [CONSTANT, DRAW_INDEXED] are each refused with E_NOTIMPL (argument count 2). With the Khronos validation layer loaded via VK_INSTANCE_LAYERS the run also exits 0 with 0 validation error lines and 0 FAIL lines. d3d12_command_signature_root_test does not exist at this head (it is added by #3929), so the HRESULT exemption was not checked.

AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent check — pass, GPU-verified (Windows 11, NVIDIA RTX 5090, driver 617.42, Vulkan SDK 1.4.363.0).

Doc check: the d3d12_vulkan.md note matches the code and honestly says the draw signatures are created but not run (they need #1865's list pipeline/targets to replay).

AI-assisted (Devin); no game files.

Raxstreams added a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
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.

5 participants