perf(gpu): eliminate per-frame pipeline stalls, fix indirect windows, reduce recording lock contention, and enable levels on demand #867
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/fxceless--victory-fork!867
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-867"
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?
@powplusplus on GitHub · 2026-11-25 11:09 UTC · original
powplusplus:perf/gpu-60fps→main· +467 −114 · 8 files · 5 commits · openSummary
Targeted GPU and recording-thread frame-time optimizations independently rebased onto
main(9376fd6), verified on live 3D world gameplay (RTX 3080 12 GB, GE-Proton11-14) with zero crashes and zero device loss over 420 s:pipeline/make.rs): TrackPending::waited_frameso a slow or still-compiling pipeline only consumes the synchronous wait budget on the first frame it is requested. Menus and one-off bakes still finish on frame 1, while subsequent world frames compile asynchronously instead of stalling416-500 ms/frame.draw.rs,list.rs,indirect.rs):args.left(arguments) < step(fit == 0previously clamped1record ofstepbytes past the buffer end) by requiringfit >= 2before widening.INDIRECT_ARGUMENTacross hits and transitioning it back toCOMMONviaState::close_windowbefore list close/cut, UAV/buffer barriers, buffer copies, or buffer-writing dispatches/draws.stride-based windowing whendiffis a multiple ofstrideso skipped/culled slots still hit, raisesWINDOW_MOSTto 256, and enablesVICTORY_INDIRECT_WINDOWby default (=0disables).host.rs,draw.rs,list.rs,indirect.rs): Track per-listuav_dirtystate (covering compute, buffer stores, root UAVs, table UAVs, and dynamic-indexed UAVs) sobarrier_groupsskips redundant global UAV barriers when no UAV write occurred since the last barrier.CARD_COMPARE+VICTORY_CARD_REHASH_RUNSon by default (host.rs,indirect.rs): UpgradesCARD_COMPAREfrom 1 thread per 64 KiB piece (4,096 serial strided reads) to 1 64-thread workgroup per 64 KiB piece with coalesced 1,024-byteLoad4bursts and groupshared reduction.descriptor/host.rs,shadow.rs,draw.rs,list.rs):AtomicU64fast-path (made_keys) inHostHeap::mirrorfor already-made slots.shadow::BUFFERSandshadow::LOOSEfromMutextoRwLockwith shared read-lock fast paths inlookupandloose.<= 64dwords) and RTV handle arrays (<= 8targets).u64) skip inshadow::merge_pieceto avoid byte-by-byte reads and unnecessary writes on unchanged words.VICTORY_LEVELS_ON_DEMANDby default (draw.rs,tiles.rs):VICTORY_TEXTURE_STAGE_MSfrom 250 ms (750 ms catchup) to 20 ms (40 ms catchup) so initial world streaming no longer freezes recording threads for 750+ ms/frame.VICTORY_LEVELS_ON_DEMANDby default (=0disables), saving ~4.0-4.9 GB VRAM on 12 GB cards.Verification
cargo clippy --target x86_64-pc-windows-gnu -p victory-gpu --all-targets(default and--features diagnostics): zero new warnings.pipeline::make::,indirect::,descriptor::host::,shadow::,host::,watch::,list::): 90/90 passed, including newslow_pipeline_waits_at_most_one_frameandcard_compare_hlsl_compilestests.victory-bench.exewithperf/gpu-60fps+ PR #737):BF GRETAvehicle HUD + minimap).416-500 ms/frame->0.0 ms/frame.list callsacross 6 threads):632-731 ms/frame->214.0 ms/frame(3.2x faster).heap_textures):750-850 ms/frame->43-68 ms/frame(12x faster).11.4 GB->6.5 GB(4.9 GB saved).241.5 ms/frame) (up from0.1-0.2 fpsbaseline and1.9-2.0 fpsin PR #824).@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 11:09 UTC · original · edited 2026-11-25 11:17 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
377fdc3ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
d7785fbintomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort; PR #841 fixes them), also with--all-features; this PR adds none.cargo test --workspace --locked: run 1: 557 passed, 0 failed, 11 ignored; run 2: 557 passed, 0 failed, 11 ignored (mainalone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
@HrHd on GitHub · 2026-11-25 22:55 UTC · original
Took the five commits onto current
main(with our clamp ring,needs spacedgather and the present stretch already in) and it removes the device here on an RTX 4060 Ti, native NVIDIA, Windows 11:host GPU device removed ... 0x887A0006, twice out of two launches, about three minutes into the prison scene, each announced first bydrvwatch("the graphics driver reported an error n=2"), at 4-5k draws.Bisect, by reverting from the tip (each step a fresh build and a fresh launch):
VICTORY_INDIRECT_WINDOW=0,VICTORY_DEFER_NEW_VIEWS=0,VICTORY_CARD_REHASH_RUNS=0- still removed, so it is not the new default flips;96a7937,d7785fb,d4fc3c2,ca1379creverted - still removed;d4e6556(the pipeline wait budget or the hashing rewrite; the two are in one commit here so I cannot split them further).Two smaller things from the port, for the record:
jump_windows/jump_windoware gone fromdraw.rsbut five tests still call them, andwindow_line/WINDOW_WHY(ours, frommain) collide withWINDOW_STATS- I kept both sets rather than deleting either.The tree is back on the base for now (250-263 ms, 0 removals, 4.2 fps at 4.8k draws). If it helps, the last 96 operations log line read "between submissions, nothing of ours running on the card, 0 lists" when it went.
@BradRoland on GitHub · 2026-11-25 23:21 UTC · original
I reproduced the wait reported in #1181 and tested the pipeline hunk from your
d4e6556on Windows WARP. With four entries held inMAKINGand a shared 20 ms budget, main charged a wait every frame. Your change eliminated it after frame one.One detail showed up when several pipelines were first bound together. The first entry spent the budget.
ready()also setwaited_frameon the remaining three beforewait()discovered that the budget was empty. Those three consequently lost their first opportunity even when a later frame had time. I moved the claim under the existing budget lock, after checking for positive time. On the same six-frame replay, pipelines 1–4 each got one wait on successive frames, then both remaining frames recorded zero. Shared and unshared modes passed. A completed WARP compute pipeline was available on its next bind with zero additional wait.The correction applies cleanly to your current head
d7785fb. I kept your original change credited and put the correction and replay in separate commits. The replay runs withcargo test --locked -p victory-gpu --features diagnostics four_inflight_frames_and_late_completion -- --nocapture. Correction · Regression replay@HrHd on GitHub · 2026-11-26 00:47 UTC · original
Split
d4e6556by file and measured each half, on an RTX 4060 Ti, native NVIDIA, Windows 11, ~4.8k draws, 70 s between samples:pipeline/make.rs(the one-frame wait budget) alone: clean, 251-258 ms, 0 removals.CARD_COMPARErewrite) on top of it: clean, 0 removals.VICTORY_CARD_FETCH_INFLIGHT=1alone: 516.3-530.0 ms against 193.3-211.3 with it off — it more than doubles the frame here.CARD_REHASH_RUNS=1alone is neutral (194.0-198.9).96a7937,ca1379c), the device removes in about three minutes ("no breadcrumbs", 0x887A0006,drvwatchn=2 first);ca1379calone dies sooner, with 0xc0000005 in the translated image.The base split is the fastest rung this machine has measured (5 fps, 0.041 ms/draw, 0 removals over 15+ minutes), so both flips are off by default here and the two later commits are out for now.
96a7937on its own was stable but 15 % slower (217-226), and not because of levels-on-demand (210-212 withVICTORY_LEVELS_ON_DEMAND=0).@ -184,3 +194,3 @@fn windows() -> bool {static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();*ON.get_or_init(|| std::env::var_os("VICTORY_INDIRECT_WINDOW").is_some_and(|v| v == "1"))*ON.get_or_init(|| std::env::var_os("VICTORY_INDIRECT_WINDOW").is_none_or(|v| v != "0"))@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 11:17 UTC · original
When a list alternates read-only direct draws with single-record indirect draws reusing the same argument offset, the now-default window survives the direct draws and serves subsequent executions from the cache. Those hits bypass
record_clamp_as, which charges the per-list work budget. A mesh record containing(65535, 1, 1)can consequently execute 1,000 times while being charged once, instead of being emptied after 16 executions. Previously, each intervening direct draw invalidated the window and forced another budget charge. This defeats the cumulative hang guard and can permit GPU timeouts; debit re-executed entries or prevent repeated cache hits before enabling this by default.Useful? React with 👍 / 👎.
@ -3010,0 +3080,4 @@&& diff <= 1024&& diff % u64::from(stride) == 0{(u64::from(stride), true)@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 11:17 UTC · original
For single-record calls with a 16-byte signature stride and arguments stored 32 bytes apart,
diff % stride == 0does not establish that the intervening slots contain arguments. Choosingstridehere makesbound_aheadinterpret padding or metadata as additional draw records and charge their counts against the shared budget. For example, valid(3, 1)draw counts at each 32-byte boundary with(65536, 1024)metadata halfway between exhaust the entire2^27budget in the first widened window, causing subsequent valid draws to be clamped to zero. The previous observed 32-byte step avoids this. Preserve the observed spacing unless dense packing is independently established.Useful? React with 👍 / 👎.
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.Merge
Merge the changes and update on Forgejo.