GPU/list: retain host resources on Aliasing/UAV barriers and include depth-plane twin #479

Open
AscilCH wants to merge 1 commit from upstream-pr/479 into main
AscilCH commented 2026-11-25 01:22:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T01:22:54Z.


Problem

In crates/victory-gpu/src/list.rs, host_barrier passed raw ID3D12Resource* pointers to ID3D12GraphicsCommandList::ResourceBarrier (which does not AddRef referenced resources):

  1. Use-After-Free on Aliasing (kind == 1) and UAV (kind == 2) barriers: Unlike Transition barriers (kind == 0, which keep Arc<HostTexture> in HostList::states via list.transition), Aliasing and UAV barriers borrowed raw pointers via resource::host_resource / resource::twin_resource without calling list.keep(...). If the title released the resource (or resource::let_go_idle evicted it) before ExecuteCommandLists, the host ID3D12Resource was destroyed while still referenced by the recorded command list.
  2. Missing depth-plane twin UAV barrier: For depth-stencil+UAV textures, kind == 2 only emitted a UAV barrier on twin.colour (stencil plane) and omitted twin.plane (depth plane).

Fix

  • Resolve owned Arc<HostTexture> / Arc<Twin> via resource::host_copy and resource::twin, retain every referenced ID3D12Resource on HostList via list.keep(...) until list reset, and emit UAV barriers for both twin.colour.texture and twin.plane.texture.
  • Add synthetic D3D12 unit test aliasing_and_uav_barriers_retain_host_resources_and_depth_plane_twin verifying COM refcount retention, both twin UAV barriers, and safe Close + ExecuteCommandLists after releasing all title textures.

Verification

  • cargo test -p victory-gpu --locked list::tests -- --test-threads=1: 2 passed, 0 failed
  • cargo xtask policy: 169 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594941698 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/479). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T01:22:54Z. --- ## Problem In `crates/victory-gpu/src/list.rs`, `host_barrier` passed raw `ID3D12Resource*` pointers to `ID3D12GraphicsCommandList::ResourceBarrier` (which does not `AddRef` referenced resources): 1. **Use-After-Free on Aliasing (`kind == 1`) and UAV (`kind == 2`) barriers**: Unlike Transition barriers (`kind == 0`, which keep `Arc<HostTexture>` in `HostList::states` via `list.transition`), Aliasing and UAV barriers borrowed raw pointers via `resource::host_resource` / `resource::twin_resource` without calling `list.keep(...)`. If the title released the resource (or `resource::let_go_idle` evicted it) before `ExecuteCommandLists`, the host `ID3D12Resource` was destroyed while still referenced by the recorded command list. 2. **Missing depth-plane twin UAV barrier**: For depth-stencil+UAV textures, `kind == 2` only emitted a UAV barrier on `twin.colour` (stencil plane) and omitted `twin.plane` (depth plane). ## Fix - Resolve owned `Arc<HostTexture>` / `Arc<Twin>` via `resource::host_copy` and `resource::twin`, retain every referenced `ID3D12Resource` on `HostList` via `list.keep(...)` until list reset, and emit UAV barriers for both `twin.colour.texture` and `twin.plane.texture`. - Add synthetic D3D12 unit test `aliasing_and_uav_barriers_retain_host_resources_and_depth_plane_twin` verifying COM refcount retention, both twin UAV barriers, and safe `Close` + `ExecuteCommandLists` after releasing all title textures. ## Verification - `cargo test -p victory-gpu --locked list::tests -- --test-threads=1`: 2 passed, 0 failed - `cargo xtask policy`: 169 files ok - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings`: clean *(AI-assisted; synthetic unit tests only, no game data.)*
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/479:upstream-pr/479'
git switch 'upstream-pr/479'

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/479'
git switch 'upstream-pr/479'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/479'
git switch 'upstream-pr/479'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/479'
git switch 'main'
git merge --squash 'upstream-pr/479'
git switch 'main'
git merge --ff-only 'upstream-pr/479'
git switch 'main'
git merge 'upstream-pr/479'
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
fxceless/victory-fork!479
No description provided.