Skip to content

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

Open
mgunes1311-lab wants to merge 7 commits into
Marvisak:mainfrom
mgunes1311-lab:gpu-twin-prelude-barriers
Open

mgunes1311-lab wants to merge 7 commits into
Marvisak:mainfrom
mgunes1311-lab:gpu-twin-prelude-barriers

Conversation

@mgunes1311-lab

@mgunes1311-lab mgunes1311-lab commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.
@DesertGamer

Copy link
Copy Markdown

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@mgunes1311-lab mgunes1311-lab changed the title GPU: copy depth twins from pre-list states in prelude and route depth UAV barriers to twin planes GPU: route UAV barriers on depth textures to their twin planes Nov 25, 2026
@mgunes1311-lab

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants