victory-gpu: pool HostList::upload buffers across command list resets #14

Merged
Androtim merged 1 commit from upstream-pr/14 into main 2026-11-28 18:44:13 +00:00
Androtim commented 2026-11-28 05:07:12 +00:00 (Migrated from github.com)

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


## Summary
Pools mapped upload buffers allocated by HostList::upload across command list resets (separately for shared = false and shared = true card_steps buffers) instead of creating and destroying a fresh D3D12 committed buffer per copy:

  • Adds power-of-two size class bucketing (64 KiB..16 MiB) with a 64 MiB idle cap per kind (16 MiB under host RAM pressure) in crates/victory-gpu/src/host.rs.
  • Holds list upload buffers in Deferred::list_uploads until the list resets/drops (after its GPU fence has completed), then returns them via give_list_uploads; buffers outside 64 KiB..16 MiB allocate exact size and drop unpooled.
  • Drains idle list upload pools in trim_spare_chunks() alongside scratch chunks, and keeps HostList::untouched() accurate.
  • Adds unit tests host::list_upload_pool_tests verifying size-class bucketing, real D3D12 HostList::upload -> close -> reset handle reuse across both shared/non-shared pools, oversized bypass, and trim_spare_chunks() cleanup.

Rig Specs Tested On

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

Run Settings & Profile

  • Build & Commit SHA: diag @ 2a7608c (victory --release --features diagnostics)
  • Console Profile & Internal Resolution / Scale: series-s (0.6666667 internal scale)
  • Ray Tracing: off
  • Upscaling: DLSS quality (VICTORY_DLSS=1 VICTORY_DLSS_MODE=quality)
  • Frame Generation: off
  • Launcher Command / Preset & Extra VICTORY_* Overrides: play.rs SETTINGS defaults (VICTORY_LEVELS_ON_DEMAND=0, VICTORY_CARD_STEPS=2, VICTORY_TEXTURE_POOL=1, VICTORY_PRELUDE_UPLOADS=1, VICTORY_CARD_ACCOUNTING=1, VICTORY_D3D12_DRED=light)
  • Scene / Area & Session Length: Mission-1 golden save (dock -> balcony open world, 11,489 max draws/frame, 75s in-world window across 14 telemetry windows)

Measurements & Verification

  • Base FPS (without Frame Gen): 10.65 fps median (93.7 ms/frame, peaking at 11.9 fps / 83.7 ms on balcony) vs baseline-main 8.9 fps median (+1.75 fps)
  • Frame-Gen FPS (if enabled): N/A (off)
  • VRAM / RAM Usage: 5,812 MB max VRAM / 6,945 MB min budget (over = 0 MB, room_false = 16.7% vs baseline-main 5,864 MB / 33.3%); 19,394 MB private commit
  • Texture Queue: 42,657 uploaded (2,058 MB), final waiting drained to 1,546 (vs baseline-main 7,121, -5,575)
  • Visual Check (24 sampled PNGs, 18 lit): median luma = 104.61, near_black = 0.0%, edge_energy = 6.97, magenta = 0.0%
  • Crashes / DRED Resets: 0 crashes, 0 no host texture errors
  • Note on Remaining Upload Buffers / Stalls: mapped() ran ~23 ms/s up to 05:06:37 until a single Windows/DXGI residency paging spike (717.1 ms max -> 91.19 ms/s overall); made so far: 5,383 upload buffers also still reflects direct host.upload_buffer() callers outside HostList::upload (to be addressed separately).
  • 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)
    • 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 diagnostics -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu (450 passed; 0 failed; 36 ignored)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5536902314 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/14). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T05:07:12Z. --- ## Summary Pools mapped upload buffers allocated by `HostList::upload` across command list resets (separately for `shared = false` and `shared = true` `card_steps` buffers) instead of creating and destroying a fresh D3D12 committed buffer per copy: - Adds power-of-two size class bucketing (64 KiB..16 MiB) with a 64 MiB idle cap per kind (16 MiB under host RAM pressure) in `crates/victory-gpu/src/host.rs`. - Holds list upload buffers in `Deferred::list_uploads` until the list resets/drops (after its GPU fence has completed), then returns them via `give_list_uploads`; buffers outside 64 KiB..16 MiB allocate exact size and drop unpooled. - Drains idle list upload pools in `trim_spare_chunks()` alongside scratch chunks, and keeps `HostList::untouched()` accurate. - Adds unit tests `host::list_upload_pool_tests` verifying size-class bucketing, real D3D12 `HostList::upload` -> `close` -> `reset` handle reuse across both `shared`/non-shared pools, oversized bypass, and `trim_spare_chunks()` cleanup. ## Rig Specs Tested On - **CPU:** 13th Gen Intel(R) Core(TM) i7-13700F - **GPU & VRAM:** NVIDIA GeForce RTX 4060 Ti (Driver 32.0.16.2124) (8 GiB VRAM) - **System RAM:** 32 GiB - **OS & GPU Driver:** Microsoft Windows 11 Home (Build 26300) (Streamline 2.14.16 / NGX 310.9.16 reported `driver 621.24.0`) ## Run Settings & Profile - **Build & Commit SHA:** `diag` @ `2a7608c` (`victory --release --features diagnostics`) - **Console Profile & Internal Resolution / Scale:** `series-s` (`0.6666667` internal scale) - **Ray Tracing:** `off` - **Upscaling:** `DLSS quality` (`VICTORY_DLSS=1 VICTORY_DLSS_MODE=quality`) - **Frame Generation:** `off` - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** `play.rs` `SETTINGS` defaults (`VICTORY_LEVELS_ON_DEMAND=0`, `VICTORY_CARD_STEPS=2`, `VICTORY_TEXTURE_POOL=1`, `VICTORY_PRELUDE_UPLOADS=1`, `VICTORY_CARD_ACCOUNTING=1`, `VICTORY_D3D12_DRED=light`) - **Scene / Area & Session Length:** Mission-1 golden save (dock -> balcony open world, 11,489 max draws/frame, 75s in-world window across 14 telemetry windows) ## Measurements & Verification - **Base FPS (without Frame Gen):** `10.65 fps` median (`93.7 ms/frame`, peaking at `11.9 fps` / `83.7 ms` on balcony) vs `baseline-main` `8.9 fps` median (`+1.75 fps`) - **Frame-Gen FPS (if enabled):** N/A (off) - **VRAM / RAM Usage:** `5,812 MB` max VRAM / `6,945 MB` min budget (`over = 0 MB`, `room_false = 16.7%` vs `baseline-main` `5,864 MB` / `33.3%`); `19,394 MB` private commit - **Texture Queue:** `42,657` uploaded (`2,058 MB`), final waiting drained to `1,546` (vs `baseline-main` `7,121`, `-5,575`) - **Visual Check (24 sampled PNGs, 18 lit):** `median luma = 104.61`, `near_black = 0.0%`, `edge_energy = 6.97`, `magenta = 0.0%` - **Crashes / DRED Resets:** `0` crashes, `0` `no host texture` errors - **Note on Remaining Upload Buffers / Stalls:** `mapped()` ran ~`23 ms/s` up to `05:06:37` until a single Windows/DXGI residency paging spike (`717.1 ms` max -> `91.19 ms/s` overall); `made so far: 5,383 upload buffers` also still reflects direct `host.upload_buffer()` callers outside `HostList::upload` (to be addressed separately). - **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`) - [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 diagnostics -- -D warnings` (0 warnings) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu` (`450 passed; 0 failed; 36 ignored`)
Androtim commented 2026-11-28 06:04:31 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers (not an approval).

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

Review Summary

This PR pools mapped upload buffers allocated by HostList::upload in crates/victory-gpu/src/host.rs across command list resets, separated into two Spare<Chunk> pools (SPARE_LIST_UPLOAD and SPARE_LIST_SHARED_UPLOAD) for shared = false and shared = true (card_steps::stage() > 1).

What looks solid

  • Lifetime & exclusivity: Pooled buffers are held in Deferred::list_uploads and returned via give_list_uploads only when Deferred drops (on HostList::reset or list drop after GPU completion), matching the existing plane_uploads / give_chunks lifetime model.
  • Size-class bucketing & OOM fallback: list_upload_class safely rounds sizes in 64 KiB..=16 MiB (LIST_UPLOAD_MIN..=LIST_UPLOAD_MAX) using checked_next_power_of_two(), and take_list_upload falls back to exact-size allocation if the rounded-up allocation fails (with give_list_uploads dropping non-power-of-two or out-of-range buffers outside the mutex lock).
  • Memory pressure & accounting: Idle pools are capped at LIST_UPLOAD_SPARE_MOST (64 MiB per kind, 16 MiB under residency::limited_host_ram()), respect scratch_pool(), and are drained in trim_spare_chunks() even when SPARE is empty. Deferred::hold_list_upload / Drop keep ALIVE[6]/ALIVE[7] balanced, and HostList::untouched() checks deferred.list_uploads.is_empty().
  • Tests: host::list_upload_pool_tests covers size-class rounding, handle reuse across shared/non-shared pools, untouched(), oversized bypass, and trim_spare_chunks().

Minor non-blocking notes

  • Unlike give_chunks, give_list_uploads does not hook into the periodic 10-second allocator_trim() (VICTORY_ALLOCATOR_TRIM=1) path (it only drains on trim_spare_chunks() under host memory pressure).
  • host_list_upload_pools_buffers_by_shared_kind_until_reset assumes card_steps::stage() <= 1 in the test process environment when exercising list_a.upload as the non-shared path.

Verdict

CI is passing and the logic/safety look solid, but because this changes D3D12 host upload/shared buffer reuse and lifetime management in crates/victory-gpu/src/host.rs, a local real-GPU smoke test is recommended before merging.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235063409 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/14#issuecomment-7235063409). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:04:31Z. --- <!-- minivi-triage v1 head=2a7608ce8e38b4ff024f512225b02771c212bad5 verdict=needs-gpu-test ci=passing at=2026-11-28T06:04:58Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary This PR pools mapped upload buffers allocated by `HostList::upload` in `crates/victory-gpu/src/host.rs` across command list resets, separated into two `Spare<Chunk>` pools (`SPARE_LIST_UPLOAD` and `SPARE_LIST_SHARED_UPLOAD`) for `shared = false` and `shared = true` (`card_steps::stage() > 1`). #### What looks solid - **Lifetime & exclusivity**: Pooled buffers are held in `Deferred::list_uploads` and returned via `give_list_uploads` only when `Deferred` drops (on `HostList::reset` or list drop after GPU completion), matching the existing `plane_uploads` / `give_chunks` lifetime model. - **Size-class bucketing & OOM fallback**: `list_upload_class` safely rounds sizes in `64 KiB..=16 MiB` (`LIST_UPLOAD_MIN..=LIST_UPLOAD_MAX`) using `checked_next_power_of_two()`, and `take_list_upload` falls back to exact-size allocation if the rounded-up allocation fails (with `give_list_uploads` dropping non-power-of-two or out-of-range buffers outside the mutex lock). - **Memory pressure & accounting**: Idle pools are capped at `LIST_UPLOAD_SPARE_MOST` (64 MiB per kind, 16 MiB under `residency::limited_host_ram()`), respect `scratch_pool()`, and are drained in `trim_spare_chunks()` even when `SPARE` is empty. `Deferred::hold_list_upload` / `Drop` keep `ALIVE[6]`/`ALIVE[7]` balanced, and `HostList::untouched()` checks `deferred.list_uploads.is_empty()`. - **Tests**: `host::list_upload_pool_tests` covers size-class rounding, handle reuse across `shared`/`non-shared` pools, `untouched()`, oversized bypass, and `trim_spare_chunks()`. #### Minor non-blocking notes - Unlike `give_chunks`, `give_list_uploads` does not hook into the periodic 10-second `allocator_trim()` (`VICTORY_ALLOCATOR_TRIM=1`) path (it only drains on `trim_spare_chunks()` under host memory pressure). - `host_list_upload_pools_buffers_by_shared_kind_until_reset` assumes `card_steps::stage() <= 1` in the test process environment when exercising `list_a.upload` as the non-shared path. #### Verdict CI is passing and the logic/safety look solid, but because this changes D3D12 host upload/shared buffer reuse and lifetime management in `crates/victory-gpu/src/host.rs`, a local real-GPU smoke test is recommended before merging. --- _Generated with Antigravity CLI (`agy`)._
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!14
No description provided.