Repository navigation
perf(gpu): eliminate per-frame pipeline stalls, fix indirect windows, reduce recording lock contention, and enable levels on demand - #867
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 377fdc38f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 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")) |
There was a problem hiding this comment.
Preserve budget charging when reusing indirect records
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 👍 / 👎.
| && diff % u64::from(stride) == 0 | ||
| { | ||
| (u64::from(stride), true) |
There was a problem hiding this comment.
Preserve observed spacing when widening indirect windows
For single-record calls with a 16-byte signature stride and arguments stored 32 bytes apart, diff % stride == 0 does not establish that the intervening slots contain arguments. Choosing stride here makes bound_ahead interpret 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 entire 2^27 budget 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 👍 / 👎.
…peed up card hashing
…cross read-only draws
…contention, and add relay/window counters
…t, and word-wise shadow merge
377fdc3 to
d7785fb
Compare
|
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 AI-assisted (Claude Code); no game data. |
…ing pass; buffer lookups under a shared lock Hand port of PalmVIDev fxceless#221 (3b8b22f3, from fxceless fxceless#867, powplusplus): - pipeline/make.rs: a pipeline that is not made is waited for only in the first frame that asks for it (VICTORY_PIPELINE_WAIT_ONCE=0 waits every frame, as before). Measured there: waits 416-500 ms/frame -> 0. - draw.rs: VICTORY_TEXTURE_STAGE_MS 250 -> 20 by default, backlog catch-up 3x -> 2x; user-data words on the stack. - shadow.rs: BUFFERS is a reader-writer lock; lookup returns a made copy under the shared lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017V7WBCi8h4eymnRhdth77t
|
Took the five commits onto current Bisect, by reverting from the tip (each step a fresh build and a fresh launch):
Two smaller things from the port, for the record: 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. |
|
I reproduced the wait reported in #1181 and tested the pipeline hunk from your One detail showed up when several pipelines were first bound together. The first entry spent the budget. The correction applies cleanly to your current head |
|
Split
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. |
A pipeline the worker has not made within a frame's wait budget (a slow or stuck driver compile) was waited for again in every frame that drew with it, each taking the whole budget (VICTORY_PIPELINE_WAIT_MS, 500 ms): world frames waited 500 ms each while four pipelines stayed MAKING (fxceless#1181), felt in play as a freeze while moving that the pause menu (no world draws) let go. Now the first frame with budget left claims the pipeline's one wait; later frames drop its draws until it is made, as past the budget before. The claim is taken under the budget lock and only with time left, so a pipeline first bound after another spent the frame's budget keeps its wait for a later frame. VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 restores the old behaviour. The one-frame cap is from powplusplus' fxceless#867; claiming only with budget left is BradRoland's correction posted there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pipeline the worker has not made within a frame's wait budget (a slow or stuck driver compile) was waited for again in every frame that drew with it, each taking the whole budget (VICTORY_PIPELINE_WAIT_MS, 500 ms): world frames waited 500 ms each while four pipelines stayed MAKING (fxceless#1181), felt in play as a freeze while moving that the pause menu (no world draws) let go. Now the first frame with budget left claims the pipeline's one wait; later frames drop its draws until it is made, as past the budget before. The claim is taken under the budget lock and only with time left, so a pipeline first bound after another spent the frame's budget keeps its wait for a later frame. VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 restores the old behaviour. The one-frame cap is from powplusplus' fxceless#867; claiming only with budget left is BradRoland's correction posted there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
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 shader: merge multiple loop back edges into one latch and raise pipeline stack #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 perf(gpu,hle): optimize view-memory guards, xmem alias mapping, texture waits, and relay card copy-back #824).