Adaptive 16/8 MiB texture pool, block-aware idle eviction, and pop-in priority #1168

Closed
mikael-jarvinen wants to merge 1 commit from upstream-pr/1168 into main
mikael-jarvinen commented 2026-11-28 14:45:19 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mikael-jarvinen on 2026-11-28T14:45:19Z.


Summary

Reduces local VRAM footprint, eliminates pool fragmentation traps, and cuts texture pop-in on 8–12 GB GPUs:

  1. Adaptive size-segregated texture pools (crates/victory-gpu/src/pool.rs, apps/victory/src/play.rs, scripts/play-foxhound.ps1):

    • Scales texture pool block sizes from the adapter's DXGI local VRAM budget (overridable via VICTORY_TEXTURE_BLOCK_MB):
      • <= 12 GiB: 16 MiB large blocks + 8 MiB small blocks
      • 12–20 GiB: 32 MiB large blocks + 16 MiB small blocks
      • >= 20 GiB: 64 MiB large blocks + 16 MiB small blocks
    • Routes small textures (<= 64 KiB, with VICTORY_POOL_SMALL=1 enabled by default) into a dedicated TEXTURES_SMALL pool so persistent small textures do not pin large streaming blocks open and prevent D3D12 heap reclamation.
    • Caps idle spare texture blocks (SPARE_KEPT_TIGHT = 2) on <= 12 GiB GPUs so drained heaps return promptly to WDDM.
    • Guards D3D12_RESOURCE_BARRIER_TYPE_ALIASING on pool::is_pooled(texture) (crates/victory-gpu/src/host.rs, crates/victory-gpu/src/texture.rs, matching the fix in #999), which is required with 16 MiB blocks because textures > 8 MiB fall back to committed ID3D12Resources where D3D12 rejects aliasing barriers with E_INVALIDARG.
  2. Pool-block growth gate + O(1) block-aware idle eviction + peak target reserve (crates/victory-gpu/src/pool.rs, crates/victory-gpu/src/resource.rs, crates/victory-gpu/src/draw.rs):

    • Adds a pool-block growth gate (pool::gate() / pool::waiting()) with a no_fit cache so when VRAM approaches room_line, waitable textures still fill existing free holes in live blocks and defer cleanly (Told::Later) instead of growing new blocks or falling back to committed allocations.
    • Tags each pooled texture (Hosted::pool_block) with its pool and block index and sorts idle eviction candidates by block occupancy tier (<25% → 25–50% → >=50% / unpooled) so sparse D3D12 heaps drain to 0 and return to the OS.
    • Caps trapped pool-free credit at 256 MiB in let_go_idle(), excludes phantom targets_room_kept from live-texture eviction, and replaces the fixed 3,072 MiB target reserve with a peak-sized reserve (clamp(peak * 1.5, 256 MiB, min(cap, 30% budget)), 2,048 MiB DLSS cap, 10 s settle to 0).
  3. Texture pop-in priority & ahead-pool trimming (crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/ahead.rs, crates/victory-gpu/src/texture/ahead.rs):

    • Splits TextureQueue due ordering (Due::ordered()) into again (partially mapped / retried) → fresh (never uploaded yet) → recheck (already uploaded whole, speculative blind-write fingerprint checks), preventing unchanged recheck scans from starving new textures during bursts.
    • Trims ahead::CARD pre-allocated 64 KiB card buffers on <= 12 GiB GPUs (256 initial / 128 kept, releasing excess above 32 under VRAM pressure).
    • Gates texture::ahead::claim on residency::admit_texture_pass(false) instead of allow_staging_growth(false) so already-committed staging blocks stay reusable for ahead uploads.

Verification

  • cargo clippy -p victory-gpu -p victory --all-targets --locked — 0 warnings in touched code
  • cargo clippy -p victory-gpu --all-targets --all-features --locked — 0 warnings in touched code
  • cargo test -p victory-gpu --lib --locked — 456 passed, 0 failed (including unit tests for Due::ordered() priority and targets_kept_from_peak / targets_most)
  • cargo xtask policy — 294 files ok
  • cargo build --release -p victory — clean release build (0 warnings)

A/B Benchmark vs origin/main (63b902f)

Tested on RTX 3080 10 GB, 1440p DLSS Performance, identical 115 s scripted launch (VICTORY_WARMUP_RESTART=0, VICTORY_POOL_STATS=1, VICTORY_KEYS=25:Enter,...,55:Enter):

Metric origin/main (63b902f) This PR (eba2e0c) Delta
Median VRAM in use 7,601 MB 6,229 MB −1,372 MB (−18.1%)
Peak VRAM in use 8,336 / 8,679 MB 8,152 / 8,556 MB −184 MB
Resident textures in pool (last 2 windows) 16,012–18,245 (2,053–2,214 MB) 27,379–28,677 (2,236–2,496 MB) +57% live textures
Trapped free pool overhead (last 2 windows) 1,433–1,580 MB (39–43%) 1,033–1,174 MB (29–33%) −400 MB wasted
Held back for room (sum across 5 s windows) 1,263,687 (137,309 max) 355,102 (70,432 max) −71.9% (−48.7% peak)
First-time textures served / 5 s (last 3) 5,915 / 6,876 / 11,153 25,139 / 41,986 / 33,981 4–6× throughput
Texture pass lateness (last 3 windows) 1.6 / 2.5 / 0.5 fr (12–15 max) 0.6 / 0.5 / 0.6 fr (6–9 max) −60–75% lateness
UPLOAD_AHEAD count & latency 30,000 (1,526 MB, 1.4 ms) 35,000 (1,596 MB, 0.7 ms) +17% count, 2× faster
Non-Streamline errors / faults 0 0 —
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5541285559 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1168). Originally posted by [mikael-jarvinen](https://github.com/mikael-jarvinen) on 2026-11-28T14:45:19Z. --- ## Summary Reduces local VRAM footprint, eliminates pool fragmentation traps, and cuts texture pop-in on 8–12 GB GPUs: 1. **Adaptive size-segregated texture pools (`crates/victory-gpu/src/pool.rs`, `apps/victory/src/play.rs`, `scripts/play-foxhound.ps1`):** - Scales texture pool block sizes from the adapter's DXGI local VRAM budget (overridable via `VICTORY_TEXTURE_BLOCK_MB`): - `<= 12 GiB`: `16 MiB` large blocks + `8 MiB` small blocks - `12–20 GiB`: `32 MiB` large blocks + `16 MiB` small blocks - `>= 20 GiB`: `64 MiB` large blocks + `16 MiB` small blocks - Routes small textures (`<= 64 KiB`, with `VICTORY_POOL_SMALL=1` enabled by default) into a dedicated `TEXTURES_SMALL` pool so persistent small textures do not pin large streaming blocks open and prevent D3D12 heap reclamation. - Caps idle spare texture blocks (`SPARE_KEPT_TIGHT = 2`) on `<= 12 GiB` GPUs so drained heaps return promptly to WDDM. - Guards `D3D12_RESOURCE_BARRIER_TYPE_ALIASING` on `pool::is_pooled(texture)` (`crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/texture.rs`, matching the fix in #999), which is required with 16 MiB blocks because textures `> 8 MiB` fall back to committed `ID3D12Resource`s where D3D12 rejects aliasing barriers with `E_INVALIDARG`. 2. **Pool-block growth gate + O(1) block-aware idle eviction + peak target reserve (`crates/victory-gpu/src/pool.rs`, `crates/victory-gpu/src/resource.rs`, `crates/victory-gpu/src/draw.rs`):** - Adds a pool-block growth gate (`pool::gate()` / `pool::waiting()`) with a `no_fit` cache so when VRAM approaches `room_line`, waitable textures still fill existing free holes in live blocks and defer cleanly (`Told::Later`) instead of growing new blocks or falling back to committed allocations. - Tags each pooled texture (`Hosted::pool_block`) with its pool and block index and sorts idle eviction candidates by block occupancy tier (`<25%` → `25–50%` → `>=50%` / unpooled) so sparse D3D12 heaps drain to 0 and return to the OS. - Caps trapped pool-free credit at 256 MiB in `let_go_idle()`, excludes phantom `targets_room_kept` from live-texture eviction, and replaces the fixed 3,072 MiB target reserve with a peak-sized reserve (`clamp(peak * 1.5, 256 MiB, min(cap, 30% budget))`, 2,048 MiB DLSS cap, 10 s settle to 0). 3. **Texture pop-in priority & ahead-pool trimming (`crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/ahead.rs`, `crates/victory-gpu/src/texture/ahead.rs`):** - Splits `TextureQueue` due ordering (`Due::ordered()`) into `again` (partially mapped / retried) → `fresh` (never uploaded yet) → `recheck` (already uploaded whole, speculative blind-write fingerprint checks), preventing unchanged `recheck` scans from starving new textures during bursts. - Trims `ahead::CARD` pre-allocated 64 KiB card buffers on `<= 12 GiB` GPUs (`256` initial / `128` kept, releasing excess above `32` under VRAM pressure). - Gates `texture::ahead::claim` on `residency::admit_texture_pass(false)` instead of `allow_staging_growth(false)` so already-committed staging blocks stay reusable for ahead uploads. ## Verification - `cargo clippy -p victory-gpu -p victory --all-targets --locked` — 0 warnings in touched code - `cargo clippy -p victory-gpu --all-targets --all-features --locked` — 0 warnings in touched code - `cargo test -p victory-gpu --lib --locked` — **456 passed, 0 failed** (including unit tests for `Due::ordered()` priority and `targets_kept_from_peak` / `targets_most`) - `cargo xtask policy` — **294 files ok** - `cargo build --release -p victory` — clean release build (0 warnings) ## A/B Benchmark vs `origin/main` (`63b902f`) Tested on RTX 3080 10 GB, 1440p DLSS Performance, identical 115 s scripted launch (`VICTORY_WARMUP_RESTART=0`, `VICTORY_POOL_STATS=1`, `VICTORY_KEYS=25:Enter,...,55:Enter`): | Metric | `origin/main` (`63b902f`) | This PR (`eba2e0c`) | Delta | |---|---:|---:|---:| | Median VRAM in use | `7,601 MB` | **`6,229 MB`** | **−1,372 MB (−18.1%)** | | Peak VRAM in use | `8,336 / 8,679 MB` | **`8,152 / 8,556 MB`** | **−184 MB** | | Resident textures in pool (last 2 windows) | `16,012–18,245` (`2,053–2,214 MB`) | **`27,379–28,677` (`2,236–2,496 MB`)** | **+57% live textures** | | Trapped free pool overhead (last 2 windows) | `1,433–1,580 MB` (`39–43%`) | **`1,033–1,174 MB` (`29–33%`)** | **−400 MB wasted** | | `Held back for room` (sum across 5 s windows) | `1,263,687` (`137,309` max) | **`355,102` (`70,432` max)** | **−71.9% (−48.7% peak)** | | First-time textures served / 5 s (last 3) | `5,915 / 6,876 / 11,153` | **`25,139 / 41,986 / 33,981`** | **4–6× throughput** | | Texture pass lateness (last 3 windows) | `1.6 / 2.5 / 0.5 fr` (`12–15` max) | **`0.6 / 0.5 / 0.6 fr` (`6–9` max)** | **−60–75% lateness** | | `UPLOAD_AHEAD` count & latency | `30,000` (`1,526 MB`, `1.4 ms`) | **`35,000` (`1,596 MB`, `0.7 ms`)** | **+17% count, 2× faster** | | Non-Streamline errors / faults | `0` | **`0`** | — |
Aniseto commented 2026-11-28 15:02:25 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-11-28T15:02:25Z.


Ran the adaptive texture-pool tests at eba2e0c on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (48a229cea 2026-09-01, pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib room_line_follows_the_budget -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 491 filtered out      (exit 0)

VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib the_slots_due_come_with_what_is_known_of_them -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 491 filtered out      (exit 0)

Both pass: the texture line tracks the adapter's VRAM budget, and the due-slot ordering carries the known state of each slot (the pop-in priority path). A 16 GB card takes the 32/16 MiB block bracket from the PR's table. These are CPU-side policy tests; I did not run the author's 115 s scripted world launch and cannot claim an FPS or pop-in improvement here. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.

Not tested: a retail title, A/B FPS or pop-in measurement, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7241151191 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1168#issuecomment-7241151191). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-28T15:02:25Z. --- Ran the adaptive texture-pool tests at `eba2e0c` on an NVIDIA Blackwell desktop part: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (48a229cea 2026-09-01, pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build. ``` VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib room_line_follows_the_budget -- --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 491 filtered out (exit 0) VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib the_slots_due_come_with_what_is_known_of_them -- --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 491 filtered out (exit 0) ``` Both pass: the texture line tracks the adapter's VRAM budget, and the due-slot ordering carries the known state of each slot (the pop-in priority path). A 16 GB card takes the 32/16 MiB block bracket from the PR's table. These are CPU-side policy tests; I did not run the author's 115 s scripted world launch and cannot claim an FPS or pop-in improvement here. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. Not tested: a retail title, A/B FPS or pop-in measurement, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
cxy0072019-sketch commented 2026-11-28 15:17:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cxy0072019-sketch on 2026-11-28T15:17:14Z.


I ran an in-game comparison on a 16 GB RTX 5070 Ti with an i5-14600KF under Windows to complement the texture-pool test results above.

Both diagnostics release builds started from a copy of the same Series S Gear Up save at 1920×1080 output, with DLSS and frame generation off. The emulator caches started with identical manifests, and each build had a separate fresh driver cache. The PR build used its VICTORY_POOL_SMALL=1 preset.

Metric Parent 63b902f PR eba2e0c
Peak local VRAM in the first 240 s after the first sample with at least 3,000 draws, as reported 7,530 MB 6,152 MB
Stable balcony view, median rendered FPS 16.75 15.65
Stable balcony view, median draws/frame 5,336 5,506
Stable balcony view, median textures waiting 1,744 1,829

The stable samples used the same camera after pipeline compilation finished. The inspected character, house and nearby water looked similar. The startup camera varied and the candidate issued about 3% more draws in the stable view, so this single restart pair is a data point for the VRAM and frame-time trade-off on 16 GB. It does not establish texture pop-in latency while moving. Test automation and analysis were AI-assisted.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7241350066 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1168#issuecomment-7241350066). Originally posted by [cxy0072019-sketch](https://github.com/cxy0072019-sketch) on 2026-11-28T15:17:14Z. --- I ran an in-game comparison on a 16 GB RTX 5070 Ti with an i5-14600KF under Windows to complement the texture-pool test results above. Both diagnostics release builds started from a copy of the same Series S Gear Up save at 1920×1080 output, with DLSS and frame generation off. The emulator caches started with identical manifests, and each build had a separate fresh driver cache. The PR build used its `VICTORY_POOL_SMALL=1` preset. | Metric | Parent `63b902f` | PR `eba2e0c` | | --- | ---: | ---: | | Peak local VRAM in the first 240 s after the first sample with at least 3,000 draws, as reported | 7,530 MB | 6,152 MB | | Stable balcony view, median rendered FPS | 16.75 | 15.65 | | Stable balcony view, median draws/frame | 5,336 | 5,506 | | Stable balcony view, median textures waiting | 1,744 | 1,829 | The stable samples used the same camera after pipeline compilation finished. The inspected character, house and nearby water looked similar. The startup camera varied and the candidate issued about 3% more draws in the stable view, so this single restart pair is a data point for the VRAM and frame-time trade-off on 16 GB. It does not establish texture pop-in latency while moving. Test automation and analysis were AI-assisted.
trustno1-coder commented 2026-11-28 19:23:22 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:23:22Z.


Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244507159 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1168#issuecomment-7244507159). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:23:22Z. --- Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!1168
No description provided.