GPU: route UAV barriers on depth textures to their twin planes #1803

Open
github-bot wants to merge 7 commits from github-bot/gh-1803 into main AGit
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-24 22:48 UTC · original
mgunes1311-lab:gpu-twin-prelude-barriers → main · +190 −29 · 1 files · 7 commits · open

Summary

Routes D3D12_RESOURCE_BARRIER_TYPE_UAV (kind == 2) barriers naming a console depth texture to its writable colour twin planes (twin.planes), and skips UAV barriers on host resources that lack D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.

(Note: this PR originally also ordered HostList::prelude twin copies before advancing copy.state; 315cea1 landed that fix on main, so host.rs is now unchanged from main.)

Root Cause

Console depth textures with unordered access get their D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS flag stripped on the host depth-stencil resource, while compute UAV writes go to Twin::planes (crates/victory-gpu/src/twin.rs). In crates/victory-gpu/src/list.rs, barrier previously translated kind == 2 (UAV) barriers by substituting host(b.first) directly:

  1. Passing a host depth resource (or non-UAV render target) without ALLOW_UNORDERED_ACCESS in a D3D12_RESOURCE_UAV_BARRIER is invalid in D3D12.
  2. Back-to-back compute dispatches writing a depth texture's unordered views received no UAV barrier on twin.planes at all.

Changes

  • crates/victory-gpu/src/list.rs:
    • Replace host_barrier with push_host_barriers so a single console UAV barrier on a depth texture with an initialized Twin expands to UAV barriers on each plane in twin.planes.
    • Emit direct resource UAV barriers only when the host resource carries D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS (dropping UAV barriers on depth textures before a twin exists or on non-UAV colour textures).
    • Add GPU unit test uav_barriers_on_depth_textures_target_their_twin_planes.

Verification

  • cargo test -p victory-gpu --locked uav_barriers_on_depth_textures_target_their_twin_planes
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo run -p xtask -- policy
**@⁠mgunes1311-lab** on GitHub · 2026-11-24 22:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803) `mgunes1311-lab:gpu-twin-prelude-barriers` → `main` · +190 −29 · 1 files · 7 commits · open ### Summary Routes `D3D12_RESOURCE_BARRIER_TYPE_UAV` (`kind == 2`) barriers naming a console depth texture to its writable colour twin planes (`twin.planes`), and skips UAV barriers on host resources that lack `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS`. *(Note: this PR originally also ordered `HostList::prelude` twin copies before advancing `copy.state`; `315cea1` landed that fix on `main`, so `host.rs` is now unchanged from `main`.)* ### Root Cause Console depth textures with unordered access get their `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` flag stripped on the host depth-stencil resource, while compute UAV writes go to `Twin::planes` (`crates/victory-gpu/src/twin.rs`). In `crates/victory-gpu/src/list.rs`, `barrier` previously translated `kind == 2` (`UAV`) barriers by substituting `host(b.first)` directly: 1. Passing a host depth resource (or non-UAV render target) without `ALLOW_UNORDERED_ACCESS` in a `D3D12_RESOURCE_UAV_BARRIER` is invalid in D3D12. 2. Back-to-back compute dispatches writing a depth texture's unordered views received no UAV barrier on `twin.planes` at all. ### Changes - **`crates/victory-gpu/src/list.rs`:** - Replace `host_barrier` with `push_host_barriers` so a single console UAV barrier on a depth texture with an initialized `Twin` expands to UAV barriers on each plane in `twin.planes`. - Emit direct resource UAV barriers only when the host resource carries `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` (dropping UAV barriers on depth textures before a twin exists or on non-UAV colour textures). - Add GPU unit test `uav_barriers_on_depth_textures_target_their_twin_planes`. ### Verification - `cargo test -p victory-gpu --locked uav_barriers_on_depth_textures_target_their_twin_planes` - `cargo clippy --workspace --all-targets --all-features -- -D warnings` - `cargo run -p xtask -- policy`
In HostList::prelude, keep pre-list states intact while recording depth-twin
copies and advance them to *last afterward when building entry barriers.
Expand UAV barriers on depth textures with a writable twin to each twin plane,
and omit UAV barriers on host textures without ALLOW_UNORDERED_ACCESS.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:05 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 22:57 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-24 22:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803#issuecomment-7146835753) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:36 UTC · original · edited 2026-11-25 18:23 UTC

Automated triage for the maintainers.

Merge candidate. After the merge with main, the PR changes only crates/victory-gpu/src/list.rs. push_host_barriers replaces host_barrier, and a title UAV barrier on a depth texture with a twin now becomes one UAV barrier per twin.planes texture. Before this, it named the host depth resource, which has no ALLOW_UNORDERED_ACCESS (in crate::twin, only the planes have that flag). Direct UAV barriers are now also dropped for host textures without that flag.

What I checked in main: host_barrier passed host(b.first) straight through for kind 2, and nothing else in barrier orders writes to twin planes (the extra global UAV_BARRIER there is only added for buffers). Transition and aliasing barriers behave as before. If a twin was never made (Some(None)), the code falls back to the flag check, so no invalid barrier is recorded. The new test uav_barriers_on_depth_textures_target_their_twin_planes submits the list and checks that the debug layer logged nothing.

CI: the check run passed on the current head.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803#issuecomment-7149747291) · edited 2026-11-25 18:23 UTC <!-- victory-triage v1 head=7c609deb480fe43dd6c16f0350b7767c20feabf2 verdict=merge-candidate at=2026-11-25T18:23:20Z --> Automated triage for the maintainers. **Merge candidate.** After the merge with `main`, the PR changes only `crates/victory-gpu/src/list.rs`. `push_host_barriers` replaces `host_barrier`, and a title UAV barrier on a depth texture with a twin now becomes one UAV barrier per `twin.planes` texture. Before this, it named the host depth resource, which has no `ALLOW_UNORDERED_ACCESS` (in `crate::twin`, only the planes have that flag). Direct UAV barriers are now also dropped for host textures without that flag. What I checked in `main`: `host_barrier` passed `host(b.first)` straight through for kind 2, and nothing else in `barrier` orders writes to twin planes (the extra global `UAV_BARRIER` there is only added for buffers). Transition and aliasing barriers behave as before. If a twin was never made (`Some(None)`), the code falls back to the flag check, so no invalid barrier is recorded. The new test `uav_barriers_on_depth_textures_target_their_twin_planes` submits the list and checks that the debug layer logged nothing. CI: the `check` run passed on the current head. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-25 17:15 UTC · original

Merged main (67e8ae1) to resolve the conflicts: since 315cea1 landed the HostList::prelude twin-copy ordering on main, crates/victory-gpu/src/host.rs now matches main with zero diff and this PR is narrowed to routing depth-texture UAV barriers to twin.planes in crates/victory-gpu/src/list.rs. Updated the PR title and description accordingly.

**@⁠mgunes1311-lab** on GitHub · 2026-11-25 17:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803#issuecomment-7169249917) Merged `main` (`67e8ae1`) to resolve the conflicts: since `315cea1` landed the `HostList::prelude` twin-copy ordering on `main`, `crates/victory-gpu/src/host.rs` now matches `main` with zero diff and this PR is narrowed to routing depth-texture UAV barriers to `twin.planes` in `crates/victory-gpu/src/list.rs`. Updated the PR title and description accordingly.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 23:03 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Copy depth twins from pre-list states in prelude + route depth: 34K gpu diff touching copy planning and prelude state. Windows-only; interacts with the placed-copy work reviewed earlier (#1374/#1725) — check for overlap.

**@⁠catminou4** on GitHub · 2026-11-24 23:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803#pullrequestreview-6048801498) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Copy depth twins from pre-list states in prelude + route depth: 34K gpu diff touching copy planning and prelude state. Windows-only; interacts with the placed-copy work reviewed earlier (#1374/#1725) — check for overlap.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 18:48 UTC · original · approved these changes

Reviewed 7c609deb480f merged cleanly onto 63bcca43.

The kind == 2 UAV barrier routing in crates/victory-gpu/src/list.rs:545-569 accurately matches how depth-twin writes execute on the host:

  • Preserves global pResource == NULL UAV barriers (list.rs:545).
  • Expands UAV barriers on depth textures with an initialized twin to one UAV barrier per twin plane (list.rs:552-560), covering both depth and stencil planes on dual-plane formats.
  • Emits a direct UAV barrier only when the host resource carries D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS (list.rs:562-568), cleanly skipping depth textures without a twin and non-UAV colour targets that would otherwise violate D3D12 barrier rules.
  • Non-blocking note: while depth/UAV host textures are not evictable (resource::evictable), calling list.keep(&plane.texture) / list.keep(&copy.texture) when emitting a UAV barrier would also protect against a title releasing a resource after recording a UAV barrier on a list that had not yet transitioned it (matching HostList::transition).

Hardware & D3D12 Debug Layer verification (RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) pass cleanly.
  • cargo test --locked -p victory-gpu list::tests:: -- --test-threads=1 passed 5/5 on both RTX 5090 and WARP under VICTORY_D3D12_DEBUG=1 (0 Debug Layer messages).
  • Co-merged cleanly with #1933 (e5750d906995) onto 63bcca43 and verified both twin::tests:: (4/4) and list::tests:: (5/5), plus an additional probe initializing a D32_FLOAT_S8X24_UINT (20) depth twin via #1933's default None UAV and executing a batch combining a global NULL UAV barrier, a pre-transition 2-plane depth UAV barrier (COMMON state), a transition to UNORDERED_ACCESS, and a post-transition 2-plane UAV barrier — zero D3D12 Debug Layer messages on both RTX 5090 and WARP.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1803#pullrequestreview-6079160707) · **approved these changes** Reviewed `7c609deb480f` merged cleanly onto `63bcca43`. The `kind == 2` UAV barrier routing in `crates/victory-gpu/src/list.rs:545-569` accurately matches how depth-twin writes execute on the host: - Preserves global `pResource == NULL` UAV barriers (`list.rs:545`). - Expands UAV barriers on depth textures with an initialized twin to one UAV barrier per twin plane (`list.rs:552-560`), covering both depth and stencil planes on dual-plane formats. - Emits a direct UAV barrier only when the host resource carries `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` (`list.rs:562-568`), cleanly skipping depth textures without a twin and non-UAV colour targets that would otherwise violate D3D12 barrier rules. - Non-blocking note: while depth/UAV host textures are not evictable (`resource::evictable`), calling `list.keep(&plane.texture)` / `list.keep(&copy.texture)` when emitting a UAV barrier would also protect against a title releasing a resource after recording a UAV barrier on a list that had not yet transitioned it (matching `HostList::transition`). **Hardware & D3D12 Debug Layer verification** (RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` and `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) pass cleanly. - `cargo test --locked -p victory-gpu list::tests:: -- --test-threads=1` passed 5/5 on both RTX 5090 and WARP under `VICTORY_D3D12_DEBUG=1` (0 Debug Layer messages). - Co-merged cleanly with `#1933` (`e5750d906995`) onto `63bcca43` and verified both `twin::tests::` (4/4) and `list::tests::` (5/5), plus an additional probe initializing a `D32_FLOAT_S8X24_UINT (20)` depth twin via `#1933`'s default `None` UAV and executing a batch combining a global `NULL` UAV barrier, a pre-transition 2-plane depth UAV barrier (`COMMON` state), a transition to `UNORDERED_ACCESS`, and a post-transition 2-plane UAV barrier — zero D3D12 Debug Layer messages on both RTX 5090 and WARP. LGTM.
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/1803/head:github-bot/gh-1803'
git switch 'github-bot/gh-1803'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1803'
git switch 'github-bot/gh-1803'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1803'
git switch 'github-bot/gh-1803'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1803'
git switch 'main'
git merge --squash 'github-bot/gh-1803'
git switch 'main'
git merge --ff-only 'github-bot/gh-1803'
git switch 'main'
git merge 'github-bot/gh-1803'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1803
No description provided.