GPU: aliasing and UAV barriers keep the host resources they name until the list is reset #2296

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2298 into main
denkencar-sketch commented 2026-11-25 10:05:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:31Z.


Summary

Aliasing and UAV barriers did not keep the host resources they name; only transition barriers did (through the list's states). A title that released a resource after recording such a barrier left the command list naming a freed resource. They now keep their resources until the list is reset.

Testing

Test uav_and_aliasing_barriers_keep_their_resources fails on main and passes with this change. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a real release after recording, in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5489190552 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2298). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:31Z. --- ## Summary Aliasing and UAV barriers did not keep the host resources they name; only transition barriers did (through the list's states). A title that released a resource after recording such a barrier left the command list naming a freed resource. They now keep their resources until the list is reset. ## Testing Test `uav_and_aliasing_barriers_keep_their_resources` fails on `main` and passes with this change. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a real release after recording, in the game. AI-assisted.
catminou4 commented 2026-11-25 10:19:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:15Z.

Review: COMMENTED


Aliasing and UAV barriers keep the host resources they name (host_barrier keeps resource alive until list reset). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055713019 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2298#pullrequestreview-6055713019). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:15Z. **Review:** COMMENTED --- Aliasing and UAV barriers keep the host resources they name (host_barrier keeps resource alive until list reset). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Marvisak commented 2026-11-25 16:09:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:25:45Z.


Automated triage for the maintainers.

Re-reviewed after the rebase. The branch now merges cleanly.

On main, host_barrier (crates/victory-gpu/src/list.rs) turns UAV and aliasing barriers into raw host-resource pointers. It takes them from a temporary host_resource clone that is dropped right away. Only transitions keep their texture, through HostList::transition. If the title releases the resource before the list runs, the recorded barrier then names a freed resource. The PR calls HostList::keep on every resource that the host closure resolves, which is the same mechanism the list already uses for replaced argument buffers. The test checks that both barrier kinds add one kept reference. The only change in host.rs is a test-only kept_count.

Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166827502 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2298#issuecomment-7166827502). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:25:45Z. --- <!-- victory-triage v1 head=2d83bf2c990076517c342c24a7c09c1306220b40 verdict=merge-candidate at=2026-11-26T03:21:15Z --> Automated triage for the maintainers. Re-reviewed after the rebase. The branch now merges cleanly. On `main`, `host_barrier` (`crates/victory-gpu/src/list.rs`) turns UAV and aliasing barriers into raw host-resource pointers. It takes them from a temporary `host_resource` clone that is dropped right away. Only transitions keep their texture, through `HostList::transition`. If the title releases the resource before the list runs, the recorded barrier then names a freed resource. The PR calls `HostList::keep` on every resource that the `host` closure resolves, which is the same mechanism the list already uses for replaced argument buffers. The test checks that both barrier kinds add one kept reference. The only change in `host.rs` is a test-only `kept_count`. **Verdict: merge candidate** (a recommendation to look, not an approval). CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 15:13:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T15:13:28Z.

Review: APPROVED


Reviewed crates/victory-gpu/src/host.rs and crates/victory-gpu/src/list.rs at 2d83bf2c merged onto origin/main (63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.

Null safety & retention audit

  • host_barrier (crates/victory-gpu/src/list.rs:499-544) retains every resolved host ID3D12Resource via list.keep(&h) (list.rs:505) inside the host closure while preserving the explicit null checks for both b.first (aliasing kind == 1 and UAV kind == 2) and b.second (aliasing kind == 1). Null/null aliasing and global null UAV barriers remain untouched (0 kept refs), and non-null before/after resources stay alive until HostList::reset().
  • git merge-tree confirms clean merges with both #2293 and #2329 (the latter adds the identical #[cfg(test)] kept_count() helper at host.rs:2262).

Verification

  • cargo run -p xtask -- policy: 191 files ok.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • list:: host:: with VICTORY_D3D12_DEBUG=1: 39/39 passed on RTX 5090 (skipping dynamic_slots_are_held_until_released) and 40/40 passed on WARP (--features diagnostics, skipping the pre-existing main compositor_failure_presents_primary_in_the_same_frame Debug Layer mismatch), including uav_and_aliasing_barriers_keep_their_resources (list.rs:1912).
  • Additional RTX 5090 + Debug Layer probe covering aliasing NULL/NULL (+0 kept), NULL/t2 (+1), t1/t2 (+2), UAV NULL (+0), UAV t1 (+1), plus recording a real D3D12 UAV barrier on t1 and releasing both title COM textures (Release() -> 0) before list.close() / host.execute() / list.reset() passed cleanly with kept_count() == 0 afterward and GetDeviceRemovedReason().is_ok().
  • Combined #2293 + #2298 merge verified cleanly on RTX 5090 + Debug Layer (2/2 targeted tests passed).
<!-- greyfinch-sync:Marvisak/VIctory:review:6076555455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2298#pullrequestreview-6076555455). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T15:13:28Z. **Review:** APPROVED --- Reviewed `crates/victory-gpu/src/host.rs` and `crates/victory-gpu/src/list.rs` at `2d83bf2c` merged onto `origin/main` (`63bcca43`) and verified on RTX 5090 and WARP (`VICTORY_D3D12_WARP=1`) with `VICTORY_D3D12_DEBUG=1`. ### Null safety & retention audit - `host_barrier` (`crates/victory-gpu/src/list.rs:499-544`) retains every resolved host `ID3D12Resource` via `list.keep(&h)` (`list.rs:505`) inside the `host` closure while preserving the explicit null checks for both `b.first` (aliasing `kind == 1` and UAV `kind == 2`) and `b.second` (aliasing `kind == 1`). Null/null aliasing and global null UAV barriers remain untouched (0 kept refs), and non-null before/after resources stay alive until `HostList::reset()`. - `git merge-tree` confirms clean merges with both `#2293` and `#2329` (the latter adds the identical `#[cfg(test)] kept_count()` helper at `host.rs:2262`). ### Verification - `cargo run -p xtask -- policy`: 191 files ok. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - `list:: host::` with `VICTORY_D3D12_DEBUG=1`: **39/39 passed** on RTX 5090 (skipping `dynamic_slots_are_held_until_released`) and **40/40 passed** on WARP (`--features diagnostics`, skipping the pre-existing `main` `compositor_failure_presents_primary_in_the_same_frame` Debug Layer mismatch), including `uav_and_aliasing_barriers_keep_their_resources` (`list.rs:1912`). - Additional RTX 5090 + Debug Layer probe covering aliasing `NULL/NULL` (+0 kept), `NULL/t2` (+1), `t1/t2` (+2), UAV `NULL` (+0), UAV `t1` (+1), plus recording a real D3D12 UAV barrier on `t1` and releasing both title COM textures (`Release() -> 0`) **before** `list.close()` / `host.execute()` / `list.reset()` passed cleanly with `kept_count() == 0` afterward and `GetDeviceRemovedReason().is_ok()`. - Combined `#2293 + #2298` merge verified cleanly on RTX 5090 + Debug Layer (`2/2` targeted tests passed).
Dukestar69 commented 2026-11-26 21:50:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:50:33Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Keeping host resources referenced by UAV and aliasing barriers alive on the command list until reset prevents use-after-free when resources are released before execution.
  • cargo test -p victory-gpu --lib list:: -- --test-threads=1: 5 passed, 0 failed (including uav_and_aliasing_barriers_keep_their_resources).
  • 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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6080867469 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2298#pullrequestreview-6080867469). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T21:50:33Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Keeping host resources referenced by UAV and aliasing barriers alive on the command list until reset prevents use-after-free when resources are released before execution. - `cargo test -p victory-gpu --lib list:: -- --test-threads=1`: 5 passed, 0 failed (including `uav_and_aliasing_barriers_keep_their_resources`). - `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).
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/2298:upstream-pr/2298'
git switch 'upstream-pr/2298'

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