gpu: compact empty indirect records in device-local clamp #998

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

@⁠UnkwnDev on GitHub · 2026-11-25 15:31 UTC · original
UnkwnDev:arc-indirect-compaction-vf → main · +1577 −417 · 2 files · 1 commits · open

Summary

Rebased onto 0b0074e, preserving MOST_DRAW (1 << 23) filtering, groupshared single-atomic budget charging and mesh diagnostics, persistent INDIRECT_ARGUMENT scratch state across draws (no done() barrier), and window_check / drvwatch::tripped() in draw.rs.

For non-windowed multi-record ExecuteIndirect calls (records > 1), empty/zero-cost and budget-zeroed records are compacted out on the GPU inside the device-local scratch buffer in exact submission order, writing the compacted command count into the scratch buffer so ExecuteIndirect skips zero-work slots instead of wasting command-processor overhead on thousands of empty records.

Changes

  • crates/victory-gpu/src/indirect.rs:
    • Added Bounded { buffer, count } returned by bound() when multi-record compaction (records > 1) writes a compacted count offset inside the scratch buffer.
    • Added compact_single (<= 256 records) and multi-tile hierarchical groupshared prefix scan passes (compact_pass1, scan_tiles, add_offsets, compact_scatter) with no cross-workgroup spin loops.
    • Unified groupshared single-atomic budget charging and mesh diagnostics (charge_group) across main, compact_single, and compact_pass1, preserving MOST_DRAW and ahead handling.
    • Kept bound_ahead() uncompacted (in_slot) so cached Window draws continue indexing Window::scratch directly, and kept make_from() single-entry compatible with CHECK_SOURCE and bench::OLD_SOURCE.
    • Kept scratch state tracking (indirect_state / indirect_readable) without done().
    • Added WARP and host D3D12 debug-layer tests covering single-tile, 1-level, and 2-level (> 65,536 records) compaction, count = 0 / all-empty batches, budget exhaustion, MOST_DRAW, and bound_ahead vs bound.
  • crates/victory-gpu/src/draw.rs:
    • Updated indirect execution to pass Some(&bounded) and compacted_count to ExecuteIndirect when bound() compacts, while keeping bound_ahead() uncompacted for cached windows.

Verification

  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib indirect -- --test-threads=1: 18 passed, 0 failed, 2 ignored (bare_cost, bench).
  • cargo test -p victory-gpu --lib -- --test-threads=1: 175 passed, 0 failed, 5 ignored.
  • cargo test -p xtask --locked: 4 passed, 0 failed.
  • cargo clippy --workspace --all-targets --all-features --locked: 0 warnings in modified code (3 pre-existing warnings in draw.rs:2406, shadow.rs:2675, and indirect.rs:3297 from 0b0074e).

AI-assisted implementation and testing.

**@⁠UnkwnDev** on GitHub · 2026-11-25 15:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/998) `UnkwnDev:arc-indirect-compaction-vf` → `main` · +1577 −417 · 2 files · 1 commits · open ## Summary Rebased onto `0b0074e`, preserving `MOST_DRAW` (`1 << 23`) filtering, `groupshared` single-atomic budget charging and mesh diagnostics, persistent `INDIRECT_ARGUMENT` scratch state across draws (no `done()` barrier), and `window_check` / `drvwatch::tripped()` in `draw.rs`. For non-windowed multi-record `ExecuteIndirect` calls (`records > 1`), empty/zero-cost and budget-zeroed records are compacted out on the GPU inside the device-local scratch buffer in exact submission order, writing the compacted command count into the scratch buffer so `ExecuteIndirect` skips zero-work slots instead of wasting command-processor overhead on thousands of empty records. ## Changes - `crates/victory-gpu/src/indirect.rs`: - Added `Bounded { buffer, count }` returned by `bound()` when multi-record compaction (`records > 1`) writes a compacted count offset inside the scratch buffer. - Added `compact_single` (<= 256 records) and multi-tile hierarchical `groupshared` prefix scan passes (`compact_pass1`, `scan_tiles`, `add_offsets`, `compact_scatter`) with no cross-workgroup spin loops. - Unified `groupshared` single-atomic budget charging and mesh diagnostics (`charge_group`) across `main`, `compact_single`, and `compact_pass1`, preserving `MOST_DRAW` and `ahead` handling. - Kept `bound_ahead()` uncompacted (`in_slot`) so cached `Window` draws continue indexing `Window::scratch` directly, and kept `make_from()` single-entry compatible with `CHECK_SOURCE` and `bench::OLD_SOURCE`. - Kept scratch state tracking (`indirect_state` / `indirect_readable`) without `done()`. - Added WARP and host D3D12 debug-layer tests covering single-tile, 1-level, and 2-level (> 65,536 records) compaction, `count = 0` / all-empty batches, budget exhaustion, `MOST_DRAW`, and `bound_ahead` vs `bound`. - `crates/victory-gpu/src/draw.rs`: - Updated indirect execution to pass `Some(&bounded)` and `compacted_count` to `ExecuteIndirect` when `bound()` compacts, while keeping `bound_ahead()` uncompacted for cached windows. ## Verification - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib indirect -- --test-threads=1`: 18 passed, 0 failed, 2 ignored (`bare_cost`, `bench`). - `cargo test -p victory-gpu --lib -- --test-threads=1`: 175 passed, 0 failed, 5 ignored. - `cargo test -p xtask --locked`: 4 passed, 0 failed. - `cargo clippy --workspace --all-targets --all-features --locked`: 0 warnings in modified code (3 pre-existing warnings in `draw.rs:2406`, `shadow.rs:2675`, and `indirect.rs:3297` from `0b0074e`). AI-assisted implementation and testing.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:29 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-25 16:59 UTC · original

Tested on RX 7900 XT (CachyOS Linux, Wine 11.22 + vkd3d-proton + RADV) stacked with #997 across multiple 480–540 s gameplay runs (to frame 4600, VICTORY_RELAY=2 + VICTORY_INDIRECT_WINDOW=1). No visual glitches, 0 device removals, and GPU time for all title lists is down around ~48 ms/frame.

**@⁠UwUCammie** on GitHub · 2026-11-25 16:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/998#issuecomment-7168838738) Tested on RX 7900 XT (CachyOS Linux, Wine 11.22 + vkd3d-proton + RADV) stacked with #997 across multiple 480–540 s gameplay runs (to frame 4600, `VICTORY_RELAY=2` + `VICTORY_INDIRECT_WINDOW=1`). No visual glitches, 0 device removals, and GPU time for all title lists is down around ~48 ms/frame.
Author
Owner

@⁠UnkwnDev on GitHub · 2026-11-25 17:17 UTC · original

@⁠UwUCammie Thanks for the extended multi-pass verification with the stacked compaction and coalescing branches on RADV/Wine. Great to see the combination running cleanly with 0 device removals.

**@⁠UnkwnDev** on GitHub · 2026-11-25 17:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/998#issuecomment-7169281205) @⁠UwUCammie Thanks for the extended multi-pass verification with the stacked compaction and coalescing branches on RADV/Wine. Great to see the combination running cleanly with 0 device removals.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/indirect.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/998/head:github-bot/gh-998'
git switch 'github-bot/gh-998'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-998'
git switch 'github-bot/gh-998'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-998'
git switch 'github-bot/gh-998'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-998'
git switch 'main'
git merge --squash 'github-bot/gh-998'
git switch 'main'
git merge --ff-only 'github-bot/gh-998'
git switch 'main'
git merge 'github-bot/gh-998'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.