GPU: validate ByteStride alignment and root signature in signature::create #3315

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

@⁠mgunes1311-lab on GitHub · 2026-11-26 17:18 UTC · original
mgunes1311-lab:gpu-command-signature-validation → main · +170 −2 · 1 files · 1 commits · open

Coordination

Claimed in #1633 (GPU: validate 4-byte ByteStride alignment and required root signature for binding arguments in signature::create). Checked STATUS.md, CLAIMS.md, and forge/main — zero overlapping PRs or diff in crates/victory-gpu/src/signature.rs.

Problem

Per Microsoft's D3D12_COMMAND_SIGNATURE_DESC and ID3D12Device::CreateCommandSignature specification:

  1. ByteStride must be a multiple of 4 bytes (E_INVALIDARG otherwise).
  2. pRootSignature is required whenever any D3D12_INDIRECT_ARGUMENT_DESC updates root bindings (CONSTANT = 5, CONSTANT_BUFFER_VIEW = 6, SHADER_RESOURCE_VIEW = 7, UNORDERED_ACCESS_VIEW = 8, INCREMENTING_CONSTANT = 11), and optional only for non-binding arguments (DRAW, DRAW_INDEXED, DISPATCH, VERTEX_BUFFER_VIEW, INDEX_BUFFER_VIEW, DISPATCH_RAYS, DISPATCH_MESH).
  3. Early E_INVALIDARG paths did not clear a non-null _COM_Outptr_opt_ ppvCommandSignature slot.

signature::create accepted unaligned ByteStride values and rootless binding signatures, deferring failure or silently misinterpreting indirect argument buffers at execution time.

Fix

  • Reject !desc.stride.is_multiple_of(4) with E_INVALIDARG in signature::create.
  • Reject root.is_null() when any indirect argument has type 5..=8 | 11 (binds_root) with E_INVALIDARG.
  • Clear *out = null on all early E_INVALIDARG returns when out is non-null.

Verification

  • Added signature::tests::misaligned_strides_and_rootless_binding_arguments_are_rejected_and_clear_out covering unaligned strides, all five root-binding argument types with and without a root signature, all non-binding argument types with a null root signature, and _COM_Outptr_opt_ clearing on early failure.
  • Added signature::tests::host_device_agrees_on_stride_alignment_and_root_requirement verifying live D3D12 ID3D12Device::CreateCommandSignature returns E_INVALIDARG on both cases.
  • Ran cargo test -p victory-gpu --locked signature::tests:: (7/7 passed), cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, and cargo xtask policy on Windows 11 (x86_64-pc-windows-msvc).

AI-assisted contribution (Google Antigravity); all code, D3D12 validation, and tests were locally executed and verified.

**@⁠mgunes1311-lab** on GitHub · 2026-11-26 17:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3315) `mgunes1311-lab:gpu-command-signature-validation` → `main` · +170 −2 · 1 files · 1 commits · open ## Coordination Claimed in https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 (`GPU: validate 4-byte ByteStride alignment and required root signature for binding arguments in signature::create`). Checked `STATUS.md`, `CLAIMS.md`, and `forge/main` — zero overlapping PRs or diff in `crates/victory-gpu/src/signature.rs`. ## Problem Per Microsoft's `D3D12_COMMAND_SIGNATURE_DESC` and `ID3D12Device::CreateCommandSignature` specification: 1. `ByteStride` must be a multiple of 4 bytes (`E_INVALIDARG` otherwise). 2. `pRootSignature` is required whenever any `D3D12_INDIRECT_ARGUMENT_DESC` updates root bindings (`CONSTANT = 5`, `CONSTANT_BUFFER_VIEW = 6`, `SHADER_RESOURCE_VIEW = 7`, `UNORDERED_ACCESS_VIEW = 8`, `INCREMENTING_CONSTANT = 11`), and optional only for non-binding arguments (`DRAW`, `DRAW_INDEXED`, `DISPATCH`, `VERTEX_BUFFER_VIEW`, `INDEX_BUFFER_VIEW`, `DISPATCH_RAYS`, `DISPATCH_MESH`). 3. Early `E_INVALIDARG` paths did not clear a non-null `_COM_Outptr_opt_` `ppvCommandSignature` slot. `signature::create` accepted unaligned `ByteStride` values and rootless binding signatures, deferring failure or silently misinterpreting indirect argument buffers at execution time. ## Fix - Reject `!desc.stride.is_multiple_of(4)` with `E_INVALIDARG` in `signature::create`. - Reject `root.is_null()` when any indirect argument has type `5..=8 | 11` (`binds_root`) with `E_INVALIDARG`. - Clear `*out = null` on all early `E_INVALIDARG` returns when `out` is non-null. ## Verification - Added `signature::tests::misaligned_strides_and_rootless_binding_arguments_are_rejected_and_clear_out` covering unaligned strides, all five root-binding argument types with and without a root signature, all non-binding argument types with a null root signature, and `_COM_Outptr_opt_` clearing on early failure. - Added `signature::tests::host_device_agrees_on_stride_alignment_and_root_requirement` verifying live D3D12 `ID3D12Device::CreateCommandSignature` returns `E_INVALIDARG` on both cases. - Ran `cargo test -p victory-gpu --locked signature::tests::` (7/7 passed), `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`, and `cargo xtask policy` on Windows 11 (`x86_64-pc-windows-msvc`). AI-assisted contribution (Google Antigravity); all code, D3D12 validation, and tests were locally executed and verified.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 17:20:41 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 17:28 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):

  • Rejecting non-4-byte-aligned ByteStride and root-binding indirect arguments (CONSTANT / CBV / SRV / UAV / INCREMENTING_CONSTANT) without a root signature while clearing non-null _COM_Outptr_opt_ slots on E_INVALIDARG matches native D3D12 behavior.
  • cargo test -p victory-gpu --lib signature:: -- --test-threads=1 (RTX 5090): 7 passed, 0 failed (including host_device_agrees_on_stride_alignment_and_root_requirement and misaligned_strides_and_rootless_binding_arguments_are_rejected_and_clear_out).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 17:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3315#pullrequestreview-6078372902) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090): - Rejecting non-4-byte-aligned `ByteStride` and root-binding indirect arguments (`CONSTANT` / `CBV` / `SRV` / `UAV` / `INCREMENTING_CONSTANT`) without a root signature while clearing non-null `_COM_Outptr_opt_` slots on `E_INVALIDARG` matches native D3D12 behavior. - `cargo test -p victory-gpu --lib signature:: -- --test-threads=1` (RTX 5090): 7 passed, 0 failed (including `host_device_agrees_on_stride_alignment_and_root_requirement` and `misaligned_strides_and_rootless_binding_arguments_are_rejected_and_clear_out`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3315'
git switch 'github-bot/gh-3315'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3315'
git switch 'github-bot/gh-3315'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3315'
git switch 'main'
git merge --squash 'github-bot/gh-3315'
git switch 'main'
git merge --ff-only 'github-bot/gh-3315'
git switch 'main'
git merge 'github-bot/gh-3315'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3315
No description provided.