victory-gpu: enable texture readback buffer pool by default (64 MiB cap) #21

Merged
Androtim merged 2 commits from upstream-pr/21 into main 2026-11-29 04:45:34 +00:00
Androtim commented 2026-11-28 06:33:03 +00:00 (Migrated from github.com)

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


Summary

Enable texture readback buffer pooling by default with a 64 MiB idle cap and pressure trimming in crates/victory-gpu/src/host.rs:

  • Extract parse_texture_readback_idle_limit and default VICTORY_READBACK_POOL to enabled (VICTORY_READBACK_POOL=0 disables pooling) with a default idle cap of 64 MiB (overridable via VICTORY_READBACK_POOL_MB).
  • Add ReadbackPool::trim() and invoke it from trim_spare_chunks() so idle readback buffers are drained whenever residency::pressured() triggers (even when SPARE scratch chunks are empty), while active leases remain untouched.
  • Add unit tests readback_pool_defaults_on_at_64_mib_and_respects_overrides and readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases.

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 @ 8878f5eb96c9356874815e240f316135896803d9 (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 pr21-diag.exe, -GoldenDataDir 'D:\victory-data\golden-data-minivi', -WorldSeconds 75, -AutoNudgeMenu (VICTORY_READBACK_POOL left unset to exercise the new default)
  • Scene / Area & Session Length: Mission-1 golden autosave (dock -> balcony), 75s in-world telemetry (14 world windows, max 11,197 draws/frame)

Measurements & Verification

  • Texture Readback Pool A/B (at copied=7,168 readbacks vs unpooled pr19-typed-uav):
    • Unpooled (pr19-typed-uav): created=8,029, reused=0, allocation_us=4,117,872 (4.12 s), peak_allocation_us=16,807, active_bytes=10,289,152
    • Default 64 MiB Pool (pr21-readback-pool): created=1,364, reused=6,681 (83.0% reuse), allocation_us=717,980 (0.72 s, 5.7x reduction), peak_allocation_us=6,348, active_bytes=7,602,176, idle_bytes=8,126,464 (7.75 MiB), peak_idle_bytes=17,301,504 (16.50 MiB), allocation_failures=0
  • Base FPS (without Frame Gen): Steady-state balcony hit 9.2–10.9 fps (peaking at 10.9 fps / 91.9 ms/frame, vs baseline-main 8.9–10.6 fps), final_waiting=4,197 (vs 7,121 baseline). Raw 14-window median was 5.05 fps due to -AutoNudgeMenu entering the dock while pipelines were compiling (waiting for pipelines = 421.3–429.4 ms/frame during dock windows). Visuals PASS: lit=9/24, luma=103.04, edge_energy=6.97, magenta=0.0% (inspected frame-8097.png water/dock & frame-9345.png balcony).
  • Frame-Gen FPS (if enabled): off
  • VRAM / RAM Usage: 5,749.0 MB median / 5,923 MB peak of 6,924 MB budget (over=0 MB, room_false=7.1% vs 33.3% baseline)
  • 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 (450 passed; 0 failed; 36 ignored, including readback_pool_defaults_on_at_64_mib_and_respects_overrides and readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5537486443 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/21). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:33:03Z. --- ## Summary Enable texture readback buffer pooling by default with a `64 MiB` idle cap and pressure trimming in [`crates/victory-gpu/src/host.rs`](https://github.com/Androtim/MiniVI/blob/8878f5eb96c9356874815e240f316135896803d9/crates/victory-gpu/src/host.rs): - Extract `parse_texture_readback_idle_limit` and default `VICTORY_READBACK_POOL` to enabled (`VICTORY_READBACK_POOL=0` disables pooling) with a default idle cap of `64 MiB` (overridable via `VICTORY_READBACK_POOL_MB`). - Add `ReadbackPool::trim()` and invoke it from `trim_spare_chunks()` so idle readback buffers are drained whenever `residency::pressured()` triggers (even when `SPARE` scratch chunks are empty), while active leases remain untouched. - Add unit tests `readback_pool_defaults_on_at_64_mib_and_respects_overrides` and `readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases`. ## 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` @ `8878f5eb96c9356874815e240f316135896803d9` (`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 `pr21-diag.exe`, `-GoldenDataDir 'D:\victory-data\golden-data-minivi'`, `-WorldSeconds 75`, `-AutoNudgeMenu` (`VICTORY_READBACK_POOL` left unset to exercise the new default) - **Scene / Area & Session Length:** Mission-1 golden autosave (`dock` -> `balcony`), 75s in-world telemetry (`14` world windows, max `11,197` draws/frame) ## Measurements & Verification - **Texture Readback Pool A/B (at `copied=7,168` readbacks vs unpooled `pr19-typed-uav`):** - Unpooled (`pr19-typed-uav`): `created=8,029`, `reused=0`, `allocation_us=4,117,872` (`4.12 s`), `peak_allocation_us=16,807`, `active_bytes=10,289,152` - Default 64 MiB Pool (`pr21-readback-pool`): **`created=1,364`, `reused=6,681` (83.0% reuse)**, **`allocation_us=717,980` (`0.72 s`, 5.7x reduction)**, `peak_allocation_us=6,348`, `active_bytes=7,602,176`, `idle_bytes=8,126,464` (`7.75 MiB`), `peak_idle_bytes=17,301,504` (`16.50 MiB`), `allocation_failures=0` - **Base FPS (without Frame Gen):** Steady-state balcony hit `9.2–10.9 fps` (peaking at `10.9 fps` / `91.9 ms/frame`, vs `baseline-main` `8.9–10.6 fps`), `final_waiting=4,197` (vs `7,121` baseline). Raw 14-window median was `5.05 fps` due to `-AutoNudgeMenu` entering the dock while pipelines were compiling (`waiting for pipelines = 421.3–429.4 ms/frame` during dock windows). Visuals `PASS`: `lit=9/24`, `luma=103.04`, `edge_energy=6.97`, `magenta=0.0%` (inspected `frame-8097.png` water/dock & `frame-9345.png` balcony). - **Frame-Gen FPS (if enabled):** `off` - **VRAM / RAM Usage:** `5,749.0 MB` median / `5,923 MB` peak of `6,924 MB` budget (`over=0 MB`, `room_false=7.1%` vs `33.3%` baseline) - **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` (`450 passed; 0 failed; 36 ignored`, including `readback_pool_defaults_on_at_64_mib_and_respects_overrides` and `readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases`)
Androtim commented 2026-11-28 06:44:01 +00:00 (Migrated from github.com)

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


Follow-up commit a78e9bc08a8c34b90901abcf9695ed4d5a4512f5: switched ReadbackPool::trim() from wiping all idle buffers on every pressure tick to Spare::trim() (low-watermark eviction).

In the pr21-readback-pool 75s telemetry run, created stayed flat at 66 (100% cache hit across copied=128..512) until residency::pressured() fired at frame 8029 and cleared active idle_bytes, driving created from 66 to 1,364 across copied=512..7,168. With Spare::trim(), actively cycled readback buffers reset low on take() and survive pressure ticks while only genuinely idle buffers are evicted. Verified via readback_pool_tests (6 passed), xtask policy (294 files ok), both workspace clippy passes (0 warnings), and clean --release build (0 non-system MinGW DLLs).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235483864 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/21#issuecomment-7235483864). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:44:01Z. --- Follow-up commit `a78e9bc08a8c34b90901abcf9695ed4d5a4512f5`: switched `ReadbackPool::trim()` from wiping all idle buffers on every pressure tick to `Spare::trim()` (low-watermark eviction). In the `pr21-readback-pool` 75s telemetry run, `created` stayed flat at `66` (100% cache hit across `copied=128..512`) until `residency::pressured()` fired at frame `8029` and cleared active `idle_bytes`, driving `created` from `66` to `1,364` across `copied=512..7,168`. With `Spare::trim()`, actively cycled readback buffers reset `low` on `take()` and survive pressure ticks while only genuinely idle buffers are evicted. Verified via `readback_pool_tests` (`6 passed`), `xtask policy` (`294 files ok`), both workspace `clippy` passes (`0` warnings), and clean `--release` build (`0` non-system MinGW DLLs).
Androtim commented 2026-11-28 07:03:06 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers (not an approval).

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

Review Summary

This PR enables the texture readback buffer pool by default in crates/victory-gpu/src/host.rs with a 64 MiB idle cap (VICTORY_READBACK_POOL=0 to disable, VICTORY_READBACK_POOL_MB to override), adds ReadbackPool::trim() invoked from trim_spare_chunks(), and adds unit tests for both.

Verified Findings

  • Default & override parsing (parse_texture_readback_idle_limit): Cleanly handles default 64 MiB, explicit disable via VICTORY_READBACK_POOL=0, and custom VICTORY_READBACK_POOL_MB (including 0 and overflow via checked_mul), cached in texture_readback_idle_limit().
  • Locking & D3D12 resource lifetime (ReadbackPool::trim): Updates stats.idle_bytes under the pool mutex and drops the evicted ID3D12Resources outside the lock, consistent with ReadbackLease::drop. Active leases are untouched.
  • Note on pressure trimming behavior (trim_spare_chunks): Unlike SPARE and SPARE_LIST_UPLOAD (which are drained completely in trim_spare_chunks()), ReadbackPool::trim() delegates to Spare::trim(), which uses a two-window low-watermark policy. As tested in readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases, the first pressure call only records low and frees 0 bytes, and subsequent calls only evict buffers that stayed continuously idle across calls. That avoids thrashing actively cycled pools, though it will not immediately reclaim readback memory on a single sudden pressure spike.
  • Default fence verification: Enabling texture_readback_idle_limit() != 0 by default also activates Host::verify_texture_readback_fence() on synchronous wait paths by default, enforcing that pooled buffers are not retired before GPU fence completion.

Verdict

needs-gpu-test — CI is passing and the implementation/tests are sound, but changing the D3D12 host's default texture readback pooling and memory-budget behavior warrants a local real-GPU smoke test before merging.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235683152 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/21#issuecomment-7235683152). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T07:03:06Z. --- <!-- minivi-triage v1 head=777e90f5d37519bd0dbd1508433671506d010e21 verdict=needs-gpu-test ci=passing at=2026-11-29T01:03:32Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary This PR enables the texture readback buffer pool by default in `crates/victory-gpu/src/host.rs` with a `64 MiB` idle cap (`VICTORY_READBACK_POOL=0` to disable, `VICTORY_READBACK_POOL_MB` to override), adds `ReadbackPool::trim()` invoked from `trim_spare_chunks()`, and adds unit tests for both. ### Verified Findings - **Default & override parsing (`parse_texture_readback_idle_limit`)**: Cleanly handles default `64 MiB`, explicit disable via `VICTORY_READBACK_POOL=0`, and custom `VICTORY_READBACK_POOL_MB` (including `0` and overflow via `checked_mul`), cached in `texture_readback_idle_limit()`. - **Locking & D3D12 resource lifetime (`ReadbackPool::trim`)**: Updates `stats.idle_bytes` under the pool mutex and drops the evicted `ID3D12Resource`s outside the lock, consistent with `ReadbackLease::drop`. Active leases are untouched. - **Note on pressure trimming behavior (`trim_spare_chunks`)**: Unlike `SPARE` and `SPARE_LIST_UPLOAD` (which are drained completely in `trim_spare_chunks()`), `ReadbackPool::trim()` delegates to `Spare::trim()`, which uses a two-window low-watermark policy. As tested in `readback_pool_trim_releases_idle_buffers_without_disturbing_active_leases`, the first pressure call only records `low` and frees `0` bytes, and subsequent calls only evict buffers that stayed continuously idle across calls. That avoids thrashing actively cycled pools, though it will not immediately reclaim readback memory on a single sudden pressure spike. - **Default fence verification**: Enabling `texture_readback_idle_limit() != 0` by default also activates `Host::verify_texture_readback_fence()` on synchronous wait paths by default, enforcing that pooled buffers are not retired before GPU fence completion. ### Verdict `needs-gpu-test` — CI is passing and the implementation/tests are sound, but changing the D3D12 host's default texture readback pooling and memory-budget behavior warrants a local real-GPU smoke test before merging. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 00:49:03 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T00:49:03Z.


Rebased onto origin/main (6e935d7 -> 777e90f):

Changes

  • Resolved the doc-comment conflict in crates/victory-gpu/src/host.rs (trim_spare_chunks).

Verification (777e90f)

  • Policy & Lints: cargo run -p xtask -- policy (301 files ok), cargo test -p xtask (6 passed), clippy --workspace --all-targets -- -D warnings (0 warnings, both plain and --features diagnostics).
  • Unit Tests: victory-gpu --lib host:: (127 passed; 0 failed; 16 ignored, including readback_pool_tests).
  • Release Builds & DLL Check: plain --release (2m 13s, objdump -p confirmed Windows system DLLs only, zero non-system MinGW runtime DLLs) and --release --features diagnostics (3m 45s).
  • Live 75s Open-World GPU Run (pr21-rebased) — 11/11 gates PASS:
    • 11.55 fps median (86.6 ms/frame, baseline 8.9 fps), 11173 max draws across 14 world windows
    • 5501 MB max VRAM / 6616 MB min budget (0 MB over, baseline 5864 MB)
    • 43686 textures uploaded, 3328 final waiting (baseline 7121), 1–2 ms making host copies / 13–16 ms making slots' views in the final 5s windows
    • mapped() rate 33.88 ms/s (35000 calls, 3393.0 ms total, longest 14.7 ms), 0 crashes
    • 17/24 lit PNGs (106.05 median luma vs 103.2 baseline, 0.01% near-black, 7.03 edge energy, 0.0% magenta); visually verified clean exterior geometry, lighting, textures, foliage, water, and UI.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7248371607 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/21#issuecomment-7248371607). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T00:49:03Z. --- Rebased onto `origin/main` (`6e935d7` -> `777e90f`): ### Changes - Resolved the doc-comment conflict in `crates/victory-gpu/src/host.rs` (`trim_spare_chunks`). ### Verification (`777e90f`) - **Policy & Lints:** `cargo run -p xtask -- policy` (`301 files ok`), `cargo test -p xtask` (`6 passed`), `clippy --workspace --all-targets -- -D warnings` (`0` warnings, both plain and `--features diagnostics`). - **Unit Tests:** `victory-gpu --lib host::` (`127 passed; 0 failed; 16 ignored`, including `readback_pool_tests`). - **Release Builds & DLL Check:** plain `--release` (`2m 13s`, `objdump -p` confirmed Windows system DLLs only, zero non-system MinGW runtime DLLs) and `--release --features diagnostics` (`3m 45s`). - **Live 75s Open-World GPU Run (`pr21-rebased`) — 11/11 gates PASS:** - `11.55 fps` median (`86.6 ms/frame`, baseline `8.9 fps`), `11173` max draws across `14` world windows - `5501 MB` max VRAM / `6616 MB` min budget (`0 MB` over, baseline `5864 MB`) - `43686` textures uploaded, `3328` final waiting (baseline `7121`), `1–2 ms` making host copies / `13–16 ms` making slots' views in the final 5s windows - `mapped()` rate `33.88 ms/s` (`35000` calls, `3393.0 ms` total, longest `14.7 ms`), `0` crashes - `17/24` lit PNGs (`106.05` median luma vs `103.2` baseline, `0.01%` near-black, `7.03` edge energy, `0.0%` magenta); visually verified clean exterior geometry, lighting, textures, foliage, water, and UI.
Androtim commented 2026-11-29 04:45:30 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T04:45:30Z.


Automated RTX 4060 Ti 8 GB A/B hardware verification passed (playtest/wave2 vs origin/main 1ab5d84):

  • Hardware cargo test (RTX 4060 Ti): victory-shader lds_sub (1/1), emit::wave64_tests (14/14), victory-gpu (505/505) — 520 passed, 0 failed.
  • Automated 45s in-world A/B (scripts/verify-world.ps1, DLSS Quality + golden autosave):
    • FPS: 13.45 fps (77.25 ms) vs 3.20 fps (308.8 ms) baseline (+10.25 fps / 4.2x faster)
    • Draws: max_draws=3122 vs 2994
    • Stability: 0 crashes / 0 DRED
    • VRAM: 6174 / 6903 MB (-25 MB vs baseline, 0 MB over budget)
    • Texture backlog: final_waiting=7638 vs 12258 (-4620)
    • Visual check: Clean rendered frames (frame-7969.png, frame-8409.png), no regressions vs origin/main.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7250844030 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/21#issuecomment-7250844030). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T04:45:30Z. --- Automated RTX 4060 Ti 8 GB A/B hardware verification passed (`playtest/wave2` vs `origin/main` `1ab5d84`): - **Hardware `cargo test` (RTX 4060 Ti):** `victory-shader` `lds_sub` (1/1), `emit::wave64_tests` (14/14), `victory-gpu` (505/505) — **520 passed, 0 failed**. - **Automated 45s in-world A/B (`scripts/verify-world.ps1`, DLSS Quality + golden autosave):** - **FPS:** **13.45 fps** (`77.25 ms`) vs **3.20 fps** (`308.8 ms`) baseline (**+10.25 fps / 4.2x faster**) - **Draws:** `max_draws=3122` vs `2994` - **Stability:** `0` crashes / `0` DRED - **VRAM:** `6174 / 6903 MB` (`-25 MB` vs baseline, `0 MB` over budget) - **Texture backlog:** `final_waiting=7638` vs `12258` (`-4620`) - **Visual check:** Clean rendered frames (`frame-7969.png`, `frame-8409.png`), no regressions vs `origin/main`.
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!21
No description provided.