d3d12: refuse command signatures with arguments before the draw (D3D-INDIRECT-STATE-REFUSE) #1737

Open
github-bot wants to merge 1 commit from github-bot/gh-1737 into main AGit
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 10:28 UTC · original
potatoe0100:d3d12-indirect-state-refuse → main · +91 −1 · 3 files · 1 commits · open

Claimed in the coordination issue as: D3D-INDIRECT-STATE-REFUSE

Depends on: none. #1620 (INDIRECT-STATE-ARGS) touches the same function; whichever lands second drops the VERTEX/INDEX_BUFFER_VIEW part of this refusal once those arguments are replayed.

What and why

On main, CreateCommandSignature accepts a valid signature that puts arguments before its draw or dispatch (root constants, root CBV/SRV/UAV, vertex and index buffer views). But the CommandSignature object keeps only its kind and stride, and ExecuteIndirect reads the draw arguments at the start of each record. So [VERTEX_BUFFER_VIEW, DRAW] or [CONSTANT, DRAW] was accepted and then drew with the state argument's bytes as its vertex and instance counts, with no message.

Until per-command state is replayed (section 4.7 of docs/d3d12_vulkan.md), CreateCommandSignature now answers E_NOTIMPL for a signature with more than one argument, and logs it once per first argument type, the way other unimplemented features are refused. Invalid descriptions are still E_INVALIDARG as on the host, since the checks run first. One-argument signatures are unchanged, and the title's five startup signatures (section 4.9) each have one argument.

  • runtime/shims/d3d12_vulkan_device.cpp: the refusal.
  • runtime/test/d3d12_execute_indirect_validation_test.cpp: a layer-only check that eight such shapes (VBV+draw, IBV+draw indexed, constant+draw, constant+dispatch, CBV+draw, SRV+draw indexed, UAV+dispatch, VBV+constant+draw) are refused with no object, that their invalid neighbours (no root signature, short stride) stay E_INVALIDARG, and that a one-argument signature with a root signature is still created.
  • docs/d3d12_vulkan.md section 4.7: says so.

Tested

Built with VS 2022 Build Tools (MSVC 19.44), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo, on main 57ba40bd6. No game files.

  • ctest -R ^d3d12_execute_indirect_validation$ with LEONIDA_VK_VALIDATION=1: passes (state-argument signatures: 8 shapes refused with E_NOTIMPL; 51 parity cases against live WARP and the RTX 4060, 0 validation errors). With only the shim change reverted, it fails at the first shape: hr=0x00000000, object created.
  • Full ctest -j 6: 384 of 384 passed, 13 skipped (game-data and optional tests).

GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro build 26300

AI-assisted: yes (Claude Code). Posted by a non-developer tester.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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: D3D12 layer, no translator change)

🤖 Generated with Claude Code

**@⁠potatoe0100** on GitHub · 2026-11-25 10:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1737) `potatoe0100:d3d12-indirect-state-refuse` → `main` · +91 −1 · 3 files · 1 commits · open Claimed in the coordination issue as: [D3D-INDIRECT-STATE-REFUSE](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: none. #1620 (INDIRECT-STATE-ARGS) touches the same function; whichever lands second drops the VERTEX/INDEX_BUFFER_VIEW part of this refusal once those arguments are replayed. ### What and why On `main`, `CreateCommandSignature` accepts a valid signature that puts arguments before its draw or dispatch (root constants, root CBV/SRV/UAV, vertex and index buffer views). But the `CommandSignature` object keeps only its kind and stride, and `ExecuteIndirect` reads the draw arguments at the start of each record. So `[VERTEX_BUFFER_VIEW, DRAW]` or `[CONSTANT, DRAW]` was accepted and then drew with the state argument's bytes as its vertex and instance counts, with no message. Until per-command state is replayed (section 4.7 of `docs/d3d12_vulkan.md`), `CreateCommandSignature` now answers `E_NOTIMPL` for a signature with more than one argument, and logs it once per first argument type, the way other unimplemented features are refused. Invalid descriptions are still `E_INVALIDARG` as on the host, since the checks run first. One-argument signatures are unchanged, and the title's five startup signatures (section 4.9) each have one argument. - `runtime/shims/d3d12_vulkan_device.cpp`: the refusal. - `runtime/test/d3d12_execute_indirect_validation_test.cpp`: a layer-only check that eight such shapes (VBV+draw, IBV+draw indexed, constant+draw, constant+dispatch, CBV+draw, SRV+draw indexed, UAV+dispatch, VBV+constant+draw) are refused with no object, that their invalid neighbours (no root signature, short stride) stay `E_INVALIDARG`, and that a one-argument signature with a root signature is still created. - `docs/d3d12_vulkan.md` section 4.7: says so. ### Tested Built with VS 2022 Build Tools (MSVC 19.44), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo, on `main` `57ba40bd6`. No game files. - `ctest -R ^d3d12_execute_indirect_validation$` with `LEONIDA_VK_VALIDATION=1`: passes (`state-argument signatures: 8 shapes refused with E_NOTIMPL`; 51 parity cases against live WARP and the RTX 4060, 0 validation errors). With only the shim change reverted, it fails at the first shape: `hr=0x00000000, object created`. - Full `ctest -j 6`: 384 of 384 passed, 13 skipped (game-data and optional tests). GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro build 26300 AI-assisted: yes (Claude Code). Posted by a non-developer tester. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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: D3D12 layer, no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A CommandSignature keeps only its kind and stride, and ExecuteIndirect reads
the draw or dispatch arguments at the start of each record. A valid signature
that puts root constants, root views or vertex/index buffer views first was
accepted, so its draws read those bytes as their counts. Until per-command
state is replayed, CreateCommandSignature answers E_NOTIMPL for a signature
with more than one argument and logs it once per first argument type.
Invalid descriptions are still E_INVALIDARG. One-argument signatures, which
are all the title creates at startup, are unchanged.

d3d12_execute_indirect_validation checks eight such shapes are refused with
no object, that the invalid neighbours stay E_INVALIDARG, and that a
one-argument signature with a root signature is still created.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:10 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 10:59 UTC · original · approved these changes

### Clean-Room & Technical Verification

  • Mergeability: 3-way merge against upstream main (bcaa13dad) is 100% clean with zero merge conflicts.
  • Clean-Room Compliance: 100% clean-room. D3D12 command signature validation logic and synthetic layer tests only; zero retail files, game data, or keys (check_no_game_data.py clean).
  • Technical Correctness & Behavioral Parity:
    • CreateCommandSignature currently preserves only kind and stride, and ExecuteIndirect consumes draw/dispatch arguments at offset 0 of each record.
    • Signatures with leading state arguments (VERTEX_BUFFER_VIEW, INDEX_BUFFER_VIEW, CONSTANT, CBV, SRV, UAV) were previously accepted, causing indirect draws to misinterpret state arguments as vertex/instance counts.
    • Refusing multi-argument command signatures with E_NOTIMPL and rate-limited logging (log_once) maintains strict conformance until per-command state replay lands (docs/d3d12_vulkan.md §4.7), while preserving standard E_INVALIDARG validation on malformed inputs and leaving single-argument startup signatures intact.
    • Verified across 8 distinct argument shapes in runtime/test/d3d12_execute_indirect_validation_test.cpp.

LGTM! Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 10:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1737#pullrequestreview-6056328411) · **approved these changes** ### Clean-Room & Technical Verification - **Mergeability**: 3-way merge against upstream `main` (`bcaa13dad`) is 100% clean with zero merge conflicts. - **Clean-Room Compliance**: 100% clean-room. D3D12 command signature validation logic and synthetic layer tests only; zero retail files, game data, or keys (`check_no_game_data.py` clean). - **Technical Correctness & Behavioral Parity**: - `CreateCommandSignature` currently preserves only kind and stride, and `ExecuteIndirect` consumes draw/dispatch arguments at offset 0 of each record. - Signatures with leading state arguments (`VERTEX_BUFFER_VIEW`, `INDEX_BUFFER_VIEW`, `CONSTANT`, `CBV`, `SRV`, `UAV`) were previously accepted, causing indirect draws to misinterpret state arguments as vertex/instance counts. - Refusing multi-argument command signatures with `E_NOTIMPL` and rate-limited logging (`log_once`) maintains strict conformance until per-command state replay lands (docs/d3d12_vulkan.md §4.7), while preserving standard `E_INVALIDARG` validation on malformed inputs and leaving single-argument startup signatures intact. - Verified across 8 distinct argument shapes in `runtime/test/d3d12_execute_indirect_validation_test.cpp`. LGTM! Approved.
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-26 05:20 UTC · original

Independent verification of head cc642e6a4b0c080b2eb2618c26a019feaf56c268, with current main (a73a57e13) merged in. The merge conflicts only in docs/d3d12_vulkan.md (I took main's side for the test build); the code merges cleanly.

Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.

Result: not ready. This confirms the finding fiestorra posted in #1608: main now implements arguments before the draw (stateful indirect), and this PR's NumArgumentDescs > 1 refusal turns that off.

  • Full suite with the PR: 469/477 pass. 6 new failures, all at indirect pixels line 117: SUCCEEDED(device->CreateCommandSignature(...)), log CreateCommandSignature refused (not implemented): arguments before the draw or dispatch, first argument type 3:
    d3d12_stateful_indirect_pixels, _multi_pixels, _counted_pixels, _nonindexed_pixels, _nonindexed_multi_pixels, _nonindexed_counted_pixels.
  • Plain main on the same machine: 475/477; the other two failures (xbox_present, d3d12_set_descriptor_heaps) fail there too.
  • The PR's own d3d12_execute_indirect_validation passes.

No game files used. AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-26 05:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1737#issuecomment-7183398386) **Independent verification** of head `cc642e6a4b0c080b2eb2618c26a019feaf56c268`, with current `main` (`a73a57e13`) merged in. The merge conflicts only in `docs/d3d12_vulkan.md` (I took `main`'s side for the test build); the code merges cleanly. Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo. **Result: not ready.** This confirms the finding fiestorra posted in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608: `main` now implements arguments before the draw (stateful indirect), and this PR's `NumArgumentDescs > 1` refusal turns that off. - Full suite with the PR: 469/477 pass. **6 new failures**, all at `indirect pixels line 117: SUCCEEDED(device->CreateCommandSignature(...))`, log `CreateCommandSignature refused (not implemented): arguments before the draw or dispatch, first argument type 3`: `d3d12_stateful_indirect_pixels`, `_multi_pixels`, `_counted_pixels`, `_nonindexed_pixels`, `_nonindexed_multi_pixels`, `_nonindexed_counted_pixels`. - Plain `main` on the same machine: 475/477; the other two failures (`xbox_present`, `d3d12_set_descriptor_heaps`) fail there too. - The PR's own `d3d12_execute_indirect_validation` passes. No game files used. AI-assisted (Claude Code).
This pull request has changes conflicting with the target branch.
  • docs/d3d12_vulkan.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1737/head:github-bot/gh-1737'
git switch 'github-bot/gh-1737'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1737'
git switch 'github-bot/gh-1737'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1737'
git switch 'github-bot/gh-1737'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1737'
git switch 'main'
git merge --squash 'github-bot/gh-1737'
git switch 'main'
git merge --ff-only 'github-bot/gh-1737'
git switch 'main'
git merge 'github-bot/gh-1737'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.