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

Manually merged
github merged 1 commit from github-bot/gh-1763 into main 2026-11-29 08:21:20 +00:00 AGit
Owner

@⁠EduardoMFOliveira on GitHub · 2026-11-28 23:58 UTC · original
EduardoMFOliveira:fix/8gb-sampled-streaming → main · +105 −29 · 5 files · 1 commits · merged 2026-11-29 08:16 UTC

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.
**@⁠EduardoMFOliveira** on GitHub · 2026-11-28 23:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1763) `EduardoMFOliveira:fix/8gb-sampled-streaming` → `main` · +105 −29 · 5 files · 1 commits · merged 2026-11-29 08:16 UTC ## 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.
- Enable VICTORY_SAMPLED_MARKS=1 and VICTORY_SAMPLED_EVICT=1 in play.rs SETTINGS.
- Add sampled::sampled_lately() and use it in TextureQueue::collect_due_and_census() and Due::ordered() to wake held slots and prioritize visibly-sampled textures.
- Gate over-the-line first_upload in draw.rs on sampled_lately() and charge real object_texture_bytes() for View::Shader instead of 1 byte.
- Fix slot_evict() in resource.rs: clamp idle_ms to the 120s ring window, align high/low watermarks with effective room_line, and release TEXTURES before evictable_slots()/evict_slots() to prevent an AB-BA deadlock with HostHeap::mirror.
- Restore tabled_out() && tabled_stamp(i) != 0 in HostHeap::slots_showing().
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:04:20 +00:00
Author
Owner

@⁠joeypercia on GitHub · 2026-11-29 04:52 UTC · original

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.)

**@⁠joeypercia** on GitHub · 2026-11-29 04:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1763#issuecomment-7250909767) 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.)
github manually merged commit e296bec220 into main 2026-11-29 08:21:20 +00:00
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/trustno1-coder--VIctory-NVIDIA!1763
No description provided.