Add opt-in enhanced-barrier optimization for placed copies and mid-list barriers #544

Open
github-bot wants to merge 2 commits from github-bot/gh-544 into main AGit
Owner

@⁠Ayphex on GitHub · 2026-12-05 02:35 UTC · original
Ayphex:pr/c6a-barriers → main · +2540 −88 · 11 files · 2 commits · open

Summary

Adds an opt-in, pure-Rust enhanced-barrier optimization pass (zero Mesa/vkd3d changes) that eliminates unnecessary full-GPU drains, L2 flushes, wildcard UAV barriers, redundant mid-list barriers, and full-pipe barriers around inline placed buffer copies. Default-off (VICTORY_BARRIER_OPT=0) for exact upstream parity; opt-in via VICTORY_BARRIER_OPT=1.

Key Changes

  • war — execution-only WAR (crates/victory-gpu/src/waits.rs): Lowers pure WAR (READ -> WRITE/COMMON) transitions to execution-only D3D12_BARRIER_ACCESS_NO_ACCESS (0x8000_0000) barriers, eliminating the unnecessary L2 cache flush/writeback; pure RAR and READ -> NO_ACCESS are skipped.
  • narrow — exact sync/access narrowing (waits.rs): Narrows SyncAfter / AccessAfter to the stages and accesses actually involved and eliminates wildcard ResourceBarrier(UAV(NULL)).
  • dirty — per-list producer tracking (waits.rs): A per-HostList DirtyTracker (dirty_write_stages / dirty_read_stages, conservatively initialized to ALL on every fresh/reset list) narrows SyncBefore mid-list and elides provably redundant barriers without weakening cross-list safety.
  • join — safe ResourceBarrier coalescing (crates/victory-gpu/src/host/rec.rs): Restores Rec::barriers() batch coalescing with conflict flushes on same-resource transitions, adjacent identical UAV/global barrier deduplication, and Acquire/Release synchronization.
  • place — placed-copy barrier narrowing (crates/victory-gpu/src/host/place.rs): Replaces the full-GPU ALL -> ALL, COMMON -> COMMON barriers in HostList::place_copy and HostList::place_source with DirtyTracker-narrowed/elided pre-copy barriers (-> COPY), pure COPY -> COPY mid-copy alias and post-source barriers, and buffer-scoped COPY (COPY_DEST) -> buffer consumers post-copy barriers (preserving DirtyTracker RT/DS consumer slots and stopping redundant DIRTY_COPY re-dirtying). parts_in_one preludes are left untouched.
  • Docs (docs/SETTINGS.md): Documented VICTORY_BARRIER_OPT, VICTORY_BARRIER_OPT_MASK, and VICTORY_BARRIER_STATS.

Settings / Env Vars

  • VICTORY_BARRIER_OPT=0|1 (default 0 = exact upstream parity).
  • VICTORY_BARRIER_OPT_MASK=war,narrow,dirty,join,place (default when enabled = all five).
  • VICTORY_BARRIER_STATS=0|1 (default 0; per-frame [barrier-opt] telemetry).

Benchmarks (RX 6800 XT 16 GB Full ReBAR, i9-12900K, VICTORY_BENCH=nort, 3840x2160 FSR4 Quality, 60 s timed window)

System & method: AMD Radeon RX 6800 XT (RDNA 2, gfx1030, 16 GB GDDR6, ReBAR), Intel i9-12900K, 32 GB DDR4-3600, CachyOS Linux; 3840x2160 FSR 4.1.2 Quality (internal 2560x1440), VICTORY_BENCH=nort, VICTORY_BENCH_MINUTES=2 (final 60 s in-world window), VICTORY_LOG=off, VICTORY_BARRIER_STATS=0.

Transparent note: measurements were taken stacked on top of the VRAM-first residency branch (#522, VICTORY_VRAM_FIRST=1 VICTORY_VRAM_CLASSES=all) comparing VICTORY_BARRIER_OPT=0 vs 1 on the same binary; this PR is cleanly rebased onto origin/main with zero dependency on #522.

C6a (war,narrow,dirty,join vs VICTORY_BARRIER_OPT=0, VICTORY_LOG=off)

Config Avg FPS vs Baseline 1% Low vs Baseline Lowest 1s GPU W Busy % VRAM GB
VICTORY_BARRIER_OPT=0 (parity) 23.9 — 10.3 — 10.6 168.2 88.3 11.3
war,narrow,join (dirty off) 23.3 -2.5% 10.0 -2.9% 14.5 164.5 86.0 11.5
war,narrow,dirty,join 26.0 +8.8% 13.5 +31.1% 15.4 177.9 91.5 10.8

C6a.5 (+place incremental A/B on the same binary, VICTORY_LOG=off)

Config Avg FPS vs C6a 1% Low Lowest 1s GPU W Busy % VRAM GB
war,narrow,dirty,join 24.9 — 13.1 7.3 172.8 90.6 11.1
war,narrow,dirty,join,place 25.5 +2.4% 12.7 9.8 178.0 91.5 10.8

Telemetry (VICTORY_BARRIER_STATS=1, per-frame averages)

  • C6a (war,narrow,dirty,join): total=925.3 emitted=770.4 noop=110.2 war_exec=52.8 narrow_before=585.3 narrow_after=770.4 elided=44.7 uav_null_elim=22.8 rec=589.2->404.3(dedup=0.5) place_joined=105.9
  • C6a + C6a.5 (+place): total=992.3 emitted=820.0 noop=119.7 war_exec=56.4 narrow_before=635.9 narrow_after=820.0 elided=52.6 uav_null_elim=7.5 rec=664.8->474.0(dedup=0.7) place_joined=51.5 place_opt=pre:19.4(elide=12.3) mid:0.0 post_copy:28.8 post_src:3.0
  • Notes: Producer A (place_copy/place_source) full-GPU drains eliminated (63.5/f -> 0, cutting place_joined from 105.9 to 51.5/f residual parts_in_one preludes); 39% pre-copy elision (12.3/31.7); guest barrier elision increased 44.7 -> 52.6/f; Rec coalescing reduced calls 664.8 -> 474.0/f (-28.7%).

Verification

  • ./build.sh (release): 0 errors on the standalone origin/main base (the single room_lately never-used warning is pre-existing in resource.rs on origin/main, outside this PR's file set).
  • Unit tests: waits::tests 11/11 pass, host::rec::tests 2/2 pass (under Wine).
  • Runtime health: 0 GPU faults / 0 corruption hints across all benchmark runs; screenshot comparison verified clean (no lighting, shadow, mesh, skinning, or texture-copy artifacts).
  • Exact parity confirmed when VICTORY_BARRIER_OPT=0.
  • Pure Rust + docs; zero Mesa/vkd3d patches.
**@⁠Ayphex** on GitHub · 2026-12-05 02:35 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/544) `Ayphex:pr/c6a-barriers` → `main` · +2540 −88 · 11 files · 2 commits · open ## Summary Adds an opt-in, pure-Rust **enhanced-barrier optimization** pass (zero Mesa/`vkd3d` changes) that eliminates unnecessary full-GPU drains, L2 flushes, wildcard UAV barriers, redundant mid-list barriers, and full-pipe barriers around inline placed buffer copies. Default-off (`VICTORY_BARRIER_OPT=0`) for exact upstream parity; opt-in via `VICTORY_BARRIER_OPT=1`. ### Key Changes - **`war` — execution-only WAR (`crates/victory-gpu/src/waits.rs`)**: Lowers pure WAR (`READ -> WRITE/COMMON`) transitions to execution-only `D3D12_BARRIER_ACCESS_NO_ACCESS` (`0x8000_0000`) barriers, eliminating the unnecessary L2 cache flush/writeback; pure RAR and `READ -> NO_ACCESS` are skipped. - **`narrow` — exact sync/access narrowing (`waits.rs`)**: Narrows `SyncAfter` / `AccessAfter` to the stages and accesses actually involved and eliminates wildcard `ResourceBarrier(UAV(NULL))`. - **`dirty` — per-list producer tracking (`waits.rs`)**: A per-`HostList` `DirtyTracker` (`dirty_write_stages` / `dirty_read_stages`, conservatively initialized to ALL on every fresh/reset list) narrows `SyncBefore` mid-list and elides provably redundant barriers without weakening cross-list safety. - **`join` — safe `ResourceBarrier` coalescing (`crates/victory-gpu/src/host/rec.rs`)**: Restores `Rec::barriers()` batch coalescing with conflict flushes on same-resource transitions, adjacent identical UAV/global barrier deduplication, and Acquire/Release synchronization. - **`place` — placed-copy barrier narrowing (`crates/victory-gpu/src/host/place.rs`)**: Replaces the full-GPU `ALL -> ALL, COMMON -> COMMON` barriers in `HostList::place_copy` and `HostList::place_source` with `DirtyTracker`-narrowed/elided pre-copy barriers (`-> COPY`), pure `COPY -> COPY` mid-copy alias and post-source barriers, and buffer-scoped `COPY (COPY_DEST) -> buffer consumers` post-copy barriers (preserving `DirtyTracker` RT/DS consumer slots and stopping redundant `DIRTY_COPY` re-dirtying). `parts_in_one` preludes are left untouched. - **Docs (`docs/SETTINGS.md`)**: Documented `VICTORY_BARRIER_OPT`, `VICTORY_BARRIER_OPT_MASK`, and `VICTORY_BARRIER_STATS`. ### Settings / Env Vars - `VICTORY_BARRIER_OPT=0|1` (default `0` = exact upstream parity). - `VICTORY_BARRIER_OPT_MASK=war,narrow,dirty,join,place` (default when enabled = all five). - `VICTORY_BARRIER_STATS=0|1` (default `0`; per-frame `[barrier-opt]` telemetry). ## Benchmarks (RX 6800 XT 16 GB Full ReBAR, i9-12900K, `VICTORY_BENCH=nort`, 3840x2160 FSR4 Quality, 60 s timed window) System & method: AMD Radeon RX 6800 XT (RDNA 2, `gfx1030`, 16 GB GDDR6, ReBAR), Intel i9-12900K, 32 GB DDR4-3600, CachyOS Linux; 3840x2160 FSR 4.1.2 Quality (internal 2560x1440), `VICTORY_BENCH=nort`, `VICTORY_BENCH_MINUTES=2` (final 60 s in-world window), `VICTORY_LOG=off`, `VICTORY_BARRIER_STATS=0`. Transparent note: measurements were taken stacked on top of the VRAM-first residency branch (#522, `VICTORY_VRAM_FIRST=1 VICTORY_VRAM_CLASSES=all`) comparing `VICTORY_BARRIER_OPT=0` vs `1` on the same binary; this PR is cleanly rebased onto `origin/main` with zero dependency on #522. ### C6a (`war,narrow,dirty,join` vs `VICTORY_BARRIER_OPT=0`, `VICTORY_LOG=off`) | Config | Avg FPS | vs Baseline | 1% Low | vs Baseline | Lowest 1s | GPU W | Busy % | VRAM GB | |---|---:|---:|---:|---:|---:|---:|---:|---:| | `VICTORY_BARRIER_OPT=0` (parity) | 23.9 | — | 10.3 | — | 10.6 | 168.2 | 88.3 | 11.3 | | `war,narrow,join` (dirty off) | 23.3 | -2.5% | 10.0 | -2.9% | 14.5 | 164.5 | 86.0 | 11.5 | | `war,narrow,dirty,join` | 26.0 | +8.8% | 13.5 | +31.1% | 15.4 | 177.9 | 91.5 | 10.8 | ### C6a.5 (`+place` incremental A/B on the same binary, `VICTORY_LOG=off`) | Config | Avg FPS | vs C6a | 1% Low | Lowest 1s | GPU W | Busy % | VRAM GB | |---|---:|---:|---:|---:|---:|---:|---:| | `war,narrow,dirty,join` | 24.9 | — | 13.1 | 7.3 | 172.8 | 90.6 | 11.1 | | `war,narrow,dirty,join,place` | 25.5 | +2.4% | 12.7 | 9.8 | 178.0 | 91.5 | 10.8 | ### Telemetry (`VICTORY_BARRIER_STATS=1`, per-frame averages) - C6a (`war,narrow,dirty,join`): `total=925.3 emitted=770.4 noop=110.2 war_exec=52.8 narrow_before=585.3 narrow_after=770.4 elided=44.7 uav_null_elim=22.8 rec=589.2->404.3(dedup=0.5) place_joined=105.9` - C6a + C6a.5 (`+place`): `total=992.3 emitted=820.0 noop=119.7 war_exec=56.4 narrow_before=635.9 narrow_after=820.0 elided=52.6 uav_null_elim=7.5 rec=664.8->474.0(dedup=0.7) place_joined=51.5 place_opt=pre:19.4(elide=12.3) mid:0.0 post_copy:28.8 post_src:3.0` - Notes: Producer A (`place_copy`/`place_source`) full-GPU drains eliminated (`63.5/f -> 0`, cutting `place_joined` from `105.9` to `51.5/f` residual `parts_in_one` preludes); 39% pre-copy elision (`12.3/31.7`); guest barrier elision increased `44.7 -> 52.6/f`; `Rec` coalescing reduced calls `664.8 -> 474.0/f` (-28.7%). ## Verification - `./build.sh` (release): 0 errors on the standalone `origin/main` base (the single `room_lately` never-used warning is pre-existing in `resource.rs` on `origin/main`, outside this PR's file set). - Unit tests: `waits::tests` 11/11 pass, `host::rec::tests` 2/2 pass (under Wine). - Runtime health: 0 GPU faults / 0 corruption hints across all benchmark runs; screenshot comparison verified clean (no lighting, shadow, mesh, skinning, or texture-copy artifacts). - Exact parity confirmed when `VICTORY_BARRIER_OPT=0`. - Pure Rust + docs; zero Mesa/`vkd3d` patches.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 02:36:12 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-05 03:18 UTC · original

Checked 040c8ae on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).

Default off looks fine. With VICTORY_BARRIER_OPT unset the only unconditional changes are ResourceBarrier becoming Rec::barriers in settle, clear_rtv and texture::alias (with join off that is flush plus ResourceBarrier, same as main), the Asked word growing to u64 with the low bits unchanged, the mark_dirty calls that return early, and stats counters behind VICTORY_BARRIER_STATS. place_copy and place_source with the flag off record the same wait_for_all calls in the same order. Both the card and WARP report EnhancedBarriersSupported, so I couldn't exercise the fallback on a device without enhanced barriers. Reading it, groups_asked goes back to the UAV(NULL) path and place.rs falls back to wait_for_all when list.precise() is None.

The problem is with the flag on, on native D3D12. Several barrier shapes the PR builds are rejected by the D3D12 runtime itself and not only by the debug layer. A list with one of them in it fails Close with E_INVALIDARG with the debug layer off too (checked on the card and on WARP), and HostList::close (host.rs:5078) turns that into fail("a host command list did not close"). So on Windows I'd expect VICTORY_BARRIER_OPT=1 to end the run on the first list that hits one of these. I'd guess vkd3d-proton doesn't check these rules, which would fit the clean Linux runs, but I haven't looked.

The first one is the place pre-copy barrier. plan_place_pre_copy asks for MB_UAV | MB_COPY_DEST | MB_RT_DS (waits.rs:1195), and encode_d3d12_access_before adds RENDER_TARGET | DEPTH_STENCIL_WRITE whenever draw stages are dirty (waits.rs:905). A fresh list starts all dirty, so the first place_copy or place_source of every list (place.rs:285 and 397) gets AccessBefore RT|UAV|DSW|COPY_DEST with SyncAfter COPY. The runtime says a global barrier with RT or DS access would need a layout transition (message 1331) and Close fails. The same happens later in a list whenever draws have read something since the last barrier, and also with dirty off in the mask. The copies only touch buffers, so MB_RT_DS shouldn't be there. Dropping it is enough for place_source, whose barrier is SyncBefore DRAW|COMPUTE|COPY with UAV|COPY_DEST and closes fine that way. place_copy also has the WAR half, which adds EXECUTE_INDIRECT to SyncBefore, and the runtime won't pair EXECUTE_INDIRECT with UAV or COPY_DEST access either. That stage needs its own execution-only barrier or has to stay out of the one with write access. The pre-copy barrier you get with compute and copy writes and no pending reads (SyncBefore COMPUTE|COPY, AccessBefore UAV|COPY_DEST) closed, ran and copied the right bytes.

The second one is narrow on the title's barriers (groups_asked, list.rs:2343). I swept plan_barrier with single-barrier calls, every buffer barrier from 18 sync values by 17 access values on each side that the runtime accepts as a buffer barrier, plus a few texture barriers into and out of UAV, against 7 tracker states. With the default mask that gives 1,845 distinct global barriers and the runtime rejects 734 of them. 710 have AccessBefore COMMON with a narrowed AccessAfter. A title barrier with AccessBefore COMMON is encoded as ACCESS_COMMON (waits.rs:893) while AccessAfter is narrowed to SRV, CBV, NO_ACCESS and so on (waits.rs:1096), and a global barrier has to keep AccessAfter COMMON when AccessBefore is COMMON. 22 come from SyncAfter ALL_SHADING or NON_PIXEL_SHADING with VERTEX_BUFFER access, because decode_sync splits the umbrella into compute, vertex and pixel (waits.rs:400) and the re-encoded COMPUTE_SHADING bit can't go with VERTEX_BUFFER. The last 2 are texture RT or DS-write going to UAV, which gives RT|DSW access in a global barrier as in the place case.

Merged calls look like the more likely trigger in practice, since Asked::of ORs every group of a title call into one word and the runtime checks each sync bit against the whole access mask. I only tried a few by hand. A pure WAR from EXECUTE_INDIRECT reads to compute UAV, in the same call as compute UAV to pixel SRV, comes out as SyncBefore COMPUTE|EXECUTE_INDIRECT with AccessBefore UAV, and Close fails. Compute UAV to indirect arguments together with pixel SRV to compute UAV comes out as SyncAfter COMPUTE|EXECUTE_INDIRECT with AccessAfter INDIRECT_ARGUMENT, and Close fails. Both come from folding the WAR stages into the memory barrier (waits.rs:1084 and 1086) while the access masks only describe the memory part. Two other merged pairs closed fine. I checked one representative of each rejected kind without the debug layer, on its own list, on the card and on WARP, and every one failed Close. Main turns all of these into after() or UAV(NULL), which the runtime accepts. Masks without narrow had zero rejections, so the war,narrow,dirty,join mask from the C6a table is affected too, not only place.

The war execution-only barriers (NO_ACCESS on both sides), the mid-copy, post-source and post-copy barriers, and the join path all passed. A place_copy-shaped sequence ran clean under the debug layer and with GPU-based validation and copied the right bytes, also on WARP. It sent the legacy transitions through Rec::barriers, which held them and flushed on a same-resource transition and on the next copy, and used the PR's barriers where they're valid.

On the other points I looked at. The PR adds only global barriers, no buffer or texture barriers and no layouts, so there's no layout versus legacy state mixing on one resource beyond what main already does with after() next to ResourceBarrier. Nothing touches placed-resource initial layouts or COMMON/UNDEFINED discards. Split barriers (and other sync bits decode_sync doesn't know) take the unknown-bit path to SYNC_ALL (waits.rs:379), which looks safe, but I didn't record one on a device. Rec::barriers takes the held lock and calls the raw list inside it, flush takes the same lock but is never reached from there, poisoning is tolerated, and the expects are only in tests.

The suite on main and on the PR, cargo test -p victory-gpu --lib skipping views_die_with_their_resource, shows the same failures (indirect host_list_* x2, the two pipeline::host library loads, the flaky watch test), and the 13 new tests pass. Same with VICTORY_BARRIER_OPT=1, with --features diagnostics and VICTORY_D3D12_DEBUG=1, and on WARP, where descriptor::host views_are_made_beside_the_heap_and_copied_in also fails, as it does on main WARP. None of the existing tests record groups_asked or place_copy on a device, so they can't catch any of this. Everything above came from a throwaway test that records each plan shape on a real list and closes it, and something like that in the PR would have caught it. cargo check -p victory is clean. Clippy adds 10 warnings in waits.rs, nine bool_assert_comparison in the new tests and one operator-precedence warning on DirtyTracker::INIT (waits.rs:583).

Two smaller things. The body says VICTORY_BARRIER_STATS is documented, but SETTINGS.md only gets the OPT and OPT_MASK rows. And narrow trims SyncAfter to the title's own consumers where main used ALL_SHADING, while the host records its own work between a title barrier and the title's next draw (indirect clamps, the ambient and lightprobe passes). I didn't find host work that reads title-written data with no barrier of its own (the in-place clamp has its own after(COMPUTE)), but I didn't go through all of it.

Not tested are the game itself, performance, Linux and vkd3d-proton, a device without enhanced barriers, title barriers with more than one group beyond the few above, and whether the dirty elision is complete. For that I only checked that mark_dirty covers the title's draws, dispatches, copies and resolves, not every host pass.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-05 03:18 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/544#issuecomment-7430957936) Checked 040c8ae on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). Default off looks fine. With VICTORY_BARRIER_OPT unset the only unconditional changes are ResourceBarrier becoming Rec::barriers in settle, clear_rtv and texture::alias (with join off that is flush plus ResourceBarrier, same as main), the Asked word growing to u64 with the low bits unchanged, the mark_dirty calls that return early, and stats counters behind VICTORY_BARRIER_STATS. place_copy and place_source with the flag off record the same wait_for_all calls in the same order. Both the card and WARP report EnhancedBarriersSupported, so I couldn't exercise the fallback on a device without enhanced barriers. Reading it, groups_asked goes back to the UAV(NULL) path and place.rs falls back to wait_for_all when list.precise() is None. The problem is with the flag on, on native D3D12. Several barrier shapes the PR builds are rejected by the D3D12 runtime itself and not only by the debug layer. A list with one of them in it fails Close with E_INVALIDARG with the debug layer off too (checked on the card and on WARP), and HostList::close (host.rs:5078) turns that into fail("a host command list did not close"). So on Windows I'd expect VICTORY_BARRIER_OPT=1 to end the run on the first list that hits one of these. I'd guess vkd3d-proton doesn't check these rules, which would fit the clean Linux runs, but I haven't looked. The first one is the place pre-copy barrier. plan_place_pre_copy asks for MB_UAV | MB_COPY_DEST | MB_RT_DS (waits.rs:1195), and encode_d3d12_access_before adds RENDER_TARGET | DEPTH_STENCIL_WRITE whenever draw stages are dirty (waits.rs:905). A fresh list starts all dirty, so the first place_copy or place_source of every list (place.rs:285 and 397) gets AccessBefore RT|UAV|DSW|COPY_DEST with SyncAfter COPY. The runtime says a global barrier with RT or DS access would need a layout transition (message 1331) and Close fails. The same happens later in a list whenever draws have read something since the last barrier, and also with dirty off in the mask. The copies only touch buffers, so MB_RT_DS shouldn't be there. Dropping it is enough for place_source, whose barrier is SyncBefore DRAW|COMPUTE|COPY with UAV|COPY_DEST and closes fine that way. place_copy also has the WAR half, which adds EXECUTE_INDIRECT to SyncBefore, and the runtime won't pair EXECUTE_INDIRECT with UAV or COPY_DEST access either. That stage needs its own execution-only barrier or has to stay out of the one with write access. The pre-copy barrier you get with compute and copy writes and no pending reads (SyncBefore COMPUTE|COPY, AccessBefore UAV|COPY_DEST) closed, ran and copied the right bytes. The second one is narrow on the title's barriers (groups_asked, list.rs:2343). I swept plan_barrier with single-barrier calls, every buffer barrier from 18 sync values by 17 access values on each side that the runtime accepts as a buffer barrier, plus a few texture barriers into and out of UAV, against 7 tracker states. With the default mask that gives 1,845 distinct global barriers and the runtime rejects 734 of them. 710 have AccessBefore COMMON with a narrowed AccessAfter. A title barrier with AccessBefore COMMON is encoded as ACCESS_COMMON (waits.rs:893) while AccessAfter is narrowed to SRV, CBV, NO_ACCESS and so on (waits.rs:1096), and a global barrier has to keep AccessAfter COMMON when AccessBefore is COMMON. 22 come from SyncAfter ALL_SHADING or NON_PIXEL_SHADING with VERTEX_BUFFER access, because decode_sync splits the umbrella into compute, vertex and pixel (waits.rs:400) and the re-encoded COMPUTE_SHADING bit can't go with VERTEX_BUFFER. The last 2 are texture RT or DS-write going to UAV, which gives RT|DSW access in a global barrier as in the place case. Merged calls look like the more likely trigger in practice, since Asked::of ORs every group of a title call into one word and the runtime checks each sync bit against the whole access mask. I only tried a few by hand. A pure WAR from EXECUTE_INDIRECT reads to compute UAV, in the same call as compute UAV to pixel SRV, comes out as SyncBefore COMPUTE|EXECUTE_INDIRECT with AccessBefore UAV, and Close fails. Compute UAV to indirect arguments together with pixel SRV to compute UAV comes out as SyncAfter COMPUTE|EXECUTE_INDIRECT with AccessAfter INDIRECT_ARGUMENT, and Close fails. Both come from folding the WAR stages into the memory barrier (waits.rs:1084 and 1086) while the access masks only describe the memory part. Two other merged pairs closed fine. I checked one representative of each rejected kind without the debug layer, on its own list, on the card and on WARP, and every one failed Close. Main turns all of these into after() or UAV(NULL), which the runtime accepts. Masks without narrow had zero rejections, so the war,narrow,dirty,join mask from the C6a table is affected too, not only place. The war execution-only barriers (NO_ACCESS on both sides), the mid-copy, post-source and post-copy barriers, and the join path all passed. A place_copy-shaped sequence ran clean under the debug layer and with GPU-based validation and copied the right bytes, also on WARP. It sent the legacy transitions through Rec::barriers, which held them and flushed on a same-resource transition and on the next copy, and used the PR's barriers where they're valid. On the other points I looked at. The PR adds only global barriers, no buffer or texture barriers and no layouts, so there's no layout versus legacy state mixing on one resource beyond what main already does with after() next to ResourceBarrier. Nothing touches placed-resource initial layouts or COMMON/UNDEFINED discards. Split barriers (and other sync bits decode_sync doesn't know) take the unknown-bit path to SYNC_ALL (waits.rs:379), which looks safe, but I didn't record one on a device. Rec::barriers takes the held lock and calls the raw list inside it, flush takes the same lock but is never reached from there, poisoning is tolerated, and the expects are only in tests. The suite on main and on the PR, cargo test -p victory-gpu --lib skipping views_die_with_their_resource, shows the same failures (indirect host_list_* x2, the two pipeline::host library loads, the flaky watch test), and the 13 new tests pass. Same with VICTORY_BARRIER_OPT=1, with --features diagnostics and VICTORY_D3D12_DEBUG=1, and on WARP, where descriptor::host views_are_made_beside_the_heap_and_copied_in also fails, as it does on main WARP. None of the existing tests record groups_asked or place_copy on a device, so they can't catch any of this. Everything above came from a throwaway test that records each plan shape on a real list and closes it, and something like that in the PR would have caught it. cargo check -p victory is clean. Clippy adds 10 warnings in waits.rs, nine bool_assert_comparison in the new tests and one operator-precedence warning on DirtyTracker::INIT (waits.rs:583). Two smaller things. The body says VICTORY_BARRIER_STATS is documented, but SETTINGS.md only gets the OPT and OPT_MASK rows. And narrow trims SyncAfter to the title's own consumers where main used ALL_SHADING, while the host records its own work between a title barrier and the title's next draw (indirect clamps, the ambient and lightprobe passes). I didn't find host work that reads title-written data with no barrier of its own (the in-place clamp has its own after(COMPUTE)), but I didn't go through all of it. Not tested are the game itself, performance, Linux and vkd3d-proton, a device without enhanced barriers, title barriers with more than one group beyond the few above, and whether the dirty elision is complete. For that I only checked that mark_dirty covers the title's draws, dispatches, copies and resolves, not every host pass. AI-assisted: yes
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/544/head:github-bot/gh-544'
git switch 'github-bot/gh-544'

Merge

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