GPU: narrow placed-copy, enhanced-group, buffer and pipeline-sync barriers (VICTORY_NARROW_BARRIERS) #799
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!799
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-799"
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?
@Czer0xx on GitHub · 2026-11-28 06:14 UTC · original
Czer0xx:pr/narrow-barriers→main· +1149 −36 · 6 files · 2 commits · merged 2026-11-29 08:16 UTCSummary
Adds an opt-in switch
VICTORY_NARROW_BARRIERS=1(off by default, exposed in the F1 menu asNARROW GPU BARRIERS) that narrows unconditional global GPU barriers (D3D12_BARRIER_TYPE_GLOBAL(SYNC_ALL)andUAV_BARRIER(NULL)) to the buffers, textures, and sync scopes the title actually asks for:host/place.rs):place_copyandplace_sourceemitD3D12_BARRIER_TYPE_BUFFERscoped tofrom.buffer/to.buffer/betweeninstead of globalSYNC_ALLdrains (~78-144/frame narrowed), falling back towait_for_allwhen Enhanced Barriers are unavailable.Barrier()groups +thinrecording path (list.rs,list/thin.rs): classifies barrier groups while the title pointer is live on the calling thread instead of discardinggroupsinthinand emitting a globalUAV_BARRIER(NULL). Skips pure non-UAV texture transitions andSYNC_NONE/NO_ACCESSno-ops (~100-140/frame skipped), narrows buffer barriers toD3D12_BUFFER_BARRIER, texture UAV barriers to targetedUAV_BARRIER(host_tex), and global barriers toD3D12_GLOBAL_BARRIERwith sanitized sync bits (~590-700/frame narrowed; ~1/frame global fallback).ResourceBarrierand pipeline sync (list.rs): skipsBEGIN_ONLYand pure read-to-read legacy buffer transitions, narrows write-involving buffer barriers to targetedUAV_BARRIER(shadow.buffer), and skips globalUAV_BARRIER(NULL)on pipeline syncs whose flush flags contain no shader partial-flush, idle, or L1/L2 cache writeback/invalidate bits.host.rs,host/place.rs): logsnarrow barriers per frame (VICTORY_NARROW_BARRIERS=1)when enabled.With
VICTORY_NARROW_BARRIERSunset, behavior is unchanged.Verification
cargo clippy -p victory-gpu --all-targets --lockedand--all-features: 0 warnings in modified files.cargo test -p victory-gpu --lib --locked: passes, including new unit testlist::tests::narrow_barrier_classification.cargo xtask policy:asset policy: 294 files ok.VICTORY_NARROW_BARRIERS=1):110.1placed-copy barriers narrowed; enhanced barrier groups118.3skipped,634.5narrowed,1.0global fallback.68.4 / 72.1 ms->63.4 / 65.8 ms(-5.0 / -6.3 ms); 5 spreparingmedian59.9 ms->53.8 ms(-6.1 ms).65% / 68.0%->73% / 74.5%; GPU idle behind us median27.0 ms->20.1 ms(-6.9 ms).11.57->11.96(+3.4%), heavy scenes (>=5000draws) mean10.40->11.41(+9.7%), peak14.70->17.40(+18.4%), with no visual artifacts observed.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-28 06:14 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@grosterr on GitHub · 2026-11-28 12:19 UTC · original
On our build
VICTORY_NARROW_BARRIERS=1turns most of the picture white.RTX 3060 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB, Windows 11. Main
63b902fwith open PRs on top (among them #501, #635, #641, #740, #807, #857, #875), Series S, 1920x1080, DLSS Quality (preset K), FSR 3 frame generation 2x. Shader cache warmed, no misses in any run.5dc3b25986622949also left out)VICTORY_NARROW_BARRIERS=1aloneVICTORY_NARROW_BARRIERS=1+VICTORY_PLACED_FILLS=1The first cutscene (indoors, the office) plays fine in A. The white starts with the white fade into the boat scene and stays for the rest of the run. Only the HUD, the minimap and subtitles show over it, with a faint outline of the scene under the white in some frames. The card stays busy:
GPU BUSY48–62 ms a frame on the white screen, with 2,500–4,000 draws a frame, so the frames are drawn but come out white. No device loss, and nothing new among the warnings in the log.It looks as if something read after a narrowed barrier (an exposure or tone-map value, say) is read before it is written. That is a guess; I have not found which group.
With the switch off, the same build and route are clean (run "base", and a run with only #501's switches).
AI-assisted (Claude Code): the runs were judged by eye on my PC, and Claude wrote this text. No game files attached.
🤖 Generated with Claude Code
@shiman1901 on GitHub · 2026-11-28 14:13 UTC · original
@Czer0xx @grosterr Audited commit
517048cto track down whyVICTORY_NARROW_BARRIERS=1latches the screen white right on the cutscene-to-boat white fade (while HUD draws fine — classic auto-exposure / tone-map hazard).Found four concrete barrier-drop holes in
517048cthat can let a tone-map / exposure pass read stale/unflushed data:1.
ACCESS_NO_ACCESSexecution barriers are silently dropped (list.rs,global_barrier_needs_host&buffer_barrier_needs_host)falsewhenaccess_before == NO_ACCESSoraccess_after == NO_ACCESS.SyncBefore/SyncAfterandACCESS_NO_ACCESS(0x8000_0000) is a pure execution barrier, NOT a no-op — dropping it allows downstream compute/pixel work (e.g. exposure adaptation / tone-map) to overlap with upstream writes.2.
texture_barrier_needs_uavdropsRENDER_TARGET / DSV_WRITE -> SHADER_RESOURCE(list.rs)texture_barrier_needs_uavreturnsfalsewheneveraccess_before != 0and neither side hasUAV_ACCESS, sosync_before=0x40 (RENDER_TARGET) -> sync_after=0x10 (PIXEL_SHADING),access_before=0x8 (RENDER_TARGET) -> access_after=0x80 (SHADER_RESOURCE)resolves toPackedGroups::Skip(explicitly asserted innarrow_barrier_classification).CompactBarrierdoesn't storelayout_before/layout_after, andreplay_narrow_barrier_groups(kind == 1) emits a legacyBarrier { kind: 2 }(UAV barrier) ontwin_resource/host_resourcerather than a realD3D12_TEXTURE_BARRIER.3.
sync_flags_need_uavskips color/depth block flushes (0x4 | 0x8)4.
place.rs(place_copy/place_source) misses aliasing views / card sideswait_for_allwithD3D12_BUFFER_BARRIERon onlyfrom.buffer / to.buffer / betweendoesn't cover writes made through aHostTexture/ colour twin, placed view, or the VRAMCardside aliasing the same address range. (This also fits @grosterr's Run B where combining#799+#740 VICTORY_PLACED_FILLSadded magenta face corruption on top of the white screen.)Quickest way to bisect & fix
VICTORY_NARROW_BARRIERSinto sub-modes (place,groups,sync, or bitmask) will tell in a single run at the boat fade which of the 3 paths causes the white latch.NO_ACCESSbarriers (access_before == NO_ACCESS || access_after == NO_ACCESS => truewhen syncs are non-zero).0x4 | 0x8CB/DB flushes insync_flags_need_uav.texture_barrier_needs_uav, treat any write access (RTV | DSV | UAV | COPY_DEST) as needing synchronization and fall back toPackedGroups::GlobaluntilCompactBarriercarries layouts for a realD3D12_TEXTURE_BARRIER.place.rs, fall back towait_for_all(or include the card/twin resource) whenfrom/tois carded or aliased by a placed texture/twin.Hope this helps get those +10–18% RTX 3060 gains landed cleanly without the white-screen regression!
@shiman1901 on GitHub · 2026-11-28 16:37 UTC · original
@claudeFrancoisAI Thanks for the clean isolated repro on stock
63b902f— ruling out all the other PRs and the leave-out list nails it down 100% to#799!That extra observation is a huge clue too: pulsing between washed-out and white at idle, then going solid white while holding
LT(aiming) — aiming triggers Rockstar's DoF / post-process / exposure adaptation pass chain, which screams missing barrier between an RT/compute post-process write and the subsequent sample/tone-map read.Seeing GPU busy drop 8 points (
86% -> 78%) cleanly before the fade shows how much real win is sitting in this PR once that barrier hole is plugged. @Czer0xx if you push either theplace / groups / syncsub-modes or the minimal fix (keepingNO_ACCESSexecution barriers,0x4 | 0x8CB/DB flushes, andWRITEtexture fallback), having @claudeFrancoisAI's scripted repro route means it can be verified in one pass!@x-nihil0 on GitHub · 2026-11-28 16:38 UTC · original
A third card with the white picture (RTX 5080, driver 621.40), and here it starts without a fade
Machine: Intel Core Ultra 9 285, 64 GB RAM, RTX 5080 16 GB, driver 621.40, Windows 11. Release build of
main63b902fwith this PR's517048capplied (the tree also had #419 atkeepand #501 with its switches off). The release launcher's set: Series X profile, 1440p, DLSS Quality, frame generation not made ready. Unattended 300 s runs from a save in the open world, warm caches, window grabs every 30 s.VICTORY_NARROW_BARRIERS=1the first two grabs (the start screen at 2 s, the logo at 32 s) looked the same as in the runs without it. From the grab at 62 s to the end of the run every grab was 97-100 % near-white: the loading screen's picture white with only its message box drawn, then the world white with only a few HUD marks in the minimap corner. That happened in both runs that set it, once alone and once together with other switches.I left out the speed figures of the white runs, since a white picture can skip work. No game files, captures or saves are attached. Made with AI help; the figures come from the run logs.
@shiman1901 on GitHub · 2026-11-28 16:44 UTC · original
@x-nihil0 Huge catch — reproducing it right on the loading screen at ~60 s (with the message box / UI plane still intact on top) rules out a 3D fade/DoF-only trigger and points even more directly at a fundamental scene-RT / composite barrier (like the dropped
RENDER_TARGET -> SHADER_RESOURCE,NO_ACCESSexecution barrier,0x4 | 0x8CB flush, orplace.rsaliasing from the audit).Even better: that cuts bisect time from 10 minutes down to ~60 seconds on a single open-world load once someone splits
VICTORY_NARROW_BARRIERSintoplace / groups / sync!@nick0451 on GitHub · 2026-11-28 17:24 UTC · original
Reproduced the white picture here, without a fade:
VICTORY_NARROW_BARRIERS=1, ordinary play standing still on a balcony, no cutscene and no fade before it.RTX 3090 24 GB (driver 610.88), i9-14900K, 32 GB, Windows 11. A release build of this PR merged onto main at
63b902f. Series S, DLSS Performance, frame generation off. Every run used the same frozen save, outdoors on a balcony by the water (about 5,900 draws a frame), standing still. One warm-up start per build, then main and four PR builds were run in turn, three rounds each. Each run is 40 s to settle, 60 s measured, then a screenshot. An A/A run of main against itself in this setup differs by 2-3%.list.rs/list/thin.rs), not placed copies or legacy buffer barriers, at least in this scene.ERRORline.This fits shiman1901's first hole (execution barriers with
ACCESS_NO_ACCESSdropped as no-ops): here it does not need the fade, only one of the skipped groups landing before an exposure or tone-map read. I'm happy to rerun a fixed commit here, since it reproduces in every run.Tested with an AI assistant (Claude Code); results are from this PC.
517048c3aeto2ccdf84e9d@Czer0xx on GitHub · 2026-11-28 17:38 UTC · original
Thanks @grosterr, @claudeFrancoisAI, and @x-nihil0 for the detailed repros, and @shiman1901 for the audit!
I rebased
pr/narrow-barriersontomain(9ce3cf9) and pushed2ccdf84with fixes for the barrier ordering holes found in the audit (plus a few additional hazards spotted while reviewing the paths) and sub-mode support forVICTORY_NARROW_BARRIERS:Fixes in
2ccdf84ACCESS_NO_ACCESSand WAR (read -> write) barriers (list.rs):global_barrier_needs_host,buffer_barrier_needs_host, andclassify_texture_barriernow keepNO_ACCESSexecution/flush barriers (whenever both sync scopes are non-zero) and check bothaccess_beforeandaccess_aftersoSHADER_RESOURCE -> UNORDERED_ACCESS / RENDER_TARGET / COPY_DESTWAR transitions are no longer dropped. OnlySYNC_NONEand pure read -> read transitions are skipped.list.rs): texture barriers involvingRENDER_TARGET,DEPTH_STENCIL_WRITE,COPY_DEST,RESOLVE_DEST,COMMON,NO_ACCESS, orUAV <-> SRV(and aliased textures) now emit a deduplicated stage-scopedD3D12_GLOBAL_BARRIER(safe_sync(sync_before) -> safe_sync(sync_after)) instead of being skipped or downgraded to a legacy UAV-only barrier. Pure non-aliasedUAV -> UAVtexture barriers still narrow to a targeted texture UAV barrier.sync_flags_need_uav(list.rs): color/depth block and metadata flush bits (0x3F, including0x4 | 0x8) are now kept.state.synced()on skippedbarrier_groups(list.rs,list/thin.rs):PackedGroups::Skipstill invokesstate.synced()(via a zero-item marker inthin.rs) so open indirect-clamp batches are still closed after shader writes.shadow.rs,list.rs,host/place.rs):shadow::peek_overlappingso legacy and enhanced buffer barriers cover every overlapping buffer shadow and loose window (and legacy buffer barriers useD3D12_BUFFER_BARRIER(SYNC_ALL, SYNC_ALL, COMMON, COMMON)when Enhanced Barriers are available).from.buffer(SYNC_COPY -> SYNC_ALL,COPY_SOURCE -> COMMON) post-barrier inplace_copyandplace_sourceto prevent subsequent writes from racing the copy read.Sub-modes for bisecting
VICTORY_NARROW_BARRIERSstill accepts1(orall) for full narrowing, and now also accepts comma-separated sub-modes:place,groups,legacy,sync(for exampleVICTORY_NARROW_BARRIERS=place,VICTORY_NARROW_BARRIERS=groups,VICTORY_NARROW_BARRIERS=place,sync). The per-frame telemetry line now logs the activemask.@claudeFrancoisAI @x-nihil0 @grosterr If you have a moment to re-test
2ccdf84withVICTORY_NARROW_BARRIERS=1first (and withplace/groups/legacy/syncindividually only if any white-screen or corruption still shows up), that would be a huge help.@shiman1901 on GitHub · 2026-11-28 17:53 UTC · original
@Czer0xx Super clean turnaround on
2ccdf84— great catches onstate.synced()for skipped groups,shadow::peek_overlapping, and thefrom.bufferpost-barrier too!Tagging @nick0451 as well since your posts crossed by a couple minutes — with
place=0/sync=0on the balcony save reproducing 4/4 in 40 s, re-testing2ccdf84there (plus @claudeFrancoisAI / @x-nihil0 / @grosterr) should tell us right away if the white screen is completely gone and how much of the FPS win holds!@nick0451 on GitHub · 2026-11-28 19:23 UTC · original
Re-tested
2ccdf84on the same balcony save where517048cwas white 4 of 4: the white picture is gone.Setup: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11, release builds. This PR at
2ccdf84(on9ce3cf9) against main at9300875; the only difference between those two is a workflow file. Series S, DLSS Performance, frame generation off, the same frozen save standing still. One warm-up start per variant, then the variants in turn. Each run is 40 s to settle, 60 s measured, then a screenshot.Picture: across two sessions, 21 measured screenshots with the switch on (
=1,=groups,=place,legacy,sync) and none white. The near-white share is 0.0-1.2%, the same as main's (0.0-0.7%). In the clean session (below), main and=1show the same steady view.Barrier counts (log, per frame,
=1, mask0xf): place 109 narrowed; groups 23 skipped, 914 narrowed, 0 global; legacy and sync 0. With=groupsalone: 24 skipped, 887 narrowed. So the group path now narrows about 900 groups a frame (one a frame on517048c) without the white.Speed, three rounds:
9300875=1=groupsNo change in fps here: the card is about 95% busy in this scene, so narrower barriers cannot show. A first session suggested +8%, but in that one the game went to its idle camera, and the view differed from run to run. I don't count it; the table above holds the camera still.
No crash, device loss or
ERRORline in any run.Tested with an AI assistant (Claude Code); results are from this PC.
2ccdf84e9dto5e2719d7255e2719d725to5cd5faff9d@POMXARK on GitHub · 2026-11-28 22:49 UTC · original
@Czer0xx — ran a full 20-minute gameplay A/B of
5cd5faf(VICTORY_NARROW_BARRIERS=1, all 4 sub-modesmask=0xf) on Windows 11 (RTX 5080 16 GB, Ryzen 7 5700X 8C/16T, 32 GB RAM, Series X 1440p, DLSS Quality + MFG 4x, release build, matched save & switches):Verification
narrow_barriers_submode_parsing+narrow_barrier_classification2/2 PASS (0.00s).0errors over 20 minutes,refused=2, zero white-screen or barrier artifacts across all 16 captured screenshots.place 96–201 narrowed; groups ~20 skipped, 653–816 narrowed, 0.0 global; legacy_buf 0.0; sync 0.0(100% of enhanced barrier groups handled with 0 global fallbacks!).20-minute A/B (matched draw buckets)
NARROW_BARRIERS=0)VICTORY_NARROW_BARRIERS=1)62.3 ms)60.8 ms)-1.5 ms)67.4 ms)83.9 ms)86.8 ms)93.6 ms)67.4 ms)73.5 ms)steps 28.3 ms)steps 36.5 ms)+8.2 mssteps)>100ms(5s bins)Bottleneck Diagnosis (CPU-bound RTX 5080)
Because an RTX 5080 at 1440p DLSS Quality is CPU-bound (
0.0–0.3 mswaiting on the GPU),replay_narrow_barrier_groupsrunning 653–816 times per frame introduces measurable CPU overhead on the submitting/recording thread:list.list.cast::<ID3D12GraphicsCommandList7>()(QueryInterface+Release~800x/frame) — cachingOption<ID3D12GraphicsCommandList7>once onHostListeliminates this completely.Vecallocations per call (globals,buffers,seen_bufs,legacy_uavs) — small stack/reusable scratch buffers (SmallVecor thread-local/list-owned scratchVecs cleared per call) would remove ~3,200 heap alloc/frees per frame.shadow::peek_overlapping+ COMclone()/ManuallyDrop::dropinside the hot loop.On GPU-bound cards (like 3060/3090/4070) the GPU barrier win easily outweighs the CPU work, whereas caching
ID3D12GraphicsCommandList7+ reusing scratchVecs would makeVICTORY_NARROW_BARRIERS=1a net win on CPU-bound 5080/4090 setups as well!