perf(gpu): fast-path card_steps planning and groupshared tiled ambient compute #304

Manually merged
github merged 1 commit from github-bot/gh-304 into gh-pr/304/base 2026-12-02 03:52:54 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 03:40 UTC · original
Androtim:perf/card-steps-and-ambient-fast → main · +458 −78 · 2 files · 1 commits · merged 2026-12-02 03:48 UTC

Summary

Speeds up CPU submission planning in card_steps and GPU compute efficiency in ambient:

  • card_steps fast planning path (VICTORY_CARD_STEPS_FAST=0 disables): omits per-frame Step::Refresh expansions from does_of_for (scanning runs on-demand only when a rare Does::Copy occurs) and short-circuits plan_fast for the common fill-only submission path without copies.
  • Groupshared tiled ambient compute & targeted UAV barriers: upgrades mean to a 64-thread parallel reduction ([numthreads(64, 1, 1)]), gather to [numthreads(8, 8, 1)] with groupshared cell/position tiling (20x12 dispatch), precomputes pixel depth/spiral rotation in raise & reflect_light, and replaces internal global NULL UAV barriers with resource-targeted barriers (uav_barrier_for on cells/points).

Refs #276

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: 320 files ok
  • Targeted unit tests (--locked):
    • victory-gpu host::card_steps::tests: 13 passed, 0 failed (1 ignored integration benchmark), including 600-round randomized equivalence test (plan_fast_matches_baseline_plan_on_randomized_steps)
    • victory-gpu ambient::tests: 15 passed, 0 failed (1 ignored timing test), including all 9 compute shaders (KEEP/keep, KEEP/mean, PLACE, GATHER, RAISE, RAISE_OUTLIERS, AIR, REFLECT, BOUND) and live D3D12 PSO creation (the_passes_build)
  • Dual workspace clippy --workspace --all-targets --locked -- -D warnings (default + --features diagnostics): passed
  • Plain --release build (--bin MiniVI --locked) + objdump -p: standard Windows DLLs only

Paired Plain --release 90s A/B Benchmarks (RTX 4060 Ti 8 GB / 32 GB RAM, vs origin/main bee160d)

1440p (-PlayParity -Res 1440, 90s in-world):

Metric origin/main (bee160d) PR Delta
FPS (all / steady median) 10.7 / 11.70 fps 11.0 / 11.70 fps +0.30 fps (93.5 -> 91.25 ms, +284 steady draws)
Preparing (all / steady med) 37.2 / 36.95 ms 34.15 / 34.20 ms -3.05 / -2.75 ms (-8.2%)
Copyback (all / steady med) 12.3 / 13.10 ms 11.35 / 12.00 ms -0.95 / -1.10 ms
async_submit worked med 56.30 ms 54.75 ms -1.55 ms
mapped() stall rate 5.59 ms/s 4.07 ms/s -27.2%
Crashes / DRED / Panics 0 0 clean

4K (-PlayParity -Res 4k, 90s in-world):

Metric origin/main (bee160d) PR Delta
FPS (all / steady median) 5.9 / 5.85 fps 5.9 / 5.90 fps +0.05 fps steady (170.4 -> 170.2 ms)
Preparing median 30.1 ms 28.0 ms -2.1 ms (-7.0%)
async_submit worked med 163.70 ms 157.95 ms -5.75 ms
Crashes / DRED / Panics 0 0 clean

Diagnostics Visual Check (--features diagnostics, 1440p, 90s):

  • All 6 gates PASS (diag exit 0): pngs=24, lit=12/24, luma=99.98, near_black=0.06%, edge_energy=7.95, magenta=0.0%, crashes=0, bakes=16, failed=0, showed_another_view=0.
  • Inspected captured gameplay frames (frame-2316.png, frame-2332.png, frame-2340.png): clean indirect lighting, sky, water, geometry, and textures with zero shader artifacts.
**@⁠Androtim** on GitHub · 2026-12-02 03:40 UTC · [original](https://github.com/Androtim/MiniVI/pull/304) `Androtim:perf/card-steps-and-ambient-fast` → `main` · +458 −78 · 2 files · 1 commits · merged 2026-12-02 03:48 UTC ### Summary Speeds up CPU submission planning in `card_steps` and GPU compute efficiency in `ambient`: - **`card_steps` fast planning path** (`VICTORY_CARD_STEPS_FAST=0` disables): omits per-frame `Step::Refresh` expansions from `does_of_for` (scanning `runs` on-demand only when a rare `Does::Copy` occurs) and short-circuits `plan_fast` for the common fill-only submission path without copies. - **Groupshared tiled `ambient` compute & targeted UAV barriers**: upgrades `mean` to a 64-thread parallel reduction (`[numthreads(64, 1, 1)]`), `gather` to `[numthreads(8, 8, 1)]` with `groupshared` cell/position tiling (`20x12` dispatch), precomputes pixel depth/spiral rotation in `raise` & `reflect_light`, and replaces internal global `NULL` UAV barriers with resource-targeted barriers (`uav_barrier_for` on `cells`/`points`). Refs #276 ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `320 files ok` - Targeted unit tests (`--locked`): - `victory-gpu` `host::card_steps::tests`: `13 passed, 0 failed` (`1 ignored` integration benchmark), including 600-round randomized equivalence test (`plan_fast_matches_baseline_plan_on_randomized_steps`) - `victory-gpu` `ambient::tests`: `15 passed, 0 failed` (`1 ignored` timing test), including all 9 compute shaders (`KEEP/keep`, `KEEP/mean`, `PLACE`, `GATHER`, `RAISE`, `RAISE_OUTLIERS`, `AIR`, `REFLECT`, `BOUND`) and live D3D12 PSO creation (`the_passes_build`) - Dual workspace `clippy --workspace --all-targets --locked -- -D warnings` (default + `--features diagnostics`): passed - Plain `--release` build (`--bin MiniVI --locked`) + `objdump -p`: standard Windows DLLs only ### Paired Plain `--release` 90s A/B Benchmarks (RTX 4060 Ti 8 GB / 32 GB RAM, vs `origin/main` `bee160d`) **1440p (`-PlayParity -Res 1440`, 90s in-world):** | Metric | `origin/main` (`bee160d`) | PR | Delta | |---|---:|---:|---:| | FPS (all / steady median) | `10.7 / 11.70 fps` | `11.0 / 11.70 fps` | `+0.30 fps` (`93.5 -> 91.25 ms`, `+284` steady draws) | | Preparing (all / steady med) | `37.2 / 36.95 ms` | `34.15 / 34.20 ms` | **`-3.05 / -2.75 ms`** (`-8.2%`) | | Copyback (all / steady med) | `12.3 / 13.10 ms` | `11.35 / 12.00 ms` | **`-0.95 / -1.10 ms`** | | `async_submit` worked med | `56.30 ms` | `54.75 ms` | **`-1.55 ms`** | | `mapped()` stall rate | `5.59 ms/s` | `4.07 ms/s` | **`-27.2%`** | | Crashes / DRED / Panics | `0` | `0` | clean | **4K (`-PlayParity -Res 4k`, 90s in-world):** | Metric | `origin/main` (`bee160d`) | PR | Delta | |---|---:|---:|---:| | FPS (all / steady median) | `5.9 / 5.85 fps` | `5.9 / 5.90 fps` | `+0.05 fps` steady (`170.4 -> 170.2 ms`) | | Preparing median | `30.1 ms` | `28.0 ms` | **`-2.1 ms`** (`-7.0%`) | | `async_submit` worked med | `163.70 ms` | `157.95 ms` | **`-5.75 ms`** | | Crashes / DRED / Panics | `0` | `0` | clean | **Diagnostics Visual Check (`--features diagnostics`, 1440p, 90s):** - **All 6 gates PASS** (`diag exit 0`): `pngs=24, lit=12/24, luma=99.98, near_black=0.06%, edge_energy=7.95, magenta=0.0%, crashes=0, bakes=16, failed=0, showed_another_view=0`. - Inspected captured gameplay frames (`frame-2316.png`, `frame-2332.png`, `frame-2340.png`): clean indirect lighting, sky, water, geometry, and textures with zero shader artifacts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 03:42:18 +00:00
github-bot changed target branch from main to gh-pr/304/base 2026-12-02 03:52:51 +00:00
github manually merged commit 8ad0a2189a into gh-pr/304/base 2026-12-02 03:52:54 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 03:48 UTC · original

Audited full diff (8ad0a218, +458 -78 across crates/victory-gpu/src/ambient.rs and crates/victory-gpu/src/host/card_steps.rs), both 90s plain---release A/B pairs (1440p & 4K), and --features diagnostics visual PNGs:

  • Shader & barrier correctness (ambient.rs): Verified all 64 threads uniformly hit both GroupMemoryBarrierWithGroupSync() barriers in gather (20x12 groups covering 160x90, active guards only the points write), CELLS = 2304 is an exact multiple of 64 for mean, uav_barrier_for properly drops ManuallyDrop COM refs after ResourceBarrier, and all 9 compute shaders + live D3D12 PSO creation pass.
  • card_steps.rs & policy: Default-on VICTORY_CARD_STEPS_FAST=0 kill-switch only (zero opt-in toggles), on-demand elsewhere_in scan for rare copies, fill-only fast path, and 600-round x 4-mode randomized equivalence tests passing.
  • Plain --release 90s A/B vs main (bee160d2):
    • 1440p: 10.7 -> 11.0 fps (93.5 -> 91.25 ms), preparing 37.2 -> 34.15 ms (-3.05 ms / -8.2%), copyback 12.3 -> 11.35 ms (-0.95 ms), async_submit -1.55 ms, mapped() -27.2%, over=0 MB, final_waiting PASS (2,324), untranslated 4 -> 4, 0 crashes.
    • 4K: 5.9 -> 5.9 fps (steady 5.85 -> 5.90), preparing 30.1 -> 28.0 ms (-2.1 ms), async_submit -5.75 ms, final_waiting 14,973 -> 13,257 (-1,716), over=0 MB, untranslated 6 -> 6, 0 crashes.
  • Direct --features diagnostics PNG inspection: All 6 gates PASS (diag exit 0); inspected frame-2332.png and frame-2340.png directly — spotless outdoor/water indirect lighting, luma=99.98, near_black=0.06%, edge_energy=7.95, magenta=0.0%, showed_another_view=0.
  • Disjoint from #300/#302, CI green (46804272497). Merging now.
**@⁠Androtim** on GitHub · 2026-12-02 03:48 UTC · [original](https://github.com/Androtim/MiniVI/pull/304#issuecomment-7334264267) Audited full diff (`8ad0a218`, `+458 -78` across `crates/victory-gpu/src/ambient.rs` and `crates/victory-gpu/src/host/card_steps.rs`), both 90s plain-`--release` A/B pairs (1440p & 4K), and `--features diagnostics` visual PNGs: - **Shader & barrier correctness (`ambient.rs`):** Verified all 64 threads uniformly hit both `GroupMemoryBarrierWithGroupSync()` barriers in `gather` (`20x12` groups covering `160x90`, `active` guards only the `points` write), `CELLS = 2304` is an exact multiple of 64 for `mean`, `uav_barrier_for` properly drops `ManuallyDrop` COM refs after `ResourceBarrier`, and all 9 compute shaders + live D3D12 PSO creation pass. - **`card_steps.rs` & policy:** Default-on `VICTORY_CARD_STEPS_FAST=0` kill-switch only (zero opt-in toggles), on-demand `elsewhere_in` scan for rare copies, fill-only fast path, and 600-round x 4-mode randomized equivalence tests passing. - **Plain `--release` 90s A/B vs `main` (`bee160d2`):** - **1440p:** `10.7 -> 11.0 fps` (`93.5 -> 91.25 ms`), **`preparing 37.2 -> 34.15 ms` (`-3.05 ms` / `-8.2%`)**, **`copyback 12.3 -> 11.35 ms` (`-0.95 ms`)**, `async_submit -1.55 ms`, `mapped() -27.2%`, `over=0 MB`, `final_waiting` PASS (`2,324`), `untranslated 4 -> 4`, `0` crashes. - **4K:** `5.9 -> 5.9 fps` (steady `5.85 -> 5.90`), **`preparing 30.1 -> 28.0 ms` (`-2.1 ms`)**, `async_submit -5.75 ms`, **`final_waiting 14,973 -> 13,257` (`-1,716`)**, `over=0 MB`, `untranslated 6 -> 6`, `0` crashes. - **Direct `--features diagnostics` PNG inspection:** **All 6 gates PASS (`diag exit 0`)**; inspected `frame-2332.png` and `frame-2340.png` directly — spotless outdoor/water indirect lighting, `luma=99.98`, `near_black=0.06%`, `edge_energy=7.95`, `magenta=0.0%`, `showed_another_view=0`. - Disjoint from `#300`/`#302`, CI green (`46804272497`). Merging now.
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/Androtim--MiniVI!304
No description provided.