GPU/list: split duplicate resource transitions across ResourceBarrier calls and sanitize committed aliasing barriers #787

Open
AscilCH wants to merge 1 commit from upstream-pr/787 into main
AscilCH commented 2026-11-25 07:35:34 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T07:35:34Z.


Summary

Fix two Direct3D 12 barrier validation bugs in crates/victory-gpu/src/list.rs:

  1. Duplicate ALL_SUBRESOURCES transitions in a single ResourceBarrier call (D3D12 error #524).

    • host_barrier() flattens per-subresource transition barriers to D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES. When a title transitions multiple subresources of the same texture to different states in one ResourceBarrier(count, barriers) call, barrier() previously submitted both whole-resource transitions together in one ResourceBarrier slice.
    • Add for_barrier_batches() to split the translated barriers into maximal contiguous slices where no single ResourceBarrier call repeats a Transition (kind == 0) barrier for the same host ID3D12Resource.
  2. Committed resources passed in D3D12_RESOURCE_BARRIER_TYPE_ALIASING barriers.

    • D3D12 only permits placed/reserved resources or NULL in aliasing barriers (and requires Flags == 0). Passing CreateCommittedResource pointers is a D3D12 validation error.
    • Resolve non-null aliasing endpoints via resource::host_copy() and aliasing_barrier(), preserving reserved (host.tiled.is_some()) resource pointers while downgrading committed host textures to NULL (forming a valid half-open or global aliasing barrier) and clearing flags.

Verification

  • cargo test -p victory-gpu --locked -- list::: 4 passed; 0 failed; 0 ignored (including barrier_batches_split_before_duplicate_resource_transitions, aliasing_barrier_downgrades_committed_resources_and_keeps_reserved, and real D3D12 device test host_barrier_handles_committed_aliasing_and_subresource_transitions_on_device; host lacks optional Windows Graphics Tools D3D12 debug layer).
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in crates/victory-gpu/src/list.rs (only pre-existing 8dd30ab warnings in draw.rs and indirect.rs).
  • cargo xtask policy: 171 files ok.

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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6599577911 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/787). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T07:35:34Z. --- ## Summary Fix two Direct3D 12 barrier validation bugs in `crates/victory-gpu/src/list.rs`: 1. **Duplicate `ALL_SUBRESOURCES` transitions in a single `ResourceBarrier` call (D3D12 error `#524`).** - `host_barrier()` flattens per-subresource transition barriers to `D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES`. When a title transitions multiple subresources of the same texture to different states in one `ResourceBarrier(count, barriers)` call, `barrier()` previously submitted both whole-resource transitions together in one `ResourceBarrier` slice. - Add `for_barrier_batches()` to split the translated barriers into maximal contiguous slices where no single `ResourceBarrier` call repeats a `Transition` (`kind == 0`) barrier for the same host `ID3D12Resource`. 2. **Committed resources passed in `D3D12_RESOURCE_BARRIER_TYPE_ALIASING` barriers.** - D3D12 only permits placed/reserved resources or `NULL` in aliasing barriers (and requires `Flags == 0`). Passing `CreateCommittedResource` pointers is a D3D12 validation error. - Resolve non-null aliasing endpoints via `resource::host_copy()` and `aliasing_barrier()`, preserving reserved (`host.tiled.is_some()`) resource pointers while downgrading committed host textures to `NULL` (forming a valid half-open or global aliasing barrier) and clearing `flags`. ## Verification - `cargo test -p victory-gpu --locked -- list::`: `4 passed; 0 failed; 0 ignored` (including `barrier_batches_split_before_duplicate_resource_transitions`, `aliasing_barrier_downgrades_committed_resources_and_keeps_reserved`, and real D3D12 device test `host_barrier_handles_committed_aliasing_and_subresource_transitions_on_device`; host lacks optional Windows Graphics Tools D3D12 debug layer). - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: 0 warnings in `crates/victory-gpu/src/list.rs` (only pre-existing `8dd30ab` warnings in `draw.rs` and `indirect.rs`). - `cargo xtask policy`: `171 files ok`. *(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/787:upstream-pr/787'
git switch 'upstream-pr/787'

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