gpu(host): pool HostList scratch UAVs and wire ahead::card_if_ready #145

Merged
Androtim merged 1 commit from upstream-pr/145 into main 2026-11-29 16:41:25 +00:00
Androtim commented 2026-11-29 15:32:19 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T15:32:19Z.


Pools HostList device-local scratch UAV buffers and reuses pre-made 64 KiB card buffers:

  • crates/victory-gpu/src/host/uav_pool.rs (UAV_SPARE, VICTORY_UAV_POOL=0 disables):
    • Pools COMMON-state device-local scratch UAVs in power-of-two multiples of 64 KiB (up to 16 MiB) for card_budget, indirect_scratch, batch_place, and place::between.
    • Transitions between buffers back to COMMON on HostList::close, retires buffers at Deferred::clear / Deferred::drop and HostList::drop, and releases them into UAV_SPARE once submissions complete in bury().
    • Respects VICTORY_ALLOCATOR_TRIM idle windows and VRAM/host commit pressure (sweep_uav_spare / trim_uav_spare_pressure) with a 16 MiB warm floor under mild pressure.
  • crates/victory-gpu/src/ahead.rs & crates/victory-gpu/src/host.rs:
    • Adds ahead::card_if_ready() so Host::uav_buffer(64 KiB) reuses pre-made card buffers without spawning victory-ahead during offline tools, while preserving Host::uav_buffer_now (unwaited internal pass semantics) and adding Host::uav_buffer_resident_now.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (305 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu uav_pool:: --locked (3 passed; 0 failed; 1 ignored including live D3D12 lifecycle test)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu ahead:: --locked (3 passed; 0 failed)
  • Dual cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets (--locked and --features diagnostics --locked, -D warnings)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5552221627 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/145). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T15:32:19Z. --- Pools `HostList` device-local scratch UAV buffers and reuses pre-made 64 KiB card buffers: - **`crates/victory-gpu/src/host/uav_pool.rs` (`UAV_SPARE`, `VICTORY_UAV_POOL=0` disables)**: - Pools `COMMON`-state device-local scratch UAVs in power-of-two multiples of 64 KiB (up to 16 MiB) for `card_budget`, `indirect_scratch`, `batch_place`, and `place::between`. - Transitions `between` buffers back to `COMMON` on `HostList::close`, retires buffers at `Deferred::clear` / `Deferred::drop` and `HostList::drop`, and releases them into `UAV_SPARE` once submissions complete in `bury()`. - Respects `VICTORY_ALLOCATOR_TRIM` idle windows and VRAM/host commit pressure (`sweep_uav_spare` / `trim_uav_spare_pressure`) with a 16 MiB warm floor under mild pressure. - **`crates/victory-gpu/src/ahead.rs` & `crates/victory-gpu/src/host.rs`**: - Adds `ahead::card_if_ready()` so `Host::uav_buffer(64 KiB)` reuses pre-made card buffers without spawning `victory-ahead` during offline tools, while preserving `Host::uav_buffer_now` (unwaited internal pass semantics) and adding `Host::uav_buffer_resident_now`. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`305 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu uav_pool:: --locked` (`3 passed; 0 failed; 1 ignored` including live D3D12 lifecycle test) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu ahead:: --locked` (`3 passed; 0 failed`) - Dual `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets` (`--locked` and `--features diagnostics --locked`, `-D warnings`)
Androtim commented 2026-11-29 15:41:54 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T15:41:54Z.


Ran a 75s Series S live GPU smoke test (--release --features diagnostics, -AutoNudgeMenu) via scripts/verify-world.ps1 into D:\victory-data\verify-runs\wave2-uav-pool.

Unit & Policy Update

  • Note on PR description above: cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu ahead:: --locked actually ran and passed 5 tests (5 passed; 0 failed — 3 in ahead::tests + 2 in texture::ahead::tests).

Live 75s Series S GPU Verification

  • Reached 3D world in 42s (world_windows=17, max_draws=10071).
  • Stability & VRAM: crashes=0, no_host_texture_errors=0, untranslated=1, used_max=5657 MB / budget_min=6713 MB (over=0 MB, room_false=7.1%), mapped_rate=4.51 ms/world_sec (14200 calls, 1027.9 ms total, longest 10.4 ms).
  • Visuals (24 PNGs): lit=14/24, luma=105.22, near_black=0.01%, edge_energy=7.31, magenta=0.0%; visually inspected frame-3209.png and frame-3217.png (clean outdoor daylight rendering, water, foliage, HUD, and text).
  • A/B vs baseline-main:
    • Median FPS: 9.5 fps vs 8.9 fps (+0.60, PASS)
    • Max VRAM: 5657 MB vs 5864 MB (-207 MB, PASS)
    • Waiting textures: 1951 vs 7121 (-5170, PASS)
    • Luma / Edge energy: 105.22 / 7.31 vs 103.2 / 7.11 (PASS)
    • Pipeline drops (world_drops_no_pipe_max): 294 vs 261.0 (+33 over older pre-PR #117 baseline threshold — note uav_pool does not touch pipeline creation).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7258294788 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/145#issuecomment-7258294788). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T15:41:54Z. --- Ran a 75s Series S live GPU smoke test (`--release --features diagnostics`, `-AutoNudgeMenu`) via `scripts/verify-world.ps1` into `D:\victory-data\verify-runs\wave2-uav-pool`. ### Unit & Policy Update - Note on PR description above: `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu ahead:: --locked` actually ran and passed **5 tests** (`5 passed; 0 failed` — `3` in `ahead::tests` + `2` in `texture::ahead::tests`). ### Live 75s Series S GPU Verification - **Reached 3D world** in `42s` (`world_windows=17`, `max_draws=10071`). - **Stability & VRAM**: `crashes=0`, `no_host_texture_errors=0`, `untranslated=1`, `used_max=5657 MB` / `budget_min=6713 MB` (`over=0 MB`, `room_false=7.1%`), `mapped_rate=4.51 ms/world_sec` (`14200` calls, `1027.9 ms` total, longest `10.4 ms`). - **Visuals (24 PNGs)**: `lit=14/24`, `luma=105.22`, `near_black=0.01%`, `edge_energy=7.31`, `magenta=0.0%`; visually inspected `frame-3209.png` and `frame-3217.png` (clean outdoor daylight rendering, water, foliage, HUD, and text). - **A/B vs `baseline-main`**: - Median FPS: `9.5 fps` vs `8.9 fps` (`+0.60`, PASS) - Max VRAM: `5657 MB` vs `5864 MB` (`-207 MB`, PASS) - Waiting textures: `1951` vs `7121` (`-5170`, PASS) - Luma / Edge energy: `105.22 / 7.31` vs `103.2 / 7.11` (PASS) - Pipeline drops (`world_drops_no_pipe_max`): `294` vs `261.0` (`+33` over older pre-PR #117 baseline threshold — note `uav_pool` does not touch pipeline creation).
Androtim commented 2026-11-29 16:06:06 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:06:06Z.


Automated triage for the maintainers (not an approval).

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

Review Summary

Logic, D3D12 state transitions, and memory-pressure handling look solid, and CI is passing. Because this PR modifies D3D12 host buffer allocation/recycling, resource barrier lifetimes, and VRAM-pressure trimming, a local real-GPU smoke test is warranted before merging.

Verified Details

  • Resource state & overwrite invariants:
    • HostList::between (crates/victory-gpu/src/host/place.rs) is only called by place_copy and place_source, both of which overwrite [0, len) and leave the buffer in D3D12_RESOURCE_STATE_COPY_SOURCE. HostList::between_common transitions between_uavs back to COMMON on HostList::close before moving them to retired_uavs. If a list is reset or dropped without closing, the unsubmitted buffers remain COMMON and are safely retired via Deferred::clear / Deferred::drop.
    • HostList::make_card_budget, indirect_scratch, and batch_place (crates/victory-gpu/src/host.rs) all overwrite their active ranges before reading and transition back to COMMON on close (card_budget_out, indirect_common, batches_common) or mid-list replacement, matching UAV_SPARE reuse assumptions.
  • ahead integration (crates/victory-gpu/src/ahead.rs, crates/victory-gpu/src/host.rs):
    • ahead::card_if_ready() checks CARD_WANTED without spawning victory-ahead, and ahead::fill() switches to host.uav_buffer_resident_now(SIZE) so the background filler cannot pop its own pre-allocated buffers in a loop.
  • Pool retirement & pressure trimming (crates/victory-gpu/src/host/uav_pool.rs):
    • retire_uavs / drain_retired_uavs (hooked from bury) defer returning buffers to UAV_SPARE until FINISHED >= STARTED + queued, and sweep_uav_spare / trim_uav_spare_pressure trim to the 16 MiB warm floor or 0 under VRAM (88%/95%) or host commit pressure.
    • Note: drain_retired_uavs uses raw finished rather than finished.saturating_sub(bury_lag()), which is reasonable here since these scratch UAVs are private to their owning HostList and not shared across unrelated command lists.

Recommendation

Run the local D3D12 GPU tests (including debug layer validation) and a short gameplay smoke test to verify zero D3D12 barrier/residency warnings and VRAM behavior under load.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7258617811 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/145#issuecomment-7258617811). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T16:06:06Z. --- <!-- minivi-triage v1 head=8cb88cff368483d222763b07acf2fa86ff3791a1 verdict=needs-gpu-test ci=passing at=2026-11-29T16:06:39Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Logic, D3D12 state transitions, and memory-pressure handling look solid, and CI is passing. Because this PR modifies D3D12 host buffer allocation/recycling, resource barrier lifetimes, and VRAM-pressure trimming, a local real-GPU smoke test is warranted before merging. ### Verified Details - **Resource state & overwrite invariants**: - `HostList::between` (`crates/victory-gpu/src/host/place.rs`) is only called by `place_copy` and `place_source`, both of which overwrite `[0, len)` and leave the buffer in `D3D12_RESOURCE_STATE_COPY_SOURCE`. `HostList::between_common` transitions `between_uavs` back to `COMMON` on `HostList::close` before moving them to `retired_uavs`. If a list is reset or dropped without closing, the unsubmitted buffers remain `COMMON` and are safely retired via `Deferred::clear` / `Deferred::drop`. - `HostList::make_card_budget`, `indirect_scratch`, and `batch_place` (`crates/victory-gpu/src/host.rs`) all overwrite their active ranges before reading and transition back to `COMMON` on `close` (`card_budget_out`, `indirect_common`, `batches_common`) or mid-list replacement, matching `UAV_SPARE` reuse assumptions. - **`ahead` integration (`crates/victory-gpu/src/ahead.rs`, `crates/victory-gpu/src/host.rs`)**: - `ahead::card_if_ready()` checks `CARD_WANTED` without spawning `victory-ahead`, and `ahead::fill()` switches to `host.uav_buffer_resident_now(SIZE)` so the background filler cannot pop its own pre-allocated buffers in a loop. - **Pool retirement & pressure trimming (`crates/victory-gpu/src/host/uav_pool.rs`)**: - `retire_uavs` / `drain_retired_uavs` (hooked from `bury`) defer returning buffers to `UAV_SPARE` until `FINISHED >= STARTED + queued`, and `sweep_uav_spare` / `trim_uav_spare_pressure` trim to the 16 MiB warm floor or 0 under VRAM (88%/95%) or host commit pressure. - Note: `drain_retired_uavs` uses raw `finished` rather than `finished.saturating_sub(bury_lag())`, which is reasonable here since these scratch UAVs are private to their owning `HostList` and not shared across unrelated command lists. ### Recommendation Run the local D3D12 GPU tests (including debug layer validation) and a short gameplay smoke test to verify zero D3D12 barrier/residency warnings and VRAM behavior under load. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 16:41:22 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:41:22Z.


Automated RTX 4060 Ti 8 GB hardware verification PASSED (playtest/wave4-no141 vs origin/main 17a2f09 — 5/5 A/B gates PASS):

  • Hardware cargo test (RTX 4060 Ti): victory 39 passed, 0 failed; victory-gpu 552 passed, 0 failed (37 ignored).
  • Automated 45s in-world A/B (scripts/verify-world.ps1, DLSS Quality + golden autosave):
    • FPS: median 11.9 fps (84.15 ms) vs 11.2 fps (88.9 ms) baseline (+0.70 fps, min improved 7.0 vs 4.6, preparing 43.2 ms vs 45.1 ms)
    • Stability: 0 crashes / 0 DRED / 0 untranslated shaders
    • VRAM: max 5641 MB vs 5760 MB (-119 MB, 0 MB over budget)
    • Texture backlog: final_waiting=5924 vs 5753 (PASS)
    • Residency stalls: mapped_rate=8.69 ms/s vs 14.96 ms/s (-42%)
    • Visual check: Clean solid skin and lighting (frame-3923.png, frame-3955.png), luma 66.54, edge energy 2.1, magenta 0.0%.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7259100187 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/145#issuecomment-7259100187). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T16:41:22Z. --- Automated RTX 4060 Ti 8 GB hardware verification **PASSED** (`playtest/wave4-no141` vs `origin/main` `17a2f09` — **5/5 A/B gates PASS**): - **Hardware `cargo test` (RTX 4060 Ti):** `victory` **39 passed, 0 failed**; `victory-gpu` **552 passed, 0 failed** (37 ignored). - **Automated 45s in-world A/B (`scripts/verify-world.ps1`, DLSS Quality + golden autosave):** - **FPS:** median **`11.9 fps`** (`84.15 ms`) vs `11.2 fps` (`88.9 ms`) baseline (**+0.70 fps**, min improved **`7.0`** vs `4.6`, preparing **`43.2 ms`** vs `45.1 ms`) - **Stability:** **0** crashes / **0** DRED / **0** untranslated shaders - **VRAM:** max **`5641 MB`** vs `5760 MB` (**-119 MB**, `0 MB` over budget) - **Texture backlog:** `final_waiting=5924` vs `5753` (PASS) - **Residency stalls:** `mapped_rate=8.69 ms/s` vs `14.96 ms/s` (**-42%**) - **Visual check:** Clean solid skin and lighting (`frame-3923.png`, `frame-3955.png`), luma `66.54`, edge energy `2.1`, magenta `0.0%`.
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!145
No description provided.