GPU: support multi-argument ExecuteIndirect signatures with root constants #956

Open
MartinIndra02 wants to merge 2 commits from upstream-pr/956 into main
MartinIndra02 commented 2026-11-24 14:27:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MartinIndra02 on 2026-11-24T14:27:18Z.


Closes #757

Summary

Adds support for multi-argument ExecuteIndirect command signatures that combine 32-bit root-constant arguments (D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT) with a draw/dispatch/mesh argument:

  • crates/victory-gpu/src/indirect.rs:
    • Extends signature parsing (Signature::ConstantPrefixed) to handle command signatures with one or more leading CONSTANT arguments followed by a draw/draw-indexed/dispatch/dispatch-mesh terminal argument.
    • Builds a matching host ID3D12CommandSignature remapping guest root-constant slots/dwords to the host pipeline's translated user_data root constants, and clamps argument counts (arg_offset / stride-aware) before executing.
    • Includes a real D3D12 GPU end-to-end test verifying multi-argument ExecuteIndirect with root constants on hardware and WARP.
  • crates/victory-gpu/src/draw.rs & pipeline/host.rs & list.rs:
    • Wires multi-argument command signatures through list.rs -> State::execute_indirect.
    • Adds State::clear_indirect_constants (per native D3D12 state-leakage feedback from @andrewpozdnakov7-jpg and @fuzeofficlal) to zero only the overwritten guest root-constant dwords after ExecuteIndirect, preserving neighboring dwords and the other pipeline's roots, with regression test draw::tests::indirect_constants_clear_only_overwritten_guest_range.

Verification (Windows 11, RTX 3080 621.24, WARP, Rust 1.98.1)

  • cargo test -p victory-gpu --lib -- --test-threads=1: 53 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
  • cargo xtask policy: 154 files ok

No game data used. AI-assisted; all builds and GPU tests executed on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584035449 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956). Originally posted by [MartinIndra02](https://github.com/MartinIndra02) on 2026-11-24T14:27:18Z. --- Closes #757 ### Summary Adds support for multi-argument `ExecuteIndirect` command signatures that combine 32-bit root-constant arguments (`D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT`) with a draw/dispatch/mesh argument: - **`crates/victory-gpu/src/indirect.rs`**: - Extends `signature` parsing (`Signature::ConstantPrefixed`) to handle command signatures with one or more leading `CONSTANT` arguments followed by a draw/draw-indexed/dispatch/dispatch-mesh terminal argument. - Builds a matching host `ID3D12CommandSignature` remapping guest root-constant slots/dwords to the host pipeline's translated `user_data` root constants, and clamps argument counts (`arg_offset` / stride-aware) before executing. - Includes a real D3D12 GPU end-to-end test verifying multi-argument `ExecuteIndirect` with root constants on hardware and WARP. - **`crates/victory-gpu/src/draw.rs` & `pipeline/host.rs` & `list.rs`**: - Wires multi-argument command signatures through `list.rs` -> `State::execute_indirect`. - Adds `State::clear_indirect_constants` (per native D3D12 state-leakage feedback from `@andrewpozdnakov7-jpg` and `@fuzeofficlal`) to zero only the overwritten guest root-constant dwords after `ExecuteIndirect`, preserving neighboring dwords and the other pipeline's roots, with regression test `draw::tests::indirect_constants_clear_only_overwritten_guest_range`. ### Verification (Windows 11, RTX 3080 `621.24`, WARP, Rust `1.98.1`) - `cargo test -p victory-gpu --lib -- --test-threads=1`: **53 passed, 0 failed, 1 ignored** - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default + `--features diagnostics`): **0 warnings** - `cargo xtask policy`: **154 files ok** *No game data used. AI-assisted; all builds and GPU tests executed on my machine.*
DenRakEiw commented 2026-11-24 15:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:32:57Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 53 passed, 0 failed, 1 ignored
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 53 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean multi-argument ExecuteIndirect root-constant signature support, passes on both Blackwell hardware and WARP with zero warnings. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6041142267 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#pullrequestreview-6041142267). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:32:57Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP** (`VICTORY_D3D12_WARP=1`): - `cargo test -p victory-gpu` (RTX 5090): **53 passed, 0 failed, 1 ignored** - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu` (WARP): **53 passed, 0 failed, 1 ignored** - `cargo clippy -p victory-gpu --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean multi-argument `ExecuteIndirect` root-constant signature support, passes on both Blackwell hardware and WARP with zero warnings. Approving. AI-assisted (Gemini 4 Neon).
MichaelSmithAI commented 2026-11-24 15:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:45:46Z.


A guest command-list readback on RTX 4090 under Wine/vkd3d-proton 3.2 checked what the next direct dispatch actually sees. A constant-prefixed indirect dispatch replaced two adjacent compute root dwords (pixel index and value) and wrote [53, 29, 1, 255] to pixel 1. The following direct dispatch wrote [0, 29, 0, 255] to pixel 0. Both overwritten dwords were zero and the neighboring dword retained 29.

With only the guest-state reset removed, the direct dispatch reused the earlier index 1 and value 19. Pixel 1 then contained [19, 29, 1, 255] and pixel 0 kept its seeded value. This checks one contiguous compute mapping in a single stage. Multi-stage mappings and title signatures remain unmeasured.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134905950 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7134905950). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T14:45:46Z. --- A guest command-list readback on RTX 4090 under Wine/vkd3d-proton 3.2 checked what the next direct dispatch actually sees. A constant-prefixed indirect dispatch replaced two adjacent compute root dwords (pixel index and value) and wrote `[53, 29, 1, 255]` to pixel 1. The following direct dispatch wrote `[0, 29, 0, 255]` to pixel 0. Both overwritten dwords were zero and the neighboring dword retained 29. With only the guest-state reset removed, the direct dispatch reused the earlier index 1 and value 19. Pixel 1 then contained `[19, 29, 1, 255]` and pixel 0 kept its seeded value. This checks one contiguous compute mapping in a single stage. Multi-stage mappings and title signatures remain unmeasured.
shortselow-byte commented 2026-11-24 16:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T15:22:22Z.


Tested at head db86e1e (on main ffe310e) on AMD, since the runs above are NVIDIA (native and vkd3d-proton): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2, driver 32.0.21045.16010).

  • multi_argument_indirect_dispatch_sets_root_constants_and_clamps: passed on the AMD device (default adapter, checked with a temporary print) and on WARP (--features diagnostics, VICTORY_D3D12_WARP=1). So AMD's driver passes each record's root constants through ExecuteIndirect and the over-limit record is clamped to zero groups (got = [0x11223344, 0, 0xCAFEBABE]).
  • The other new tests (plan_indirect_maps_root_constants_and_rejects_unsupported, indirect_constants_clear_only_overwritten_guest_range) pass too.
  • cargo test --locked -p victory-gpu --lib -- --test-threads=1: 53 passed on AMD, 56 on WARP with diagnostics. Whole workspace: 345 passed, 0 failed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.

Not covered: no D3D12 debug layer on this machine, and no in-title run.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135913375 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7135913375). Originally posted by [shortselow-byte](https://github.com/shortselow-byte) on 2026-11-24T15:22:22Z. --- Tested at head `db86e1e` (on `main` `ffe310e`) on AMD, since the runs above are NVIDIA (native and vkd3d-proton): Windows 11, Rust 1.98.1 MSVC, **AMD Radeon RX 6900 XT** (RDNA2, driver 32.0.21045.16010). - `multi_argument_indirect_dispatch_sets_root_constants_and_clamps`: passed on the AMD device (default adapter, checked with a temporary print) and on WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`). So AMD's driver passes each record's root constants through `ExecuteIndirect` and the over-limit record is clamped to zero groups (`got = [0x11223344, 0, 0xCAFEBABE]`). - The other new tests (`plan_indirect_maps_root_constants_and_rejects_unsupported`, `indirect_constants_clear_only_overwritten_guest_range`) pass too. - `cargo test --locked -p victory-gpu --lib -- --test-threads=1`: 53 passed on AMD, 56 on WARP with `diagnostics`. Whole workspace: 345 passed, 0 failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. Not covered: no D3D12 debug layer on this machine, and no in-title run.
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:32Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at db86e1e: cargo test -p victory-gpu passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136423835 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7136423835). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:32Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at db86e1e: `cargo test -p victory-gpu` passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 01:07:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:29:20Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/draw.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148560872 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7148560872). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:29:20Z. --- <!-- victory-triage v1 head=db86e1e387a61e5cc1a0f407646211d7e70926a4 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-gpu/src/draw.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 10:07:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T09:36:17Z.


I rebased db86e1e387 onto current main 940d32f69b. The fork branch contains 8c89464 and 3003511, both with MartinIndra02's Git authorship. The second retains the original co-author trailer.

On WARP, a local guest shader ran through State::execute_indirect and then a normal direct dispatch in the same list. The indirect dispatch wrote [1, 0.25, 0.75, 2] to the output texture in both controls. Without the guest-side clear call, the direct dispatch read back [1, 0.5, -0.25, 2]. With the clear, it read back [1, 0, 0, 2], preserving both neighboring dwords. All eight indirect-related tests and the full GPU suite passed (149 passed, 2 ignored). Strict Clippy with and without diagnostics and the repository policy check passed.

If you reuse the rebased patch or its test coverage, please preserve the existing Git authorship and keep this trailer on the clearing change if it is folded into another commit:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158554669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7158554669). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T09:36:17Z. --- I rebased db86e1e387a61e5cc1a0f407646211d7e70926a4 onto current main 940d32f69b22265690a0b5a15d6ded572ba33baf. The [fork branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/rebase/956-indirect-root-constants) contains [8c89464](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8c89464eff22f218c604e288c045fe693a6da903) and [3003511](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3003511a5309d2eaa2c2a5110f3285f9a413461b), both with MartinIndra02's Git authorship. The second retains the original co-author trailer. On WARP, a local guest shader ran through State::execute_indirect and then a normal direct dispatch in the same list. The indirect dispatch wrote [1, 0.25, 0.75, 2] to the output texture in both controls. Without the guest-side clear call, the direct dispatch read back [1, 0.5, -0.25, 2]. With the clear, it read back [1, 0, 0, 2], preserving both neighboring dwords. All eight indirect-related tests and the full GPU suite passed (149 passed, 2 ignored). Strict Clippy with and without diagnostics and the repository policy check passed. If you reuse the rebased patch or its test coverage, please preserve the existing Git authorship and keep this trailer on the clearing change if it is folded into another commit: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
andrewpozdnakov7-jpg commented 2026-11-25 18:02:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T17:28:09Z.


I refreshed the rebase of db86e1e387 on main 13f91caee2. The current clamp writes the list's own argument buffer. The rebased shader copies the constant prefix into that buffer and clamps the draw or dispatch at its offset. Diagnostics read the clamped records. Both commits retain MartinIndra02 as Git author. Fork branch · 32385fc · b0e185a

In six paired WARP runs the same synthetic indirect dispatch wrote [1, 0.25, 0.75, 2] and left its input arguments intact. A following direct dispatch read [1, 0.5, -0.25, 2] with the guest constant clear disabled and [1, 0, 0, 2] with the clear. The included multi-record clamp test also passed. Serial victory-gpu passed with 201 passed and 1 ignored in both D3D12 debug flag settings. Strict GPU Clippy and repository policy passed.

The second commit retains the original trailer. Please keep it if you squash or otherwise fold the change into a new commit.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic data only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169547236 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7169547236). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T17:28:09Z. --- I refreshed the rebase of db86e1e387a61e5cc1a0f407646211d7e70926a4 on main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. The current clamp writes the list's own argument buffer. The rebased shader copies the constant prefix into that buffer and clamps the draw or dispatch at its offset. Diagnostics read the clamped records. Both commits retain MartinIndra02 as Git author. [Fork branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/rebase/956-indirect-root-constants-13f91ca) · [32385fc](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/32385fc95bc902cb36fbe1462c60a1830f2225ef) · [b0e185a](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b0e185a06bdb0913929d54633ab8955308bfa70b) In six paired WARP runs the same synthetic indirect dispatch wrote [1, 0.25, 0.75, 2] and left its input arguments intact. A following direct dispatch read [1, 0.5, -0.25, 2] with the guest constant clear disabled and [1, 0, 0, 2] with the clear. The included multi-record clamp test also passed. Serial victory-gpu passed with 201 passed and 1 ignored in both D3D12 debug flag settings. Strict GPU Clippy and repository policy passed. The second commit retains the original trailer. Please keep it if you squash or otherwise fold the change into a new commit. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic data only.
andrewpozdnakov7-jpg commented 2026-11-26 02:06:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T01:13:53Z.


I refreshed the #956 rebase on 63bcca43c6a00a758510398fa43096ce7e4f7df0. 8ac1ec7 carries the multi-argument signature support. abad7ee carries the post-indirect constant clear and its test. Both retain MartinIndra02 as Git author. The new main's placed-UAV tests and the original indirect regression coexist after resolving the test insertion conflict. Fork branch.

With the same synthetic WARP readback, the support-only commit leaves the later direct dispatch at [1, 0.5, -0.25, 2]. The two-commit branch returns [1, 0, 0, 2]. Indirect readback is [1, 0.25, 0.75, 2] on both, and both keep the original arguments. Six paired runs passed their expected comparison. The full GPU suite passed with 249 tests and one ignored with each D3D12 debug setting, including all eight indirect tests. Strict GPU Clippy and asset policy passed.

Please preserve both Git authors when replaying the commits and retain the existing Co-authored-by: andrewpozdnakov7-jpg <[email protected]> on the constant-clear change.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179564455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7179564455). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T01:13:53Z. --- I refreshed the #956 rebase on `63bcca43c6a00a758510398fa43096ce7e4f7df0`. [8ac1ec7](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8ac1ec75917a8e70ee1e169348d1dc838c09e766) carries the multi-argument signature support. [abad7ee](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/abad7eee20ac2b0804b4e8041e35b890cb6048dd) carries the post-indirect constant clear and its test. Both retain MartinIndra02 as Git author. The new main's placed-UAV tests and the original indirect regression coexist after resolving the test insertion conflict. [Fork branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/rebase/956-indirect-root-constants-63bcca4). With the same synthetic WARP readback, the support-only commit leaves the later direct dispatch at `[1, 0.5, -0.25, 2]`. The two-commit branch returns `[1, 0, 0, 2]`. Indirect readback is `[1, 0.25, 0.75, 2]` on both, and both keep the original arguments. Six paired runs passed their expected comparison. The full GPU suite passed with 249 tests and one ignored with each D3D12 debug setting, including all eight indirect tests. Strict GPU Clippy and asset policy passed. Please preserve both Git authors when replaying the commits and retain the existing `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` on the constant-clear change.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/956:upstream-pr/956'
git switch 'upstream-pr/956'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/956'
git switch 'upstream-pr/956'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/956'
git switch 'upstream-pr/956'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/956'
git switch 'main'
git merge --squash 'upstream-pr/956'
git switch 'main'
git merge --ff-only 'upstream-pr/956'
git switch 'main'
git merge 'upstream-pr/956'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!956
No description provided.