Skip to content

CreateCommandSignature refuses the descriptions the host refuses - #1886

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Callimann8:claude/project-thread-p7hg7w
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Callimann8:claude/project-thread-p7hg7w

Conversation

@Callimann8

Copy link
Copy Markdown

Claimed in the coordination issue as: new D3D item, CreateCommandSignature refusals (#1745)

What and why

ID3D12Device::CreateCommandSignature only refused stride 0, no arguments and null pointers. It accepted descriptions that the PC runtime refuses, and when an argument came after a draw or dispatch the last one silently won. This change checks the description before it creates the object, and every new check was measured against the host runtime:

  • NodeMask with any bit other than node 0 set: E_INVALIDARG
  • an unknown argument type: E_INVALIDARG
  • exactly one draw/dispatch argument (draw, draw indexed, dispatch, dispatch rays, dispatch mesh), and it must be the last: otherwise E_INVALIDARG
  • constant, incrementing-constant, CBV, SRV or UAV arguments without a root signature: E_INVALIDARG
  • ByteStride not a multiple of 4, or smaller than the arguments' total size: E_INVALIDARG
  • a valid description with a null output: E_UNEXPECTED, as the host returns (this was E_POINTER)

Which argument kinds are supported is unchanged (D3D-17). A valid signature whose last argument is not draw, draw indexed or dispatch still returns E_NOTIMPL.

compare_invalid_arguments in d3d12_vulkan_device_test gets 22 command signature: cases (no root signature). A null description is not compared because it faults in the host runtime (0xC0000005), the same as the existing null D3D12_HEAP_PROPERTIES case.

Tested

  • Before the shim change, the new cases gave 14 mismatches against the host: every refusal above was S_OK or E_NOTIMPL in ours, and null output was E_POINTER in ours where the host returns E_UNEXPECTED.
  • After: d3d12_vulkan_device_test with LEONIDA_D3D49_VERBOSE=1 matches the host on all 22 cases and has 0 mismatches overall. ctest -R "d3d12_vulkan_device|d3d12_indirect": 3/3 passed (d3d12_vulkan_device, d3d12_indirect_zero, d3d12_indirect_rt).
  • GPU: NVIDIA GeForce RTX 4070, driver 621.14 (32.0.16.2114), unelevated; Windows 11 Pro build 26300; MSVC from Visual Studio 18 (2026), Windows SDK 10.0.26100.0; Ninja Release build with LEONIDA_VULKAN_HEADERS_FETCH=ON. No new warnings.
  • Not compared with the host: signatures with a root signature (the root-argument types themselves), dispatch rays and dispatch mesh.

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a, no translator change)

@RobertPattinson007

Copy link
Copy Markdown
Contributor

Tested 54e2fee on NVIDIA GeForce RTX 3070 Ti (driver 617.42) and AMD Radeon Graphics, Ryzen 7 7800X3D iGPU (driver 32.0.21045.29003), Windows 11 build 26300, MSVC 19.44, Ninja, RelWithDebInfo: pass.

  • d3d12_vulkan_device with LEONIDA_D3D49_VERBOSE=1: all command signature: cases agree with the host runtime on both GPUs (19 compared with HRESULTs, plus null output and wrong interface), 0 differ.
  • At the PR head on its base 003e7812, the test passes on the RTX 3070 Ti. On the AMD iGPU it fails, but only on 9 format N RT/DS cases (40, 41, 42, 43, 54, 55, 56, 65, 67), which fail the same way on 003e7812 without this PR. Merged into current main (6a6704df), the test passes on both GPUs: those formats are now reported as "the host accepts it, this Vulkan driver can't".
  • Full ctest on the RTX 3070 Ti: 102 of 103 run passed. The one failure is d3d12_draw (bundle blend), the known failure on 003e7812.
  • The PR's test built against the base code fails on the RTX 3070 Ti, where the PR head passes, so the new cases catch the old answers.

Synthetic inputs only. AI-assisted.

@dev-ewann

Copy link
Copy Markdown
Contributor

Reviewed and tested 54e2fee, merged into main 6a6704d, on NVIDIA GeForce RTX 5070, driver 621.14, Vulkan 1.4.357, Windows 11 build 26300, MSVC 19.44 (BuildTools 2022), Ninja RelWithDebInfo: pass. I found four host refusals the shim still accepts. They are listed below as a possible follow-up and don't block this PR.

AI-assisted (Claude), on behalf of dev-ewann.

Runs

Mutations of the new CreateCommandSignature, one at a time. Each was a 1-line change, then only d3d12_vulkan_device_test was rebuilt and run. Every one fails the test:

Mutation Case that catches it
no NodeMask check node mask 2: ours S_OK, host E_INVALIDARG
no ByteStride % 4 stride 18
E_UNEXPECTED → E_POINTER for a null output null output
no root-signature check constant and UAV without a root signature
draw-indexed size counted as a draw (16) draw indexed stride 16
only "a draw must be last" (not "the last must be a draw") vertex buffer view only: ours E_NOTIMPL

Extra cases I compared with the host. These were local only, added to compare_invalid_arguments and not pushed, with no root signature:

These agree with the host:

  • DISPATCH_MESH at stride 8 and DISPATCH_RAYS at stride 100: both E_INVALIDARG, so the 12/104-byte sizes are right.
  • VBV + draw at stride 32 / 28: S_OK / E_INVALIDARG.
  • IBV + draw indexed at stride 36 / 32: S_OK / E_INVALIDARG.
  • VBVs on slots 0,1 and on slots 1,0: S_OK. A VBV on slot 31: S_OK.
  • An incrementing constant or a CBV without a root signature: E_INVALIDARG.
  • Dispatch at stride 13 / 4096: E_INVALIDARG / S_OK.
  • Type -1 and node mask 3: E_INVALIDARG.
  • An invalid stride with a null output: E_INVALIDARG, so the description is checked before the output.

These differ, ours S_OK and host E_INVALIDARG:

Description Stride
IBV, then a non-indexed draw 32
two IBVs, then a draw indexed 52
two VBVs on the same slot (0, 0), then a draw 48
one VBV on slot 32, then a draw (40 too) 32

So the host takes an index buffer view only once and only before a draw indexed, and a vertex buffer slot only once and below D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT (32). As expected, DISPATCH_MESH (stride 12) and DISPATCH_RAYS (stride 104) are E_NOTIMPL in ours and S_OK on the host, as the description says.

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

Reviewed 54e2fee2 and tested on NVIDIA GeForce RTX 5070 Ti (driver 610.88, Windows 11 Pro, MSVC 19.50.35719.0, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0): tests pass, with one small overflow fix suggested before merge.

Code review (runtime/shims/d3d12_vulkan_device.cpp, runtime/test/d3d12_vulkan_device_test.cpp)

  • Validation logic (node mask, known argument types, draw/dispatch count and final position, root-signature requirement for non-IA arguments, multiple-of-4 stride, ByteStride >= size, and E_UNEXPECTED when out == nullptr) cleanly matches all 22 new compare_invalid_arguments host comparisons in d3d12_vulkan_device_test.cpp.
  • Minor overflow bug (CreateCommandSignature): UINT size = 0 and 4 * arg.Constant.Num32BitValuesToSet accumulate in 32-bit unsigned arithmetic, so a large Num32BitValuesToSet (for example 0x40000000u) or sum of arguments can wrap around 2^32 and slip past desc->ByteStride < size. Using UINT64 size = 0; and UINT64{4} * arg.Constant.Num32BitValuesToSet prevents wrapping.
  • Out-of-scope host cases (not added in this PR, worth keeping in mind for follow-up): passing a non-null root_signature when there are no root arguments, VertexBuffer.Slot bounds, and matching root arguments against the supplied root signature.

Checks on 54e2fee2

  • d3d12_vulkan_device_test.exe (default and LEONIDA_VK_VALIDATION=1): passed (EXIT_DEV=0, EXIT_DEV_VAL=0, 0 Vulkan validation errors, host comparisons matched)
  • d3d12_indirect_zero_test.exe: passed (EXIT_INDZ=0)
  • d3d12_indirect_rt_test.exe: passed (EXIT_INDRT=0)
  • ctest --test-dir runtime/build --output-on-failure -j 4: 102/103 passed (only pre-existing d3d12_draw bundle blend pixel failure from its base; 7 skipped/disabled)

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 54e2fee2 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Vulkan SDK 1.4.363: pass.

AI-assisted (Claude Code).

@0xTehuti 0xTehuti 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 54e2fee on NVIDIA GeForce RTX 2070 SUPER (driver 595.79), Windows 11 24H2, MSVC 19.44 (VS 2022 Community), Ninja RelWithDebInfo: pass

  • Build: Clean compile and link with MSVC and Ninja.
  • Runtime verification: d3d12_vulkan_device_test.exe passes cleanly on RTX 2070 SUPER (0.85s), validating the 22 CreateCommandSignature refusal cases against host D3D12 behavior (node mask, unknown arguments, draw/dispatch positioning, root signature presence, and alignment).
  • Standards: Clean-room implementation, no game files.

No game data used or added. AI-assisted.

A large Num32BitValuesToSet could wrap the 32-bit total and pass the
ByteStride check (review on ItsNotRexed#1886).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ2Pr9JZJaj81r4m2MtQZk
@Callimann8

Copy link
Copy Markdown
Author

Thanks all for testing. @Serrambi: done in e9f315f, the argument sizes now add up in 64 bits (UINT64 size, UINT64{4} * Num32BitValuesToSet). Rebuilt on RTX 4070 / 621.14: d3d12_vulkan_device, d3d12_indirect_zero, d3d12_indirect_rt pass, no new warnings.
@dev-ewann: thanks for the mutations and the extra host cases. I'll take the four IBV/VBV refusals (IBV before a non-indexed draw, two IBVs, a repeated VBV slot, a slot >= 32) as a follow-up PR so this one stays as reviewed.

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