GPU: keep bound render and depth targets alive on command lists #2542
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2542"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fuzeofficlal on 2026-11-29T14:02:02Z.
Summary
BoundTargets::restore(called by bothState::set_targetsandState::replay) creates host RTV/DSV descriptors from each target'sID3D12Resourceand recordsOMSetRenderTargetsdirectly onto the host command list without retaining those textures viaHostList::keep.HostList::transitiononly runs later inState::prepare_forwhen a draw executes. If a title binds render or depth targets, switches targets (replacingState.host_targets) or drops draws without drawing to them, and releases the title resources before submission, the hostID3D12Resourcecan be destroyed (for example whenVICTORY_BURY_LAG=0or afterbury_lag()other submissions drain) while still referenced by the recorded command list. Under the D3D12 debug layer,ID3D12CommandList::Closefails with a deleted-resource error.Fix
list.keep(texture)for each bound render target and depth target insideBoundTargets::restore(crates/victory-gpu/src/draw.rs), covering bothState::set_targetsandState::replayafter segment cuts/internal passes so the host command list holds a COM reference untilHostList::reset.draw::tests::render_and_depth_targets_stay_alive_until_list_resetverifying both zero D3D12 debug layer errors after releasing targets beforeClose/Executeand exact COM refcount retention (+1 across target switch, -1 onHostList::reset).Verification
VICTORY_D3D12_DEBUG=1 cargo test --locked -p victory-gpu --lib draw::tests::render_and_depth_targets_stay_alive_until_list_reset— passed on RTX 5090 (default andVICTORY_BURY_LAG=0) and WARP (VICTORY_D3D12_WARP=1 VICTORY_BURY_LAG=0).cargo clippy --locked -p victory-gpu --tests— 0 warnings indraw.rs.cargo run --quiet --locked -p xtask -- policy --staged— passed.