vkback: drain refused_slots when GTT room recovers and spill object textures #191

Open
github-bot wants to merge 1 commit from github-bot/gh-191 into main AGit
Owner

@⁠Mhyster on GitHub · 2026-12-02 06:52 UTC · original
Mhyster:fix/tex-refused-slots-gtt-drain → main · +82 −13 · 4 files · 1 commits · open

What

Fixes permanently black textures after transient GTT pressure while VRAM stays over its line:

  1. Drain refused_slots on GTT recovery, not only VRAM recovery (residency.rs room_for_textures / room_update, srclife.rs texture_place): slots are only parked in refused_slots (with Exit::Own, so they stay cached as null until drained) when both VRAM and GTT are past their lines (Place::None). Previously, room_for_textures only drained refused_slots when VRAM transitioned false -> true. Whenever VRAM remained over its line and GTT spiked and recovered, refused slots stayed null forever even though texture_place was already spilling new textures to GTT.
  2. Re-check room when refused_slots is non-empty (arena.rs take_retry_slots, srclife.rs source_sweep): take_retry_slots calls room_for_textures (which still enforces its 100 ms throttle) when refused_slots is non-empty so refused slots recover even if no new texture creation occurs, and source_sweep invalidates the 100 ms timestamp when it frees copies (matching let_go_idle).
  3. Spill object textures to GTT in create_object (lib.rs create_object): check self.texture_place() == Place::None instead of !self.room_for_textures(), matching ensure_image_or and write_view so object textures also spill to GTT instead of being deferred lazy when VRAM is full and GTT has room.

Reproduces the console's never-refuse-a-texture rule (srclife.rs module doc): once either heap has room again, every previously refused slot is retried.

The reference

  • crates/victory-gpu/src/resource.rs (room, let_go_idle): the D3D12 path tracks texture residency against a single budget line without a separate GTT spill path; vkback's two-heap spill (Place::Vram / Place::Gtt / Place::None) is specific to greenfield/vkback/src/srclife.rs (texture_place) and residency.rs (room_for_textures).

Evidence

  • Unit tests in greenfield/vkback/src/residency.rs (room_update):
    • gtt_recovery_drains_refused_slots_even_while_vram_stays_over
    • vram_recovery_drains_refused_slots_while_gtt_stays_over
    • unknown_budget_has_room_in_both_heaps
  • Local CI checks passed (Linux x86_64):
    • cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked
    • (cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked) (171 passed, 3 ignored; 6/6 policy tests including file_size)
    • cargo clippy --all-targets --locked -- -D warnings on root native crates, greenfield, greenfield/wine, and greenfield/vkback/translate.
  • Not run: live game / AMD GPU screenshot check, Vulkan validation run (house scene), and A/B frame timing (frames.py) could not be run in this session (no live game run performed); cargo xwin clippy for x86_64-pc-windows-msvc runs in GitHub Actions CI.

Checklist (docs/AGENTS.md)

  • One topic (rule 31); docs/TASKS.md not edited, the fixed item named above (rule 29)
  • "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen (it drops the maintainers' commits)
  • No fallback or second path for a case that can't happen, in title data or in our own setup (rule 33); unexpected input fails loudly (rule 9)
  • Constants come from the console, the hardware or the title's data, not tuned by eye or ear (rule 9b)
  • Every switch is listed, read in one place, and a bad value stops the start (rule 2)
  • Queues and other externally synchronized Vulkan objects are used under their lock (rule 35)
  • Every unsafe block has a // SAFETY: comment; no raw pointer around the borrow checker (rule 36)
  • Clippy clean; tests call the production code; TRANSLATOR_VERSION bumped if the translator's output changes (rule 27)
  • Comments say what is true now and name functions, not line numbers (rule 3)
  • Nothing from the title, and no pointers to where non-free data can be found (hard constraints)
**@⁠Mhyster** on GitHub · 2026-12-02 06:52 UTC · [original](https://github.com/vktory6/VKtory/pull/191) `Mhyster:fix/tex-refused-slots-gtt-drain` → `main` · +82 −13 · 4 files · 1 commits · open ## What Fixes permanently black textures after transient GTT pressure while VRAM stays over its line: 1. **Drain `refused_slots` on GTT recovery, not only VRAM recovery** (`residency.rs` `room_for_textures` / `room_update`, `srclife.rs` `texture_place`): slots are only parked in `refused_slots` (with `Exit::Own`, so they stay cached as null until drained) when *both* VRAM and GTT are past their lines (`Place::None`). Previously, `room_for_textures` only drained `refused_slots` when VRAM transitioned `false -> true`. Whenever VRAM remained over its line and GTT spiked and recovered, refused slots stayed null forever even though `texture_place` was already spilling new textures to GTT. 2. **Re-check room when `refused_slots` is non-empty** (`arena.rs` `take_retry_slots`, `srclife.rs` `source_sweep`): `take_retry_slots` calls `room_for_textures` (which still enforces its 100 ms throttle) when `refused_slots` is non-empty so refused slots recover even if no new texture creation occurs, and `source_sweep` invalidates the 100 ms timestamp when it frees copies (matching `let_go_idle`). 3. **Spill object textures to GTT in `create_object`** (`lib.rs` `create_object`): check `self.texture_place() == Place::None` instead of `!self.room_for_textures()`, matching `ensure_image_or` and `write_view` so object textures also spill to GTT instead of being deferred lazy when VRAM is full and GTT has room. Reproduces the console's never-refuse-a-texture rule (`srclife.rs` module doc): once either heap has room again, every previously refused slot is retried. ## The reference - `crates/victory-gpu/src/resource.rs` (`room`, `let_go_idle`): the D3D12 path tracks texture residency against a single budget line without a separate GTT spill path; vkback's two-heap spill (`Place::Vram` / `Place::Gtt` / `Place::None`) is specific to `greenfield/vkback/src/srclife.rs` (`texture_place`) and `residency.rs` (`room_for_textures`). ## Evidence - Unit tests in `greenfield/vkback/src/residency.rs` (`room_update`): - `gtt_recovery_drains_refused_slots_even_while_vram_stays_over` - `vram_recovery_drains_refused_slots_while_gtt_stays_over` - `unknown_budget_has_room_in_both_heaps` - Local CI checks passed (Linux x86_64): - `cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked` - `(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)` (171 passed, 3 ignored; 6/6 policy tests including `file_size`) - `cargo clippy --all-targets --locked -- -D warnings` on root native crates, `greenfield`, `greenfield/wine`, and `greenfield/vkback/translate`. - **Not run**: live game / AMD GPU screenshot check, Vulkan validation run (house scene), and A/B frame timing (`frames.py`) could not be run in this session (no live game run performed); `cargo xwin clippy` for `x86_64-pc-windows-msvc` runs in GitHub Actions CI. ## Checklist (docs/AGENTS.md) - [x] One topic (rule 31); `docs/TASKS.md` not edited, the fixed item named above (rule 29) - [x] "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen (it drops the maintainers' commits) - [x] No fallback or second path for a case that can't happen, in title data or in our own setup (rule 33); unexpected input fails loudly (rule 9) - [x] Constants come from the console, the hardware or the title's data, not tuned by eye or ear (rule 9b) - [x] Every switch is listed, read in one place, and a bad value stops the start (rule 2) - [x] Queues and other externally synchronized Vulkan objects are used under their lock (rule 35) - [x] Every `unsafe` block has a `// SAFETY:` comment; no raw pointer around the borrow checker (rule 36) - [x] Clippy clean; tests call the production code; `TRANSLATOR_VERSION` bumped if the translator's output changes (rule 27) - [x] Comments say what is true now and name functions, not line numbers (rule 3) - [x] Nothing from the title, and no pointers to where non-free data can be found (hard constraints)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 06:52:59 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-02 15:28 UTC · original

Thanks, this fixes the same black textures as #188, more simply. #188 has the better structure (one cached room check), so this waits for it:

  • If #188 lands: this shrinks to the create_object spill to GTT plus the sweep invalidation, as one small PR.
  • If #188 stalls: we merge this as the bug fix.
**@⁠vktory6** on GitHub · 2026-12-02 15:28 UTC · [original](https://github.com/vktory6/VKtory/pull/191#issuecomment-7350389249) Thanks, this fixes the same black textures as #188, more simply. #188 has the better structure (one cached room check), so this waits for it: - **If #188 lands:** this shrinks to the `create_object` spill to GTT plus the sweep invalidation, as one small PR. - **If #188 stalls:** we merge this as the bug fix.
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/191/head:github-bot/gh-191'
git switch 'github-bot/gh-191'

Merge

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