feat(gpu/resource,shadow,descriptor): dynamic budget-reactive VRAM reclaim & 4K 8 GiB headroom #291

Manually merged
github merged 1 commit from gh-pr/291/head into gh-pr/291/base 2026-12-01 20:26:49 +00:00
Owner

@⁠Androtim on GitHub · 2026-12-01 16:50 UTC · original
Androtim:fix/dynamic-vram-reclaim-and-4k-headroom → main · +525 −146 · 8 files · 1 commits · merged 2026-12-01 19:10 UTC

Root Cause & Architecture Changes

Fixes #149.

  1. Dynamic Budget-Reactive Eviction & Bindless Slot Parking (descriptor/host.rs, descriptor.rs, draw.rs,
    esource.rs)

    • Enables slot_evict by default (VICTORY_SLOT_EVICT=0 kill-switch) so eviction starts strictly from live DXGI budget/usage ratios.
    • Unlocks bindless (stamp == 0) and stale tabled (> 240 frames idle) title slots during active reclaim via TextureQueue::evicted_bindless parking and slot_evicting() gating on texture_slots_room.
    • Prioritizes tabled victims and copies in sparse pool blocks (block_used < BLOCK_BYTES / 2) first via evict_covering so sparse 64 MiB blocks drain cleanly back to DXGI.
    • Lifts the 256 MiB per-sweep cap above 90% of DXGI budget (with 88% emergency cutoff fallback) to drain transition bursts in one sweep.
    • Eliminates an AB-BA lock cycle between textures() and HostHeap::made (which HostHeap::mirror -> placed_texture -> create_at_address acquires in the reverse order) by staging candidate gathering, descriptor unmake/re-arm, and resource retire in lock-ordered phases in both let_go_idle and slot_evict.
    • Adds unmapped pinned host-copy reclaim (evict_unmapped_resource_slots) in let_go_idle without polluting WAITING.
  2. 8 GiB Target/Buffer Guard & 4K Headroom (shadow.rs, play.rs, erify-world.ps1)

    • Reserves targets_room_kept under a 92% ceiling in card_room_for / wc_mapped_for only when DXGI budget <= 9 GiB, leaving 16+ GiB GPUs at full unthrottled 97% headroom.
    • Applies 4k 8 GiB headroom tuning (VICTORY_TEXTURE_ROOM_PERCENT=84, VICTORY_SLOT_EVICT_PERCENT=80, VICTORY_SLOT_EVICT_LOW_PERCENT=74, VICTORY_CARD_BUFFERS_MB=512, VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048) only when low_vram is active.

Verification

Static Checks & Unit Tests

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: PASS (318 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked descriptor::host:: -- --test-threads=1: PASS (64 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked resource:: -- --test-threads=1: PASS (35 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory --locked: PASS (40 + 2 passed; 0 failed)
  • Dual workspace clippy --workspace --all-targets --locked -- -D warnings (default and --features diagnostics): PASS (0 warnings)
  • objdump -p on plain --release binary: standard Windows DLLs only.

Paired Plain --release Benchmarks vs origin/main (27aa2ae4, RTX 4060 Ti 8 GB, Series X Low-VRAM parity)

Profile (60s in-world) Metric origin/main (27aa2ae4) This PR (e394a7df) Delta
1440p -> 4K DLSS Quality VRAM over budget 96 MB (FAIL) (6834 / 6722 MB) 0 MB (PASS) (6113 / 6666 MB) -96 MB over (-721 MB peak)
1440p -> 4K DLSS Quality room=false / no_room_so_far 81.8% / 28,500 8.3% / 0 -73.5 pp
1440p -> 4K DLSS Quality unmapped mips median 372 MB 0.0 MB -372 MB
1440p -> 4K DLSS Quality final_waiting / preparing 13,127 / 34.8 ms 5,413 / 20.4 ms -58.8% waiting, -41.4% prep
1440p DLSS Quality Median FPS / Preparing 12.85 fps / 32.95 ms 14.3 fps / 26.9 ms +11.3% FPS, -18.4% prep
1440p DLSS Quality VRAM max / over / crashes 6018 / 0 MB / 0 5884 / 0 MB / 0 -134 MB peak, 0 over, 0 crashes

Extended Diagnostics Check (90s 1440p -> 4K, --features diagnostics)

  • Reached 3D world cleanly (world_windows=19, max_draws=14,760, crashes=0, failed=0).
  • used_max = 6269 MB vs budget_min = 6717 MB -> over = 0 MB across the entire 90s run (30,575 copies / 1,251 MB reclaimed including a 516 MB burst sweep).
  • Visually inspected captured 4K PNGs (outdoors waterfront and balcony gameplay + HUD): crisp textures, shadows, foliage, clouds, and UI with zero black/missing/magenta surfaces.
**@⁠Androtim** on GitHub · 2026-12-01 16:50 UTC · [original](https://github.com/Androtim/MiniVI/pull/291) `Androtim:fix/dynamic-vram-reclaim-and-4k-headroom` → `main` · +525 −146 · 8 files · 1 commits · merged 2026-12-01 19:10 UTC ## Root Cause & Architecture Changes Fixes #149. 1. **Dynamic Budget-Reactive Eviction & Bindless Slot Parking (descriptor/host.rs, descriptor.rs, draw.rs, esource.rs)** - Enables `slot_evict` by default (`VICTORY_SLOT_EVICT=0` kill-switch) so eviction starts strictly from live DXGI budget/usage ratios. - Unlocks bindless (`stamp == 0`) and stale tabled (`> 240` frames idle) title slots during active reclaim via `TextureQueue::evicted_bindless` parking and `slot_evicting()` gating on `texture_slots_room`. - Prioritizes tabled victims and copies in sparse pool blocks (`block_used < BLOCK_BYTES / 2`) first via `evict_covering` so sparse 64 MiB blocks drain cleanly back to DXGI. - Lifts the 256 MiB per-sweep cap above 90% of DXGI budget (with 88% emergency cutoff fallback) to drain transition bursts in one sweep. - Eliminates an AB-BA lock cycle between `textures()` and `HostHeap::made` (which `HostHeap::mirror -> placed_texture -> create_at_address` acquires in the reverse order) by staging candidate gathering, descriptor unmake/re-arm, and resource retire in lock-ordered phases in both `let_go_idle` and `slot_evict`. - Adds unmapped pinned host-copy reclaim (`evict_unmapped_resource_slots`) in `let_go_idle` without polluting `WAITING`. 2. **8 GiB Target/Buffer Guard & 4K Headroom (shadow.rs, play.rs, erify-world.ps1)** - Reserves `targets_room_kept` under a 92% ceiling in `card_room_for` / `wc_mapped_for` only when DXGI `budget <= 9 GiB`, leaving 16+ GiB GPUs at full unthrottled 97% headroom. - Applies `4k` 8 GiB headroom tuning (`VICTORY_TEXTURE_ROOM_PERCENT=84`, `VICTORY_SLOT_EVICT_PERCENT=80`, `VICTORY_SLOT_EVICT_LOW_PERCENT=74`, `VICTORY_CARD_BUFFERS_MB=512`, `VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048`) only when `low_vram` is active. ## Verification ### Static Checks & Unit Tests - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: PASS (`318 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked descriptor::host:: -- --test-threads=1`: PASS (`64 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked resource:: -- --test-threads=1`: PASS (`35 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory --locked`: PASS (`40 + 2 passed; 0 failed`) - Dual workspace `clippy --workspace --all-targets --locked -- -D warnings` (default and `--features diagnostics`): PASS (0 warnings) - `objdump -p` on plain `--release` binary: standard Windows DLLs only. ### Paired Plain `--release` Benchmarks vs `origin/main` (`27aa2ae4`, RTX 4060 Ti 8 GB, Series X Low-VRAM parity) | Profile (60s in-world) | Metric | `origin/main` (`27aa2ae4`) | This PR (`e394a7df`) | Delta | |---|---|---|---|---| | **1440p -> 4K DLSS Quality** | **VRAM over budget** | **96 MB (FAIL)** (`6834 / 6722 MB`) | **0 MB (PASS)** (`6113 / 6666 MB`) | **-96 MB over (-721 MB peak)** | | 1440p -> 4K DLSS Quality | `room=false` / `no_room_so_far` | 81.8% / 28,500 | **8.3% / 0** | **-73.5 pp** | | 1440p -> 4K DLSS Quality | `unmapped mips` median | 372 MB | **0.0 MB** | **-372 MB** | | 1440p -> 4K DLSS Quality | `final_waiting` / `preparing` | 13,127 / 34.8 ms | **5,413 / 20.4 ms** | **-58.8% waiting, -41.4% prep** | | **1440p DLSS Quality** | **Median FPS / Preparing** | 12.85 fps / 32.95 ms | **14.3 fps / 26.9 ms** | **+11.3% FPS, -18.4% prep** | | 1440p DLSS Quality | VRAM max / over / crashes | 6018 / 0 MB / 0 | **5884 / 0 MB / 0** | **-134 MB peak, 0 over, 0 crashes** | ### Extended Diagnostics Check (90s 1440p -> 4K, `--features diagnostics`) - Reached 3D world cleanly (`world_windows=19`, `max_draws=14,760`, `crashes=0`, `failed=0`). - `used_max = 6269 MB` vs `budget_min = 6717 MB` -> **`over = 0 MB`** across the entire 90s run (30,575 copies / 1,251 MB reclaimed including a 516 MB burst sweep). - Visually inspected captured 4K PNGs (outdoors waterfront and balcony gameplay + HUD): crisp textures, shadows, foliage, clouds, and UI with zero black/missing/magenta surfaces.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:26:47 +00:00
github manually merged commit 66c855b146 into gh-pr/291/base 2026-12-01 20:26:49 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 17:10 UTC · original

Architect & Strict-Gate Review (e394a7df): marking triage: needs work.

Bringing 1440p -> 4K VRAM down to 6,113 / 6,666 MB (over = 0 MB, room_false = 8.3%) and eliminating the textures() <-> HostHeap::made AB-BA lock cycle are strong progress on #149, but direct visual PNG inspection and 4K/1440p telemetry caught severe regressions that block merge:

  1. Severe visual regression in 90s 4K --features diagnostics (near_black = 32.84%, lit = 19/24):
    • Direct inspection of late 4K world PNGs shows the exterior house wall, deck railing, ladder, and character skin/arms/head rendered as solid pitch-black silhouettes. Evicting bindless (stamp == 0) / active tabled slots is stripping textures/lighting maps still actively sampled in the live scene.
  2. Severe 4K performance, GPU, copyback, and mapped() regression:
    • Plain --release 4K A/B vs 27aa2ae4: median FPS dropped 8.2 -> 6.6 fps (-19.5%), GPU time jumped 7.2 -> 97.6 ms, and copyback regressed 10.0 -> 13.5 ms (+3.5 ms).
    • In 90s 4K diagnostics, mapped() residency stalls exploded to 57.62 ms/world_sec (5,997.6 ms total, 19,800 calls), while pool_given_back stayed 0 despite 1,021 MB free in the pool (blocks are being emptied/thrashed and re-uploaded rather than cleanly reclaimed without touching active slots).
  3. 1440p final_waiting regression:
    • Plain --release 1440p A/B increased final_waiting 1,653 -> 2,512 (+859) vs 27aa2ae4.

To Unblock Merge (and v2026.12.01.01 Release)

  • Protect actively-sampled bindless/lighting textures from eviction (e.g., track live bindless/frame usage or evict only genuinely cold/unmapped copies & return empty 64 MiB pool blocks pool_given_back > 0) so late 4K world PNGs render with zero black silhouettes (near_black < 2%, lit = 24/24).
  • Re-run paired plain --release 60s 4K and 1440p A/B vs updated main (post-#289) confirming over = 0 MB, non-regressing 4K FPS / copyback / mapped(), and final_waiting <= main, plus wait for minivi-triage review.
**@⁠Androtim** on GitHub · 2026-12-01 17:10 UTC · [original](https://github.com/Androtim/MiniVI/pull/291#issuecomment-7318879097) Architect & Strict-Gate Review (`e394a7df`): marking `triage: needs work`. Bringing `1440p -> 4K` VRAM down to `6,113 / 6,666 MB` (`over = 0 MB`, `room_false = 8.3%`) and eliminating the `textures()` <-> `HostHeap::made` AB-BA lock cycle are strong progress on `#149`, **but direct visual PNG inspection and 4K/1440p telemetry caught severe regressions that block merge:** 1. **Severe visual regression in 90s 4K `--features diagnostics` (`near_black = 32.84%`, `lit = 19/24`):** - Direct inspection of late 4K world PNGs shows the exterior house wall, deck railing, ladder, and character skin/arms/head rendered as **solid pitch-black silhouettes**. Evicting bindless (`stamp == 0`) / active tabled slots is stripping textures/lighting maps still actively sampled in the live scene. 2. **Severe 4K performance, GPU, `copyback`, and `mapped()` regression:** - Plain `--release` 4K A/B vs `27aa2ae4`: median FPS dropped **`8.2 -> 6.6 fps` (`-19.5%`)**, `GPU` time jumped **`7.2 -> 97.6 ms`**, and `copyback` regressed **`10.0 -> 13.5 ms` (`+3.5 ms`)**. - In 90s 4K diagnostics, `mapped()` residency stalls exploded to **`57.62 ms/world_sec`** (`5,997.6 ms` total, `19,800` calls), while `pool_given_back` stayed **`0`** despite `1,021 MB` free in the pool (blocks are being emptied/thrashed and re-uploaded rather than cleanly reclaimed without touching active slots). 3. **1440p `final_waiting` regression:** - Plain `--release` 1440p A/B increased `final_waiting` **`1,653 -> 2,512` (`+859`)** vs `27aa2ae4`. ### To Unblock Merge (and `v2026.12.01.01` Release) - Protect actively-sampled bindless/lighting textures from eviction (e.g., track live bindless/frame usage or evict only genuinely cold/unmapped copies & return empty 64 MiB pool blocks `pool_given_back > 0`) so late 4K world PNGs render with zero black silhouettes (`near_black < 2%`, `lit = 24/24`). - Re-run paired plain `--release` 60s 4K and 1440p A/B vs updated `main` (post-`#289`) confirming `over = 0 MB`, non-regressing 4K FPS / `copyback` / `mapped()`, and `final_waiting <= main`, plus wait for `minivi-triage` review.
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 17:45 UTC · original

Root-Cause Audit (e394a7df)

Both 4K regressions and the 1440p final_waiting regression trace directly to two distinct, provable mechanisms in PR #291:


1. Why diag-vram-reclaim-4k-90s Produces Pitch-Black Silhouettes (near_black = 32.84%)

A 4-step causal chain permanently replaces ~30,000 live scene bindless textures with NULL (0,0,0,0) SRVs:

  1. Zero live-use tracking for bindless textures (crates/victory-gpu/src/descriptor/host.rs:3626-3629, crates/victory-gpu/src/resource.rs:3102-3123):
    • Bindless textures (tabled_stamp(i) == 0) are sampled directly by shader index from material buffers — never via dynamic table copies — so seen_since(0, cutoff, frame) is always false, and r.host.used is only stamped once at initial upload/creation (hosted()), never updated on shader reads.
    • Passing allow_bindless = true (resource.rs:3123) plus lifting the per-sweep cap to u64::MAX above 90% (resource.rs:3073) and bypassing idle_ms at 88% (resource.rs:3081) causes evict_covering() (resource.rs:2997-3014) to sort by oldest r.host.used and evict the longest-lived live scene/foreground textures first: diag evicted 30,575 host copies (1,251 MB) (r3: 33,704, 1,267 MB), leaving only 8,834 (706 MB) alive in the entire 4K world (only 654 made again).
  2. Eviction turns 64 MiB pool blocks into Swiss cheese (pool_given_back == 0):
    • crates/victory-gpu/src/pool.rs:604 only returns a 64 MiB ID3D12Heap to D3D12 when b.free.whole(BLOCK) (100% empty).
    • Because each block retains a few non-evictable/recent textures, diag ends with 27 blocks (1,728 MB), 1,021 MB free (15 blocks under 25% full holding just 38 MB total — ~2.5 MB/block!), and pool_given_back = 0. DXGI used therefore never drops (6,222 -> 6,269 MB, ~92% of 6,786 MB).
  3. Unreachable low mark wedges EVICTING = true forever (apps/victory/src/play.rs:427-432, resource.rs:3072-3076):
    • At 4K on 8 GiB, fixed live allocations alone (2,595 MB render targets/UAVs + 844 MB card buffers + 1,728 MB texture blocks with 0 returned + D3D12 overhead = ~6,100–6,269 MB) sit permanently above VICTORY_SLOT_EVICT_LOW_PERCENT = 74 (~4,958 MB). SLOT_STATE[0] (slot_evicting()) therefore stays true indefinitely.
  4. Parked bindless slots never return (descriptor/host.rs:1740-1763, 3655-3693, descriptor.rs:1998-2013, draw.rs:3494):
    • texture_slot_evicted_bindless() calls unmake(index) (writing a NULL SRV into the live GPU descriptor heap -> 0,0,0,0 black) and parks index in evicted_bindless (NOT WAITING).
    • Because draw.rs:3494 gates host.texture_slots_room(frame) on if room && !crate::resource::slot_evicting(), TextureQueue::room() is never called once slot_evicting() wedges true. Every evicted live bindless texture stays permanently black.
    • (This exact slot_evicting() wedge also caused the 1440p final_waiting regression 1,653 -> 2,512: 1440p peaked at 5,884 / 6,662 MB = 88.3% > 86% with 0 evictions, wedged EVICTING = true above 80%, and blocked texture_slots_room() for 888 frames despite room_false = 0.0%.)
    • (Note: PR #291's unmapped_pinned path at resource.rs:2855-2876 / descriptor.rs:2024-2040 worked cleanly — diag logged 0 MB of unmapped textures still pinned by descriptor slots. The black silhouettes came 100% from slot_evict evicting mapped bindless slots.)

2. Why 4K GPU Time Exploded 7.2 -> 97.6 ms and mapped() Exploded 7.6 -> 35–57 ms/s

Telemetry proves 93–95% of ReBAR GPU_UPLOAD write-combined buffers and ~330 hot card shadow buffers were forced out of local VRAM into system RAM over PCIe:

Metric main 4K (27aa2ae4) PR #291 1440p PR #291 4K (r3) PR #291 4K (diag)
VICTORY_CARD_BUFFERS_MB 1024 MiB 1024 MiB 512 MiB 512 MiB
VICTORY_CARD_ROOM_FOR_TARGETS_MB 512 MiB 512 MiB 2048 MiB 2048 MiB
ReBAR GPU_UPLOAD WC buffers (wc_mapped_for) 2,898 (621.0 MB) 2,919 (626.4 MB) 192 (308.9 MB, -93.4%) 136 (314.5 MB, -95.3%)
Card shadow copies (host copies in card memory) 514 (1,356 MB) 522 (1,352 MB) 185 (844 MB) 164 (844 MB)
GPU time / frame 7.2 ms 0.0 ms 97.6 ms (+90.4 ms) 94.3 ms (+87.1 ms)
Submitting thread waiting for flights 0.0 ms 0.0 ms 108.5 ms ~100+ ms
mapped() rate / total 7.6 ms/s (1,851 ms / 16,000) 7.32 ms/s (1,373 ms / 16,800) 35.19 ms/s (3,225 ms / 16,200) 57.62 ms/s (5,998 ms / 19,800)
  • Exact mechanism (apps/victory/src/play.rs:440, 442, scripts/verify-world.ps1:174, 176, crates/victory-gpu/src/shadow.rs:546-588, 3174-3203):
    1. CARD_BYTES[0] is shared by both card_room_for() (shadow.rs:586) and wc_mapped_for() (shadow.rs:3200) against most = VICTORY_CARD_BUFFERS_MB. Cutting it to 512 MiB on 4K (plus subtracting targets_room_kept = 2048 MiB against a 92% ceiling in shadow.rs:549-562, 3183-3196) hit the 512 MiB wall on frame 2268 (the first 3D world frame, 314.5 MB WC + 197.5 MB card copies = 512 MB).
    2. From frame 2268 onward, 2,706–2,762 write-combined geometry/vertex/meshlet/constant buffers (~310 MB) and ~330 shader buffers (~200 MB) silently fell back (shadow.rs:588, 3198, 3202) to CPU shared_buffers (D3D12_HEAP_TYPE_CUSTOM L0 over PCIe).
    3. Shaders reading ~512 MB of hot per-frame buffers over PCIe (~12–24 GB/s) instead of local VRAM (~288 GB/s) blew GPU time up 7.2 -> 97.6–122.3 ms, blocking the submitting thread 108.5 ms/frame on flights and regressing copyback (10.0 -> 13.5 ms, as non-carded buffers fall back to CPU scan + wait behind the 97 ms GPU).
    4. host::mapped() submits on ASIDE copy queue sharing PCIe/WDDM scheduling with the 97 ms PCIe-saturated GPU, inflating per-call latency from 0.09 ms/call to 0.81 ms/call in late diag (+4,716 ms across the final 5,800 calls). (Note: PR #291 is also based on 27aa2ae4 pre-#289; rebasing onto main c15df49b eliminates >95% of ahead mapped() calls automatically.)

3. Minimal, Default-On Architectural Fix Blueprint

  1. Rebase onto main (c15df49b, post-#289) & restore 4K card/ReBAR WC buffer residency:
    • Keep VICTORY_CARD_BUFFERS_MB = 1024 on 4K (play.rs:440, verify-world.ps1:174) and remove the SMALL_VRAM_CEILING targets_room_kept subtraction / 92% throttle from shadow.rs:546-562 and shadow.rs:3180-3196 (reserve targets_room_kept exclusively for resource::room()'s texture queue — never starve wc_mapped_for()). Hot WC geometry/constant buffers cost 10–20× more GPU ms per MiB over PCIe than texture mip streaming.
    • Optional safeguard: if CARD_BYTES[0] ever approaches most, reserve a dedicated slice (e.g., 640 MiB) or priority for ReBAR wc_mapped_for() over large cold card_room_for() buffers.
  2. Keep unmapped_pinned cleanup (resource.rs:2855-2876, descriptor.rs:2024-2040), but NEVER evict mapped bindless (stamp == 0) textures to NULL:
    • Tier A (Unmapped placed textures — safe even for stamp == 0): Keep evict_unmapped_resource_slots() + evict_idle_host_with(..., false) (with seen_mapped / !committed + IDLE_FRAMES age guard), and raise the 512-per-sweep cap when used >= high so scene-out unmaps drain immediately.
    • Tier B (Cold tabled textures — allow_bindless = false): Keep descriptor/host.rs:3628's fix (!is_bindless || allow_bindless, dropping the broken tabled_lately(i) 240-frame cutoff), and pass allow_bindless = false in slot_evict() (resource.rs:3123). Tabled slots automatically re-upload via WAITING + HostHeap::mirror_after() if re-bound.
    • Remove evicted_bindless, park_evicted(), texture_slot_evicted_bindless(), and the !slot_evicting() gate in draw.rs:3494.
    • Fix slot_evict hysteresis & caps (resource.rs:3073-3081): Drop the u64::MAX cap lift and 88% idle_ms bypass, and immediately clear EVICTING = false (SLOT_STATE[0] = 0) whenever a sweep finds 0 evictable bytes — eliminating both the 1440p final_waiting regression and permanently-wedged eviction state.
  3. Actually free 64 MiB pool blocks (pool_given_back > 0) & shed 8 GiB 4K / 12 GiB FG VRAM safely without NULL SRVs:
    • Whole-block-first eviction (pool.rs:857, resource.rs:2997): Return (block_idx, block_used) from pool::block_used_bytes(), group evictable candidates by block_idx, and prioritize blocks where evictable_bytes_in_block == block_used so pool.rs:604 (b.free.whole(BLOCK)) actually frees whole 64 MiB ID3D12Heaps back to DXGI instead of leaving 15 Swiss-cheese blocks.
    • Safe bindless VRAM relief (replace-in-place mip drop, NEVER NULL): For 8 GiB 4K and 12 GiB long-session FG pressure (used >= 88% after Tier A + Tier B), shed VRAM on large (>= 1–2 MiB) bindless textures by clamping top mip(s) (first_mip += 1) on newly created large bindless textures (and/or atomically swapping cold >= 2 MiB bindless SRVs to a 1/4-VRAM lower-mip host copy before retiring the full-res copy). That cuts large bindless texture VRAM by 75% with zero NULL descriptors and zero black silhouettes, while leaving 16 GiB+ GPUs (and 8–12 GiB GPUs below 88% budget) 100% untouched at full resolution and zero CPU cost.
**@⁠Androtim** on GitHub · 2026-12-01 17:45 UTC · [original](https://github.com/Androtim/MiniVI/pull/291#issuecomment-7319807113) ### Root-Cause Audit (`e394a7df`) Both 4K regressions and the 1440p `final_waiting` regression trace directly to two distinct, provable mechanisms in PR `#291`: --- ### 1. Why `diag-vram-reclaim-4k-90s` Produces Pitch-Black Silhouettes (`near_black = 32.84%`) A 4-step causal chain permanently replaces ~30,000 live scene bindless textures with `NULL` (`0,0,0,0`) SRVs: 1. **Zero live-use tracking for bindless textures (`crates/victory-gpu/src/descriptor/host.rs:3626-3629`, `crates/victory-gpu/src/resource.rs:3102-3123`):** - Bindless textures (`tabled_stamp(i) == 0`) are sampled directly by shader index from material buffers — never via dynamic table copies — so `seen_since(0, cutoff, frame)` is **always `false`**, and `r.host.used` is only stamped once at initial upload/creation (`hosted()`), never updated on shader reads. - Passing `allow_bindless = true` (`resource.rs:3123`) plus lifting the per-sweep cap to `u64::MAX` above 90% (`resource.rs:3073`) and bypassing `idle_ms` at 88% (`resource.rs:3081`) causes `evict_covering()` (`resource.rs:2997-3014`) to sort by oldest `r.host.used` and **evict the longest-lived live scene/foreground textures first**: `diag` evicted **`30,575` host copies (`1,251 MB`)** (`r3`: **`33,704`**, `1,267 MB`), leaving only `8,834` (`706 MB`) alive in the entire 4K world (`only 654 made again`). 2. **Eviction turns 64 MiB pool blocks into Swiss cheese (`pool_given_back == 0`):** - `crates/victory-gpu/src/pool.rs:604` only returns a 64 MiB `ID3D12Heap` to D3D12 when `b.free.whole(BLOCK)` (100% empty). - Because each block retains a few non-evictable/recent textures, `diag` ends with **`27` blocks (`1,728 MB`), `1,021 MB` free (`15` blocks under 25% full holding just `38 MB` total — ~2.5 MB/block!), and `pool_given_back = 0`**. DXGI `used` therefore **never drops** (`6,222 -> 6,269 MB`, ~92% of `6,786 MB`). 3. **Unreachable `low` mark wedges `EVICTING = true` forever (`apps/victory/src/play.rs:427-432`, `resource.rs:3072-3076`):** - At 4K on 8 GiB, fixed live allocations alone (`2,595 MB` render targets/UAVs + `844 MB` card buffers + `1,728 MB` texture blocks with 0 returned + D3D12 overhead = `~6,100–6,269 MB`) sit permanently above `VICTORY_SLOT_EVICT_LOW_PERCENT = 74` (`~4,958 MB`). `SLOT_STATE[0]` (`slot_evicting()`) therefore stays **`true` indefinitely**. 4. **Parked bindless slots never return (`descriptor/host.rs:1740-1763, 3655-3693`, `descriptor.rs:1998-2013`, `draw.rs:3494`):** - `texture_slot_evicted_bindless()` calls `unmake(index)` (writing a `NULL` SRV into the live GPU descriptor heap -> `0,0,0,0` black) and parks `index` in `evicted_bindless` (NOT `WAITING`). - Because `draw.rs:3494` gates `host.texture_slots_room(frame)` on `if room && !crate::resource::slot_evicting()`, `TextureQueue::room()` is **never called** once `slot_evicting()` wedges `true`. Every evicted live bindless texture stays permanently black. - *(This exact `slot_evicting()` wedge also caused the 1440p `final_waiting` regression `1,653 -> 2,512`: 1440p peaked at `5,884 / 6,662 MB = 88.3% > 86%` with `0` evictions, wedged `EVICTING = true` above `80%`, and blocked `texture_slots_room()` for 888 frames despite `room_false = 0.0%`.)* - *(Note: PR `#291`'s `unmapped_pinned` path at `resource.rs:2855-2876` / `descriptor.rs:2024-2040` worked cleanly — `diag` logged `0 MB` of unmapped textures still pinned by descriptor slots. The black silhouettes came 100% from `slot_evict` evicting **mapped** bindless slots.)* --- ### 2. Why 4K GPU Time Exploded `7.2 -> 97.6 ms` and `mapped()` Exploded `7.6 -> 35–57 ms/s` Telemetry proves **93–95% of ReBAR `GPU_UPLOAD` write-combined buffers and ~330 hot card shadow buffers were forced out of local VRAM into system RAM over PCIe**: | Metric | `main` 4K (`27aa2ae4`) | PR `#291` 1440p | PR `#291` 4K (`r3`) | PR `#291` 4K (`diag`) | |---|---:|---:|---:|---:| | `VICTORY_CARD_BUFFERS_MB` | `1024 MiB` | `1024 MiB` | **`512 MiB`** | **`512 MiB`** | | `VICTORY_CARD_ROOM_FOR_TARGETS_MB` | `512 MiB` | `512 MiB` | **`2048 MiB`** | **`2048 MiB`** | | ReBAR `GPU_UPLOAD` WC buffers (`wc_mapped_for`) | **`2,898` (`621.0 MB`)** | **`2,919` (`626.4 MB`)** | **`192` (`308.9 MB`, -93.4%)** | **`136` (`314.5 MB`, -95.3%)** | | Card shadow copies (`host copies in card memory`) | **`514` (`1,356 MB`)** | **`522` (`1,352 MB`)** | **`185` (`844 MB`)** | **`164` (`844 MB`)** | | GPU time / frame | **`7.2 ms`** | **`0.0 ms`** | **`97.6 ms` (+90.4 ms)** | **`94.3 ms` (+87.1 ms)** | | Submitting thread `waiting for flights` | `0.0 ms` | `0.0 ms` | **`108.5 ms`** | **`~100+ ms`** | | `mapped()` rate / total | `7.6 ms/s` (`1,851 ms` / `16,000`) | `7.32 ms/s` (`1,373 ms` / `16,800`) | **`35.19 ms/s`** (`3,225 ms` / `16,200`) | **`57.62 ms/s`** (`5,998 ms` / `19,800`) | - **Exact mechanism (`apps/victory/src/play.rs:440, 442`, `scripts/verify-world.ps1:174, 176`, `crates/victory-gpu/src/shadow.rs:546-588, 3174-3203`):** 1. `CARD_BYTES[0]` is shared by **both** `card_room_for()` (`shadow.rs:586`) and `wc_mapped_for()` (`shadow.rs:3200`) against `most = VICTORY_CARD_BUFFERS_MB`. Cutting it to `512 MiB` on 4K (plus subtracting `targets_room_kept = 2048 MiB` against a `92%` ceiling in `shadow.rs:549-562, 3183-3196`) hit the `512 MiB` wall on **frame 2268** (the first 3D world frame, `314.5 MB` WC + `197.5 MB` card copies = `512 MB`). 2. From frame 2268 onward, **`2,706–2,762` write-combined geometry/vertex/meshlet/constant buffers (`~310 MB`)** and **`~330` shader buffers (`~200 MB`)** silently fell back (`shadow.rs:588, 3198, 3202`) to CPU `shared_buffer`s (`D3D12_HEAP_TYPE_CUSTOM` L0 over PCIe). 3. Shaders reading ~512 MB of hot per-frame buffers over PCIe (~12–24 GB/s) instead of local VRAM (~288 GB/s) blew GPU time up **`7.2 -> 97.6–122.3 ms`**, blocking the submitting thread `108.5 ms/frame` on flights and regressing `copyback` (`10.0 -> 13.5 ms`, as non-carded buffers fall back to CPU scan + wait behind the 97 ms GPU). 4. `host::mapped()` submits on `ASIDE` copy queue sharing PCIe/WDDM scheduling with the 97 ms PCIe-saturated GPU, inflating per-call latency from `0.09 ms/call` to **`0.81 ms/call`** in late `diag` (`+4,716 ms` across the final `5,800` calls). *(Note: PR `#291` is also based on `27aa2ae4` pre-`#289`; rebasing onto `main` `c15df49b` eliminates >95% of `ahead` `mapped()` calls automatically.)* --- ### 3. Minimal, Default-On Architectural Fix Blueprint 1. **Rebase onto `main` (`c15df49b`, post-`#289`) & restore 4K card/ReBAR WC buffer residency:** - Keep `VICTORY_CARD_BUFFERS_MB = 1024` on 4K (`play.rs:440`, `verify-world.ps1:174`) and remove the `SMALL_VRAM_CEILING` `targets_room_kept` subtraction / `92%` throttle from `shadow.rs:546-562` and `shadow.rs:3180-3196` (reserve `targets_room_kept` exclusively for `resource::room()`'s texture queue — never starve `wc_mapped_for()`). Hot WC geometry/constant buffers cost 10–20× more GPU ms per MiB over PCIe than texture mip streaming. - Optional safeguard: if `CARD_BYTES[0]` ever approaches `most`, reserve a dedicated slice (e.g., `640 MiB`) or priority for ReBAR `wc_mapped_for()` over large cold `card_room_for()` buffers. 2. **Keep `unmapped_pinned` cleanup (`resource.rs:2855-2876`, `descriptor.rs:2024-2040`), but NEVER evict mapped bindless (`stamp == 0`) textures to `NULL`:** - **Tier A (Unmapped placed textures — safe even for `stamp == 0`):** Keep `evict_unmapped_resource_slots()` + `evict_idle_host_with(..., false)` (with `seen_mapped` / `!committed` + `IDLE_FRAMES` age guard), and raise the `512`-per-sweep cap when `used >= high` so scene-out unmaps drain immediately. - **Tier B (Cold tabled textures — `allow_bindless = false`):** Keep `descriptor/host.rs:3628`'s fix (`!is_bindless || allow_bindless`, dropping the broken `tabled_lately(i)` 240-frame cutoff), and pass **`allow_bindless = false`** in `slot_evict()` (`resource.rs:3123`). Tabled slots automatically re-upload via `WAITING` + `HostHeap::mirror_after()` if re-bound. - **Remove** `evicted_bindless`, `park_evicted()`, `texture_slot_evicted_bindless()`, and the `!slot_evicting()` gate in `draw.rs:3494`. - **Fix `slot_evict` hysteresis & caps (`resource.rs:3073-3081`):** Drop the `u64::MAX` cap lift and `88%` `idle_ms` bypass, and immediately clear `EVICTING = false` (`SLOT_STATE[0] = 0`) whenever a sweep finds `0` evictable bytes — eliminating both the 1440p `final_waiting` regression and permanently-wedged eviction state. 3. **Actually free 64 MiB pool blocks (`pool_given_back > 0`) & shed 8 GiB 4K / 12 GiB FG VRAM safely without `NULL` SRVs:** - **Whole-block-first eviction (`pool.rs:857`, `resource.rs:2997`):** Return `(block_idx, block_used)` from `pool::block_used_bytes()`, group evictable candidates by `block_idx`, and prioritize blocks where `evictable_bytes_in_block == block_used` so `pool.rs:604` (`b.free.whole(BLOCK)`) actually frees whole 64 MiB `ID3D12Heap`s back to DXGI instead of leaving 15 Swiss-cheese blocks. - **Safe bindless VRAM relief (replace-in-place mip drop, NEVER `NULL`):** For 8 GiB 4K and 12 GiB long-session FG pressure (`used >= 88%` after Tier A + Tier B), shed VRAM on large (`>= 1–2 MiB`) bindless textures by **clamping top mip(s) (`first_mip += 1`)** on newly created large bindless textures (and/or atomically swapping cold `>= 2 MiB` bindless SRVs to a `1/4`-VRAM lower-mip host copy before retiring the full-res copy). That cuts large bindless texture VRAM by **75%** with **zero `NULL` descriptors and zero black silhouettes**, while leaving 16 GiB+ GPUs (and 8–12 GiB GPUs below 88% budget) 100% untouched at full resolution and zero CPU cost.
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 18:04 UTC · original · edited 2026-12-01 19:03 UTC

Automated triage for the maintainers (not an approval).

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

Automated PR Review — needs-gpu-test

CI is passing, lock-ordering changes are sound, and the new unit tests cover the core budget/reservation/slot-classification logic. Because this PR enables VICTORY_SLOT_EVICT by default, adds IDXGIAdapter3::SetVideoMemoryReservation (VICTORY_VRAM_RESERVE), changes VRAM budget guards in shadow.rs/resource.rs, and updates 4K low-VRAM launcher defaults, it warrants a local real-GPU smoke test before merging.

What looks good

  • Deadlock fix (crates/victory-gpu/src/resource.rs): Staging slot_evict and let_go_idle's unmapped_pinned path into lock-ordered phases (dropping textures() before descriptor::* / pool::* calls, re-checking all.contains(&at) under textures(), and deferring descriptor::texture_made until after textures() is dropped) cleanly breaks the textures() <-> HostHeap::made AB-BA cycle.
  • Floor & small-VRAM guards (crates/victory-gpu/src/resource.rs, crates/victory-gpu/src/shadow.rs): floor_allows_room and block_room_fits stop the texture floor from bypassing real DXGI headroom (REAL_MARGIN / room_line), and card_room_for / wc_mapped_for reserve targets_room_kept under a 92% ceiling only when budget <= 9 GiB, leaving >9 GiB GPUs unchanged.
  • DXGI reservation (crates/victory-gpu/src/residency.rs, crates/victory-gpu/src/host.rs): reserve_vram uses a 64 MiB hysteresis band in reservation_target, logs failures once, and provides a VICTORY_VRAM_RESERVE=0 kill-switch.
  • Accounting (crates/victory-gpu/src/resource.rs): card_accounting now respects host.base so dropped top mips are not miscounted as unmapped.

Minor notes / polish

  1. apps/victory/src/play.rs (settings_with_vram, L422-L424) vs scripts/verify-world.ps1 (L1772): When low_vram && is_4k && framegen, play.rs unconditionally sets VICTORY_TEXTURE_ROOM_PERCENT=88, overwriting the 86 set for framegen at L393. verify-world.ps1 guards this with if ($is4k -and -not $FrameGen). Consider if is_4k && !framegen in play.rs for parity.
  2. crates/victory-gpu/src/resource.rs (let_go_idle, unmapped_pinned): If evict_idle_host_with(..., false) returns None due to a concurrent use between Phase 2 (evict_unmapped_resource_slots) and Phase 3, the slot has already been unmade without being added to WAITING or restored. Very narrow window given mapped_bytes == 0, but worth noting.
  3. Stale docs/description:
    • crates/victory-gpu/src/descriptor/host.rs (slots_showing_from_raws) doc comment lists a 5-tuple (index, raw, evictable, seen_recently, is_bindless) while the function returns a 4-tuple Vec<(u32, usize, bool, bool)>.
    • The PR body references an earlier iteration (evicted_bindless, slot_evicting(), 90%/88% thresholds, and 84/80/74/512 4K defaults), whereas the diff keeps live bindless slots protected (allow_bindless = false in slot_evict), uses 92%/95% thresholds, and sets 88/85/78/384/128/2048.

Note: This is an automated technical review and does not constitute formal maintainer approval.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-12-01 18:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/291#issuecomment-7320354186) · edited 2026-12-01 19:03 UTC <!-- minivi-triage v1 head=66c855b146a95afd990dc195b42ece08db6f20ea verdict=needs-gpu-test ci=passing at=2026-12-01T19:04:19Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Automated PR Review — `needs-gpu-test` CI is passing, lock-ordering changes are sound, and the new unit tests cover the core budget/reservation/slot-classification logic. Because this PR enables `VICTORY_SLOT_EVICT` by default, adds `IDXGIAdapter3::SetVideoMemoryReservation` (`VICTORY_VRAM_RESERVE`), changes VRAM budget guards in `shadow.rs`/`resource.rs`, and updates 4K low-VRAM launcher defaults, it warrants a local real-GPU smoke test before merging. #### What looks good - **Deadlock fix (`crates/victory-gpu/src/resource.rs`)**: Staging `slot_evict` and `let_go_idle`'s `unmapped_pinned` path into lock-ordered phases (dropping `textures()` before `descriptor::*` / `pool::*` calls, re-checking `all.contains(&at)` under `textures()`, and deferring `descriptor::texture_made` until after `textures()` is dropped) cleanly breaks the `textures()` <-> `HostHeap::made` AB-BA cycle. - **Floor & small-VRAM guards (`crates/victory-gpu/src/resource.rs`, `crates/victory-gpu/src/shadow.rs`)**: `floor_allows_room` and `block_room_fits` stop the texture floor from bypassing real DXGI headroom (`REAL_MARGIN` / `room_line`), and `card_room_for` / `wc_mapped_for` reserve `targets_room_kept` under a 92% ceiling only when `budget <= 9 GiB`, leaving >9 GiB GPUs unchanged. - **DXGI reservation (`crates/victory-gpu/src/residency.rs`, `crates/victory-gpu/src/host.rs`)**: `reserve_vram` uses a 64 MiB hysteresis band in `reservation_target`, logs failures once, and provides a `VICTORY_VRAM_RESERVE=0` kill-switch. - **Accounting (`crates/victory-gpu/src/resource.rs`)**: `card_accounting` now respects `host.base` so dropped top mips are not miscounted as unmapped. #### Minor notes / polish 1. **`apps/victory/src/play.rs` (`settings_with_vram`, L422-L424) vs `scripts/verify-world.ps1` (L1772)**: When `low_vram && is_4k && framegen`, `play.rs` unconditionally sets `VICTORY_TEXTURE_ROOM_PERCENT=88`, overwriting the `86` set for `framegen` at L393. `verify-world.ps1` guards this with `if ($is4k -and -not $FrameGen)`. Consider `if is_4k && !framegen` in `play.rs` for parity. 2. **`crates/victory-gpu/src/resource.rs` (`let_go_idle`, `unmapped_pinned`)**: If `evict_idle_host_with(..., false)` returns `None` due to a concurrent use between Phase 2 (`evict_unmapped_resource_slots`) and Phase 3, the slot has already been unmade without being added to `WAITING` or restored. Very narrow window given `mapped_bytes == 0`, but worth noting. 3. **Stale docs/description**: - `crates/victory-gpu/src/descriptor/host.rs` (`slots_showing_from_raws`) doc comment lists a 5-tuple `(index, raw, evictable, seen_recently, is_bindless)` while the function returns a 4-tuple `Vec<(u32, usize, bool, bool)>`. - The PR body references an earlier iteration (`evicted_bindless`, `slot_evicting()`, 90%/88% thresholds, and `84/80/74/512` 4K defaults), whereas the diff keeps live bindless slots protected (`allow_bindless = false` in `slot_evict`), uses 92%/95% thresholds, and sets `88/85/78/384/128/2048`. *Note: This is an automated technical review and does not constitute formal maintainer approval.* --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 18:41 UTC · original

Updated PR #291 on commit 66c855b1 (rebased onto main c15df49b) to address the triage: needs work review, eliminate the black-silhouette regression, and achieve over = 0 MB on 8 GiB 4K & 1440p.

Root Fixes Applied

  1. Removed live bindless eviction (allow_bindless = false): Stripped evicted_bindless, park_evicted, texture_slot_evicted_bindless, and the slot_evicting() gate across descriptor/host.rs, descriptor.rs, draw.rs, and resource.rs. let_go_idle now reclaims slot-pinned copies only when mapped_bytes == 0 across the full mip chain, and retains the AB-BA textures() <-> HostHeap::made lock-order fix.
  2. Dynamic DXGI local VRAM reservation (VICTORY_VRAM_RESERVE=0 kill-switch): Added reserve_vram / reservation_target in residency.rs and wired into host.rs (create and sweep) so WDDM prioritizes the active local VRAM working set.
  3. Real VRAM headroom gate on texture_floor_bytes + host.base-aware accounting: Added floor_allows_room and block_room_fits in resource.rs so the 25% texture floor never bypasses room_line(budget) for new 64 MiB pool blocks or budget - REAL_MARGIN when VRAM is already full (used_max dropped -627 MB at 4K). Updated card_accounting to respect host.base instead of counting already-omitted top mips as unmapped.
  4. 4K 8 GiB card-buffer caps: Tightened low_vram && is_4k defaults in apps/victory/src/play.rs and scripts/verify-world.ps1 to VICTORY_CARD_BUFFERS_MB=384, VICTORY_CARD_WINDOWS_MB=128, and VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048 (1440p and >=10 GB cards remain untouched).

Static & Policy Checks

  • crates/victory-gpu/src/host.rs: 646,836 bytes (<= 655,360 bytes)
  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: 318 files ok
  • Targeted unit tests (--locked): victory-gpu --lib resource:: (36 passed), descriptor::host:: (64 passed), residency:: (4 passed), -p victory (40 + 2 passed)
  • Dual clippy --workspace --locked --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
  • objdump -p: standard Windows DLLs only

Verified Benchmarks (RTX 4060 Ti 8 GB / Series X / DLSS Quality)

  • 4K Plain --release (60s, paired-291-final-4k-60s vs main c15df49b):
    • used_max: 7,059 -> 6,432 MB (-627 MB), over: 275 -> 0 MB
    • FPS: 6.6 -> 6.5 fps ([PASS] A/B FPS non-regression)
    • preparing: 28.5 -> 20.1 ms | copyback: 17.4 -> 14.3 ms | mapped_rate: 3.06 -> 2.59 ms/s
    • uploaded: 47,011 -> 61,170 | crashes: 0
  • 1440p Plain --release (60s, paired-291-final-1440p-60s vs main c15df49b):
    • FPS: 15.05 -> 15.4 fps (+0.35 fps)
    • used_max: 6,406 -> 6,083 MB (-323 MB, over = 0 MB)
    • final_waiting: 2,665 -> 2,414 (-251)
    • preparing: 27.7 -> 27.0 ms | copyback: 11.2 -> 10.5 ms | mapped_rate: 10.21 -> 7.17 ms/s | crashes: 0
  • 4K Diagnostics Visual Check (90s, diag-291-final-4k-90s) + D3D12 Debug Check (bisect-noskip-d3ddebug):
    • crashes = 0, over = 0 MB, failed = 0, near_black: 32.84% -> 0.2%, luma = 107.38, lit = 17/24.
    • Visual PNG inspection confirms the world, house, greenery, ocean, clothing, and HUD render lit and textured cleanly; note that on 8 GiB at 4K (where 4K render targets + DLSS use ~4.18 GB), late-arriving character skin textures can still wait behind room=false until tiled levels_on_demand lands, while 1440p stays at room_false = 8.3% and final_waiting = 2,414.
**@⁠Androtim** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/Androtim/MiniVI/pull/291#issuecomment-7321357962) Updated PR #291 on commit `66c855b1` (rebased onto `main` `c15df49b`) to address the `triage: needs work` review, eliminate the black-silhouette regression, and achieve `over = 0 MB` on 8 GiB 4K & 1440p. ### Root Fixes Applied 1. **Removed live bindless eviction (`allow_bindless = false`):** Stripped `evicted_bindless`, `park_evicted`, `texture_slot_evicted_bindless`, and the `slot_evicting()` gate across `descriptor/host.rs`, `descriptor.rs`, `draw.rs`, and `resource.rs`. `let_go_idle` now reclaims slot-pinned copies only when `mapped_bytes == 0` across the full mip chain, and retains the AB-BA `textures()` <-> `HostHeap::made` lock-order fix. 2. **Dynamic DXGI local VRAM reservation (`VICTORY_VRAM_RESERVE=0` kill-switch):** Added `reserve_vram` / `reservation_target` in `residency.rs` and wired into `host.rs` (`create` and `sweep`) so WDDM prioritizes the active local VRAM working set. 3. **Real VRAM headroom gate on `texture_floor_bytes` + `host.base`-aware accounting:** Added `floor_allows_room` and `block_room_fits` in `resource.rs` so the 25% texture floor never bypasses `room_line(budget)` for new 64 MiB pool blocks or `budget - REAL_MARGIN` when VRAM is already full (`used_max` dropped `-627 MB` at 4K). Updated `card_accounting` to respect `host.base` instead of counting already-omitted top mips as unmapped. 4. **4K 8 GiB card-buffer caps:** Tightened `low_vram && is_4k` defaults in `apps/victory/src/play.rs` and `scripts/verify-world.ps1` to `VICTORY_CARD_BUFFERS_MB=384`, `VICTORY_CARD_WINDOWS_MB=128`, and `VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048` (1440p and >=10 GB cards remain untouched). ### Static & Policy Checks - `crates/victory-gpu/src/host.rs`: `646,836` bytes (`<= 655,360` bytes) - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `318 files ok` - Targeted unit tests (`--locked`): `victory-gpu --lib resource::` (`36 passed`), `descriptor::host::` (`64 passed`), `residency::` (`4 passed`), `-p victory` (`40 + 2 passed`) - Dual `clippy --workspace --locked --all-targets -- -D warnings` (default + `--features diagnostics`): 0 warnings - `objdump -p`: standard Windows DLLs only ### Verified Benchmarks (RTX 4060 Ti 8 GB / Series X / DLSS Quality) - **4K Plain `--release` (60s, `paired-291-final-4k-60s` vs `main` `c15df49b`):** - `used_max`: `7,059 -> 6,432 MB` (**`-627 MB`**), **`over`: `275 -> 0 MB`** - `FPS`: `6.6 -> 6.5 fps` (`[PASS] A/B FPS non-regression`) - `preparing`: `28.5 -> 20.1 ms` | `copyback`: `17.4 -> 14.3 ms` | `mapped_rate`: `3.06 -> 2.59 ms/s` - `uploaded`: `47,011 -> 61,170` | `crashes`: `0` - **1440p Plain `--release` (60s, `paired-291-final-1440p-60s` vs `main` `c15df49b`):** - `FPS`: `15.05 -> 15.4 fps` (**`+0.35 fps`**) - `used_max`: `6,406 -> 6,083 MB` (**`-323 MB`**, **`over = 0 MB`**) - `final_waiting`: `2,665 -> 2,414` (`-251`) - `preparing`: `27.7 -> 27.0 ms` | `copyback`: `11.2 -> 10.5 ms` | `mapped_rate`: `10.21 -> 7.17 ms/s` | `crashes`: `0` - **4K Diagnostics Visual Check (90s, `diag-291-final-4k-90s`) + D3D12 Debug Check (`bisect-noskip-d3ddebug`):** - `crashes = 0`, `over = 0 MB`, `failed = 0`, `near_black`: `32.84% -> 0.2%`, `luma = 107.38`, `lit = 17/24`. - Visual PNG inspection confirms the world, house, greenery, ocean, clothing, and HUD render lit and textured cleanly; note that on 8 GiB at 4K (where 4K render targets + DLSS use ~4.18 GB), late-arriving character skin textures can still wait behind `room=false` until tiled `levels_on_demand` lands, while 1440p stays at `room_false = 8.3%` and `final_waiting = 2,414`.
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 19:10 UTC · original

Architect & Strict-Gate Review (66c855b1, CI passing, minivi-triage verified, host.rs = 646,836 <= 655,360 bytes, xtask policy 318 files ok, zero semantic conflict with #285 40567147):

All blocking items from the previous review were cleanly resolved — live bindless eviction removed (allow_bindless = false), textures() <-> HostHeap::made AB-BA deadlock eliminated, dynamic DXGI local VRAM reservation added (VICTORY_VRAM_RESERVE=0 kill-switch), and 8 GiB / 4K guards kept strictly budget-reactive (<= 9 GiB / low_vram only; 16+ GiB cards remain untouched):

  • 1440p Plain --release 60s A/B vs c15df49b:
    • Median FPS: 15.05 -> 15.4 fps (+0.35 fps, mean 13.11 -> 14.25, min 4.5 -> 6.3)
    • Preparing / Copyback / mapped(): 27.7 -> 27.0 ms (-0.7 ms) / 11.2 -> 10.5 ms (-0.7 ms) / 10.21 -> 7.17 ms/s (-29.8%)
    • VRAM & Queue: 6,406 -> 6,083 MB (-323 MB, over = 0 MB), final_waiting 2,665 -> 2,414 (-251, uploaded +7,448)
  • 1440p -> 4K Lab Spec Plain --release 60s A/B vs c15df49b:
    • VRAM: 7,059 -> 6,432 MB (-627 MB, over: 275 -> 0 MB)
    • Preparing / Copyback / mapped(): 28.5 -> 20.1 ms (-8.4 ms) / 17.4 -> 14.3 ms (-3.1 ms) / 3.06 -> 2.59 ms/s
    • Uploaded / FPS: 47,011 -> 61,170 (+30%), 6.6 -> 6.5 fps (parity while eliminating 275 MB overflow)
  • Visuals & Stability: near_black slashed 32.84% -> 0.2% (luma = 107.38, edge_energy = 8.06, magenta = 0.0%), 0 crashes/DRED, untranslated = 6 -> 6, D3D12 debug-layer check clean. (Note: minor follow-ups from minivi-triage — if is_4k && !framegen parity in play.rs, slots_showing_from_raws doc comment — can be folded into a future pass.)

Squash-merging into main (will tag v2026.12.01.03 once main CI passes cleanly).

**@⁠Androtim** on GitHub · 2026-12-01 19:10 UTC · [original](https://github.com/Androtim/MiniVI/pull/291#issuecomment-7322311253) Architect & Strict-Gate Review (`66c855b1`, CI passing, `minivi-triage` verified, `host.rs = 646,836 <= 655,360` bytes, `xtask policy` `318 files ok`, zero semantic conflict with `#285` `40567147`): All blocking items from the previous review were cleanly resolved — live bindless eviction removed (`allow_bindless = false`), `textures()` <-> `HostHeap::made` AB-BA deadlock eliminated, dynamic DXGI local VRAM reservation added (`VICTORY_VRAM_RESERVE=0` kill-switch), and 8 GiB / 4K guards kept strictly budget-reactive (`<= 9 GiB` / `low_vram` only; 16+ GiB cards remain untouched): - **1440p Plain `--release` 60s A/B vs `c15df49b`:** - **Median FPS:** `15.05 -> 15.4 fps` (**`+0.35 fps`**, `mean 13.11 -> 14.25`, `min 4.5 -> 6.3`) - **Preparing / Copyback / `mapped()`:** `27.7 -> 27.0 ms` (`-0.7 ms`) / `11.2 -> 10.5 ms` (`-0.7 ms`) / `10.21 -> 7.17 ms/s` (`-29.8%`) - **VRAM & Queue:** `6,406 -> 6,083 MB` (**`-323 MB`, `over = 0 MB`**), `final_waiting` `2,665 -> 2,414` (**`-251`**, `uploaded +7,448`) - **1440p -> 4K Lab Spec Plain `--release` 60s A/B vs `c15df49b`:** - **VRAM:** `7,059 -> 6,432 MB` (**`-627 MB`, `over: 275 -> 0 MB`**) - **Preparing / Copyback / `mapped()`:** `28.5 -> 20.1 ms` (`-8.4 ms`) / `17.4 -> 14.3 ms` (`-3.1 ms`) / `3.06 -> 2.59 ms/s` - **Uploaded / FPS:** `47,011 -> 61,170` (`+30%`), `6.6 -> 6.5 fps` (parity while eliminating 275 MB overflow) - **Visuals & Stability:** `near_black` slashed `32.84% -> 0.2%` (`luma = 107.38`, `edge_energy = 8.06`, `magenta = 0.0%`), `0` crashes/DRED, `untranslated = 6 -> 6`, D3D12 debug-layer check clean. *(Note: minor follow-ups from `minivi-triage` — `if is_4k && !framegen` parity in `play.rs`, `slots_showing_from_raws` doc comment — can be folded into a future pass.)* Squash-merging into `main` (will tag `v2026.12.01.03` once `main` CI passes cleanly).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!291
No description provided.