Skip to content

Preserve GPU-generated ExecuteIndirect arguments and apply the work budget in order - #1

Open
Pin0d1 wants to merge 1 commit into
mainfrom
gpu/execute-indirect-review
Open

Pin0d1 wants to merge 1 commit into
mainfrom
gpu/execute-indirect-review

Conversation

@Pin0d1

@Pin0d1 Pin0d1 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Problem

The host currently clamps the argument buffer in place before it knows whether the title pipeline can execute. With a GPU count of zero, a populated inactive tail can consume the list budget. A subsequent valid draw can produce zero input vertices. A failed descriptor-table bind can have the same effect. A producer that uses the same buffer later can observe the host's clamped values. These failures reproduce with a synthetic triangle and a two-thread compute shader.

D3D12 executes the first min(MaxCommandCount, count) records, or MaxCommandCount records when the count buffer is absent. Its stride can include padding. With four 16-byte draw payloads at stride 24, the last byte needed is byte 87. A separate native DISPATCH probe accepted 84 bytes at stride 24 for four 12-byte payloads and rejected 83 on both adapters. The per-list work limit is VIctory policy. ExecuteIndirect · Indirect drawing specification

Implementation

  • Check the signature, dword offsets, 64-bit source extent, pipeline kind, index binding and fallible descriptor tables before charging work. A zero maximum returns immediately. The native signature uses the packed payload width.
  • Read the GPU producer's arguments and count, write the count and clamped active payloads to list-owned scratch, and execute from that scratch. The source remains available to later title commands. Track shadow-buffer state changes for GPU writes and reads, handle argument/count aliasing, and restore the title's pipeline and compute bindings. Declare the helper's root SRVs DATA_VOLATILE because the title can return an input to writable state. The full debug layer diagnosed a default static-while-set SRV with message 1003. Root Signature 1.1 data flags
  • Admit records against the work budget in their original order. One 64-lane group loads and writes records in tiles. One lane accounts for the tile in order. A record that exceeds the remaining budget runs empty and leaves room for a later smaller record. Byte-address windows cover at most 4,096 records and successive windows have a UAV barrier. The existing work limits remain part of the host policy.
  • Reset the budget in the recorded GPU list, so replay resets it too. Reuse scratch in command order. Split a guest submission at a repeated native list and fence the preceding group before reusing the list, its prelude and its scratch. Independent lists still batch. Command queue execution rules

Reproduction

  1. Draw a full-screen green triangle on a 4×4 target. Precede it with 2,048 populated indirect records and a GPU count of zero. Repeat with an unavailable pipeline and with exhausted descriptor-table slots. The reference draw produces three input vertices and 16 green pixels.
  2. Put a count at byte 4 and four draw records at byte 20 with stride 24. Give the last record exactly 16 bytes. Change the count from the GPU in the same list and in a preceding list. A count of two selects records producing nine input vertices.
  3. To inspect budget ordering, stage two large records that leave a budget of 128, one record costing 129 and 255 unit-cost records. Run only the sanitizer and read back its output. The large rejected record leaves room for the first 128 unit-cost records, and the input bytes match the original. No large draw is submitted. The committed regression also crosses record 4,096, replays the list with a changed count and checks individual record IDs.

Results

Each entry reproduced three times on WARP and three times on an RTX 2060 SUPER. The five raster cases and eight count cases are subcases of the eight common checks. The ordered-budget readback is a separate check.
ExecuteIndirect-evidence.zip

Source Common checks Raster cases Count cases Ordered readback, correct runs
Current main 4/8 3/5 8/8 0/6
Marvisak#242 on main 5/8 5/5 8/8 0/6
Marvisak#583 on main 4/8 4/5 8/8 0/6
Previous local patch 8/8 5/5 8/8 0/6 in the final comparative run
This patch 8/8 5/5 8/8 6/6

An earlier WARP run of the previous patch matched the order once in three attempts. The other two differed at 134 and 128 records. The final table uses the common comparison build and three fresh runs per adapter.

A native mesh-only pass produced 16 green pixels. A second list switched between mesh, indexed draw, compute and draw. The strict suite passed 72 test invocations across both adapters, including six CPU-only layout checks. GPU-Based Validation, synchronized queue validation and full resource-state tracking were enabled before device creation. The info queue recorded zero errors and six warnings, all ID 971 for the first lookup of the synthetic mesh PSO in an empty pipeline library. The logs include the messages.

On the RTX, 256 active one-group dispatches took a median of 88.48 µs of queue time with this patch, 101.41 µs on main, 18.43 ms with Marvisak#242 and 18.21 ms with Marvisak#583. The same synthetic workload issued directly took 78.91 µs. CPU recording took 18.0 µs with this patch and 13.2 µs on main. On WARP the corresponding candidate and main GPU timestamp intervals were 699.5 and 680.9 µs. Each cell has 21 measured samples with validation disabled. Sources and raw samples are in the evidence kit.

From a Windows x64 Developer PowerShell with the pinned toolchain, run the following commands in this branch. Start a fresh test process for each adapter.

cargo test --workspace --locked
cargo test --workspace --all-features --locked
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo build --workspace --release --locked
cargo xtask policy
$env:VICTORY_D3D12_WARP = '1'
cargo test -p victory-gpu --profile diag --features diagnostics --locked indirect -- --test-threads=1 --nocapture
Remove-Item Env:VICTORY_D3D12_WARP
cargo test -p victory-gpu --profile diag --features diagnostics --locked indirect -- --test-threads=1 --nocapture

The evidence kit's reproduce.py also rebuilds each comparison tree, enables strict validation, compiles the synthetic mesh fixture, and runs the native range oracle, timing and scratch-lifetime probes. The clean workspace suites passed 345 and 356 tests respectively, with six ignored in each. Both Clippy configurations, the release build and asset policy passed. Workspace rustfmt reports existing drift on the same 35 files in main and this branch.

Scope and limitations

This change covers the single-operation signatures VIctory translates for DRAW, DRAW_INDEXED, DISPATCH and DISPATCH_MESH. Root-argument and other multi-operation signatures remain tracked separately. The existing indirect rectangle-list limitation is covered by #346. The state-tracking work overlaps Marvisak#334 and should share one implementation if both changes land. Issue #757 · PR #334

Scratch is sized for the declared maximum. Older allocations stay alive until list reset when a recording grows through several capacities. The CPU still requests the declared input extent for the guest shadow refresh. The timing and residency measurements cover one software adapter and one physical NVIDIA adapter. They use synthetic shaders and buffers. The first mission and game frame rate have not been verified.

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.

1 participant