GPU: giving up a texture leaves the dynamic slots of recorded lists alone #2598
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2598
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2598"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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 · openWhat's wrong
HostHeap::evict(69d1e8e, which scanskeptsinceed25c0e) 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.rssays lists recorded before an eviction keep what they use until they are reset.What the fix does
In
HostHeap::evict:index >= count) still taken innext, i.e. held by a list not yet reset;madeandnextbefore scanningkeptand hold them across the clearing, so a slot taken or rewritten meanwhile is not nulled. The order ismade, thennext, thenkept(taken bykeep), and no path holdskeptwhile 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:
main(67e8ae1) it fails:a live dynamic slot keeps its view.resource::tests(17) anddescriptor::host::tests(13). The exception isdynamic_slots_are_held_until_released, which fails onmaintoo 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.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: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
releaseonly clears the taken bit. Dropping the reference at reset would meanreleasetakingkepttoo, so I'd rather leave it and say so.1c356e5adds that line to the comment inevict.@oni-swr on GitHub · 2026-11-25 16:49 UTC · original
Verification of
1c356e5Environment: Windows 11, D3D12 on the WARP software adapter only (
VICTORY_D3D12_WARP=1,cargo ... --features diagnostics, which is what compiles that switch in;VICTORY_DXILset to the Windows SDKdxil.dll). No physical GPU device was created. Not run on real GPU hardware.git merge-treeagainstorigin/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 thehost()early return (checked on the earlier headed0fa73).evictslot filter disabled and the test kept, it fails ata live dynamic slot keeps its view. The test does catch #2597.cargo test -p victory-gpu --features diagnostics --libat 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.
@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.
@Marvisak on GitHub · 2026-11-25 23:17 UTC · original
Automated triage for the maintainers.
In
crates/victory-gpu/src/descriptor/host.rs,HostHeap::evictnow skips dynamic slots (index >=count) that are still marked taken innext, 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 (kepthascount + dynamicentries andnext.1hasdynamic, sotaken.1[d]stays in bounds) and the lock order:made, thennext, thenkept.mirrortakesmadethenkept, anddynamic/releasetake onlynext, so I found no inversion. One thing to weigh:madeis now held during the fullkeptscan. Before, it was taken only after the scan, so title threads waiting onmademay block a little longer while an eviction pass runs. The new testlive_dynamic_slots_keep_a_texture_given_upcovers held, released and title slots. CI: passing (check). This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
@fyernald on GitHub · 2026-11-25 16:41 UTC · original · approved these changes
Tested on an RTX 3080 (617.42), Windows 10 (19045),
main67e8ae1:cargo test -p victory-gpu --lib --locked -- --test-threads=1gives 193 passed, 3 failed.live_dynamic_slots_keep_a_texture_given_uppasses. The 3 failures also fail onmainhere: the two heap-cap tests (FIND-9) and the Windows 10 castable test (#1999).I checked the lock order, since
evictnow holdsnexttoo. Every function indescriptor/host.rsthat holds more than one of these locks takesmadebeforekept(mirror,describe_slot,unmade_placed).dynamicandreleaseholdnextalone and call nothing that locks. Somade→next→kepthere 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
keptafter the list resets.releaseonly clears thetakenbit, so the reference goes when the slot is next written bymake_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.@fuzeofficlal on GitHub · 2026-11-26 16:12 UTC · original · approved these changes
Reviewed
1c356e5140948aefeba3ac036e4f1d2caad491de(merged cleanly onto63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.Audit
crates/victory-gpu/src/descriptor/host.rs:787,:793,:794,:799):keptis sizedcount + extraandnext.1is sizedextra, soi.checked_sub(self.count)cleanly partitions title slots (None, evicted) and dynamic slots (Some(d)withd < taken.1.len(), skipped whiletaken.1[d]is true).made -> next -> keptinevicthas no inversion againstmirror/describe_slot/unmade_placed(made -> kept),dynamic/release(nextonly), orkeep(keptonly, retiring old resources viacrate::host::retire).ID3D12Resourceinkeptfor a live dynamic slot prevents recorded lists from sampling null views, and once the slot is released it is reclaimed either on the nextevictpass or whenmake_atnext reuses the slot (accurately documented in1c356e51).Verification
63bcca43c6a00a758510398fa43096ce7e4f7df0+cargo run -p xtask -- policy(191 files ok)cargo clippy -p victory-gpu --all-targets -- -D warnings(default &--all-features)victory-gpudescriptor::host:: resource::withVICTORY_D3D12_DEBUG=1:--skip dynamic_slots_are_held_until_released, pre-existing 1M view-heap cap failure onmain): 33/33 passed (includinglive_dynamic_slots_keep_a_texture_given_up).--features diagnostics, no skips): 34/34 passed.0and a released dynamic slot are both nulled ongive_up_nowwhile a live dynamic slot keeps its view, and afterrelease(live, 1)a subsequentevictpass clears the slot cleanly.@Dukestar69 on GitHub · 2026-11-26 19:51 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).madeandnextacross 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 (includinglive_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).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.