GPU: keep bound render and depth targets alive on command lists #2542

Manually merged
github merged 1 commit from github-bot/gh-2542 into main 2026-11-30 14:16:52 +00:00 AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-29 14:02 UTC · original
fuzeofficlal:fix/gpu-keep-render-targets-on-list → main · +158 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

Summary

BoundTargets::restore (called by both State::set_targets and State::replay) creates host RTV/DSV descriptors from each target's ID3D12Resource and records OMSetRenderTargets directly onto the host command list without retaining those textures via HostList::keep.

HostList::transition only runs later in State::prepare_for when a draw executes. If a title binds render or depth targets, switches targets (replacing State.host_targets) or drops draws without drawing to them, and releases the title resources before submission, the host ID3D12Resource can be destroyed (for example when VICTORY_BURY_LAG=0 or after bury_lag() other submissions drain) while still referenced by the recorded command list. Under the D3D12 debug layer, ID3D12CommandList::Close fails with a deleted-resource error.

Fix

  • Call list.keep(texture) for each bound render target and depth target inside BoundTargets::restore (crates/victory-gpu/src/draw.rs), covering both State::set_targets and State::replay after segment cuts/internal passes so the host command list holds a COM reference until HostList::reset.
  • Add regression test draw::tests::render_and_depth_targets_stay_alive_until_list_reset verifying both zero D3D12 debug layer errors after releasing targets before Close/Execute and exact COM refcount retention (+1 across target switch, -1 on HostList::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 and VICTORY_BURY_LAG=0) and WARP (VICTORY_D3D12_WARP=1 VICTORY_BURY_LAG=0).
  • cargo clippy --locked -p victory-gpu --tests — 0 warnings in draw.rs.
  • cargo run --quiet --locked -p xtask -- policy --staged — passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-29 14:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2542) `fuzeofficlal:fix/gpu-keep-render-targets-on-list` → `main` · +158 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC ### Summary `BoundTargets::restore` (called by both `State::set_targets` and `State::replay`) creates host RTV/DSV descriptors from each target's `ID3D12Resource` and records `OMSetRenderTargets` directly onto the host command list without retaining those textures via `HostList::keep`. `HostList::transition` only runs later in `State::prepare_for` when a draw executes. If a title binds render or depth targets, switches targets (replacing `State.host_targets`) or drops draws without drawing to them, and releases the title resources before submission, the host `ID3D12Resource` can be destroyed (for example when `VICTORY_BURY_LAG=0` or after `bury_lag()` other submissions drain) while still referenced by the recorded command list. Under the D3D12 debug layer, `ID3D12CommandList::Close` fails with a deleted-resource error. ### Fix - Call `list.keep(texture)` for each bound render target and depth target inside `BoundTargets::restore` (`crates/victory-gpu/src/draw.rs`), covering both `State::set_targets` and `State::replay` after segment cuts/internal passes so the host command list holds a COM reference until `HostList::reset`. - Add regression test `draw::tests::render_and_depth_targets_stay_alive_until_list_reset` verifying both zero D3D12 debug layer errors after releasing targets before `Close`/`Execute` and exact COM refcount retention (+1 across target switch, -1 on `HostList::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 and `VICTORY_BURY_LAG=0`) and WARP (`VICTORY_D3D12_WARP=1 VICTORY_BURY_LAG=0`). - `cargo clippy --locked -p victory-gpu --tests` — 0 warnings in `draw.rs`. - `cargo run --quiet --locked -p xtask -- policy --staged` — passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 14:06:51 +00:00
github manually merged commit fa0fc3de65 into main 2026-11-30 14:16:52 +00:00
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!2542
No description provided.