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

Open
github-bot wants to merge 1 commit from github-bot/gh-787 into main AGit
Owner

@⁠AscilCH on GitHub · 2026-11-25 07:35 UTC · original
AscilCH:fix/gpu-list-barrier-dedup-and-committed-aliasing → main · +316 −23 · 1 files · 1 commits · open

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.)

**@⁠AscilCH** on GitHub · 2026-11-25 07:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/787) `AscilCH:fix/gpu-list-barrier-dedup-and-committed-aliasing` → `main` · +316 −23 · 1 files · 1 commits · open ## 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.)*
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 passes
   two barriers transitioning different subresources of the same texture to
   different states in one `ResourceBarrier(count, barriers)` call, `barrier()`
   previously submitted both whole-resource transitions together in a single
   `ResourceBarrier` slice. Split the translated barriers via
   `for_barrier_batches()` so no single `ResourceBarrier` call repeats a
   `Transition` (`kind == 0`) barrier for the same host `ID3D12Resource`.

2. Committed resources in `D3D12_RESOURCE_BARRIER_TYPE_ALIASING` barriers:
   `host_barrier()` previously passed raw `ID3D12Resource*` pointers for host
   textures created via `CreateCommittedResource` directly into aliasing
   barriers (and forwarded `flags`). D3D12 forbids committed resources and
   non-zero barrier flags on aliasing barriers (only placed/reserved resources
   or `NULL` are allowed). Resolve each non-null endpoint via
   `resource::host_copy()` and `aliasing_barrier()`, preserving reserved
   (`host.tiled.is_some()`) resource pointers while downgrading committed
   resources to `NULL` (yielding a valid half-open or global aliasing barrier)
   and zeroing `flags`.

Add unit tests covering batch splitting, aliasing normalization, and a real
D3D12 device test exercising committed aliasing and multi-subresource
transitions in a single `barrier()` call.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:09 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/787/head:github-bot/gh-787'
git switch 'github-bot/gh-787'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-787'
git switch 'github-bot/gh-787'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-787'
git switch 'github-bot/gh-787'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-787'
git switch 'main'
git merge --squash 'github-bot/gh-787'
git switch 'main'
git merge --ff-only 'github-bot/gh-787'
git switch 'main'
git merge 'github-bot/gh-787'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.