gpu: serialize short indirect argument clamps #3937

Open
Tigoniukas wants to merge 1 commit from upstream-pr/3937 into main
Tigoniukas commented 2026-12-01 16:33:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Tigoniukas on 2026-12-01T16:33:50Z.


Summary

Use a single-lane serial path when clamping 2–8 indirect argument records.

This avoids group-wide synchronization overhead for small record counts while preserving record order and budget semantics.

Performance

Synthetic D3D12 GPU benchmark (median per call):

Records Original Optimized Reduction
2 12.8796 us 5.0587 us 60.72%
4 12.8797 us 6.0416 us 53.09%
8 12.8790 us 8.1194 us 36.96%

These are GPU operation timings, not game FPS improvements.

Validation

  • 7/7 indirect tests passed on the clean branch.
  • Full workspace tests passed.
  • Clippy passed with -D warnings.
  • Real D3D12 ExecuteIndirect validation passed 12/12 scenarios on a combined experimental branch.
  • GPU-Based Validation reported 0 errors during the tested commands.
  • One unrelated D3D12 initialization diagnostic (ID 1419) was observed.

Scope

One file changed, 32 lines added.
No benchmark instrumentation or diagnostic code included.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5589999171 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3937). Originally posted by [Tigoniukas](https://github.com/Tigoniukas) on 2026-12-01T16:33:50Z. --- ## Summary Use a single-lane serial path when clamping 2–8 indirect argument records. This avoids group-wide synchronization overhead for small record counts while preserving record order and budget semantics. ## Performance Synthetic D3D12 GPU benchmark (median per call): | Records | Original | Optimized | Reduction | |---|---:|---:|---:| | 2 | 12.8796 us | 5.0587 us | 60.72% | | 4 | 12.8797 us | 6.0416 us | 53.09% | | 8 | 12.8790 us | 8.1194 us | 36.96% | These are GPU operation timings, not game FPS improvements. ## Validation - 7/7 indirect tests passed on the clean branch. - Full workspace tests passed. - Clippy passed with -D warnings. - Real D3D12 ExecuteIndirect validation passed 12/12 scenarios on a combined experimental branch. - GPU-Based Validation reported 0 errors during the tested commands. - One unrelated D3D12 initialization diagnostic (ID 1419) was observed. ## Scope One file changed, 32 lines added. No benchmark instrumentation or diagnostic code included.
cloph-dsp commented 2026-12-01 17:38:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-12-01T17:38:37Z.


Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.

Base 63bcca43c6a00a758510398fa43096ce7e4f7df0, head fe464e5087304901533aa7927e21c87683fd29db. git diff --numstat → crates/victory-gpu/src/indirect.rs 32/0.

The test is new on the base:

git grep -F short_serial_records_preserve_order_and_layouts 63bcca43 -- .

→ no match, exit 1.

git diff --check "63bcca43..fe464e50" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3937'
cargo test --locked -p victory-gpu --lib -- indirect::tests::short_serial_records_preserve_order_and_layouts --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 232 filtered out; finished in 1.10s.

What the test actually pins, since the shader change itself cannot run here: it works through the host-side clamped replica of the short path for all four record kinds and checks (a) a 1<<24 cost clamps to the budget and leaves the remaining records zeroed, (b) four records of cost 7 each fill the budget exactly, (c) 3,1,1 at budget 8 runs all eight records on the leftover, (d) the same at a 10-record list stops at the budget. The one gap worth naming: the if (records > 1 && records <= 8) branch is HLSL, so these assertions cover the host model of that branch and the barrier removal is not exercised by a device here.

No title memory, no device opened; GPU/driver N/A. No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7319621601 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3937#issuecomment-7319621601). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T17:38:37Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, head `fe464e5087304901533aa7927e21c87683fd29db`. `git diff --numstat` → crates/victory-gpu/src/indirect.rs 32/0. The test is new on the base: ``` git grep -F short_serial_records_preserve_order_and_layouts 63bcca43 -- . ``` → no match, exit 1. `git diff --check "63bcca43..fe464e50"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3937' cargo test --locked -p victory-gpu --lib -- indirect::tests::short_serial_records_preserve_order_and_layouts --exact --test-threads=1 --quiet ``` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 232 filtered out; finished in 1.10s`. What the test actually pins, since the shader change itself cannot run here: it works through the host-side `clamped` replica of the short path for all four record kinds and checks (a) a 1<<24 cost clamps to the budget and leaves the remaining records zeroed, (b) four records of cost 7 each fill the budget exactly, (c) 3,1,1 at budget 8 runs all eight records on the leftover, (d) the same at a 10-record list stops at the budget. The one gap worth naming: the `if (records > 1 && records <= 8)` branch is HLSL, so these assertions cover the host model of that branch and the barrier removal is not exercised by a device here. No title memory, no device opened; GPU/driver N/A. No game data.
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/3937:upstream-pr/3937'
git switch 'upstream-pr/3937'

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/3937'
git switch 'upstream-pr/3937'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3937'
git switch 'upstream-pr/3937'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3937'
git switch 'main'
git merge --squash 'upstream-pr/3937'
git switch 'main'
git merge --ff-only 'upstream-pr/3937'
git switch 'main'
git merge 'upstream-pr/3937'
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!3937
No description provided.