GPU/list: retain host ID3D12Resources in Aliasing and UAV barriers an… #540

Open
pug205gti6 wants to merge 1 commit from upstream-pr/540 into main
pug205gti6 commented 2026-11-25 02:02:22 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T02:02:22Z.


…d include depth-plane twin

D3D12 command lists do not AddRef resources passed to ID3D12GraphicsCommandList::ResourceBarrier. Transition barriers (kind == 0) kept host textures alive via HostList::transition, but Aliasing (kind == 1) and UAV (kind == 2) barriers extracted raw ID3D12Resource* pointers via host_resource/twin_resource without calling list.keep(...). Releasing a title texture (or idle eviction) before ExecuteCommandLists therefore caused a host ID3D12Resource use-after-free.

Additionally, UAV barriers on depth-stencil+UAV textures only emitted a barrier for twin.colour, omitting twin.plane (the depth-plane twin).

Hold owned Arc<HostTexture> / Arc<Twin> via resource::host_copy / resource::twin, retain every referenced ID3D12Resource on the command list with list.keep(...), and emit UAV barriers for both twin.colour and twin.plane. Add a synthetic D3D12 unit test verifying COM refcount retention, depth-plane twin emission, and safe execution after releasing title textures.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595434078 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/540). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T02:02:22Z. --- …d include depth-plane twin D3D12 command lists do not AddRef resources passed to `ID3D12GraphicsCommandList::ResourceBarrier`. Transition barriers (`kind == 0`) kept host textures alive via `HostList::transition`, but Aliasing (`kind == 1`) and UAV (`kind == 2`) barriers extracted raw `ID3D12Resource*` pointers via `host_resource`/`twin_resource` without calling `list.keep(...)`. Releasing a title texture (or idle eviction) before `ExecuteCommandLists` therefore caused a host `ID3D12Resource` use-after-free. Additionally, UAV barriers on depth-stencil+UAV textures only emitted a barrier for `twin.colour`, omitting `twin.plane` (the depth-plane twin). Hold owned `Arc<HostTexture>` / `Arc<Twin>` via `resource::host_copy` / `resource::twin`, retain every referenced `ID3D12Resource` on the command list with `list.keep(...)`, and emit UAV barriers for both `twin.colour` and `twin.plane`. Add a synthetic D3D12 unit test verifying COM refcount retention, depth-plane twin emission, and safe execution after releasing title textures.
Revens2 commented 2026-11-25 08:09:01 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:37:42Z.


Duplicate of #479: @AscilCH opened this patch 39 minutes earlier, and gh pr diff returns the same bytes for both (+255/-37 on 1 file(s), same title).

Please continue in #479 so the review history and any test data stay in one place.
Thanks.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156073841 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/540#issuecomment-7156073841). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:37:42Z. --- Duplicate of #479: @AscilCH opened this patch 39 minutes earlier, and `gh pr diff` returns the same bytes for both (+255/-37 on 1 file(s), same title). Please continue in #479 so the review history and any test data stay in one place. Thanks.
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/540:upstream-pr/540'
git switch 'upstream-pr/540'

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