Skip to content

feat(renderer): mid-session texture eviction system (DX11)#592

Open
noisethanks wants to merge 2 commits into
themrdemonized:all-in-one-vs2022-wpo-mtfrom
noisethanks:feature/evict-stalled-textures
Open

feat(renderer): mid-session texture eviction system (DX11)#592
noisethanks wants to merge 2 commits into
themrdemonized:all-in-one-vs2022-wpo-mtfrom
noisethanks:feature/evict-stalled-textures

Conversation

@noisethanks

Copy link
Copy Markdown

This is a refocused version of #589. EvictAllTextures has been removed since it duplicated existing functionality.

This PR contains only EvictStalledTextures, which adds an age-based LRU texture eviction during gameplay sessions. No equivalent exists in the codebase.
UnloadAllTexturesOnLevelUnload() handles level transitions only; nothing currently evicts stale textures during a single play session.

  • dwLastUsedFrame field added to CTexture, stamped in Apply() and apply_normal() after the bLoading spin-wait (MT-safe)
  • EvictStalledTextures() scans m_textures in batches, evicting textures unused beyond a configurable age threshold
  • Excludes render targets ($user$*), $null sentinel, UI textures, and ref-locked textures (dwReference > 1)
  • Fixes surface_set() to correctly set flags.bUser for $user$ render targets created before device ready

Tunable via console variables:

  • r__tex_evict_enabled (default 0)
  • r__tex_evict_age_frames (default 1800, ~30s at 60fps)
  • r__tex_evict_batch_size (default 200)
    At the default batch size of 200, the engine clears out 100-200Mb of VRAM every 30 seconds on my configurations and it seems to add no stuttering or instability.

…guards

- Add r__tex_evict_interval cvar (default 600, min 60, max 3600)
  controls frames between eviction passes, previously hardcoded
- Wrap all TexEvict Msg() calls and counter variables in #ifdef DEBUG
  so release builds have zero logging overhead
- Four cvars now expose the complete eviction tuning surface:
  r__tex_evict_enabled, r__tex_evict_age_frames,
  r__tex_evict_batch_size, r__tex_evict_interval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant