GPU: giving up a texture leaves the dynamic slots of recorded lists alone #2598

Open
github-bot wants to merge 2 commits from github-bot/gh-2598 into main AGit
Owner

@⁠BastienRodz on GitHub · 2026-11-25 16:29 UTC · original
BastienRodz:gpu/evict-keeps-live-dynamic-slots-pr → main · +51 −4 · 1 files · 2 commits · open

What's wrong

HostHeap::evict (69d1e8e, which scans kept since ed25c0e) nulled every slot viewing a given-up texture. That included the dynamic slots of lists recorded but not yet reset: a list's descriptor tables for its draws, released only at reset and not made again before the list runs. Such a list's draws then read a null 2D view, and the slot no longer held the texture. resource.rs says lists recorded before an eviction keep what they use until they are reset.

What the fix does

In HostHeap::evict:

  • skip dynamic slots (index >= count) still taken in next, i.e. held by a list not yet reset;
  • keep nulling title slots and dynamic slots already released;
  • take made and next before scanning kept and hold them across the clearing, so a slot taken or rewritten meanwhile is not nulled. The order is made, then next, then kept (taken by keep), and no path holds kept while taking either of the other two.

Tests

New descriptor::host::tests::live_dynamic_slots_keep_a_texture_given_up: a placed texture viewed from a title slot, from a dynamic slot still held, and from a dynamic slot already released. When the texture is given up, the held dynamic slot must keep its view and texture, while the other two are nulled.

Results:

  • On main (67e8ae1) it fails: a live dynamic slot keeps its view.
  • With the fix it passes, and so do resource::tests (17) and descriptor::host::tests (13). The exception is dynamic_slots_are_held_until_released, which fails on main too under vkd3d-proton because of its heap cap. Run under Wine 10 with vkd3d-proton 3.1 on llvmpipe; without a host device the test returns early.
  • windows-latest run on the fork: https://github.com/BastienRodz/VIctory/actions/runs/45654306765

Not tested

No title run, and no AMD/NVIDIA GPU. How often a texture viewed from a held list's table is given up is not measured. It needs either a texture idle for longer than the eviction delay while a list recorded earlier still runs, or the budget pass reaching textures that recorded lists use.

Fixes #2597

AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.

🤖 Generated with Claude Code

**@⁠BastienRodz** on GitHub · 2026-11-25 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598) `BastienRodz:gpu/evict-keeps-live-dynamic-slots-pr` → `main` · +51 −4 · 1 files · 2 commits · open ### What's wrong `HostHeap::evict` (69d1e8e, which scans `kept` since ed25c0e) nulled every slot viewing a given-up texture. That included the dynamic slots of lists recorded but not yet reset: a list's descriptor tables for its draws, released only at reset and not made again before the list runs. Such a list's draws then read a null 2D view, and the slot no longer held the texture. `resource.rs` says lists recorded before an eviction keep what they use until they are reset. ### What the fix does In `HostHeap::evict`: - skip dynamic slots (`index >= count`) still taken in `next`, i.e. held by a list not yet reset; - keep nulling title slots and dynamic slots already released; - take `made` and `next` before scanning `kept` and hold them across the clearing, so a slot taken or rewritten meanwhile is not nulled. The order is `made`, then `next`, then `kept` (taken by `keep`), and no path holds `kept` while taking either of the other two. ### Tests New `descriptor::host::tests::live_dynamic_slots_keep_a_texture_given_up`: a placed texture viewed from a title slot, from a dynamic slot still held, and from a dynamic slot already released. When the texture is given up, the held dynamic slot must keep its view and texture, while the other two are nulled. Results: - On `main` (67e8ae1) it fails: `a live dynamic slot keeps its view`. - With the fix it passes, and so do `resource::tests` (17) and `descriptor::host::tests` (13). The exception is `dynamic_slots_are_held_until_released`, which fails on `main` too under vkd3d-proton because of its heap cap. Run under Wine 10 with vkd3d-proton 3.1 on llvmpipe; without a host device the test returns early. - windows-latest run on the fork: https://github.com/BastienRodz/VIctory/actions/runs/45654306765 ### Not tested No title run, and no AMD/NVIDIA GPU. How often a texture viewed from a held list's table is given up is not measured. It needs either a texture idle for longer than the eviction delay while a list recorded earlier still runs, or the budget pass reaching textures that recorded lists use. Fixes #2597 AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since 69d1e8e, giving up a host texture (idle, or past the card's
budget) nulls every heap slot viewing it (HostHeap::evict). Since
ed25c0e it finds them by scanning `kept`, which covers the dynamic slots
too: the descriptor tables lists build for their draws. A recorded list
not yet reset still uses those (the dynamic slots it took are not
released until then), and its table is not made again before it runs,
so its draws read a null 2D view, and the slot no longer held the
texture. resource.rs: "Lists recorded before hold it until they are
reset, so no GPU work reads it freed".

evict now leaves dynamic slots a list still holds (taken in `next`), and
holds `made` and `next` across the scan and the clearing.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the slot is next made, not until its list is reset (review by
fyernald).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:02 +00:00
Author
Owner

@⁠BastienRodz on GitHub · 2026-11-25 16:43 UTC · original

Thanks @⁠fyernald, the lock-order check is appreciated. On your question: yes, a held dynamic slot keeps the given-up texture until the slot is next made, not until its list resets, since release only clears the taken bit. Dropping the reference at reset would mean release taking kept too, so I'd rather leave it and say so. 1c356e5 adds that line to the comment in evict.

**@⁠BastienRodz** on GitHub · 2026-11-25 16:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#issuecomment-7168436221) Thanks @⁠fyernald, the lock-order check is appreciated. On your question: yes, a held dynamic slot keeps the given-up texture until the slot is next made, not until its list resets, since `release` only clears the taken bit. Dropping the reference at reset would mean `release` taking `kept` too, so I'd rather leave it and say so. 1c356e5 adds that line to the comment in `evict`.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 16:49 UTC · original

Verification of 1c356e5

Environment: Windows 11, D3D12 on the WARP software adapter only (VICTORY_D3D12_WARP=1, cargo ... --features diagnostics, which is what compiles that switch in; VICTORY_DXIL set to the Windows SDK dxil.dll). No physical GPU device was created. Not run on real GPU hardware.

  • Mergeable: git merge-tree against origin/main (67e8ae1) is clean.
  • cargo test -p victory-gpu --features diagnostics --lib live_dynamic_slots_keep_a_texture_given_up: 1 passed. I confirmed it runs on a real WARP device and is not skipped by the host() early return (checked on the earlier head ed0fa73).
  • Baseline-red: with the new evict slot filter disabled and the test kept, it fails at a live dynamic slot keeps its view. The test does catch #2597.
  • Full cargo test -p victory-gpu --features diagnostics --lib at this head, two runs: 199 passed, 0 failed, 1 ignored.
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.

Independent verification by Claude Code (Claude Sonnet 5.5), an AI assistant, run for oni-swr. No game files, dumps, or shader names were used.

**@⁠oni-swr** on GitHub · 2026-11-25 16:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#issuecomment-7168594814) **Verification of `1c356e5`** **Environment:** Windows 11, D3D12 on the **WARP software adapter only** (`VICTORY_D3D12_WARP=1`, `cargo ... --features diagnostics`, which is what compiles that switch in; `VICTORY_DXIL` set to the Windows SDK `dxil.dll`). No physical GPU device was created. Not run on real GPU hardware. - Mergeable: `git merge-tree` against `origin/main` (`67e8ae1`) is clean. - `cargo test -p victory-gpu --features diagnostics --lib live_dynamic_slots_keep_a_texture_given_up`: **1 passed**. I confirmed it runs on a real WARP device and is not skipped by the `host()` early return (checked on the earlier head `ed0fa73`). - **Baseline-red:** with the new `evict` slot filter disabled and the test kept, it fails at `a live dynamic slot keeps its view`. The test does catch #2597. - Full `cargo test -p victory-gpu --features diagnostics --lib` at this head, two runs: **199 passed, 0 failed, 1 ignored**. - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean. _Independent verification by Claude Code (Claude Sonnet 5.5), an AI assistant, run for oni-swr. No game files, dumps, or shader names were used._
Author
Owner

@⁠Machad3x on GitHub · 2026-11-25 18:26 UTC · original

Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main 67e8ae1.

Applied cleanly on that stack, together with #2601, #2576, #2611, #2626. One 10-minute game run reached gameplay with no device removal. These five PRs were not tested one by one, so nothing in that run is attributed to this PR alone.

Written with Claude Code; tested locally.

**@⁠Machad3x** on GitHub · 2026-11-25 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#issuecomment-7170913035) Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main 67e8ae1. Applied cleanly on that stack, together with #2601, #2576, #2611, #2626. One 10-minute game run reached gameplay with no device removal. These five PRs were not tested one by one, so nothing in that run is attributed to this PR alone. Written with Claude Code; tested locally.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:17 UTC · original

Automated triage for the maintainers.

In crates/victory-gpu/src/descriptor/host.rs, HostHeap::evict now skips dynamic slots (index >= count) that are still marked taken in next, so a recorded list that is not yet reset keeps the view and texture it uses when that texture is given up. Title slots and released dynamic slots are still nulled. I checked the index math (kept has count + dynamic entries and next.1 has dynamic, so taken.1[d] stays in bounds) and the lock order: made, then next, then kept. mirror takes made then kept, and dynamic/release take only next, so I found no inversion. One thing to weigh: made is now held during the full kept scan. Before, it was taken only after the scan, so title threads waiting on made may block a little longer while an eviction pass runs. The new test live_dynamic_slots_keep_a_texture_given_up covers held, released and title slots. CI: passing (check). This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#issuecomment-7177370822) <!-- victory-triage v1 head=1c356e5140948aefeba3ac036e4f1d2caad491de verdict=merge-candidate at=2026-11-25T23:17:32Z --> Automated triage for the maintainers. In `crates/victory-gpu/src/descriptor/host.rs`, `HostHeap::evict` now skips dynamic slots (index >= `count`) that are still marked taken in `next`, so a recorded list that is not yet reset keeps the view and texture it uses when that texture is given up. Title slots and released dynamic slots are still nulled. I checked the index math (`kept` has `count + dynamic` entries and `next.1` has `dynamic`, so `taken.1[d]` stays in bounds) and the lock order: `made`, then `next`, then `kept`. `mirror` takes `made` then `kept`, and `dynamic`/`release` take only `next`, so I found no inversion. One thing to weigh: `made` is now held during the full `kept` scan. Before, it was taken only after the scan, so title threads waiting on `made` may block a little longer while an eviction pass runs. The new test `live_dynamic_slots_keep_a_texture_given_up` covers held, released and title slots. CI: passing (check). This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fyernald on GitHub · 2026-11-25 16:41 UTC · original · approved these changes

Tested on an RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1: cargo test -p victory-gpu --lib --locked -- --test-threads=1 gives 193 passed, 3 failed. live_dynamic_slots_keep_a_texture_given_up passes. The 3 failures also fail on main here: the two heap-cap tests (FIND-9) and the Windows 10 castable test (#1999).

I checked the lock order, since evict now holds next too. Every function in descriptor/host.rs that holds more than one of these locks takes made before kept (mirror, describe_slot, unmade_placed). dynamic and release hold next alone and call nothing that locks. So made → next → kept here can't deadlock with them.

One question, not a blocker: a texture given up while a recorded list holds its dynamic slot stays referenced from kept after the list resets. release only clears the taken bit, so the reference goes when the slot is next written by make_at, not at the reset. If evictions are about freeing video memory under pressure, that texture lives until the dynamic cursor comes back round. That's probably fine given how fast the dynamic range cycles, but worth a line in the comment.

**@⁠fyernald** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#pullrequestreview-6061366102) · **approved these changes** Tested on an **RTX 3080 (617.42), Windows 10 (19045)**, `main` `67e8ae1`: `cargo test -p victory-gpu --lib --locked -- --test-threads=1` gives 193 passed, 3 failed. `live_dynamic_slots_keep_a_texture_given_up` passes. The 3 failures also fail on `main` here: the two heap-cap tests (`FIND-9`) and the Windows 10 castable test (#1999). I checked the lock order, since `evict` now holds `next` too. Every function in `descriptor/host.rs` that holds more than one of these locks takes `made` before `kept` (`mirror`, `describe_slot`, `unmade_placed`). `dynamic` and `release` hold `next` alone and call nothing that locks. So `made` → `next` → `kept` here can't deadlock with them. One question, not a blocker: a texture given up while a recorded list holds its dynamic slot stays referenced from `kept` after the list resets. `release` only clears the `taken` bit, so the reference goes when the slot is next written by `make_at`, not at the reset. If evictions are about freeing video memory under pressure, that texture lives until the dynamic cursor comes back round. That's probably fine given how fast the dynamic range cycles, but worth a line in the comment.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:12 UTC · original · approved these changes

Reviewed 1c356e5140948aefeba3ac036e4f1d2caad491de (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.

Audit

  • Index & lock-order safety (crates/victory-gpu/src/descriptor/host.rs:787, :793, :794, :799):
    • kept is sized count + extra and next.1 is sized extra, so i.checked_sub(self.count) cleanly partitions title slots (None, evicted) and dynamic slots (Some(d) with d < taken.1.len(), skipped while taken.1[d] is true).
    • Lock acquisition order made -> next -> kept in evict has no inversion against mirror/describe_slot/unmade_placed (made -> kept), dynamic/release (next only), or keep (kept only, retiring old resources via crate::host::retire).
    • Holding ID3D12Resource in kept for a live dynamic slot prevents recorded lists from sampling null views, and once the slot is released it is reclaimed either on the next evict pass or when make_at next reuses the slot (accurately documented in 1c356e51).

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features)
  • victory-gpu descriptor::host:: resource:: with VICTORY_D3D12_DEBUG=1:
    • RTX 5090 (--skip dynamic_slots_are_held_until_released, pre-existing 1M view-heap cap failure on main): 33/33 passed (including live_dynamic_slots_keep_a_texture_given_up).
    • WARP (--features diagnostics, no skips): 34/34 passed.
  • Additional probe on both RTX 5090 and WARP confirmed title slot 0 and a released dynamic slot are both nulled on give_up_now while a live dynamic slot keeps its view, and after release(live, 1) a subsequent evict pass clears the slot cleanly.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#pullrequestreview-6077338400) · **approved these changes** Reviewed `1c356e5140948aefeba3ac036e4f1d2caad491de` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer. ### Audit - **Index & lock-order safety** (`crates/victory-gpu/src/descriptor/host.rs:787`, `:793`, `:794`, `:799`): - `kept` is sized `count + extra` and `next.1` is sized `extra`, so `i.checked_sub(self.count)` cleanly partitions title slots (`None`, evicted) and dynamic slots (`Some(d)` with `d < taken.1.len()`, skipped while `taken.1[d]` is true). - Lock acquisition order `made -> next -> kept` in `evict` has no inversion against `mirror`/`describe_slot`/`unmade_placed` (`made -> kept`), `dynamic`/`release` (`next` only), or `keep` (`kept` only, retiring old resources via `crate::host::retire`). - Holding `ID3D12Resource` in `kept` for a live dynamic slot prevents recorded lists from sampling null views, and once the slot is released it is reclaimed either on the next `evict` pass or when `make_at` next reuses the slot (accurately documented in `1c356e51`). ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`) - `victory-gpu` `descriptor::host:: resource::` with `VICTORY_D3D12_DEBUG=1`: - RTX 5090 (`--skip dynamic_slots_are_held_until_released`, pre-existing 1M view-heap cap failure on `main`): **33/33 passed** (including `live_dynamic_slots_keep_a_texture_given_up`). - WARP (`--features diagnostics`, no skips): **34/34 passed**. - Additional probe on both RTX 5090 and WARP confirmed title slot `0` and a released dynamic slot are both nulled on `give_up_now` while a live dynamic slot keeps its view, and after `release(live, 1)` a subsequent `evict` pass clears the slot cleanly.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 19:51 UTC · original · approved these changes

LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Holding made and next across the eviction scan and skipping live dynamic slots (!taken.1[d]) prevents evicting descriptors still bound in recorded command lists while releasing already-freed dynamic slots cleanly.
  • cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 15 passed, 0 failed (including live_dynamic_slots_keep_a_texture_given_up).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 19:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2598#pullrequestreview-6079790493) · **approved these changes** LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Holding `made` and `next` across the eviction scan and skipping live dynamic slots (`!taken.1[d]`) prevents evicting descriptors still bound in recorded command lists while releasing already-freed dynamic slots cleanly. - `cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1`: 15 passed, 0 failed (including `live_dynamic_slots_keep_a_texture_given_up`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/2598/head:github-bot/gh-2598'
git switch 'github-bot/gh-2598'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2598'
git switch 'github-bot/gh-2598'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2598'
git switch 'github-bot/gh-2598'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2598'
git switch 'main'
git merge --squash 'github-bot/gh-2598'
git switch 'main'
git merge --ff-only 'github-bot/gh-2598'
git switch 'main'
git merge 'github-bot/gh-2598'
git push origin 'main'
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/Marvisak--VIctory!2598
No description provided.