Slot eviction: look for victims off the submitting thread (VICTORY_SLOT_EVICT_ASIDE) #3750

Closed
github-bot wants to merge 5 commits from github-bot/gh-3750 into main AGit
Owner

@⁠Mikey970 on GitHub · 2026-11-30 05:57 UTC · original
Mikey970:pr/slot-evict-aside → main · +664 −77 · 4 files · 2 commits · closed without merging

[pr-performance] Slot eviction: look for victims off the submitting thread (VICTORY_SLOT_EVICT_ASIDE)

Fixes #1644

What it changes

With VICTORY_SLOT_EVICT=1 and the card over its line, every sweep (once a second, on the submitting thread, before a submission) ran slot_evict's whole look: every title texture under the textures table's lock (a made lock for each idle one), then descriptor::evictable_slots over every slot of every heap (HostHeap::slots_showing, a slot lock each). #1644 measured 28–79 ms a second for it on an 8 GB card; on our RTX 4080 16 GB at 4K output with about 58,000 title textures it was 57–104 ms a sweep, about once a second.

This moves the look, not the eviction:

  • slot_evict keeps everything cheap on the submitting thread (the frame ring, the two lines, need, cutoff). The look (slot_look over the table, slot_choose with evictable_slots and oldest_covering) then runs on a thread of its own (victory-slot-look), one look at a time, holding the table 4,096 entries at a time (table_part) instead of all at once. The slots are looked at after the table is let go, as now (a thread making a slot takes the table under the slot's lock).
  • Its choice is carried out at the next submission's sweep (slot_evict_ready, at the top of host::sweep). Each texture is looked at again first (slot_still_victim): still in the table, still unused for the idle time, the same host copy held by its texture alone, and every one of its slots still showing that copy and still of the kind it was found to be (descriptor::slots_still_evictable → HostHeap::slot_still_evictable, which repeats slots_showing's rules for that one slot; with VICTORY_SAMPLED_EVICT=1, also no shader mark since cutoff). Anything that changed is kept and counted. A slot made of the copy in between is a use of it (hosted stamps used), so it fails the second check.
  • The rules, the order, the caps and the counts (SLOT_EVICT, SLOT_STATE, sampled::COLD) are the same; only where and when the look runs moves. The carrying out is the loop that was already there (slot_apply), unchanged but for the second look and a check that the copy taken is still the one chosen.
  • A flush (F7/F8) still looks and evicts on the submitting thread, as it says what it let go at once.
  • A line (on the 1st, 2nd, 4th… and every 64th look): looks aside, their average and longest time, textures let go, kept at their second look, the longest carrying out.

VICTORY_SLOT_EVICT_ASIDE=0 (read with toggled!): the whole pass on the submitting thread, as before. Nothing changes without VICTORY_SLOT_EVICT=1.

Files: crates/victory-gpu/src/resource.rs (slot_evict split into slot_look / slot_choose / slot_apply, the aside machinery, two tests), descriptor.rs (slots_still_evictable), descriptor/host.rs (HostHeap::slot_still_evictable), host.rs (one call in sweep). The GPL attribution of the slot-eviction code (memory stack by skornuta, skornuta/victory-memory-stack 57fb136, GPL-3.0) is kept and carried onto the new function in descriptor/host.rs.

How it was tested

  • In game on this branch's base (main 41adb551 + this change): the full 375 s route completed with no errors and no lost device. slot eviction aside (VICTORY_SLOT_EVICT_ASIDE), since the start: 16 looks off the submitting thread, 37.2 ms each, the longest 52.8 — that is 16 stalls of 37–53 ms each that the submitting thread no longer takes. Build: main at 41adb551 with this change, release, RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Series X profile, DLSS Performance through Streamline (1080p rendered, 3840x2160 output), ray tracing off, frame generation off, warm pipeline cache from an earlier run, the 375 s Chapter 1 route (interrogation, therapist, flyover, boat, shore) driven by VICTORY_KEYS.

  • GPU and profile: RTX 4080 16 GB, Series X profile, 1080p → 4K DLSS, no frame generation, no ray tracing. The same 375 s route each time, VICTORY_SLOT_EVICT=1, the card over its high line.

  • The numbers below are from our fork's build, where this change was first written. This branch is a hand port onto current main (41adb551), whose slot_evict has changed a good deal since (the table is already let go before evictable_slots, the sampled-marks path, flushes); the in-game check of the rebased build is the first item above.

  • Before (run R12): 237 frame intervals over 100 ms, p99 126 ms; boat segment 21 over 100 ms, shore 16. The slow sweeps were all in "host copies of textures": 57–104 ms a sweep, 200 sweeps of 20 ms or more, while let_go_idle's own look stayed under 2.7 ms.

  • After, four full runs (R14, R19, R20, R21): 89–97 frame intervals over 100 ms, p99 87 ms in R14; boat segment 0 (against 21), shore 0. Those runs carry other changes of the fork too; an earlier isolated A/B on one exe (room line lowered so the look never ran) went 237 → 28, which is the part this hitch accounts for.

  • New unit tests: resource::tests::the_table_is_walked_in_parts_every_entry_once (every entry once, in order, for any part size; empty table; the top address), resource::tests::a_texture_freed_since_the_look_aside_is_left_alone (a choice for a texture no longer in the table is kept, counted, and never read).

  • CI-equivalent commands on this branch (5a1c053f on 41adb551; offline, --locked):

    • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: does not get as far as victory-gpu. victory-shader fails on current main without this PR (unused import PAIR_MEETINGS and analysis::lane_regions, while_immutable_condition in emit/lower/analysis.rs). So CI's clippy steps are red on main as it stands.
    • cargo clippy -p victory-gpu --all-targets --locked and the same with --all-features: exit 0. No warning in the lines this adds. The one warning near them, unused variable: busy at resource.rs slot_apply, is main's own line (let (reset, busy) = evict_slots(..) in slot_evict), moved, not changed. evict_slots documents that a busy slot means the copy must stay, and main never reads it. Worth a look, but left out of this PR on purpose.
    • cargo test -p victory-gpu --lib --locked (with VICTORY_WARP=1): 922 passed, 2 failed, 60 ignored. Both failures are the same on 41adb551 without this PR: shader_cache::tests::every_switch_of_the_translator_is_in_the_key ("VICTORY_SCALAR_SPLITS is not read by the translator any more"), and host::menu::tests::a_change_is_saved_at_once_however_the_game_was_started, which fails whenever the menu tests run together and passes alone, on both.
    • The new tests and the existing slot tests (cargo test -p victory-gpu --lib -- slot, and the two by name): all pass.
    • cargo xtask policy --staged: "asset policy: 4 files ok". (cargo xtask policy over the tree fails on main at crates/victory-loader/src/heap_sites/frame_users.rs, a run of 2022 hex digits. This PR does not touch that file.)
  • cargo test passed for the crates it touches: yes, apart from the two failures above, which fail the same way on main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2720, #1358, #3476.
    • #2720 (open) makes HostHeap::slots_showing cheaper with an atomic occupancy bitmap. That is one of the two walks; it leaves the walk of every title texture under the table's lock on the submitting thread. This PR moves both walks off that thread and does not touch slots_showing, so the two compose: with #2720 the look aside is simply shorter. #2720 moves kept behind KeptSlots; HostHeap::slot_still_evictable here reads self.kept.get(i) and the slot lock, so whichever lands second needs a one-line change there (raw_at).
    • #1358 and #3476 (both open) release retired D3D12 objects on a thread of their own. This PR does not do that and adds no such thread; what it lets go is retired through host::retire as before.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 05:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750) `Mikey970:pr/slot-evict-aside` → `main` · +664 −77 · 4 files · 2 commits · closed without merging [pr-performance] Slot eviction: look for victims off the submitting thread (VICTORY_SLOT_EVICT_ASIDE) Fixes #1644 ## What it changes With `VICTORY_SLOT_EVICT=1` and the card over its line, every sweep (once a second, on the submitting thread, before a submission) ran `slot_evict`'s whole look: every title texture under the textures table's lock (a `made` lock for each idle one), then `descriptor::evictable_slots` over every slot of every heap (`HostHeap::slots_showing`, a slot lock each). #1644 measured 28–79 ms a second for it on an 8 GB card; on our RTX 4080 16 GB at 4K output with about 58,000 title textures it was 57–104 ms a sweep, about once a second. This moves the look, not the eviction: - `slot_evict` keeps everything cheap on the submitting thread (the frame ring, the two lines, `need`, `cutoff`). The look (`slot_look` over the table, `slot_choose` with `evictable_slots` and `oldest_covering`) then runs on a thread of its own (`victory-slot-look`), one look at a time, holding the table 4,096 entries at a time (`table_part`) instead of all at once. The slots are looked at after the table is let go, as now (a thread making a slot takes the table under the slot's lock). - Its choice is carried out at the next submission's sweep (`slot_evict_ready`, at the top of `host::sweep`). Each texture is looked at again first (`slot_still_victim`): still in the table, still unused for the idle time, the same host copy held by its texture alone, and every one of its slots still showing that copy and still of the kind it was found to be (`descriptor::slots_still_evictable` → `HostHeap::slot_still_evictable`, which repeats `slots_showing`'s rules for that one slot; with `VICTORY_SAMPLED_EVICT=1`, also no shader mark since `cutoff`). Anything that changed is kept and counted. A slot made of the copy in between is a use of it (`hosted` stamps `used`), so it fails the second check. - The rules, the order, the caps and the counts (`SLOT_EVICT`, `SLOT_STATE`, `sampled::COLD`) are the same; only where and when the look runs moves. The carrying out is the loop that was already there (`slot_apply`), unchanged but for the second look and a check that the copy taken is still the one chosen. - A flush (F7/F8) still looks and evicts on the submitting thread, as it says what it let go at once. - A line (on the 1st, 2nd, 4th… and every 64th look): looks aside, their average and longest time, textures let go, kept at their second look, the longest carrying out. `VICTORY_SLOT_EVICT_ASIDE=0` (read with `toggled!`): the whole pass on the submitting thread, as before. Nothing changes without `VICTORY_SLOT_EVICT=1`. Files: `crates/victory-gpu/src/resource.rs` (`slot_evict` split into `slot_look` / `slot_choose` / `slot_apply`, the aside machinery, two tests), `descriptor.rs` (`slots_still_evictable`), `descriptor/host.rs` (`HostHeap::slot_still_evictable`), `host.rs` (one call in `sweep`). The GPL attribution of the slot-eviction code (memory stack by skornuta, skornuta/victory-memory-stack 57fb136, GPL-3.0) is kept and carried onto the new function in `descriptor/host.rs`. ## How it was tested - **In game on this branch's base (`main` 41adb551 + this change):** the full 375 s route completed with no errors and no lost device. `slot eviction aside (VICTORY_SLOT_EVICT_ASIDE), since the start: 16 looks off the submitting thread, 37.2 ms each, the longest 52.8` — that is 16 stalls of 37–53 ms each that the submitting thread no longer takes. Build: `main` at 41adb551 with this change, release, RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Series X profile, DLSS Performance through Streamline (1080p rendered, 3840x2160 output), ray tracing off, frame generation off, warm pipeline cache from an earlier run, the 375 s Chapter 1 route (interrogation, therapist, flyover, boat, shore) driven by `VICTORY_KEYS`. - GPU and profile: RTX 4080 16 GB, Series X profile, 1080p → 4K DLSS, no frame generation, no ray tracing. The same 375 s route each time, `VICTORY_SLOT_EVICT=1`, the card over its high line. - The numbers below are from our fork's build, where this change was first written. This branch is a hand port onto current `main` (41adb551), whose `slot_evict` has changed a good deal since (the table is already let go before `evictable_slots`, the sampled-marks path, flushes); the in-game check of the rebased build is the first item above. - Before (run R12): 237 frame intervals over 100 ms, p99 126 ms; boat segment 21 over 100 ms, shore 16. The slow sweeps were all in "host copies of textures": 57–104 ms a sweep, 200 sweeps of 20 ms or more, while `let_go_idle`'s own look stayed under 2.7 ms. - After, four full runs (R14, R19, R20, R21): 89–97 frame intervals over 100 ms, p99 87 ms in R14; boat segment 0 (against 21), shore 0. Those runs carry other changes of the fork too; an earlier isolated A/B on one exe (room line lowered so the look never ran) went 237 → 28, which is the part this hitch accounts for. - New unit tests: `resource::tests::the_table_is_walked_in_parts_every_entry_once` (every entry once, in order, for any part size; empty table; the top address), `resource::tests::a_texture_freed_since_the_look_aside_is_left_alone` (a choice for a texture no longer in the table is kept, counted, and never read). - CI-equivalent commands on this branch (5a1c053f on 41adb551; offline, `--locked`): - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: does not get as far as `victory-gpu`. `victory-shader` fails on current `main` without this PR (unused import `PAIR_MEETINGS` and `analysis::lane_regions`, `while_immutable_condition` in `emit/lower/analysis.rs`). So CI's clippy steps are red on `main` as it stands. - `cargo clippy -p victory-gpu --all-targets --locked` and the same with `--all-features`: exit 0. No warning in the lines this adds. The one warning near them, `unused variable: busy` at `resource.rs` `slot_apply`, is `main`'s own line (`let (reset, busy) = evict_slots(..)` in `slot_evict`), moved, not changed. `evict_slots` documents that a busy slot means the copy must stay, and `main` never reads it. Worth a look, but left out of this PR on purpose. - `cargo test -p victory-gpu --lib --locked` (with `VICTORY_WARP=1`): 922 passed, 2 failed, 60 ignored. Both failures are the same on `41adb551` without this PR: `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` ("VICTORY_SCALAR_SPLITS is not read by the translator any more"), and `host::menu::tests::a_change_is_saved_at_once_however_the_game_was_started`, which fails whenever the menu tests run together and passes alone, on both. - The new tests and the existing slot tests (`cargo test -p victory-gpu --lib -- slot`, and the two by name): all pass. - `cargo xtask policy --staged`: "asset policy: 4 files ok". (`cargo xtask policy` over the tree fails on `main` at `crates/victory-loader/src/heap_sites/frame_users.rs`, a run of 2022 hex digits. This PR does not touch that file.) - `cargo test` passed for the crates it touches: yes, apart from the two failures above, which fail the same way on `main`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2720, #1358, #3476. - **#2720** (open) makes `HostHeap::slots_showing` cheaper with an atomic occupancy bitmap. That is one of the two walks; it leaves the walk of every title texture under the table's lock on the submitting thread. This PR moves both walks off that thread and does not touch `slots_showing`, so the two compose: with #2720 the look aside is simply shorter. #2720 moves `kept` behind `KeptSlots`; `HostHeap::slot_still_evictable` here reads `self.kept.get(i)` and the slot lock, so whichever lands second needs a one-line change there (`raw_at`). - **#1358** and **#3476** (both open) release retired D3D12 objects on a thread of their own. This PR does not do that and adds no such thread; what it lets go is retired through `host::retire` as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With VICTORY_SLOT_EVICT=1 and the card over its line, every sweep ran
slot_evict's whole look on the submitting thread: every title texture
under the textures table's lock, then evictable_slots over every slot of
every heap. #1644 measured 28-79 ms a second on an 8 GB card; on an RTX
4080 16 GB at 4K output (about 58,000 title textures) it was 57-104 ms a
sweep, about once a second.

- slot_evict keeps the cheap part (ring, lines, need, cutoff) where it
  was; the look (slot_look over the table, slot_choose with
  evictable_slots and oldest_covering) runs on victory-slot-look, one look
  at a time, the table held 4096 entries at a time (table_part).
- Its choice is carried out at the next submission's sweep
  (slot_evict_ready). Each texture is looked at again first
  (slot_still_victim): still in the table, still idle, the same host copy
  held by its texture alone, and every slot still showing it and still of
  the kind found (descriptor::slots_still_evictable,
  HostHeap::slot_still_evictable); else it is kept and counted.
- Same rules, order, caps and counts; slot_apply is the loop that was
  there. A flush (F7, F8) still looks on the submitting thread.

VICTORY_SLOT_EVICT_ASIDE=0: the whole pass on the submitting thread, as
before. Nothing changes without VICTORY_SLOT_EVICT=1.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 05:57:23 +00:00
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 06:00 UTC · original

Holding this as a draft while I check a possible regression. In two in-game runs of main 41adb551 + this PR + #3749/#3750/#3751 together (RTX 4080, Series X, DLSS Performance via Streamline), the run ended near the end of the 375 s route with a host command list did not close (The parameter is incorrect. (0x80070057)); a run of plain main with the same settings finished clean. The slot-eviction look let go of no texture in either run, and the trim fired 1–3 times, so neither is an obvious cause yet. I am running each change on its own and will mark this ready again (or fix it) with the result.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 06:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7270215417) Holding this as a draft while I check a possible regression. In two in-game runs of `main` 41adb551 + this PR + #3749/#3750/#3751 together (RTX 4080, Series X, DLSS Performance via Streamline), the run ended near the end of the 375 s route with `a host command list did not close (The parameter is incorrect. (0x80070057))`; a run of plain `main` with the same settings finished clean. The slot-eviction look let go of no texture in either run, and the trim fired 1–3 times, so neither is an obvious cause yet. I am running each change on its own and will mark this ready again (or fix it) with the result. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 06:16 UTC · original

Update: with this PR's look-aside switched off (VICTORY_SLOT_EVICT_ASIDE=0) the same route completed cleanly, while both runs with it on ended at the shore with a host command list did not close (0x80070057), even though the look let go of no texture in either. Two runs each is not proof either way (upstream has open reports of the same error on main), but it is enough that I am keeping this a draft until a diagnostics build with VICTORY_D3D12_DEBUG=1 names the failing command.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 06:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7270477685) Update: with this PR's look-aside switched off (`VICTORY_SLOT_EVICT_ASIDE=0`) the same route completed cleanly, while both runs with it on ended at the shore with `a host command list did not close (0x80070057)`, even though the look let go of no texture in either. Two runs each is not proof either way (upstream has open reports of the same error on `main`), but it is enough that I am keeping this a draft until a diagnostics build with `VICTORY_D3D12_DEBUG=1` names the failing command. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 07:18 UTC · original

Cleared: with the twin-copy fix (#3792, the CopyTextureRegion into a held copy) in the same build, main + this PR + #3749 completed the whole 375 s route with no did not close error (the look ran 16 times, 37.8 ms each, off the submitting thread). The debug layer had named the failing command as that out-of-bounds BC7 copy, which this PR does not touch, so the earlier ends were the copy bug, not this change. Marking ready.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 07:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7271596015) Cleared: with the twin-copy fix (#3792, the `CopyTextureRegion` into a held copy) in the same build, `main` + this PR + #3749 completed the whole 375 s route with no `did not close` error (the look ran 16 times, 37.8 ms each, off the submitting thread). The debug layer had named the failing command as that out-of-bounds BC7 copy, which this PR does not touch, so the earlier ends were the copy bug, not this change. Marking ready. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Yoruiopz on GitHub · 2026-11-30 07:38 UTC · original

I reproduced the cost this targets on an RTX 5070 Laptop GPU with 8 GB. The measured descriptor lock walk took 16.53 ms median in a busy Series X segment and yielded zero texture evictions in 38 passes. The breakdown is on #1644.

One correctness case to cover for the worker path. In 5a1c053, slot_still_victim checks that a slot still holds the planned host copy. Later, evict_slots calls texture_slot_evicted, which takes the per-slot Made lock but only tests for a nonzero current key before clearing the slot. A slot rewrite from A to B could finish in that gap. The eviction would then acquire the lock uncontended and clear B. Checking only the returned busy flag would miss a completed rewrite.

Could the commit path validate the expected view identity under the same Made guard that protects the clear, and decline the victim on mismatch or a busy slot? A focused test could validate a slot showing A, install B before the clear, then check that the stale plan leaves B and its waiting state intact. This is a source-review finding. I have not reproduced the race in gameplay.

**@⁠Yoruiopz** on GitHub · 2026-11-30 07:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7271949924) I reproduced the cost this targets on an RTX 5070 Laptop GPU with 8 GB. The measured descriptor lock walk took 16.53 ms median in a busy Series X segment and yielded zero texture evictions in 38 passes. The breakdown is on #1644. One correctness case to cover for the worker path. In `5a1c053`, `slot_still_victim` checks that a slot still holds the planned host copy. Later, `evict_slots` calls `texture_slot_evicted`, which takes the per-slot `Made` lock but only tests for a nonzero current key before clearing the slot. A slot rewrite from A to B could finish in that gap. The eviction would then acquire the lock uncontended and clear B. Checking only the returned `busy` flag would miss a completed rewrite. Could the commit path validate the expected view identity under the same `Made` guard that protects the clear, and decline the victim on mismatch or a busy slot? A focused test could validate a slot showing A, install B before the clear, then check that the stale plan leaves B and its waiting state intact. This is a source-review finding. I have not reproduced the race in gameplay.
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 07:47 UTC · original

I reproduced the busy-descriptor half of the concern above with a real Direct3D 12 heap and a synthetic 4×4 texture on 5a1c053. The fixture holds the slot's Made lock while slot_apply runs. evict_slots reports that the slot is busy, and the current loop still retires one host copy (4,096 bytes in this fixture). The ignored busy result is inherited from main.

Cherry-pickable 8c82f6e uses the existing keep-and-restore path when a slot is busy, including when earlier slots in the same pass were already reset. The regression test preserves the exact host copy and reports zero evictions. Windows WARP cargo test --locked -p victory-gpu --lib slot passed 46 tests (2 ignored). The regression also passed with the normal adapter selection and with #3697 applied alongside this PR. Staged asset policy passed. The locked-slot reproduction and patch were built with Codex assistance.

The completed descriptor rewrite described in the preceding comment would need the identity checked under the Made lock at the clear. The test here exercises an actual failed try-lock.

**@⁠tyr0nsur** on GitHub · 2026-11-30 07:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7272126669) I reproduced the busy-descriptor half of the concern above with a real Direct3D 12 heap and a synthetic 4×4 texture on `5a1c053`. The fixture holds the slot's `Made` lock while `slot_apply` runs. `evict_slots` reports that the slot is busy, and the current loop still retires one host copy (4,096 bytes in this fixture). The ignored `busy` result is inherited from main. [Cherry-pickable `8c82f6e`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/8c82f6e4c044a6a862e5b6f56602d5bca5d58a33) uses the existing keep-and-restore path when a slot is busy, including when earlier slots in the same pass were already reset. The regression test preserves the exact host copy and reports zero evictions. Windows WARP `cargo test --locked -p victory-gpu --lib slot` passed 46 tests (2 ignored). The regression also passed with the normal adapter selection and with #3697 applied alongside this PR. Staged asset policy passed. The locked-slot reproduction and patch were built with Codex assistance. The completed descriptor rewrite described in the preceding comment would need the identity checked under the `Made` lock at the clear. The test here exercises an actual failed try-lock.
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 07:59 UTC · original

I reproduced the completed rewrite from Yoruiopz's review with live D3D12 descriptors and synthetic textures. The fixture captures the slot showing A, writes and mirrors B, then calls the real apply loop with the old plan. With 8c82f6e alone, the loop retired A and cleared B's host descriptor.

Commit 846517f, on top of 8c82f6e, carries the heap ID and view key through the scan and validates the view key and expected host texture under the same Made lock as the clear. It also keeps a texture when make_again has cleared the key while the old resource remains in the slot.

The regression checks replacement by another texture, replacement by another mip view of the same texture, an invalidated key with a live view, and the successful clear of a matching descriptor. It passed in Windows WARP and with normal adapter selection. The 46 tests selected by --lib slot, the diagnostics feature check and staged asset policy also passed. The tests use synthetic textures. In-game impact remains unmeasured. Implemented and verified with Codex assistance.

**@⁠tyr0nsur** on GitHub · 2026-11-30 07:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7272350644) I reproduced the completed rewrite from [Yoruiopz's review](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/3750) with live D3D12 descriptors and synthetic textures. The fixture captures the slot showing A, writes and mirrors B, then calls the real apply loop with the old plan. With `8c82f6e` alone, the loop retired A and cleared B's host descriptor. [Commit `846517f`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/846517fda088b5651750ecfd26d30c9239262cf1), on top of `8c82f6e`, carries the heap ID and view key through the scan and validates the view key and expected host texture under the same `Made` lock as the clear. It also keeps a texture when `make_again` has cleared the key while the old resource remains in the slot. The regression checks replacement by another texture, replacement by another mip view of the same texture, an invalidated key with a live view, and the successful clear of a matching descriptor. It passed in Windows WARP and with normal adapter selection. The 46 tests selected by `--lib slot`, the diagnostics feature check and staged asset policy also passed. The tests use synthetic textures. In-game impact remains unmeasured. Implemented and verified with Codex assistance.
Author
Owner

@⁠Yoruiopz on GitHub · 2026-11-30 08:11 UTC · original

Following up on the completed-rewrite case from my earlier comment. I tested 56c1294 on top of 5a1c053 and @⁠tyr0nsur's original busy-slot fix 8c82f6e.

The patch carries the planned heap identity and made key, then checks the key and retained resource under the same Made lock as the clear. A mismatch or busy slot preserves the texture and uses the existing recovery path for slots already reset.

The deterministic synthetic test publishes B after validating A. It exercises a different resource under the same key and a different key for the same resource. Both cases preserve the new slot and its waiting state. The focused slot_eviction_ filter passed four tests on the RTX 5070 Laptop GPU, including the distinct busy-slot regression. Dino's WARP runtime exposed Shader Model 6.2, so these results use the native D3D12 adapter.

The identity commit is available to cherry-pick if useful. These tests cover completed replacements of the planned slot. They leave exact same-key/same-resource republication and newly added references in other slots outside the validation scope.

**@⁠Yoruiopz** on GitHub · 2026-11-30 08:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7272590310) Following up on the completed-rewrite case from my earlier comment. I tested [`56c1294`](https://github.com/Yoruiopz/VIctory-NVIDIA/commit/56c1294df8a41d702f0b473df85b4b0a16e67691) on top of `5a1c053` and @⁠tyr0nsur's original busy-slot fix `8c82f6e`. The patch carries the planned heap identity and made key, then checks the key and retained resource under the same `Made` lock as the clear. A mismatch or busy slot preserves the texture and uses the existing recovery path for slots already reset. The deterministic synthetic test publishes B after validating A. It exercises a different resource under the same key and a different key for the same resource. Both cases preserve the new slot and its waiting state. The focused `slot_eviction_` filter passed four tests on the RTX 5070 Laptop GPU, including the distinct busy-slot regression. Dino's WARP runtime exposed Shader Model 6.2, so these results use the native D3D12 adapter. The identity commit is available to cherry-pick if useful. These tests cover completed replacements of the planned slot. They leave exact same-key/same-resource republication and newly added references in other slots outside the validation scope.
Respect the busy result from descriptor eviction before taking the host copy. The existing keep path queues any slots reset earlier in the pass for restoration.

Exercise the submission eviction loop with a real locked Direct3D descriptor slot.
Carry the heap ID and view key through the eviction plan. Clear only the expected view and host copy under the Made lock, and keep a texture with an invalidated slot that still displays it.

Reproduce descriptor replacement, a changed mip view, and an invalidated key with actual Direct3D 12 descriptors.
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 13:54 UTC · original

@⁠Yoruiopz @⁠tyr0nsur thank you both; the analysis is right on both counts. evict_slots reported a busy slot and the loop ignored it (that is inherited from main), and texture_slot_evicted only tested for a nonzero key, so a rewrite A→B completing between the plan and the clear would have cleared B.

This branch now carries @⁠tyr0nsur's two commits unchanged (fast-forward, authorship kept):

  • 8c82f6e: a busy slot keeps the texture, through the existing restore path for slots already reset.
  • 846517f: the plan carries heap ID and view key, and the clear checks key and host texture under the same Made lock; an invalidated key that still shows the old resource also keeps the texture.

@⁠Yoruiopz, your 56c1294 does the same check (sampling the key under the lock at plan time too); the two conflict, so I took one. I went with 846517f because it builds directly on 8c82f6e and its test runs the real apply loop on texture SRVs, including the same-texture/other-mip and make_again cases. Your report is what found this, thanks.

Tested at 846517f (VICTORY_WARP=1): cargo test -p victory-gpu --lib -- descriptor:: resource:: 152 passed, 0 failed; --lib slot 50 passed; the busy-slot and stale-rewrite tests pass. cargo check --all-features --all-targets is clean, and clippy adds no warnings (it drops the old unused busy one). The CI check failure is the pre-existing unwind_copy one on main 41adb551.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 13:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7280546211) @⁠Yoruiopz @⁠tyr0nsur thank you both; the analysis is right on both counts. `evict_slots` reported a busy slot and the loop ignored it (that is inherited from `main`), and `texture_slot_evicted` only tested for a nonzero key, so a rewrite A→B completing between the plan and the clear would have cleared B. This branch now carries @⁠tyr0nsur's two commits unchanged (fast-forward, authorship kept): - `8c82f6e`: a busy slot keeps the texture, through the existing restore path for slots already reset. - `846517f`: the plan carries heap ID and view key, and the clear checks key and host texture under the same `Made` lock; an invalidated key that still shows the old resource also keeps the texture. @⁠Yoruiopz, your `56c1294` does the same check (sampling the key under the lock at plan time too); the two conflict, so I took one. I went with `846517f` because it builds directly on `8c82f6e` and its test runs the real apply loop on texture SRVs, including the same-texture/other-mip and `make_again` cases. Your report is what found this, thanks. Tested at `846517f` (`VICTORY_WARP=1`): `cargo test -p victory-gpu --lib -- descriptor:: resource::` 152 passed, 0 failed; `--lib slot` 50 passed; the busy-slot and stale-rewrite tests pass. `cargo check --all-features --all-targets` is clean, and clippy adds no warnings (it drops the old unused `busy` one). The CI `check` failure is the pre-existing `unwind_copy` one on `main` 41adb551. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`slots_showing` took the slot's `Made` key with `?`, but `Made` has keys
for the title's `count` slots only while `kept` also has the dynamic
ones: a host texture shown by a dynamic slot was no longer reported, so
it was no longer blocked and could be chosen (freeing nothing, as the
dynamic slot holds a reference, while the title made a second copy).
Those slots are reported again with key 0, as before the key was carried;
they are never put back to waiting, only counted as blocking. Test:
`a_dynamic_slot_showing_a_texture_still_blocks_its_eviction`.

`SLOT_LOOKING` is now cleared by a drop guard, so a look that panics does
not stop every later look.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 14:44 UTC · original

Follow-up b23c0c40 on top of 846517f:

  • slots_showing read the slot's Made key with ?, but Made holds keys only for the title's count slots while kept also has the dynamic ones. A host texture shown by a dynamic slot was therefore dropped from the answer and no longer counted as blocked, so it could be chosen (freeing nothing, since the dynamic slot holds a reference). Dynamic slots are reported again with key 0, as on main, which also restores the VICTORY_SLOT_EVICT_ASIDE=0 path. New test: a_dynamic_slot_showing_a_texture_still_blocks_its_eviction.
  • SLOT_LOOKING is now cleared by a drop guard, so a look thread that panics no longer stops all later looks.

Tested (WARP): cargo test -p victory-gpu --lib -- descriptor:: resource:: 153 passed, 0 failed. Clippy warnings are unchanged.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 14:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7281851500) Follow-up `b23c0c40` on top of `846517f`: - `slots_showing` read the slot's `Made` key with `?`, but `Made` holds keys only for the title's `count` slots while `kept` also has the dynamic ones. A host texture shown by a dynamic slot was therefore dropped from the answer and no longer counted as blocked, so it could be chosen (freeing nothing, since the dynamic slot holds a reference). Dynamic slots are reported again with key 0, as on `main`, which also restores the `VICTORY_SLOT_EVICT_ASIDE=0` path. New test: `a_dynamic_slot_showing_a_texture_still_blocks_its_eviction`. - `SLOT_LOOKING` is now cleared by a drop guard, so a look thread that panics no longer stops all later looks. Tested (WARP): `cargo test -p victory-gpu --lib -- descriptor:: resource::` 153 passed, 0 failed. Clippy warnings are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Conflicts resolved against #3848 (queue-counted plan, untouched here),
2fb0d44d (byte-line plan, untouched), 156e3567 (empty-pass back-off) and
5bae53c3 (dead render-target reclaim):
- The back-off (`slot_evict_backoff_ms`) now covers both paths: one
  `SLOT_NEXT_MS` gates the pass, set after a pass here, after a look
  aside that chose nothing, and after a choice carried out at the sweep
  (`slot_back_off`; `SlotJob` carries `over_budget`).
- Main's `if busy { continue }` in the apply loop is dropped: a busy or
  changed slot already keeps the texture there, and that path also makes
  again (`texture_made`) the slots reset earlier in the pass.
- Main's `texture_slot_evicted(index, expected_raw)` stays for the dead
  render-target reclaim; planned slot eviction uses
  `texture_slot_evicted_as_planned` (heap id, view key and host texture
  checked under the `Made` lock). The reclaim reads the key-bearing
  `slots_showing` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 15:05 UTC · original

Merged current main (c71899d9) into this branch: aa8873af. Conflicts were resolved against #3848, 2fb0d44d, 156e3567 and 5bae53c3:

  • Plan unchanged: the queue-counted, byte-line eviction plan from main is kept as-is; this PR only moves the look aside and checks slots at the clear.
  • Back-off covers both paths: the empty-pass back-off (slot_evict_backoff_ms) now gates both the inline look and the look aside. It is set after an inline pass, after a look aside that chose nothing, and after a choice carried out at the sweep.
  • Busy slots: main's if busy { continue } in the apply loop is dropped. Here a busy or changed slot already keeps the texture, and that path also re-makes slots reset earlier in the pass (texture_made), which the continue skipped.
  • Two eviction checks: main's texture_slot_evicted(index, expected_raw) stays for the dead render-target reclaim. Planned slot eviction uses texture_slot_evicted_as_planned, which checks heap id, view key and host texture under the Made lock.

Tested (WARP): cargo test -p victory-gpu --lib -- descriptor:: resource:: 185 passed, 0 failed; cargo check --all-features --all-targets clean; clippy adds no warnings. To run the tests I had to patch two card_pass test calls in host.rs locally: on main c71899d9 they do not compile because they lack the new capture argument. That patch is not pushed.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 15:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7282407409) Merged current `main` (c71899d9) into this branch: `aa8873af`. Conflicts were resolved against #3848, 2fb0d44d, 156e3567 and 5bae53c3: - **Plan unchanged:** the queue-counted, byte-line eviction plan from `main` is kept as-is; this PR only moves the look aside and checks slots at the clear. - **Back-off covers both paths:** the empty-pass back-off (`slot_evict_backoff_ms`) now gates both the inline look and the look aside. It is set after an inline pass, after a look aside that chose nothing, and after a choice carried out at the sweep. - **Busy slots:** `main`'s `if busy { continue }` in the apply loop is dropped. Here a busy or changed slot already keeps the texture, and that path also re-makes slots reset earlier in the pass (`texture_made`), which the `continue` skipped. - **Two eviction checks:** `main`'s `texture_slot_evicted(index, expected_raw)` stays for the dead render-target reclaim. Planned slot eviction uses `texture_slot_evicted_as_planned`, which checks heap id, view key and host texture under the `Made` lock. Tested (WARP): `cargo test -p victory-gpu --lib -- descriptor:: resource::` 185 passed, 0 failed; `cargo check --all-features --all-targets` clean; clippy adds no warnings. To run the tests I had to patch two `card_pass` test calls in `host.rs` locally: on `main` c71899d9 they do not compile because they lack the new `capture` argument. That patch is not pushed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Aniseto on GitHub · 2026-11-30 16:31 UTC · original

Attempted the two new unit tests and the slot tests at aa8873af; they could not run at this head.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug, detached worktree at the exact PR head, no local patches
  • Env: VICTORY_D3D12_ADAPTER=NVIDIA

Results

  • VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib --locked: exit 101, error[E0061] twice. The same error appears for resource::tests::the_table_is_walked_in_parts_every_entry_once, resource::tests::a_texture_freed_since_the_look_aside_is_left_alone, and cargo test -p victory-gpu --lib --locked -- slot --test-threads=1.
  • Both errors are in unchanged baseline GPU fixtures: card_pass(...) is called with 5 arguments at crates/victory-gpu/src/host.rs:20305 and :20331 but takes 6 (the [u32; 3] capture argument), declared at :4248. The victory-gpu lib test target does not compile, so no test result was emitted.

What this adds
This run confirms the same compile blocker on a second NVIDIA host with 16 GB of VRAM: the two new unit tests and the slot tests are unreachable at this head without editing test fixtures, which I did not do. The author's WARP run at 41adb551 and the 922/2/60 counts were on a different tree; nothing here exercises slot eviction or the descriptor lock walk.

Not tested
The two new unit tests, the slot tests, the full suite, slot eviction, a retail title, paired smoke runs, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - ran the commands above at the exact head on this machine and wrote this report; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-30 16:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7284819173) Attempted the two new unit tests and the slot tests at `aa8873af`; they could not run at this head. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug, detached worktree at the exact PR head, no local patches - Env: `VICTORY_D3D12_ADAPTER=NVIDIA` **Results** - `VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib --locked`: exit 101, `error[E0061]` twice. The same error appears for `resource::tests::the_table_is_walked_in_parts_every_entry_once`, `resource::tests::a_texture_freed_since_the_look_aside_is_left_alone`, and `cargo test -p victory-gpu --lib --locked -- slot --test-threads=1`. - Both errors are in unchanged baseline GPU fixtures: `card_pass(...)` is called with 5 arguments at `crates/victory-gpu/src/host.rs:20305` and `:20331` but takes 6 (the `[u32; 3]` capture argument), declared at `:4248`. The `victory-gpu` lib test target does not compile, so no test result was emitted. **What this adds** This run confirms the same compile blocker on a second NVIDIA host with 16 GB of VRAM: the two new unit tests and the slot tests are unreachable at this head without editing test fixtures, which I did not do. The author's WARP run at `41adb551` and the 922/2/60 counts were on a different tree; nothing here exercises slot eviction or the descriptor lock walk. **Not tested** The two new unit tests, the slot tests, the full suite, slot eviction, a retail title, paired smoke runs, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - ran the commands above at the exact head on this machine and wrote this report; no game data was used.
github-bot closed this pull request 2026-12-01 18:51:22 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:49 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3750#issuecomment-7321602778) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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!3750
No description provided.