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

Open
github-bot wants to merge 2 commits from github-bot/gh-956 into main AGit
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 14:27 UTC · original
MartinIndra02:feat/gpu-multi-arg-execute-indirect → main · +673 −28 · 4 files · 2 commits · open

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.

**@⁠MartinIndra02** on GitHub · 2026-11-24 14:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/956) `MartinIndra02:feat/gpu-multi-arg-execute-indirect` → `main` · +673 −28 · 4 files · 2 commits · open 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:54 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:45 UTC · original

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.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7134905950) 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.
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 15:22 UTC · original

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.

**@⁠shortselow-byte** on GitHub · 2026-11-24 15:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7135913375) 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.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:40 UTC · original

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).

**@⁠Zipettte** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7136423835) 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)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:29 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 00:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7148560872) <!-- 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)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 09:36 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 09:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7158554669) 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.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:28 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 17:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7169547236) 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.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 01:13 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 01:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/956#issuecomment-7179564455) 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 has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/pipeline/host.rs
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/956/head:github-bot/gh-956'
git switch 'github-bot/gh-956'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-956'
git switch 'github-bot/gh-956'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-956'
git switch 'github-bot/gh-956'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-956'
git switch 'main'
git merge --squash 'github-bot/gh-956'
git switch 'main'
git merge --ff-only 'github-bot/gh-956'
git switch 'main'
git merge 'github-bot/gh-956'
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!956
No description provided.