GPU: preserve taken dynamic descriptor slots across texture eviction #2705

Open
Batushn wants to merge 1 commit from upstream-pr/2707 into main
Batushn commented 2026-11-25 18:33:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Batushn on 2026-11-25T18:33:28Z.


Fixes #2597

Summary

  • Split \HostHeap::evict\ into title slots (\
<!-- greyfinch-sync:Marvisak/VIctory:issue:6611124259 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2707). Originally posted by [Batushn](https://github.com/Batushn) on 2026-11-25T18:33:28Z. --- Fixes #2597 ### Summary - Split \HostHeap::evict\ into title slots (\
kotekompotek commented 2026-11-25 19:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:54:53Z.


Correct split of the two slot families: title slots evict as before (viewed + forget_read), while dynamic slots are only cleared when not still taken by an in-flight list - and the guard lock is held across the whole scan so a slot cannot be reallocated mid-evict. Nulling the CPU descriptor before taking the kept entry keeps the slot safe against late shader reads. Retiring the old resources after dropping the locks avoids holding next/kept across retire().

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171573599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2707#issuecomment-7171573599). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:54:53Z. --- Correct split of the two slot families: title slots evict as before (viewed + forget_read), while dynamic slots are only cleared when not still taken by an in-flight list - and the guard lock is held across the whole scan so a slot cannot be reallocated mid-evict. Nulling the CPU descriptor before taking the kept entry keeps the slot safe against late shader reads. Retiring the old resources after dropping the locks avoids holding next/kept across retire().
oni-swr commented 2026-11-25 19:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:56:59Z.


Independent WARP/CPU verification (claim: Marvisak/VIctory#1633)

  • PR head: fb10ff37a684fb65f5c9076437c6f3ff349c822d / origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • State: OPEN, non-draft; git merge-tree --write-tree origin/main <head> merges cleanly; no prior oni-swr comment on this head.
  • Environment: Windows 11 Pro 10.0.26200, VICTORY_WARP=1 + VICTORY_D3D12_WARP=1 (WARP only, no physical GPU, no game files/dumps/retail hashes), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, via VICTORY_DXIL), rustc 1.98.1 (48a229cea 2026-09-01), debug profile, --locked.

Commands / results (baseline = origin/main, same environment)

cargo test -p victory-shader --locked
cargo test -p victory-gpu --locked
cargo clippy -p victory-gpu --locked --all-targets
  • victory-gpu: 196 passed / 0 failed / 1 ignored (+1 vs baseline 195). New descriptor::host::tests::evict_keeps_taken_dynamic_slots_until_released ok; it executes on WARP (creates a texture, compiles with FXC, dispatches a compute shader and reads back 0xCAFEBABE).
  • Also cargo test -p victory-gpu --locked --features diagnostics: 199 / 0 / 1 (baseline with the feature: 198 / 0 / 1); cargo clippy -p victory-gpu --locked --all-targets --features diagnostics: clean.
  • victory-shader: 267 / 3 / 3, identical to baseline (the same 3 pre-existing WARP failures; unaffected by this PR).
  • clippy -p victory-gpu: 0 warnings, 0 errors (baseline 0).

Negative control: with the eviction restored to the old behaviour (loop over all kept slots incl. dynamic ones, no dynamic pass), the new test FAILS; reverted afterwards.

Code review: No correctness bugs found. Lock order: next then kept only in the new pass; no other site nests them the other way, so no deadlock risk seen. Taken dynamic slots keep their view and reference; released ones are nulled and retired. Nits (non-blocking): the test silently returns (passes) when no host device exists, so it only has value where WARP/GPU is available; let _ = index; is a leftover for non-diagnostics builds; the test depends on process-global host::release_retired() timing (bounded 5 s wait).

Not tested: physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates.

AI use: Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171620260 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2707#issuecomment-7171620260). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:56:59Z. --- **Independent WARP/CPU verification** (claim: Marvisak/VIctory#1633) - PR head: `fb10ff37a684fb65f5c9076437c6f3ff349c822d` / `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - State: OPEN, non-draft; `git merge-tree --write-tree origin/main <head>` merges cleanly; no prior `oni-swr` comment on this head. - Environment: Windows 11 Pro 10.0.26200, `VICTORY_WARP=1` + `VICTORY_D3D12_WARP=1` (WARP only, no physical GPU, no game files/dumps/retail hashes), `dxil.dll` 1.8.2502.11 (Windows SDK 10.0.26100.0, via `VICTORY_DXIL`), rustc 1.98.1 (48a229cea 2026-09-01), debug profile, `--locked`. **Commands / results** (baseline = `origin/main`, same environment) ``` cargo test -p victory-shader --locked cargo test -p victory-gpu --locked cargo clippy -p victory-gpu --locked --all-targets ``` - victory-gpu: 196 passed / 0 failed / 1 ignored (+1 vs baseline 195). New `descriptor::host::tests::evict_keeps_taken_dynamic_slots_until_released` ok; it executes on WARP (creates a texture, compiles with FXC, dispatches a compute shader and reads back 0xCAFEBABE). - Also `cargo test -p victory-gpu --locked --features diagnostics`: 199 / 0 / 1 (baseline with the feature: 198 / 0 / 1); `cargo clippy -p victory-gpu --locked --all-targets --features diagnostics`: clean. - victory-shader: 267 / 3 / 3, identical to baseline (the same 3 pre-existing WARP failures; unaffected by this PR). - clippy -p victory-gpu: 0 warnings, 0 errors (baseline 0). **Negative control:** with the eviction restored to the old behaviour (loop over all kept slots incl. dynamic ones, no dynamic pass), the new test FAILS; reverted afterwards. **Code review:** No correctness bugs found. Lock order: `next` then `kept` only in the new pass; no other site nests them the other way, so no deadlock risk seen. Taken dynamic slots keep their view and reference; released ones are nulled and retired. Nits (non-blocking): the test silently returns (passes) when no host device exists, so it only has value where WARP/GPU is available; `let _ = index;` is a leftover for non-diagnostics builds; the test depends on process-global `host::release_retired()` timing (bounded 5 s wait). **Not tested:** physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates. **AI use:** Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.
fuzeofficlal commented 2026-11-25 20:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:32:20Z.


Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of fb10ff37 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics -> 199 passed, 0 failed, 1 ignored (including evict_keeps_taken_dynamic_slots_until_released).
  • RTX 5090: cargo test --locked -p victory-gpu --lib -- descriptor -> 18 passed, 1 failed (evict_keeps_taken_dynamic_slots_until_released passes on hardware; the sole failure is the pre-existing #1744 1M view-heap cap assertion in dynamic_slots_are_held_until_released).

Review Notes

  • Splitting HostHeap::evict into title slots (0..self.count) and dynamic slots (self.count..self.count + self.dynamic) under next -> kept lock ordering (with crate::host::retire called outside both locks) is deadlock-free, closes the race against concurrent dynamic() allocation, and keeps in-flight dynamic table descriptors backed by a live ID3D12Resource.
  • Merge-ordering notes: cleanly orthogonal to #2601 (zero overlap); overlaps HostHeap::evict with #2650 (self.title_of mapping on the title-slot half, straightforward rebase once either lands).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172436020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2707#issuecomment-7172436020). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:32:20Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `fb10ff37` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics`: **0 warnings**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics` -> **199 passed, 0 failed, 1 ignored** (including `evict_keeps_taken_dynamic_slots_until_released`). - **RTX 5090:** `cargo test --locked -p victory-gpu --lib -- descriptor` -> **18 passed, 1 failed** (`evict_keeps_taken_dynamic_slots_until_released` passes on hardware; the sole failure is the pre-existing #1744 1M view-heap cap assertion in `dynamic_slots_are_held_until_released`). ### Review Notes - Splitting `HostHeap::evict` into title slots (`0..self.count`) and dynamic slots (`self.count..self.count + self.dynamic`) under `next -> kept` lock ordering (with `crate::host::retire` called outside both locks) is deadlock-free, closes the race against concurrent `dynamic()` allocation, and keeps in-flight dynamic table descriptors backed by a live `ID3D12Resource`. - **Merge-ordering notes:** cleanly orthogonal to #2601 (zero overlap); overlaps `HostHeap::evict` with #2650 (`self.title_of` mapping on the title-slot half, straightforward rebase once either lands).
Marvisak commented 2026-11-25 23:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:16:09Z.


Automated triage for the maintainers.

Needs rebase. This branch no longer merges cleanly into main: the conflict is in crates/victory-gpu/src/descriptor/host.rs. No content review was done yet; it will be reviewed once it is rebased onto current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176148796 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2707#issuecomment-7176148796). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:16:09Z. --- <!-- victory-triage v1 head=fb10ff37a684fb65f5c9076437c6f3ff349c822d verdict=needs-rebase at=2026-11-25T22:17:00Z --> Automated triage for the maintainers. **Needs rebase.** This branch no longer merges cleanly into `main`: the conflict is in `crates/victory-gpu/src/descriptor/host.rs`. No content review was done yet; it will be reviewed once it is rebased onto current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2707:upstream-pr/2707'
git switch 'upstream-pr/2707'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2707'
git switch 'upstream-pr/2707'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2707'
git switch 'upstream-pr/2707'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2707'
git switch 'main'
git merge --squash 'upstream-pr/2707'
git switch 'main'
git merge --ff-only 'upstream-pr/2707'
git switch 'main'
git merge 'upstream-pr/2707'
git push origin 'main'
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
Marvisak/VIctory!2705
No description provided.