gpu/barriers: split depth-write & UAV->SRV barriers and fold null UAVs into global barriers #178

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

@⁠Zalthor on GitHub · 2026-12-05 21:26 UTC · original
Zalthor:gpu/barrier-drain-and-coalescing → main · +756 −84 · 5 files · 1 commits · open

Summary

Eliminates remaining full GPU pipeline drains (d0/fd0) and cuts redundant per-frame barriers on the GPU submission path:

  1. Complete Depth-Write Drain Elimination (crates/victory-gpu/src/list/groups.rs, crates/victory-gpu/src/list.rs):
    • Generalizes depth read-state tracking (depth_after_state()) across explicit read accesses (DEPTH_STENCIL_READ, SHADER_RESOURCE, COPY_SOURCE) as well as concrete read-only layout_after layouts (DEPTH_STENCIL_READ, *_SHADER_RESOURCE, *_COPY_SOURCE, *_GENERIC_READ) when access_after == COMMON (while rejecting sync::SPLIT, undefined/COMMON, or write-capable layouts so depth-stencil textures never transition to legacy COMMON).
    • Adds strip_depth_write() and pre-transitions eligible Plain and Twin depth targets via ensure_state_from() in barrier_groups().
  2. Plain UAV -> SRV Global Double-Barrier Elimination (crates/victory-gpu/src/list/groups.rs, crates/victory-gpu/src/list.rs):
    • Adds strip_uav_write() so when ensure_state_from() transitions a plain texture directly from UNORDERED_ACCESS (0x8) to SHADER_RESOURCE (with no sync::SPLIT), the redundant UNORDERED_ACCESS pre-scope is stripped from the subsequent enhanced global barrier.
  3. Global Coalescing & Enhanced-Gated Rec-Routed Clamp Barriers (crates/victory-gpu/src/host/rec.rs, crates/victory-gpu/src/indirect.rs, crates/victory-gpu/src/indirect/batch.rs, crates/victory-gpu/src/list.rs):
    • Emits uav_global_barrier() via Rec::global from unbatched record_clamp_rec() and batched batch::record_rec() when join_barriers / join_first is enabled and EnhancedBarriersSupported holds (crate::list::enhanced() / device_supports_enhanced()), avoiding D3D12 error 1343 on drivers without Enhanced Barriers even when merged independently of PR #176 (leaves Rec::new untouched).
    • Ensures generic legacy null UAV barriers absorbed in Rec::barriers/Rec::global widen held.1 to full ALL/COMMON -> ALL/COMMON synchronization rather than narrowing unrelated full drains or non-UAV transitions, and distinguishes global_covers_named_uav vs global_covers_null_uav across Rec::barriers.

Verification

  • Rebased Checks (on origin/main ca49e25, post-review):
    • cargo clippy --workspace --all-targets --locked -- -D warnings and cargo clippy --workspace --all-targets --all-features --locked -- -D warnings pass (0 warnings).
    • cargo test --workspace --locked and cargo test --workspace --all-features --locked -- --test-threads=1 pass (including depth_after_state_maps_allowed_reads_or_read_layouts_and_rejects_others, rec_barriers_and_global_close_across_mixed_uav_and_null_uav, warp_record_clamp_rec_coalesced_and_zero_records, mixed-access D3D12 closing checks, and xtask policy tests; excluding pre-existing Win10 LTSC inbox-D3D12 host skips depth_bounds_pipeline_loads_and_filters_draws, a_submissions_times_are_the_pcs, a_frame_is_recorded_and_replayed, and emit::{valu,intersect,waterfall}_tests).
  • Pre-Review Hardware Telemetry (builtin:cruise, Radeon RX 9070 XT, 2560×1440 Borderless FSR 4 Performance, VICTORY_FSR_FRAMEGEN=0 real frames only):
    • Full GPU pipeline drains eliminated: 14–17/f (33/28/27 drained groups) reduced to 0/f (d0/fd0) across spawn_idle, cruise_out, and cruise_back (0 device removals).
    • Depth-write split (C2_DEPTH_OPT vs C2_BASE -> C3_POOL_DEPTH): initial split lifted cruise_out 50.27 -> 57.23 fps and cruise_back 63.87 -> 70.86 fps; C3_POOL_DEPTH (d0/fd0) reached 44.70 / 58.76 / 71.77 fps.
    • Barrier coalescing (C6_OPT / C6_OPT_GPUTIME vs Cycle 5 baseline):
      • No-op barrier groups jumped +69.7%..+73.9% (76 -> 129, 71 -> 123, 69 -> 120), eliminating 48–54 enhanced global barriers per frame (1016 -> 968, 965 -> 917, 921 -> 871 in C6_OPT).
      • Folded state changes / null UAV barriers jumped 30–36 -> 115–127/f (+83..+93/f).
      • indirect_clamp GPU span improved to 0.782 / 0.662 / 0.576 ms.
**@⁠Zalthor** on GitHub · 2026-12-05 21:26 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/177) `Zalthor:gpu/barrier-drain-and-coalescing` → `main` · +756 −84 · 5 files · 1 commits · open ## Summary Eliminates remaining full GPU pipeline drains (`d0/fd0`) and cuts redundant per-frame barriers on the GPU submission path: 1. **Complete Depth-Write Drain Elimination (`crates/victory-gpu/src/list/groups.rs`, `crates/victory-gpu/src/list.rs`):** - Generalizes depth read-state tracking (`depth_after_state()`) across explicit read accesses (`DEPTH_STENCIL_READ`, `SHADER_RESOURCE`, `COPY_SOURCE`) as well as concrete read-only `layout_after` layouts (`DEPTH_STENCIL_READ`, `*_SHADER_RESOURCE`, `*_COPY_SOURCE`, `*_GENERIC_READ`) when `access_after == COMMON` (while rejecting `sync::SPLIT`, undefined/`COMMON`, or write-capable layouts so depth-stencil textures never transition to legacy `COMMON`). - Adds `strip_depth_write()` and pre-transitions eligible `Plain` and `Twin` depth targets via `ensure_state_from()` in `barrier_groups()`. 2. **Plain `UAV -> SRV` Global Double-Barrier Elimination (`crates/victory-gpu/src/list/groups.rs`, `crates/victory-gpu/src/list.rs`):** - Adds `strip_uav_write()` so when `ensure_state_from()` transitions a plain texture directly from `UNORDERED_ACCESS` (`0x8`) to `SHADER_RESOURCE` (with no `sync::SPLIT`), the redundant `UNORDERED_ACCESS` pre-scope is stripped from the subsequent enhanced global barrier. 3. **Global Coalescing & Enhanced-Gated `Rec`-Routed Clamp Barriers (`crates/victory-gpu/src/host/rec.rs`, `crates/victory-gpu/src/indirect.rs`, `crates/victory-gpu/src/indirect/batch.rs`, `crates/victory-gpu/src/list.rs`):** - Emits `uav_global_barrier()` via `Rec::global` from unbatched `record_clamp_rec()` and batched `batch::record_rec()` when `join_barriers` / `join_first` is enabled and `EnhancedBarriersSupported` holds (`crate::list::enhanced()` / `device_supports_enhanced()`), avoiding D3D12 error 1343 on drivers without Enhanced Barriers even when merged independently of PR #176 (leaves `Rec::new` untouched). - Ensures generic legacy null UAV barriers absorbed in `Rec::barriers`/`Rec::global` widen `held.1` to full `ALL/COMMON -> ALL/COMMON` synchronization rather than narrowing unrelated full drains or non-UAV transitions, and distinguishes `global_covers_named_uav` vs `global_covers_null_uav` across `Rec::barriers`. ## Verification - **Rebased Checks (on `origin/main` `ca49e25`, post-review):** - `cargo clippy --workspace --all-targets --locked -- -D warnings` and `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` pass (`0` warnings). - `cargo test --workspace --locked` and `cargo test --workspace --all-features --locked -- --test-threads=1` pass (including `depth_after_state_maps_allowed_reads_or_read_layouts_and_rejects_others`, `rec_barriers_and_global_close_across_mixed_uav_and_null_uav`, `warp_record_clamp_rec_coalesced_and_zero_records`, mixed-access D3D12 closing checks, and `xtask` policy tests; excluding pre-existing Win10 LTSC inbox-D3D12 host skips `depth_bounds_pipeline_loads_and_filters_draws`, `a_submissions_times_are_the_pcs`, `a_frame_is_recorded_and_replayed`, and `emit::{valu,intersect,waterfall}_tests`). - **Pre-Review Hardware Telemetry (`builtin:cruise`, Radeon RX 9070 XT, `2560×1440` Borderless FSR 4 Performance, `VICTORY_FSR_FRAMEGEN=0` real frames only):** - **Full GPU pipeline drains eliminated:** `14–17/f` (`33/28/27` drained groups) reduced to **`0/f` (`d0/fd0`)** across `spawn_idle`, `cruise_out`, and `cruise_back` (`0` device removals). - **Depth-write split (`C2_DEPTH_OPT` vs `C2_BASE` -> `C3_POOL_DEPTH`):** initial split lifted `cruise_out` `50.27 -> 57.23 fps` and `cruise_back` `63.87 -> 70.86 fps`; `C3_POOL_DEPTH` (`d0/fd0`) reached **`44.70 / 58.76 / 71.77 fps`**. - **Barrier coalescing (`C6_OPT` / `C6_OPT_GPUTIME` vs Cycle 5 baseline):** - No-op barrier groups jumped **`+69.7%..+73.9%`** (`76 -> 129`, `71 -> 123`, `69 -> 120`), eliminating **`48–54` enhanced global barriers per frame** (`1016 -> 968`, `965 -> 917`, `921 -> 871` in `C6_OPT`). - Folded state changes / null UAV barriers jumped **`30–36 -> 115–127/f`** (`+83..+93/f`). - `indirect_clamp` GPU span improved to **`0.782 / 0.662 / 0.576 ms`**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 21:27:11 +00:00
github-bot force-pushed github-bot/gh-177 from 51419e4ddc to 9158fd235f 2026-12-05 22:20:06 +00:00 Compare
github-bot force-pushed github-bot/gh-177 from 9158fd235f to 363be0b98c 2026-12-05 23:16:02 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/rec.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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