Skip to content

Runtime: CreateCommandSignature with a root signature answers as the host does (D3D-359) - #3929

Open
mrp1no wants to merge 2 commits into
ItsNotRexed:mainfrom
mrp1no:d3d-command-signature-root-host
Open

mrp1no wants to merge 2 commits into
ItsNotRexed:mainfrom
mrp1no:d3d-command-signature-root-host

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

D3D-359. New D3D item, claimed in #3796 (claim). It stays out of #2077's execution path (indirect patching, DGC): this is the validation CreateCommandSignature does before any of that. ## What was wrong compare_invalid_arguments compares CreateCommandSignature with the host only for signatures without a root signature. With one, the layer took root arguments without looking at the root signature, and three things differed from the host: - Too permissive: every root argument was accepted, whatever parameter it named. - No root argument: a root signature passed with no root argument at all was accepted. - Refused call: the layer cleared the output, where the host leaves it as it was. ## The host's rules The new test measured these (RTX 3060, driver 610.88). Each case is a refusal with E_INVALIDARG, and the output is left alone: - A root signature with no root argument. That includes a plain draw, a dispatch, and vertex/index buffer views only. - A root argument that names a missing parameter, or one of another type. CONSTANT needs root constants. A CBV/SRV/UAV argument needs the same kind of root descriptor, so a root SRV is no good for a CBV argument. - Constants that don't fit their parameter, or set no value. Examples: [3, 5) into 4 values, an offset of 0xffffffff, a count of 0. - Root arguments out of parameter order. "Constants p0, then CBV p1" is accepted; "CBV p1, then constants p0" is not. Constants into one parameter must come in increasing ranges that don't overlap: [0,2) then [2,4) is fine, while overlapping, repeated or decreasing ranges are refused. The same view twice is refused too. - Vertex and index buffer views. These rules hold without a root signature too: - A VB slot of 32 or more is refused. - So is the same slot twice. Slot order is free. - A VB view with a dispatch is refused. - An IB view twice is refused, and so is an IB view with a plain draw or with a dispatch. ## The change - CreateCommandSignature applies these rules. With a root signature from another device it can't check root arguments, so it doesn't. Vertex and index buffer views alongside DISPATCH_MESH aren't measured, so they're left as they were: still E_NOTIMPL. - The root signature model keeps each parameter's D3D12 type. parse_rts0 folded CBV/SRV/UAV into one kind. rt::rootsig::RootParameter::d3d_type and RootArgumentLayout::Parameter::d3d_type now carry it. - docs/d3d12_vulkan.md §4.7 lists the rules. - New d3d12_command_signature_root_test: both devices get one root signature, from a blob the host serializes. It has 4 and 1 root constants, a root CBV/SRV/UAV and a descriptor table. The test runs 91 signatures on both and records each HRESULT and whether a refused call wrote its output: 185 values in all, counting the root signature's creation. Of these, 177 are compared; the four mesh-dispatch signatures the host takes (8 values) are E_NOTIMPL in the layer until #3777, so they are left out. ## Tested Windows 11 Pro 26300, MSVC 19.52 (VS 18 Build Tools, Ninja, RelWithDebInfo), NVIDIA GeForce RTX 3060, driver 610.88: - d3d12_command_signature_root_test with LEONIDA_VK_VALIDATION=1: 177 values compared, 0 mismatches. The second commit adds INCREMENTING_CONSTANT and DISPATCH_MESH. - Negative control: on main's layer, 98 mismatches and exit 1. - d3d12_vulkan_device_test (its command signature: cases included) passes under validation. - Full ctest: 154/154 pass. gameinput isn't built without SDL3. - No other caller in runtime/ passes a root signature to CreateCommandSignature, so no existing test changes behaviour. No game files involved. AI-assisted (Claude Code). 🤖 Generated with Claude Code

@Kam471 Kam471 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.

Tested 73523299 on Windows 11 (RTX 5070 Ti, WARP available).

  • Built d3d12_command_signature_root_test in a private RelWithDebInfo/Ninja build.
  • d3d12_command_signature_root_test.exe -> exit 0: 159 values compared with the host, 0 more not compared, 0 mismatches; device NVIDIA GeForce RTX 5070 Ti, subgroup 32..32.
  • ctest -R d3d12_command_signature_root -> 1/1 passed, 0.33 s.

The new comparisons cover the root-argument validation before the signature is stored, while the execution path remains #2077's. Every requested value is compared (no silent skip). No game files; no blocker.

@rafaelpssz

Copy link
Copy Markdown
Contributor

Tested 73523299 on Windows 11, RTX 3060 (driver 616.64), Vulkan SDK 1.4.363.1, built with clang-cl + xwin (RelWithDebInfo).

  • d3d12_command_signature_root_test: OK. 159 values compared with the host (0 more not compared), 0 mismatches. It also exits 0 under LEONIDA_VK_VALIDATION=1.
  • Red check: I put back the parent's runtime/shims/d3d12_vulkan_device.cpp and rebuilt only the new test. It then gives 159 values compared with the host … 98 mismatches and fails at line 302: mismatches == 0, so the comparison exercises the new validation.
  • d3d12_vulkan_device_test: exit 0, and all sections match.

My host runtime is on driver 616.64, against 610.88 in your measurement, and it gave the same answers in all 159 cases.

@mrp1no

mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Second commit, 5b28c7d: the comparison now also covers INCREMENTING_CONSTANT and DISPATCH_MESH. That adds 26 values, 14 of which differed on RTX 3060 / 610.88:

  • Incrementing constants: an incrementing constant follows the root-constant rules (a root-constants parameter, an offset inside it, no overlap). The layer had accepted any.
  • Index buffer views: the host refuses one with a mesh dispatch, so it now comes only with an indexed draw. A vertex buffer view with a mesh dispatch is taken.
  • Mesh-dispatch signatures: the host takes them, and the layer still answers E_NOTIMPL until indirect mesh dispatch lands (Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) #3777). Those four aren't compared, and the test says why.

Result: 177 values compared, 0 mismatches under LEONIDA_VK_VALIDATION=1, and d3d12_vulkan_device_test still passes. Thanks @rafaelpssz and @Kam471 for the runs on the first commit.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 5b28c7d on NVIDIA GeForce RTX 4090 (driver 32.0.16.2101), Windows 11, MSVC 14.51: pass.

I built the branch with CMake and Ninja, RelWithDebInfo. The build has no Vulkan SDK, thus no validation layers.
d3d12_command_signature_root_test.exe prints 177 values compared with the host (8 more not compared), 0 mismatches and OK.
ctest --output-on-failure -j 4 gives 134 tests: 132 pass and 2 fail.
The 2 failures are d3d12_present and xbox_present. They also fail on main aa2988cc on this computer, because of the window size. Main gives 133 tests with the same 2 failures and the same skipped tests.

Negative control: with runtime/shims/d3d12_vulkan_device.cpp from main, the test prints 109 mismatches.

The earlier results are for commit 7352329. This result is for the current head. AI-assisted.

@mrp1no mrp1no changed the title Runtime: CreateCommandSignature with a root signature answers as the host does Runtime: CreateCommandSignature with a root signature answers as the host does (D3D-359) Nov 23, 2026
mrp1no and others added 2 commits November 23, 2026 04:43
…signature, as the host does

d3d12_command_signature_root_test compares CreateCommandSignature with a root
signature on the Vulkan-backed device and on the host runtime: root
constants (parameter index, offset, count), root CBV/SRV/UAV, vertex and
index buffer views, their order and repeats, draws and dispatches, strides,
and whether a refused call writes its output. That is 159 values, of which
98 differed on main (RTX 3060, driver 610.88). The layer accepted root
arguments without looking at the root signature, accepted a root signature
with no root argument, and cleared the output on a refusal. The host refuses
all of these:

- a root signature with no root argument;
- a root argument whose parameter doesn't exist or is of another type (a
  view must name the same kind of root descriptor);
- constants that don't fit their parameter or set no value;
- root arguments out of parameter order, or overlapping or decreasing ranges
  of one parameter's constants;
- a vertex buffer slot of 32 or more, a slot twice, a vertex buffer view
  with a dispatch, and an index buffer view twice, with a plain draw or with
  a dispatch. These vertex and index buffer rules hold without a root
  signature too.

A refused call now leaves *out alone.

The root signature model keeps the parameter's D3D12 type (parse_rts0 folded
CBV/SRV/UAV into one kind), and RootArgumentLayout carries it, so the
command signature can tell the three views apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the host does

The command-signature comparison now also covers INCREMENTING_CONSTANT and
DISPATCH_MESH: 26 more values, 14 of which differed (RTX 3060, driver 610.88).

- An incrementing constant follows the root-constant rules: a root-constants
  parameter, an offset inside it, and no overlap with that parameter's other
  constants. The layer accepted any.
- The host refuses an index buffer view with a mesh dispatch, so an index
  buffer view now comes only with an indexed draw. A vertex buffer view with
  a mesh dispatch is taken.
- The host takes mesh-dispatch signatures, which the layer still answers
  with E_NOTIMPL until indirect mesh dispatch lands (ItsNotRexed#3777). The test leaves
  those four out of the comparison and says why.

177 values compared, 0 mismatches.

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

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (now 25a27b29) to clear the runtime/CMakeLists.txt conflict with the d3d12_residency_test and d3d12_heap_properties_test blocks that just landed. All the blocks are kept, and there is no code change. d3d12_command_signature_root_test passes with LEONIDA_VK_VALIDATION=1 (177 values compared with the host, 0 mismatches; RTX 3060 / 610.88). AI-assisted (Claude Code).

@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 25a27b2 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_command_signature_root)$" (the tests this PR adds/changes): pass on both GPUs, 1/1 each. No game files.

AI-assisted.

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