Skip to content

GPU: committed host textures past the budget are evicted and kept, no… - #2872

Open
mitaka1959 wants to merge 1 commit into
Marvisak:mainfrom
mitaka1959:claude/compassionate-cerf-n9485q
Open

mitaka1959 wants to merge 1 commit into
Marvisak:mainfrom
mitaka1959:claude/compassionate-cerf-n9485q

Conversation

@mitaka1959

@mitaka1959 mitaka1959 commented Nov 25, 2026 •

Copy link
Copy Markdown

Past the card's budget the eviction pass gave up (destroyed) the least recently used host textures fed from title memory, and their next use made them again from title memory, detiled and uploaded. A committed one is now evicted instead (ID3D12Device::Evict): its contents and GPU address stay, and its next use only makes it resident again. Textures in heaps of textures cannot be evicted on their own (residency is the heap's) and are given up as before, as are idle textures (two minutes and 300 frames unused).

No GPU work reaches an evicted texture. The textures a submission's lists name are made resident before they run. The pass leaves the heap slots viewing a texture null before it evicts it, a use makes a texture resident before a view of it is made, and a slot made while a pass picked or evicted its texture is checked once it holds it. If the device refuses to make textures resident, others are evicted first; refused again, the run ends instead of faulting the GPU. Each texture's residency changes together with its device call, under one lock, so the device's count stays 1 or 0.

The policy (which textures go, the budget marks, the address-space check) lives in residency.rs with tests that need no GPU, among them every order of passes and uses; GPU tests cover an eviction, a use, a list recorded before the eviction and a heap slot. The first eviction of a run logs the card's use before and after, and if evicting did not lower it, textures are given up from then on. Diagnostics builds take VICTORY_VRAM_BUDGET_MB (a smaller budget) and VICTORY_GIVE_UP_TEXTURES (the old behaviour, for comparing runs).

…t given up

Past the card's budget the eviction pass gave up (destroyed) the least
recently used host textures fed from title memory, and their next use
made them again from title memory, detiled and uploaded. A committed one
is now evicted instead (ID3D12Device::Evict): its contents and GPU
address stay, and its next use only makes it resident again. Textures in
heaps of textures cannot be evicted on their own (residency is the
heap's) and are given up as before, as are idle textures (two minutes
and 300 frames unused).

No GPU work reaches an evicted texture. The textures a submission's
lists name are made resident before they run. The pass leaves the heap
slots viewing a texture null before it evicts it, a use makes a texture
resident before a view of it is made, and a slot made while a pass
picked or evicted its texture is checked once it holds it. If the device
refuses to make textures resident, others are evicted first; refused
again, the run ends instead of faulting the GPU. Each texture's residency
changes together with its device call, under one lock, so the device's
count stays 1 or 0.

The policy (which textures go, the budget marks, the address-space
check) lives in residency.rs with tests that need no GPU, among them
every order of passes and uses; GPU tests cover an eviction, a use, a
list recorded before the eviction and a heap slot. The first eviction of
a run logs the card's use before and after, and if evicting did not
lower it, textures are given up from then on. Diagnostics builds take
VICTORY_VRAM_BUDGET_MB (a smaller budget) and VICTORY_GIVE_UP_TEXTURES
(the old behaviour, for comparing runs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GgVYzJwCz6RmvFNMHeHDWR

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The budget plumbing checks out: check_resident fires exactly where a slot starts holding a texture, the evict-vs-give-up split is env-gated with documented semantics (evicted-and-kept default, given-up under VICTORY_GIVE_UP_TEXTURES), and the README entries match the implementation. Coherent with the #2870 series. LGTM.

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified head f5497882 cleanly merged onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).

Architecture & Concurrency Audit

  • State machine & D3D12 residency count: Transitions among RESIDENT(0) <-> PICKED(1) -> EVICTED(2) happen under residency::LOCK paired with Evict/MakeResident, keeping device residency counts strictly in {0, 1} (well covered by the exhaustive interleaving test residency_counts_stay_one_or_zero_in_every_order).
  • In-flight & bindless safety: resource::evict_unused() runs under Host::execute's submitted lock after prior GPU work is idle; previously recorded lists referencing evicted textures are made resident by residency::before_running(runs) before ExecuteCommandLists (with make_room retry + host::fail guard); and descriptor::evict clears shader-visible heap slots to null prior to device.Evict so bindless shaders cannot touch evicted resources.
  • Lock ordering: Acyclic — descriptor releases kept and may acquire residency::LOCK under made, while residency calls descriptor::evict and resource::make_room only after releasing residency::LOCK.
  • Minor observation (non-blocking): The one-shot FIRST effectiveness check in residency::evict permanently sets INEFFECTIVE = true if system-wide video_memory() drops by less than bytes / 4 across the first Evict. Concurrent VRAM allocations by another process during that window could trigger a false-positive permanent fallback to drop-on-evict.

Local Verification (VICTORY_D3D12_DEBUG=1)

  • RTX 5090: residency:: 13/13, resource::tests 17/17, descriptor::tests 7/7, draw::tests 20/20, host::tests 30/31 (only the pre-existing dynamic_slots_are_held_until_released 1M view cap baseline).
  • WARP: residency:: 13/13, resource::tests 17/17, host::tests 31/31.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (192 files ok): clean.

Solid design and verification.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. This evicts committed host textures past the budget (ID3D12Device::Evict) instead of destroying them, and makes them resident again on next use (residency.rs, Resource::host, HostHeap::check_resident, Host::execute). The design holds together on paper, but it changes GPU resource lifetime and needs evidence from hardware: a title run with VICTORY_VRAM_BUDGET_MB low enough to force evictions, showing the eviction lines, per-frame evict/resident counts, no device removal, and fewer remade textures than with VICTORY_GIVE_UP_TEXTURES=1. Please also say whether GPU work outside Host::execute's lists (copy-queue uploads, present blits) can name a texture when it is evicted, and whether video_memory() right after Evict reliably shows the drop.

CI: passing.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants