gpu: fence-safe LRU texture eviction and budget-aware mip clamping #1289

Open
github-bot wants to merge 3 commits from github-bot/gh-1289 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 11:01 UTC · original
Vladimir-Human:perf/texture-vram-lru-mipcap → main · +6001 −1874 · 7 files · 3 commits · open

Summary

Addresses VRAM exhaustion ("no room on the card" -> refused texture uploads and black surfaces, plus streaming frame-time spikes) on 8–12 GB VRAM GPUs without overlapping #45 (draw.rs is untouched):

  1. Fence-safe LRU placed/committed texture eviction under DXGI budget pressure (VICTORY_TEXTURE_LRU_EVICT, default on; =0 disables):

    • Tracks last_used_frame and last_fence_value on HostTexture, stamped before ExecuteCommandLists in Host::submit alongside Host::last_signalled.
    • Runs a two-pass TOCTOU-safe LRU eviction (evict_lru_textures_with) over title-filled (fills && !host_wrote) textures when hitting the VRAM budget cap or OOM, requiring last_fence_value <= completed_fence, Arc::strong_count == 1, COM references == 1 (by default never pinned in any live shader-visible HostHeap::kept slot), and a 1,000 ms / 2-frame idle window. All staging and COM references are released outside locks, and HOST_TEXTURES / KINDS / MIP_CLAMP_STATS update synchronously even under VICTORY_REAPER=1.
    • Opt-in cold descriptor-heap slot eviction (VICTORY_TEXTURE_LRU_HEAP_EVICT=1, default off so bindless textures bound once into shader-visible HostHeap slots and read continuously by shaders are never evicted by default): under Host::submitted when no GPU submissions are in flight (evict_if_pressured), safely unmakes cold shader-visible title heap slots and untaken dynamic descriptor-table slots (descriptor::evict_kept_resources / HostHeap::evict_kept), preserving a 240-frame anti-thrash cooldown across texture_slots_room and transparently re-creating + re-uploading from host console memory if drawn again later.
  2. Budget-aware mip-tail clamping (VICTORY_TEXTURE_AUTO_MIP_CLAMP, default off — unchanged unless enabled):

    • VICTORY_TEXTURE_AUTO_MIP_CLAMP=1 (auto): clamps eligible large mip-chained read-only 2D textures to <= 2048 on 8 GiB < budget <= 12 GiB (< 85% pressure) and <= 1024 on budget <= 8 GiB or >= 85% effective budget pressure (leaving > 12 GiB cards with headroom unclamped). Passing an explicit dimension (>= 4, e.g. 1024 or 2048) enforces that cap directly.
    • Preserves title-facing ResourceDesc, footprint(), and console layouts; clamps only the host D3D12 texture (mip_levels > 1, depth_or_array_size == 1, sample_count <= 1, single-plane non-XOR layout, base <= first_tail_mip, and BC 4x4 block alignment).
    • Offsets Staging::detile by base_mip, validates cached Staging shape across upgrades, adjusts explicit Texture2D / Texture2DArray SRV MostDetailedMip / MipLevels / ResourceMinLODClamp, and upgrades cleanly via ensure_unclamped (with deferred SRV rebinding in Host::submit) if touched by an explicit GPU copy or resolve.

Verification

  • cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated (default & --features diagnostics): 0 warnings
  • cargo test -p victory-gpu --lib -- --test-threads=1: 225 passed, 0 failed
  • cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1: 244 passed, 0 failed
  • VICTORY_D3D12_DEBUG=1 + VICTORY_D3D12_WARP=1 + VICTORY_REAPER=1 unit & GPU tests covering:
    • Default VICTORY_TEXTURE_LRU_HEAP_EVICT off (allow_heap_unmake: false): older fence-completed bindless textures held in a live shader-visible HostHeap (references >= 2) are never unmade or evicted under VRAM pressure (evict_if_pressured), while unreferenced (references == 1) fence-completed idle textures evict cleanly
    • In-flight fenced textures held on a GPU queue fence are never evicted early, then evict cleanly once their fence completes
    • Opt-in VICTORY_TEXTURE_LRU_HEAP_EVICT=1 (allow_heap_unmake: true) unmakes cold HostHeap and untaken dynamic table slots under budget cap, respects the 240-frame cooldown across texture_slots_room, does not resurrect in make_waiting(), and transparently detiles/re-uploads updated host bytes on reuse
    • Mip-clamped 2K RGBA8 and 4K BC7 textures create valid D3D12 resources & SRVs on hardware and WARP (>= 19 MiB measured GetResourceAllocationInfo savings per texture), upload the exact clamped console mips, and upgrade + rebind SRVs cleanly on ensure_unclamped
  • cargo run -p xtask -- policy --staged: passed
**@⁠Vladimir-Human** on GitHub · 2026-11-26 11:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289) `Vladimir-Human:perf/texture-vram-lru-mipcap` → `main` · +6001 −1874 · 7 files · 3 commits · open ## Summary Addresses VRAM exhaustion ("no room on the card" -> refused texture uploads and black surfaces, plus streaming frame-time spikes) on 8–12 GB VRAM GPUs without overlapping #45 (`draw.rs` is untouched): 1. **Fence-safe LRU placed/committed texture eviction under DXGI budget pressure** (`VICTORY_TEXTURE_LRU_EVICT`, default on; `=0` disables): - Tracks `last_used_frame` and `last_fence_value` on `HostTexture`, stamped before `ExecuteCommandLists` in `Host::submit` alongside `Host::last_signalled`. - Runs a two-pass TOCTOU-safe LRU eviction (`evict_lru_textures_with`) over title-filled (`fills && !host_wrote`) textures when hitting the VRAM budget cap or OOM, requiring `last_fence_value <= completed_fence`, `Arc::strong_count == 1`, COM `references == 1` (by default never pinned in any live shader-visible `HostHeap::kept` slot), and a 1,000 ms / 2-frame idle window. All staging and COM references are released outside locks, and `HOST_TEXTURES` / `KINDS` / `MIP_CLAMP_STATS` update synchronously even under `VICTORY_REAPER=1`. - Opt-in cold descriptor-heap slot eviction (`VICTORY_TEXTURE_LRU_HEAP_EVICT=1`, **default off** so bindless textures bound once into shader-visible `HostHeap` slots and read continuously by shaders are never evicted by default): under `Host::submitted` when no GPU submissions are in flight (`evict_if_pressured`), safely unmakes cold shader-visible title heap slots and untaken dynamic descriptor-table slots (`descriptor::evict_kept_resources` / `HostHeap::evict_kept`), preserving a 240-frame anti-thrash cooldown across `texture_slots_room` and transparently re-creating + re-uploading from host console memory if drawn again later. 2. **Budget-aware mip-tail clamping** (`VICTORY_TEXTURE_AUTO_MIP_CLAMP`, default off — unchanged unless enabled): - `VICTORY_TEXTURE_AUTO_MIP_CLAMP=1` (`auto`): clamps eligible large mip-chained read-only 2D textures to `<= 2048` on `8 GiB < budget <= 12 GiB` (`< 85%` pressure) and `<= 1024` on `budget <= 8 GiB` or `>= 85%` effective budget pressure (leaving `> 12 GiB` cards with headroom unclamped). Passing an explicit dimension (`>= 4`, e.g. `1024` or `2048`) enforces that cap directly. - Preserves title-facing `ResourceDesc`, `footprint()`, and console layouts; clamps only the host D3D12 texture (`mip_levels > 1`, `depth_or_array_size == 1`, `sample_count <= 1`, single-plane non-XOR layout, `base <= first_tail_mip`, and BC `4x4` block alignment). - Offsets `Staging::detile` by `base_mip`, validates cached `Staging` shape across upgrades, adjusts explicit `Texture2D` / `Texture2DArray` SRV `MostDetailedMip` / `MipLevels` / `ResourceMinLODClamp`, and upgrades cleanly via `ensure_unclamped` (with deferred SRV rebinding in `Host::submit`) if touched by an explicit GPU copy or resolve. ## Verification - `cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated` (default & `--features diagnostics`): 0 warnings - `cargo test -p victory-gpu --lib -- --test-threads=1`: 225 passed, 0 failed - `cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1`: 244 passed, 0 failed - `VICTORY_D3D12_DEBUG=1` + `VICTORY_D3D12_WARP=1` + `VICTORY_REAPER=1` unit & GPU tests covering: - Default `VICTORY_TEXTURE_LRU_HEAP_EVICT` off (`allow_heap_unmake: false`): older fence-completed bindless textures held in a live shader-visible `HostHeap` (`references >= 2`) are never unmade or evicted under VRAM pressure (`evict_if_pressured`), while unreferenced (`references == 1`) fence-completed idle textures evict cleanly - In-flight fenced textures held on a GPU queue fence are never evicted early, then evict cleanly once their fence completes - Opt-in `VICTORY_TEXTURE_LRU_HEAP_EVICT=1` (`allow_heap_unmake: true`) unmakes cold `HostHeap` and untaken dynamic table slots under budget cap, respects the 240-frame cooldown across `texture_slots_room`, does not resurrect in `make_waiting()`, and transparently detiles/re-uploads updated host bytes on reuse - Mip-clamped 2K RGBA8 and 4K BC7 textures create valid D3D12 resources & SRVs on hardware and WARP (`>= 19 MiB` measured `GetResourceAllocationInfo` savings per texture), upload the exact clamped console mips, and upgrade + rebind SRVs cleanly on `ensure_unclamped` - `cargo run -p xtask -- policy --staged`: passed
Prevent VRAM exhaustion and black texture surfaces on 8-12 GB cards when
title-filled textures accumulate in card memory and descriptor heaps:

1. Fence-safe LRU texture eviction under DXGI budget pressure
   (`VICTORY_TEXTURE_LRU_EVICT`, default on, `=0` disables):
   - Track `last_used_frame` and `last_fence_value` on `HostTexture`,
     stamped at submission in `Host::submit` alongside atomic
     `Host::last_signalled`.
   - Evict least-recently-used title-filled (`fills && !host_wrote`)
     textures in two TOCTOU-safe passes once `last_fence_value <=
     completed_fence`, `Arc::strong_count == 1`, and COM `references == 1`,
     respecting a 1,000 ms / 2-frame idle guard and dropping staging/COM
     objects strictly outside locks.
   - Under `Host::submitted` when no submissions are in flight, unmake
     cold shader-visible title slots and untaken dynamic table slots via
     `descriptor::evict_kept_resources` / `HostHeap::evict_kept` (with
     `made_now` cleared first, 240-frame re-queue cooldown preserved
     across `texture_slots_room`, and no premature resurrection in
     `make_waiting`), transparently re-uploading from host console memory
     if sampled again later.

2. Budget-aware mip-tail clamping (`VICTORY_TEXTURE_AUTO_MIP_CLAMP`,
   default off; `1`/`auto` clamps <= 2048 on <= 12 GiB budgets and
   <= 1024 on <= 8 GiB budgets or >= 85% pressure; numeric >= 4 sets an
   explicit max dimension):
   - Keep title-facing `ResourceDesc`, `footprint()`, and console layouts
     unchanged; clamp only eligible single-slice non-MSAA read-only 2D
     host D3D12 textures (`mip_levels > 1`, `base <= first_tail_mip`,
     BC 4x4 block alignment enforced).
   - Offset console mip detiling in `Staging::detile`, validate cached
     `Staging` dimensions/mip counts, shift SRV `MostDetailedMip`,
     `MipLevels`, and `ResourceMinLODClamp` for `Texture2D`/`Texture2DArray`,
     and upgrade cleanly via `ensure_unclamped` + deferred SRV rebinding
     on explicit GPU copies/resolves.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:19:56 +00:00
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 12:10 UTC · original

A/B on the RTX 3080 (same build as our #1279 test + #1287/#1002/#1279, boat mission, ~3 min standing): the room problem goes away (passes that made none for lack of room 5,912 → 100), fps 9.6 → 9.4, VRAM peak 9.3 → 9.4 GB. But the picture regresses: a character's black printed jacket comes out plain grey (its texture replaced), and white/green speckles appear along the hull and the outboard motors; distinct colours per capture ~120k → ~97k. So the eviction (or the mip clamp) seems to drop or lower textures that are still being drawn. No device loss. Happy to rerun with VICTORY_TEXTURE_LRU_EVICT=0 to tell the two parts apart.

**@⁠Garu667** on GitHub · 2026-11-26 12:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289#issuecomment-7191658515) A/B on the RTX 3080 (same build as our #1279 test + #1287/#1002/#1279, boat mission, ~3 min standing): the room problem goes away (`passes that made none for lack of room` 5,912 → 100), fps 9.6 → 9.4, VRAM peak 9.3 → 9.4 GB. But the picture regresses: a character's black printed jacket comes out plain grey (its texture replaced), and white/green speckles appear along the hull and the outboard motors; distinct colours per capture ~120k → ~97k. So the eviction (or the mip clamp) seems to drop or lower textures that are still being drawn. No device loss. Happy to rerun with `VICTORY_TEXTURE_LRU_EVICT=0` to tell the two parts apart.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 12:19 UTC · original

Follow-up, same build and checkpoint with VICTORY_TEXTURE_LRU_EVICT=0 (mip clamp still on): the picture is clean again (the black printed jacket has its print, no speckles on the hull or motors), and passes that made none for lack of room goes back to 5,364 (5,912 without the PR). fps 9.4. So the regression comes from the LRU eviction, not the mip clamp: it seems to evict textures that are still drawn. No device loss either way.

**@⁠Garu667** on GitHub · 2026-11-26 12:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289#issuecomment-7191856218) Follow-up, same build and checkpoint with `VICTORY_TEXTURE_LRU_EVICT=0` (mip clamp still on): the picture is clean again (the black printed jacket has its print, no speckles on the hull or motors), and `passes that made none for lack of room` goes back to 5,364 (5,912 without the PR). fps 9.4. So the regression comes from the LRU eviction, not the mip clamp: it seems to evict textures that are still drawn. No device loss either way.
`HostList::stamp_textures` only stamps textures tracked in `HostList::states`
(barriers), not bindless textures bound once into shader-visible
`HostHeap::kept` and read continuously by shaders. Enabling
`allow_heap_unmake: true` by default in `evict_if_pressured` evicted live
shader-visible `HostHeap` SRVs onto the 240-frame cooldown under VRAM
pressure.

- Add `lru_heap_evict_enabled()` gated strictly on opt-in
  `VICTORY_TEXTURE_LRU_HEAP_EVICT=1` (default off) and pass it as
  `allow_heap_unmake` in `evict_if_pressured()`, so default LRU eviction
  (`VICTORY_TEXTURE_LRU_EVICT=1`) only reclaims fence-completed idle
  textures with `references == 1` (never pinned in a live `HostHeap`).
- Gate `NEED_HEAP_EVICT` reads and writes on `lru_heap_evict_enabled()`
  and gate `hosted()`'s proactive eviction pass on `lru_evict_enabled()`.
- Call `host.uncount()` synchronously in `flush_unclamped_rebinds()` and
  drain `VICTORY_REAPER=1` via `flush_reaper_for_test()` in unit tests.
- Add `default_lru_eviction_preserves_live_host_heap_textures_until_opt_in`
  covering `evict_if_pressured()` under default off and opt-in `=1`.
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 14:27 UTC · original · edited 2026-11-26 15:37 UTC

Thanks a ton @⁠Garu667 for running both A/B captures and isolating VICTORY_TEXTURE_LRU_EVICT=0 + VICTORY_TEXTURE_AUTO_MIP_CLAMP — that pinpointed the exact root cause right away.

Root Cause

HostList::stamp_textures() only stamps textures tracked in HostList::states (explicit resource barriers), not bindless textures bound once into shader-visible HostHeap::kept and sampled continuously by shaders across later frames. Because evict_if_pressured() had allow_heap_unmake: true enabled by default, VRAM pressure could unmake live shader-visible HostHeap SRV slots onto the 240-frame cooldown even while draws were still reading them (causing the grey jacket surface and hull/motor speckles).

Fix (16a6f8e, rebased cleanly onto 58de9bf)

  • Added lru_heap_evict_enabled() gated strictly on opt-in VICTORY_TEXTURE_LRU_HEAP_EVICT=1 (off by default), and wired allow_heap_unmake: lru_heap_evict_enabled() in evict_if_pressured() (with NEED_HEAP_EVICT reads/writes gated on it as well, plus hosted()'s proactive check gated on lru_evict_enabled()).
  • By default (VICTORY_TEXTURE_LRU_EVICT=1), LRU eviction now only reclaims fence-completed idle textures whose COM reference count is references(&host.texture) == 1 (never pinned in any live shader-visible HostHeap slot), while keeping VICTORY_TEXTURE_AUTO_MIP_CLAMP and flush_unclamped_rebinds() intact.
  • Added default_lru_eviction_preserves_live_host_heap_textures_until_opt_in verifying under D3D12 debug + VICTORY_REAPER=1 (hardware & WARP) that live HostHeap-pinned textures (references >= 2) are never unmade or evicted under pressure by default while references == 1 idle textures still evict cleanly.
**@⁠Vladimir-Human** on GitHub · 2026-11-26 14:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289#issuecomment-7194852683) · edited 2026-11-26 15:37 UTC Thanks a ton @⁠Garu667 for running both A/B captures and isolating `VICTORY_TEXTURE_LRU_EVICT=0` + `VICTORY_TEXTURE_AUTO_MIP_CLAMP` — that pinpointed the exact root cause right away. ### Root Cause `HostList::stamp_textures()` only stamps textures tracked in `HostList::states` (explicit resource barriers), **not** bindless textures bound once into shader-visible `HostHeap::kept` and sampled continuously by shaders across later frames. Because `evict_if_pressured()` had `allow_heap_unmake: true` enabled by default, VRAM pressure could unmake live shader-visible `HostHeap` SRV slots onto the 240-frame cooldown even while draws were still reading them (causing the grey jacket surface and hull/motor speckles). ### Fix (`16a6f8e`, rebased cleanly onto `58de9bf`) - Added `lru_heap_evict_enabled()` gated strictly on opt-in `VICTORY_TEXTURE_LRU_HEAP_EVICT=1` (**off by default**), and wired `allow_heap_unmake: lru_heap_evict_enabled()` in `evict_if_pressured()` (with `NEED_HEAP_EVICT` reads/writes gated on it as well, plus `hosted()`'s proactive check gated on `lru_evict_enabled()`). - By default (`VICTORY_TEXTURE_LRU_EVICT=1`), LRU eviction now **only** reclaims fence-completed idle textures whose COM reference count is `references(&host.texture) == 1` (never pinned in any live shader-visible `HostHeap` slot), while keeping `VICTORY_TEXTURE_AUTO_MIP_CLAMP` and `flush_unclamped_rebinds()` intact. - Added `default_lru_eviction_preserves_live_host_heap_textures_until_opt_in` verifying under D3D12 debug + `VICTORY_REAPER=1` (hardware & WARP) that live `HostHeap`-pinned textures (`references >= 2`) are never unmade or evicted under pressure by default while `references == 1` idle textures still evict cleanly.
github-bot force-pushed github-bot/gh-1289 from 4c18c9e422 to 16a6f8ece4 2026-11-26 14:47:40 +00:00 Compare
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 15:03 UTC · original

Retest of 16a6f8e on the RTX 3080 (58de9bf + this PR, same boat checkpoint, ~3 min standing, defaults of the PR): the picture is clean now (printed jacket intact, no speckles on hull or motors), no device loss. But the room problem is back too: passes that made none for lack of room 4,540, about what the same build shows without the PR (4,547), VRAM peak 9.3 GB. So with live heap textures left alone, eviction finds little else to free in this scene. The earlier 5,912 → 100 came from evicting textures that were still bound. Maybe the textures worth evicting here are bound ones the title has not drawn for a while (last draw frame rather than refcount)? Happy to test the next iteration, and if it's easier to iterate, I'm garu667 on Discord.

**@⁠Garu667** on GitHub · 2026-11-26 15:03 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289#issuecomment-7195711963) Retest of 16a6f8e on the RTX 3080 (`58de9bf` + this PR, same boat checkpoint, ~3 min standing, defaults of the PR): the picture is clean now (printed jacket intact, no speckles on hull or motors), no device loss. But the room problem is back too: `passes that made none for lack of room` 4,540, about what the same build shows without the PR (4,547), VRAM peak 9.3 GB. So with live heap textures left alone, eviction finds little else to free in this scene. The earlier 5,912 → 100 came from evicting textures that were still bound. Maybe the textures worth evicting here are bound ones the title has not drawn for a while (last draw frame rather than refcount)? Happy to test the next iteration, and if it's easier to iterate, I'm `garu667` on Discord.
github-bot force-pushed github-bot/gh-1289 from 16a6f8ece4 to 42fdddc7e6 2026-11-26 17:21:35 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 17:22 UTC · original

Updated perf/texture-vram-lru-mipcap to 42fdddc (rebased onto main e4245f3, mergeable) with a two-tier fix for @Garu667's findings:

1. Tier 2 (default ON, zero-corruption superseded-view yield)

When keep_views() retains an older placed texture copy in a descriptor slot while a sharper view waits, HostHeap now records that slot in keeping (clearing it on keep(), unmake(), or pressure). Under VRAM pressure (!room() or pending want > 0), evict_if_pressured() calls descriptor::host::yield_kept_views() before/alongside refs == 1 LRU eviction (VICTORY_KEPT_VIEWS_YIELD=0 kill-switch, default 1). That releases stale superseded copies down to refs == 1 so VRAM can reclaim them while leaving every non-superseded live HostHeap-pinned texture untouched (references >= 2).

2. Tier 3 (opt-in VICTORY_TEXTURE_LRU_HEAP_EVICT=1, last_used_frame recency guard)

Directly matching your suggestion to track draw recency instead of only COM refcounts:

  • HostHeap now tracks per-slot last_used_frame, stamped in HostHeap::mirror(..., for_draw = true) and keep().
  • With VICTORY_TEXTURE_LRU_HEAP_EVICT=1 (remains OFF by default), evict_lru_textures_with drains dead refs == 1 textures first, then unmakes cold HostHeap slots ordered by oldest last_used_frame (skipping taken dynamic slots, non-heap COM pins where refs > 1 + kept_refs, and any slot touched within VICTORY_TEXTURE_LRU_HEAP_IDLE_FRAMES, default 120 frames).
  • Unmade texture slots re-queue with a 30-frame cooldown instead of 240 frames so re-drawn textures recover quickly without multi-second stalls.

Verification (42fdddc, VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1)

  • clippy (default & diagnostics): 0 warnings
  • HW & WARP descriptor::host:: (35/35), resource:: (19/19)
  • Full victory-gpu --lib: default 236/236 (6 ignored), diagnostics 255/255 (7 ignored)

@⁠Garu667 If you have a moment to retest on the 3080, baseline defaults now exercise Tier 2 (yield_kept_views), and adding VICTORY_TEXTURE_LRU_HEAP_EVICT=1 exercises Tier 3 recency-guarded heap eviction as well.

**@⁠Vladimir-Human** on GitHub · 2026-11-26 17:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/1289#issuecomment-7198900792) Updated `perf/texture-vram-lru-mipcap` to `42fdddc` (rebased onto `main` `e4245f3`, mergeable) with a two-tier fix for `@Garu667`'s findings: ### 1. Tier 2 (default ON, zero-corruption superseded-view yield) When `keep_views()` retains an older placed texture copy in a descriptor slot while a sharper view waits, `HostHeap` now records that slot in `keeping` (clearing it on `keep()`, `unmake()`, or pressure). Under VRAM pressure (`!room()` or pending `want > 0`), `evict_if_pressured()` calls `descriptor::host::yield_kept_views()` before/alongside `refs == 1` LRU eviction (`VICTORY_KEPT_VIEWS_YIELD=0` kill-switch, default `1`). That releases stale superseded copies down to `refs == 1` so VRAM can reclaim them while leaving every non-superseded live `HostHeap`-pinned texture untouched (`references >= 2`). ### 2. Tier 3 (opt-in `VICTORY_TEXTURE_LRU_HEAP_EVICT=1`, `last_used_frame` recency guard) Directly matching your suggestion to track draw recency instead of only COM refcounts: - `HostHeap` now tracks per-slot `last_used_frame`, stamped in `HostHeap::mirror(..., for_draw = true)` and `keep()`. - With `VICTORY_TEXTURE_LRU_HEAP_EVICT=1` (remains OFF by default), `evict_lru_textures_with` drains dead `refs == 1` textures first, then unmakes cold `HostHeap` slots ordered by **oldest `last_used_frame`** (skipping taken dynamic slots, non-heap COM pins where `refs > 1 + kept_refs`, and any slot touched within `VICTORY_TEXTURE_LRU_HEAP_IDLE_FRAMES`, default `120` frames). - Unmade texture slots re-queue with a `30`-frame cooldown instead of `240` frames so re-drawn textures recover quickly without multi-second stalls. ### Verification (`42fdddc`, `VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1`) - `clippy` (default & `diagnostics`): 0 warnings - HW & WARP `descriptor::host::` (`35/35`), `resource::` (`19/19`) - Full `victory-gpu --lib`: default `236/236` (`6 ignored`), `diagnostics` `255/255` (`7 ignored`) @⁠Garu667 If you have a moment to retest on the 3080, baseline defaults now exercise Tier 2 (`yield_kept_views`), and adding `VICTORY_TEXTURE_LRU_HEAP_EVICT=1` exercises Tier 3 recency-guarded heap eviction as well.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1289/head:github-bot/gh-1289'
git switch 'github-bot/gh-1289'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1289'
git switch 'github-bot/gh-1289'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1289'
git switch 'github-bot/gh-1289'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1289'
git switch 'main'
git merge --squash 'github-bot/gh-1289'
git switch 'main'
git merge --ff-only 'github-bot/gh-1289'
git switch 'main'
git merge 'github-bot/gh-1289'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.