victory-gpu: fast-path refresh flushes and pending checks #22

Merged
Androtim merged 1 commit from upstream-pr/22 into main 2026-11-28 21:17:33 +00:00
Androtim commented 2026-11-28 06:55:01 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T06:55:01Z.


Summary

Reduce submitting-thread per-frame refresh flush overhead across crates/victory-gpu/src/watch.rs, crates/victory-gpu/src/shadow.rs, and crates/victory-gpu/src/host.rs:

  • Expose watch::journal_kept() and check journal().kept at the very top of ask_ahead() before filtering ranges, checking published(), allocating pieces, or sorting.
  • Skip building ranges and calling ask_ahead / ask_ahead_done in host.rs whenever watch::journal_kept() is true.
  • Add lock-free Shadow::has_pending (AtomicBool, maintained under Shadow::pending in writing and copy_back_done) so writes_pending, writes_pending_in, and nothing_new bypass locking pending on buffers with no in-flight GPU writes, plus unit test shadow::window_tests::has_pending_tracks_writing_and_copy_back_done_without_dropping_checks.
  • Chunk wide_each buffer refresh loops in host.rs into 32-item slices via Host::refresh_span_chunk with chunk-local skipped accumulation before a single FLUSHES[2] update, while keeping due-texture refreshes 1-per-item.

Rig Specs Tested On

  • CPU: 13th Gen Intel(R) Core(TM) i7-13700F
  • GPU & VRAM: NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM)
  • System RAM: 32 GiB
  • OS & GPU Driver: Windows 11 Home (Build 26300) / NVIDIA Driver 32.0.16.2124

Run Settings & Profile

  • Build & Commit SHA: release & --release --features victory-gpu/diagnostics @ c3ef1583614a330da73e130da4e697b928e785d2 (0 non-system MinGW DLLs each)
  • Console Profile & Internal Resolution / Scale: series-s
  • Ray Tracing: off
  • Upscaling: DLSS quality
  • Frame Generation: off
  • Launcher Command / Preset & Extra VICTORY_* Overrides: D:\victory-build\verify-tools\verify-world.ps1 with pr22-diag.exe, -GoldenDataDir 'D:\victory-data\golden-data-minivi', -WorldSeconds 75, -AutoNudgeMenu
  • Scene / Area & Session Length: Mission-1 golden autosave (dock -> balcony), 75s in-world telemetry (14 world windows, max 11,361 draws/frame)

Measurements & Verification

  • Base FPS (without Frame Gen): Median preparing dropped to 58.7 ms (vs pr21-readback-pool 64.4 ms and pr19-typed-uav 60.35 ms); steady-state balcony ran 7.3–10.1 fps with 50.8–55.7 ms preparing and refreshes ~18.1–21.4 ms (vs pr21 22.3 ms). Raw 14-window median landed on 2.95 fps because 8 windows captured dock PSO warmup (2.4–2.9 fps) vs 6 balcony windows; final_waiting=4,381 (vs 7,121 baseline). Visuals PASS: lit=8/24, luma=104.8, edge_energy=6.98, magenta=0.0% (inspected frame-8024.png & frame-9120.png).
  • Frame-Gen FPS (if enabled): off
  • VRAM / RAM Usage: card accounting logged 0 samples (sweep threshold not hit), while copystat last reported: 2026-11-28T06:52:45.852623Z  INFO victory_gpu::copystat: memory of textures: 7878 title textures have no host copy yet (7158 MB of title memory); host copies the host renders to or writes: 642 alive 1120 MB; host copies the title fills: 31606 alive 3084 MB (31551 of them placed), 4914 let go 437 MB and 45 made again 4 MB since the start; 38410 host copies made in all; passes that made none for lack of room: 0; the card: 6038 MB in use of a budget of 6981 MB, 5678 MB of the PC's memory shared with it in use
  • Crashes / DRED Resets: 0 (crashes=0, no_host_texture_errors=0)
  • Automated Checks:
    • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (294 files ok)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask (6 passed; 0 failed)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu (449 passed; 0 failed; 36 ignored, including has_pending_tracks_writing_and_copy_back_done_without_dropping_checks, refresh_tests, and wide_refresh_tests)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5537639182 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/22). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:55:01Z. --- ## Summary Reduce submitting-thread per-frame refresh flush overhead across [`crates/victory-gpu/src/watch.rs`](https://github.com/Androtim/MiniVI/blob/c3ef1583614a330da73e130da4e697b928e785d2/crates/victory-gpu/src/watch.rs), [`crates/victory-gpu/src/shadow.rs`](https://github.com/Androtim/MiniVI/blob/c3ef1583614a330da73e130da4e697b928e785d2/crates/victory-gpu/src/shadow.rs), and [`crates/victory-gpu/src/host.rs`](https://github.com/Androtim/MiniVI/blob/c3ef1583614a330da73e130da4e697b928e785d2/crates/victory-gpu/src/host.rs): - Expose `watch::journal_kept()` and check `journal().kept` at the very top of `ask_ahead()` before filtering ranges, checking `published()`, allocating `pieces`, or sorting. - Skip building `ranges` and calling `ask_ahead` / `ask_ahead_done` in `host.rs` whenever `watch::journal_kept()` is true. - Add lock-free `Shadow::has_pending` (`AtomicBool`, maintained under `Shadow::pending` in `writing` and `copy_back_done`) so `writes_pending`, `writes_pending_in`, and `nothing_new` bypass locking `pending` on buffers with no in-flight GPU writes, plus unit test `shadow::window_tests::has_pending_tracks_writing_and_copy_back_done_without_dropping_checks`. - Chunk `wide_each` buffer refresh loops in `host.rs` into 32-item slices via `Host::refresh_span_chunk` with chunk-local `skipped` accumulation before a single `FLUSHES[2]` update, while keeping due-texture refreshes 1-per-item. ## Rig Specs Tested On - **CPU:** `13th Gen Intel(R) Core(TM) i7-13700F` - **GPU & VRAM:** `NVIDIA GeForce RTX 4060 Ti` (`8 GiB` VRAM) - **System RAM:** `32 GiB` - **OS & GPU Driver:** `Windows 11 Home (Build 26300)` / NVIDIA Driver `32.0.16.2124` ## Run Settings & Profile - **Build & Commit SHA:** `release` & `--release --features victory-gpu/diagnostics` @ `c3ef1583614a330da73e130da4e697b928e785d2` (`0` non-system MinGW DLLs each) - **Console Profile & Internal Resolution / Scale:** `series-s` - **Ray Tracing:** `off` - **Upscaling:** `DLSS quality` - **Frame Generation:** `off` - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** `D:\victory-build\verify-tools\verify-world.ps1` with `pr22-diag.exe`, `-GoldenDataDir 'D:\victory-data\golden-data-minivi'`, `-WorldSeconds 75`, `-AutoNudgeMenu` - **Scene / Area & Session Length:** Mission-1 golden autosave (`dock` -> `balcony`), 75s in-world telemetry (`14` world windows, max `11,361` draws/frame) ## Measurements & Verification - **Base FPS (without Frame Gen):** Median `preparing` dropped to `58.7 ms` (vs `pr21-readback-pool` `64.4 ms` and `pr19-typed-uav` `60.35 ms`); steady-state balcony ran `7.3–10.1 fps` with `50.8–55.7 ms` preparing and `refreshes` ~`18.1–21.4 ms` (vs `pr21` `22.3 ms`). Raw 14-window median landed on `2.95 fps` because 8 windows captured dock PSO warmup (`2.4–2.9 fps`) vs 6 balcony windows; `final_waiting=4,381` (vs `7,121` baseline). Visuals `PASS`: `lit=8/24`, `luma=104.8`, `edge_energy=6.98`, `magenta=0.0%` (inspected `frame-8024.png` & `frame-9120.png`). - **Frame-Gen FPS (if enabled):** `off` - **VRAM / RAM Usage:** `card accounting` logged 0 samples (sweep threshold not hit), while `copystat` last reported: `2026-11-28T06:52:45.852623Z  INFO victory_gpu::copystat: memory of textures: 7878 title textures have no host copy yet (7158 MB of title memory); host copies the host renders to or writes: 642 alive 1120 MB; host copies the title fills: 31606 alive 3084 MB (31551 of them placed), 4914 let go 437 MB and 45 made again 4 MB since the start; 38410 host copies made in all; passes that made none for lack of room: 0; the card: 6038 MB in use of a budget of 6981 MB, 5678 MB of the PC's memory shared with it in use` - **Crashes / DRED Resets:** `0` (`crashes=0`, `no_host_texture_errors=0`) - **Automated Checks:** - [x] `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`294 files ok`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask` (`6 passed; 0 failed`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` (`0` warnings) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings` (`0` warnings) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu` (`449 passed; 0 failed; 36 ignored`, including `has_pending_tracks_writing_and_copy_back_done_without_dropping_checks`, `refresh_tests`, and `wide_refresh_tests`)
Androtim commented 2026-11-28 07:03:18 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T07:03:18Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Logic and concurrency look solid across all three files, and CI is passing. Because this modifies the D3D12 host submission/refresh hot path and write-watch/pending-write synchronization, a local real-GPU smoke test is recommended before merging.

Verified Changes

  • crates/victory-gpu/src/watch.rs:
    • Exposes journal_kept() (journal().kept) and hoists the if journal().kept { return; } guard to the top of ask_ahead(), avoiding unnecessary filtering, published() checks, Vec allocation, and sorting when the submission's single asking already stands. Behavior is strictly equivalent since the original early return had no preceding side effects.
  • crates/victory-gpu/src/host.rs:
    • Guards ahead with !crate::watch::journal_kept() in Batch::refresh_front and Batch::flush_all, skipping ranges construction and ask_ahead/ask_ahead_done calls when the kept journal is active.
    • Chunks wide_each buffer refresh dispatch into 32-item slices via Batch::refresh_span_chunk (with chunk-local skipped aggregation into a single FLUSHES[2] atomic update) while keeping due texture refreshes 1-per-item. Slice bounds (div_ceil(32), (start + CHUNK).min(len)) handle 0, partial, and exact-multiple lengths cleanly.
  • crates/victory-gpu/src/shadow.rs:
    • Adds Shadow::has_pending: AtomicBool initialized to false in Shadow::new, updated with Ordering::Release while holding self.pending in both Shadow::writing (card and non-card paths) and Shadow::copy_back_done.
    • Fast-paths Shadow::writes_pending, Shadow::writes_pending_in, and Shadow::nothing_new with has_pending.load(Ordering::Acquire) before locking self.pending. Since all pending mutations and has_pending stores occur under self.pending's mutex, the fast path cannot miss a previously published pending write or race with copy_back_done.
    • Adds unit test window_tests::has_pending_tracks_writing_and_copy_back_done_without_dropping_checks covering the full writing -> writes_pending*/nothing_new -> copy_back_done lifecycle.

Note: This is an independent technical review, not formal maintainer approval.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235685416 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/22#issuecomment-7235685416). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T07:03:18Z. --- <!-- minivi-triage v1 head=c3ef1583614a330da73e130da4e697b928e785d2 verdict=needs-gpu-test ci=passing at=2026-11-28T07:03:45Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Logic and concurrency look solid across all three files, and CI is passing. Because this modifies the D3D12 host submission/refresh hot path and write-watch/pending-write synchronization, a local real-GPU smoke test is recommended before merging. #### Verified Changes - **`crates/victory-gpu/src/watch.rs`**: - Exposes `journal_kept()` (`journal().kept`) and hoists the `if journal().kept { return; }` guard to the top of `ask_ahead()`, avoiding unnecessary filtering, `published()` checks, `Vec` allocation, and sorting when the submission's single asking already stands. Behavior is strictly equivalent since the original early return had no preceding side effects. - **`crates/victory-gpu/src/host.rs`**: - Guards `ahead` with `!crate::watch::journal_kept()` in `Batch::refresh_front` and `Batch::flush_all`, skipping `ranges` construction and `ask_ahead`/`ask_ahead_done` calls when the kept journal is active. - Chunks `wide_each` buffer refresh dispatch into 32-item slices via `Batch::refresh_span_chunk` (with chunk-local `skipped` aggregation into a single `FLUSHES[2]` atomic update) while keeping `due` texture refreshes 1-per-item. Slice bounds (`div_ceil(32)`, `(start + CHUNK).min(len)`) handle `0`, partial, and exact-multiple lengths cleanly. - **`crates/victory-gpu/src/shadow.rs`**: - Adds `Shadow::has_pending: AtomicBool` initialized to `false` in `Shadow::new`, updated with `Ordering::Release` while holding `self.pending` in both `Shadow::writing` (card and non-card paths) and `Shadow::copy_back_done`. - Fast-paths `Shadow::writes_pending`, `Shadow::writes_pending_in`, and `Shadow::nothing_new` with `has_pending.load(Ordering::Acquire)` before locking `self.pending`. Since all `pending` mutations and `has_pending` stores occur under `self.pending`'s mutex, the fast path cannot miss a previously published pending write or race with `copy_back_done`. - Adds unit test `window_tests::has_pending_tracks_writing_and_copy_back_done_without_dropping_checks` covering the full `writing` -> `writes_pending*`/`nothing_new` -> `copy_back_done` lifecycle. *Note: This is an independent technical review, not formal maintainer approval.* --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-28 21:11:12 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T21:11:12Z.


Real-GPU Playtest Report (Combined Build 1 Stack — RT OFF)

Tested in combined Build 1 (origin/main + Build 1 PRs #2, #3, #4, #6, #7, #9, #10, #11, #12, #14, #15, #18, #19, #22, #25, #26, #27, #33, #34, #36, #40, #43, #44, #46) on NVIDIA GeForce RTX 4060 Ti (8 GB), Windows, Series S (quality-720p, DLSS Quality):

  • Duration & Stability: 21-minute open-world session (1a-build1-world.log) — 0 crashes, 0 DRED resets, clean exit.
  • Performance: 28.2 fps (35.4 ms/frame) mid-run, 16.9 fps (59.3 ms/frame, 4,446 draws/frame) in heavy scene.
  • Key Subsystems Verified in Logs:
    • Swap chain / tearing: tearing=true, 0 refused presents.
    • Underwater compute (926c46bab3b86bd6): Translated and built host PSO cleanly.
    • Descriptor slots (VICTORY_THIN_GATE): Active (0 no free dynamic descriptor slots warnings).
    • VRAM & texture pool: Bounded at 6,934 MB in use (33 texture blocks = 2,112 MB, 1,036 MB free), 0 bogus POOL: errors.
    • DLSS: 16,577 upscalings (0 failed).
  • Visual observation during heavy initial streaming: Character top briefly appeared solid black while 8,802 textures were still queued / 206 non-RT draws dropped without a host pipeline; no D3D12 errors.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7245834326 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/22#issuecomment-7245834326). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T21:11:12Z. --- ### Real-GPU Playtest Report (Combined Build 1 Stack — RT OFF) Tested in combined Build 1 (`origin/main` + Build 1 PRs `#2, #3, #4, #6, #7, #9, #10, #11, #12, #14, #15, #18, #19, #22, #25, #26, #27, #33, #34, #36, #40, #43, #44, #46`) on **NVIDIA GeForce RTX 4060 Ti (8 GB), Windows, Series S (`quality-720p`, DLSS Quality)**: - **Duration & Stability:** **21-minute** open-world session (`1a-build1-world.log`) — **0 crashes, 0 DRED resets**, clean exit. - **Performance:** `28.2 fps` (`35.4 ms/frame`) mid-run, `16.9 fps` (`59.3 ms/frame`, `4,446` draws/frame) in heavy scene. - **Key Subsystems Verified in Logs:** - **Swap chain / tearing:** `tearing=true`, `0` refused presents. - **Underwater compute (`926c46bab3b86bd6`):** Translated and built host PSO cleanly. - **Descriptor slots (`VICTORY_THIN_GATE`):** Active (`0` `no free dynamic descriptor slots` warnings). - **VRAM & texture pool:** Bounded at `6,934 MB` in use (`33` texture blocks = `2,112 MB`, `1,036 MB` free), `0` bogus `POOL:` errors. - **DLSS:** `16,577` upscalings (`0` failed). - **Visual observation during heavy initial streaming:** Character top briefly appeared solid black while `8,802` textures were still queued / `206` non-RT draws dropped without a host pipeline; no D3D12 errors.
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
Androtim/MiniVI!22
No description provided.