perf(gpu): forward texture enhanced barriers as resource-scoped host barriers #408
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!408
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-408"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tommiehansen on GitHub · 2026-12-04 01:08 UTC · original
tommiehansen:perf/texture-scoped-barriers→main· +1424 −24 · 7 files · 6 commits · openWhy
Global texture barriers may over-synchronize unrelated resources.
What changes
Opt-in
VICTORY_TEXTURE_BARRIERS=1, resource-scoped enhanced barriers with lifetime/eligibility checks and existing fallback.Benchmark results
CPU-only Standard at
79ab078: 0.009→0.046 ms, +406.28%, exact planning output; global barrier count 16→13, two resource transitions and two resource UAV barriers in fixture.Why this should be merged / current decision
No verified net performance benefit. Hold opt-in implementation until GPU synchronization savings outweigh measured planning cost.
Validation
Standard.
fd5767fCI passed ten targeted tests and all-targets; one ignored. Unchanged-main descriptor PSO failure reproduced separately.Compatibility
Preserve upstream CountBatch, translation statistics and fallback. Physical parity and timing outstanding.
Archived detailed evidence and review history.
@Kal0s-design on GitHub · 2026-12-04 02:12 UTC · original
Tested
a56159fnatively on Windows 11 (MSVC) with real D3D12, one NVIDIA desktop card plus WARP.Full
cargo test -p victory-gpu --lib(skippingdescriptor::tests::views_die_with_their_resource) gives 339 passed / 5 failed / 23 ignored on the merge-base, and this PR gives 346 / 5 / 24 with the switch unset and the same withVICTORY_TEXTURE_BARRIERS=1. The five failures are the ones main already has on this machine (twoindirect::tests::host_list_*, twopipeline::hostlibrary loads, the flakywatchone). The new tests are CPU only, so I also ran a throwaway local test (not pushed) that sends barrier groups through a newer-layout title list with the switch on and submits it, in adiagnosticsbuild withVICTORY_D3D12_DEBUG=1, on the card and on WARP. Before each planned call it puts the texture into UAV state in the back list the same way a dispatch would, throughensure_state.Eight calls, same result on both adapters.
So 2 calls scoped, 6 global, and the debug layer had nothing to say about any of the barriers. I checked that it was really validating by adding one wrong transition at the end, which it reported.
I looked at
7383d45first and this head fixes what I had noted there. Unnamed syncs (ALL, COPY, RESOLVE, SPLIT) and partial subresource ranges or non-zero flags now stay on the global path (eligible_texture_wait, waits.rs:333-356), unmade or untracked textures fall back instead of being skipped (resource.rs:1744, host.rs:5241), andgroups_askedis back to main's logic, so a call with nothing to wait for records the same as before. The old access-derived mapping, with the comment about layout 18 and thelet _for unused constants, is gone andbarrier_state(waits.rs:487) is a strict whitelist now. With the switch unset the recording and replay are the same as main's apart from the extrafalsepassed tocount_groups.Only remark left is about how often it'll actually fire. A texture has to already be tracked in the same host list, so a barrier at the start of a list on something the previous list wrote always takes the global path. That's the safe choice, it just means the RDNA numbers will depend a lot on how a title splits its lists.
Clippy
-p victory-gpu --all-targets, with and withoutdiagnostics, shows the same warnings as the merge-base.AI-assisted: yes
@fsrajner on GitHub · 2026-12-04 08:14 UTC · original
Tested on top of main together with the other PRs listed below, with
VICTORY_TEXTURE_BARRIERS=1and without it. There is no measurable change in this scene. The worst window was a bit tighter with the switch (61.5 vs 82.9 ms). The 82.9 ms came from a first run that re-prepared shaders, so I would not read anything into it. No visual problems were noticed in these headless runs, but I did not check the output image.Setup: RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, RADV from this repo's
setup.sh. Series X, 3840x2160 output, FSR 4 Quality (4.1.2), RT at defaults, headless gamescope. Same save (the intro); the game stops 120 s after the first press. The figures come from the 5 sstats: framewindows after loading. 2 runs per variant; main =0fd7614. The PR build is main + #382 + #392 + #393 + #408 + #445 + #369 together. #398 was left out because it conflicts with #369 in the residency planning. The #369 merge conflicted only with local counters.VICTORY_TEXTURE_BARRIERS=1VICTORY_CARD_KEPT_MB=9216The first run of main and of the PR build each began by re-preparing shaders after a translator change. That is likely where the 48 ms run and the 82.9 ms worst window come from. Otherwise the spread between runs is about ±1 ms/frame, so all of these are within noise. In this scene the card is the limit (about 21-24 ms of GPU wait per frame).
@Luxuride on GitHub · 2026-12-04 12:20 UTC · original
Careful, self-documenting patch — and it makes the thing it speeds up about seven times slower on the CPU, with zero D3D12 calls ever executed. Park it until someone can show a frame-time win.
The numbers are your own: planning cost +676% paired (4.98 µs → 37.96 µs per 1024 calls) to narrow 3 of 16 synthetic calls. That is a record-path regression bought with an unmeasured GPU-side maybe, and the GPU side is exactly where an off-by-one in a barrier state pair becomes a black screen under vkd3d-proton.
Two things that would have to change before it is reviewable at all:
crates/victory-gpu/src/waits.rs:1086). Either someone runs it on a real device and reports the frame time, or it stays a draft.waits.rs:135is the only mention. Nothing indocs/SETTINGS.md, nothing inrun.conf.default, so perREADME.md:125it never appears in the F1 menu. A switch that does nothing until someone reads the source is a switch nobody will ever turn on.Credit where it is due:
try_barrier_copies(crates/victory-gpu/src/host.rs:5241-5268) validates every op before mutating any state entry, so a mid-wayScopeFallbackcannot leave tracked states half-advanced. That was the thing most likely to be wrong and it is right.42 behind, no conflict. If it comes back, bring the measured delta and the
docs/SETTINGS.mdrow.@Xough on GitHub · 2026-12-04 21:43 UTC · original
Tested on an RX 6700 XT (12 GB, RDNA 2), Ryzen 9 7900X, CachyOS, ray tracing off, preset high, FSR 4.1 performance, no frame generation, 1920x1080 output. Built-in benchmark (
VICTORY_BENCH=nort, 3 min each, first 60 s excluded), this PR merged on top of main.VICTORY_TEXTURE_BARRIERSNo measurable difference here, within run-to-run noise (about 0.3-0.5 fps). I only measured frame rates, not rendering correctness. A frame in this scene records roughly 500 barriers, so replacing some global ones does not move the total much on this card.
gpu: forward texture enhanced barriers as resource-scoped host barriersto perf(gpu): forward texture enhanced barriers as resource-scoped host barriers@tommiehansen on GitHub · 2026-12-05 10:21 UTC · original
Thanks for the reviews and hardware runs. The switch is now documented in both SETTINGS.md and run.conf.default. Kal0s-design's native D3D12 test also exercised actual barriers. The new Standard CPU comparison still shows extra planning cost (about 37 µs per synthetic sample), and the gameplay tests show no measurable gain. It remains experimental.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.