Prioritize on-screen sampled textures and fix slot_evict on 8 GB GPUs #1763

Merged
EduardoMFOliveira merged 1 commit from upstream-pr/1763 into main 2026-11-29 08:16:53 +00:00
EduardoMFOliveira commented 2026-11-28 23:58:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by EduardoMFOliveira on 2026-11-28T23:58:31Z.


Summary

Follow-up fix for 8 GB GPUs on top of d4b5d51 (tested on an NVIDIA GeForce RTX 5060 Laptop 8 GB, Series S + DLSS + FrameGen 2x).

Problems Observed

  • slot_evict received idle_ms = 600_000 (10 min) while RING only stores 120 seconds, causing frame_at to return None after 2 minutes of play and disabling slot eviction.
  • Once slot_evict ran, holding TEXTURES across evictable_slots() / evict_slots() caused an AB-BA deadlock with HostHeap::mirror (made lock -> TEXTURES), triggering the title's 30s watchdog.
  • View::Shader first uploads over the room line charged reserve = 1 byte instead of the texture's footprint, allowing VRAM to reach 7,937 MB on a ~7,054 MB budget (causing 1,600+ DLSS out of VRAM (39) failures and permanently black interior textures).

Changes

  1. Enable & leverage VICTORY_SAMPLED_MARKS=1 + VICTORY_SAMPLED_EVICT=1 (apps/victory/src/play.rs, crates/victory-gpu/src/sampled.rs, crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs):
    • Added sampled::sampled_lately() so TextureQueue::collect_due_and_census() wakes held slots and Due::ordered() prioritizes textures shaders are actively sampling on screen.
    • Gated over-the-line first_upload in draw.rs on sampled_lately(index, 120) and used resource::object_texture_bytes() for View::Shader.
  2. Fix slot_evict & HostHeap::slots_showing (crates/victory-gpu/src/resource.rs, crates/victory-gpu/src/descriptor/host.rs):
    • Clamped evict_idle_ms inside the 120s ring window, aligned high/low watermarks with room_line(budget) - face_headroom_bytes(), and dropped TEXTURES before calling evictable_slots() / evict_slots().
    • Restored tabled_out() && self.tabled_stamp(i) != 0 in HostHeap::slots_showing.

Results & Testing

  • In-game (RTX 5060 Laptop 8 GB): VRAM stays around ~5.4–6.8 GB (under the ~7.0 GB budget), 0 DLSS failures, interior & exterior textures load cleanly with no green/black artifacts, ~30 FPS.
  • cargo test --release -p victory-gpu: 550 passed; 0 failed (and 25 passed; 0 failed on -- slot after the final deadlock fix).
  • cargo build --release --locked -p victory: clean release build.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5545829189 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1763). Originally posted by [EduardoMFOliveira](https://github.com/EduardoMFOliveira) on 2026-11-28T23:58:31Z. --- ## Summary Follow-up fix for 8 GB GPUs on top of `d4b5d51` (tested on an NVIDIA GeForce RTX 5060 Laptop 8 GB, Series S + DLSS + FrameGen 2x). ### Problems Observed - `slot_evict` received `idle_ms = 600_000` (10 min) while `RING` only stores 120 seconds, causing `frame_at` to return `None` after 2 minutes of play and disabling slot eviction. - Once `slot_evict` ran, holding `TEXTURES` across `evictable_slots()` / `evict_slots()` caused an AB-BA deadlock with `HostHeap::mirror` (`made` lock -> `TEXTURES`), triggering the title's 30s watchdog. - `View::Shader` first uploads over the room line charged `reserve = 1` byte instead of the texture's footprint, allowing VRAM to reach 7,937 MB on a ~7,054 MB budget (causing 1,600+ DLSS `out of VRAM (39)` failures and permanently black interior textures). ### Changes 1. **Enable & leverage `VICTORY_SAMPLED_MARKS=1` + `VICTORY_SAMPLED_EVICT=1`** (`apps/victory/src/play.rs`, `crates/victory-gpu/src/sampled.rs`, `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/draw.rs`): - Added `sampled::sampled_lately()` so `TextureQueue::collect_due_and_census()` wakes `held` slots and `Due::ordered()` prioritizes textures shaders are actively sampling on screen. - Gated over-the-line `first_upload` in `draw.rs` on `sampled_lately(index, 120)` and used `resource::object_texture_bytes()` for `View::Shader`. 2. **Fix `slot_evict` & `HostHeap::slots_showing`** (`crates/victory-gpu/src/resource.rs`, `crates/victory-gpu/src/descriptor/host.rs`): - Clamped `evict_idle_ms` inside the 120s ring window, aligned `high`/`low` watermarks with `room_line(budget) - face_headroom_bytes()`, and dropped `TEXTURES` before calling `evictable_slots()` / `evict_slots()`. - Restored `tabled_out() && self.tabled_stamp(i) != 0` in `HostHeap::slots_showing`. ### Results & Testing - In-game (RTX 5060 Laptop 8 GB): VRAM stays around ~5.4–6.8 GB (under the ~7.0 GB budget), 0 DLSS failures, interior & exterior textures load cleanly with no green/black artifacts, ~30 FPS. - `cargo test --release -p victory-gpu`: **550 passed; 0 failed** (and **25 passed; 0 failed** on `-- slot` after the final deadlock fix). - `cargo build --release --locked -p victory`: clean release build.
joeypercia commented 2026-11-29 04:52:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by joeypercia on 2026-11-29T04:52:12Z.


A data point for one part of this PR, the drop(all) before evict_slots in slot_evict. On current main that lock order is a real deadlock, not only a cost.

On an RTX 4070 Ti (12 GB), main 568c5e5, release, Series X, the run stalled 150 s in and ended with the title's watchdog (+0x23cf683). Thread stacks taken with cdb 21 s into the stall show a ring of three locks:

thread holds waits for
victory-submit: sweep → let_go_idle → slot_evict → evict_slots → texture_slot_evicted (Made::lock) TEXTURES (held by slot_evict to the end) a slot's Made lock
victory-views-*, victory-aside: HostHeap::mirror_inner → begun_before → placed_texture → texture_at that slot's Made lock PLACED_TEXTURES
a list thread: texture_at → create_at_address → hand_out_resource (textures().insert) PLACED_TEXTURES TEXTURES

Letting TEXTURES go before evict_slots, as this PR does, breaks the ring. It doesn't depend on the card being 8 GB: it showed on a 12 GB card, and it can show wherever slot eviction runs.

I had opened #1969 with only that change, before I saw it here; I'm closing it as a duplicate of this part. Since this PR conflicts with main now, it might be worth landing the lock-order part on its own. #1969's branch has it as one small commit (pins the candidates with add_ref_alive/Held instead of re-taking the table per texture), if that helps.

(Written with Claude Code, Claude Opus 5.5.)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7250909767 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1763#issuecomment-7250909767). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-29T04:52:12Z. --- A data point for one part of this PR, the `drop(all)` before `evict_slots` in `slot_evict`. On current `main` that lock order is a real deadlock, not only a cost. On an RTX 4070 Ti (12 GB), `main` `568c5e5`, release, Series X, the run stalled 150 s in and ended with the title's watchdog (`+0x23cf683`). Thread stacks taken with `cdb` 21 s into the stall show a ring of three locks: | thread | holds | waits for | |---|---|---| | `victory-submit`: `sweep` → `let_go_idle` → `slot_evict` → `evict_slots` → `texture_slot_evicted` (`Made::lock`) | `TEXTURES` (held by `slot_evict` to the end) | a slot's `Made` lock | | `victory-views-*`, `victory-aside`: `HostHeap::mirror_inner` → `begun_before` → `placed_texture` → `texture_at` | that slot's `Made` lock | `PLACED_TEXTURES` | | a list thread: `texture_at` → `create_at_address` → `hand_out_resource` (`textures().insert`) | `PLACED_TEXTURES` | `TEXTURES` | Letting `TEXTURES` go before `evict_slots`, as this PR does, breaks the ring. It doesn't depend on the card being 8 GB: it showed on a 12 GB card, and it can show wherever slot eviction runs. I had opened #1969 with only that change, before I saw it here; I'm closing it as a duplicate of this part. Since this PR conflicts with `main` now, it might be worth landing the lock-order part on its own. #1969's branch has it as one small commit (pins the candidates with `add_ref_alive`/`Held` instead of re-taking the table per texture), if that helps. (Written with Claude Code, Claude Opus 5.5.)
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!1763
No description provided.