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/Belobug--VIctory-Belobug-AMD!215
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-215"
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?
@SPFCChris on GitHub · 2026-11-26 01:24 UTC · original
SPFCChris:perf/overlap-prep→main· +453 −17 · 3 files · 1 commits · openBoth switches are off by default, and the gain below was measured on top of #178 and #179. On
mainalone I could not show one (see "Measured"). Read that section before deciding where this belongs.What it is for
In a world frame the title makes about 36 submissions, each followed by a
Signal. Each is prepared on the processor and then waited for on the host GPU, one after the other: on a Radeon 8060S a heavy frame is about 60-85 ms of preparing and 80-87 ms of waiting. This lets part of the preparing of a submission happen while the one before is still running.Three parts
Each is inert unless something is in flight when the next submission comes, which is rare while the title's
Signalwaits for the host GPU.VICTORY_LATE_SIGNALS=1(off by default;timeline.rs,host.rs). A title fence signalled behind an unwaited host submission is noted against that submission's host fence value and signalled fromHost::reap_completed(timeline::deliver).Signalreturns at once, as the console's does, and the title's thread goes on to its next submission. A thread (victory-finish) waits for the host GPU without holdingsubmittedwhen fences are owed, so a title that only waits for its fence is served.Wait, lists not ready and other work wait as before.VICTORY_EARLY_FILLS=0turns it off;host.rs).Host::prewarmalso does the lists'Step::Fillcopies: title memory into the list's own upload memory, which nothing that runs reads. Up to the first step that writes title memory in any list of the submission, and not from ranges the submissions still running write back.Deferred::prefilledtellsrun_deferredwhich fills are done.VICTORY_EARLY_PLAN=1(off by default;descriptor/host.rs,host.rs).Host::prewarmmakes the directly indexed heaps' plans too. The slots such a plan makes go to a staging heap no shader sees (HostHeap::plan_aheadmarks the thread;HostHeap::cputhen hands out the slot's place in the staging heap and notes the slot staged), andHost::execute_innercopies them into the shader-visible heap once the submission before has run (HostHeap::flush_staged:CopyDescriptorsSimplein runs, under themadelock; a write in place forgets what was staged for the slot). The plan made ahead is kept, andBatch::prepare_bindlesscopies its bounces and refreshes its reads before the heap's newer plan.Why a plan made ahead used to stop the host GPU
It was tried before and gave
DXGI_ERROR_DEVICE_HUNGat the world's first frames. The cause was not the slot writes. The plan made ahead was dropped, and when the submission then made a newer plan, that one listed as new (fresh,fresh_reads) only its own slots: the host copies behind the slots made ahead were never filled, and shaders read what the memory happened to hold. Two runs with the staging heap but the plan dropped still lost the device, the second right after "8147 slots staged and copied"; with the plan kept, none of the runs below did at that point.Measured
Radeon 8060S (Ryzen AI Max+ 395), diag build, Series X profile, opening cutscene, 220 s in the world per run, runs alternated.
On
main(4f62c2a) plus #148, #178, #179 (with its fix), the terminator fix of #156/#207 and a local texture-hash change, two runs per arm, every frame's time logged:VICTORY_LATE_SIGNALS=1VICTORY_EARLY_PLAN=1Median frame 165 ms to 145 ms with both switches (12 %; the two pairs gave 8 % and 17 %), 19 % more frames delivered. The gain is in scenes of up to about 3,000 draws; above that it is inside the noise. With both on, per 5 s (about 25 frames): 350-450 ms of plans made ahead, 30-67 MB of fills done ahead, 15,000-35,000 slots staged and copied.
On this branch as it is (
mainplus #148 only), one run per arm, from the frame-rate lines: 798 frames in 220 s with the switches off, 750 with both on; heavy frames 305 and 310 ms. No gain, and on that build a heavy frame is 305 ms rather than 180: its time goes to what #178 and #179 remove (threads made at everyin_parallelcall, which the prewarm calls too; copy-back 31 ms a frame against 9). So I would not merge this for speed before those, and one pair of runs proves little either way.Stability
host GPU device removed after a submission of 1 lists,DEVICE_HUNG); it also hadVICTORY_TEXTURES=keepset, so I cannot say which was the cause.000ffdd, late signals alone lost the device in one run of four. Never explained.Tested
cargo test -p victory-gpu --lib --locked: 113 passed, 0 failed, 4 ignored.cargo clippy -p victory-gpu --all-targets --locked: 40 warnings in the library, as onmain.4f62c2a.)Not tested
diagnostics.AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@thejacte on GitHub · 2026-11-26 14:40 UTC · original
Measured on a second machine: here the gain shows on
mainalone.Machine: RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, 64 GB, Windows 11.
Build: this PR's
91a914e(onmainat4f62c2a, without #178/#179), diag build with diagnostics, plus a local patch so my save loads (no runtime change).Runs: same place of the same save in the world, about 4-5 minutes each, alternated. Both switches on (
VICTORY_LATE_SIGNALS=1,VICTORY_EARLY_PLAN=1) against all off (VICTORY_EARLY_FILLS=0). Medians are over the 5-second frame-rate lines with more than 3,000 draws and no pipelines being made. One run before these only made pipelines.DXGI_ERROR_DEVICE_HUNG. One driver compiler crash in run 2 was caught by the guard, and that pipeline left out (this card's compiler crashes on some compute pipelines whatever the switches; I've seen it onrx9070xttoo).Two pairs of runs is still little, but on this machine the gain does not seem to depend on #178/#179.
🤖 Generated with Claude Code
@gut0to on GitHub · 2026-11-26 15:39 UTC · original · reviewed
AI-assisted static review; I inspected the descriptor staging and write-lock paths, but did not run tests or the game.
@ -1148,0 +1228,4 @@/// the lock on `made` (a title thread writing a slot in place holds it,/// and forgets what was staged for the slot). Returns how many.pub(crate) fn flush_staged(&self) -> usize {if !self.staged_any.swap(false, Ordering::AcqRel) {@gut0to on GitHub · 2026-11-26 15:39 UTC · original
Could the made lock be acquired before clearing staged_any? A concurrent title-thread writer can enter cpu() after this swap but before the lock below; it then sees staged_any == false, skips clearing the staged bit for this slot, and writes the newer descriptor to the live heap. The subsequent flush still consumes that bit and copies the older staged descriptor over the newer write. Taking made before the swap would serialize the bit drain with descriptor writes.
@gut0to on GitHub · 2026-11-26 15:46 UTC · original · reviewed
AI-assisted static review; I inspected the staging allocation failure path, but did not run tests or the game.
@ -1143,0 +1164,4 @@if index < self.count && !self.sampler {let (word, bit) = (index as usize / 64, 1u64 << (index % 64));if STAGING.get() {if let Some(at) = self.staging_cpu() {@gut0to on GitHub · 2026-11-26 15:46 UTC · original
If
staging_cpu()fails to create the staging heap, this branch falls through and returns the shader-visible descriptor handle.plan_ahead()then updates a live slot while the prior submission may still be reading that heap, which is the device-hang condition this staging path is meant to avoid. Could a failed staging allocation abort/defer the ahead plan instead of falling back to the live heap?@adrianmjim on GitHub · 2026-11-26 19:52 UTC · original
Tested
91a914eagainst its base4f62c2a. Hardware: RX 7900 XT (RDNA3, driver 32.0.32029.2010), Windows 11 26300. Some tests also ran on WARP (diagnostics build). Other jobs were running on the machine at the same time. #178 and #179 were not included unless stated.The lib tests do not reach the change
can_asyncinexecute_innerstarts with!cfg!(test), andlate()has!cfg!(test)too. Undercargo testnothing is ever in flight, soprewarm, early fills, late signals andvictory-finishnever run.cargo test -p victory-gpu --lib(debug), 8 interleaved runs each of base, PR, PR +VICTORY_LATE_SIGNALS=1, PR + late signals +VICTORY_EARLY_FILLS=0, and PR + late signals +VICTORY_EARLY_PLAN=1.watch::guard-page tests failed in some runs of every config, base included.frame::tests::waits_end_on_ticks_and_count_framesfailed once, in the PR + late signals + fills-off config.Local tests with title submissions made async
I added a test-only switch that lets
can_asyncandlate()be true under test, plus three tests inhost.rs. They drive realHostLists throughHost::execute_titleand aTimeline. Results:Signalbetween them.VICTORY_EARLY_FILLS=0, B's fill sees 0x22 in every run (10/10).owedinprewarmonly takesFinish::back.finish_submissionalso writes title memory through the in-flight lists'deferred.writes(bottom-of-pipe writes, timestamps) andreadbacks. Those writes happen after the prewarm, so a fill from those ranges is stale. The test covers only thedeferred.writescase. Adding those target ranges toowedwould cover both.i, then signalsi. After each signal the test checks that the fence never shows a value whose write is not done yet.VICTORY_LATE_SIGNALS=1it failed in 3/10 runs, and in 5/10 with fills also off. On WARP it failed 1/5 in each of those two configs. It failed 0/10 with late signals off and 0/10 on base.reap_completedpops the submission fromin_flightbeforefinish_submissionruns. Ifvictory-finishis reaping at that moment,signal_lateseesin_flightempty (target 0) andLATEempty, and signals at once. A possible fix: take the target from the last async fence value and compare it withFINISHED_FENCE, instead of checking whetherin_flightis empty.wait_in_flighton main when more than one thread reaps. With 3 title threads this test fails on base too (10/10). That part is older than this PR, butvictory-finishadds another thread that reaps.VICTORY_LATE_SIGNALS=1,SetEventOnCompletion(value, NULL)right after the queue'sSignal, with host work still running, returnsE_NOTIMPL("blocking fence wait not implemented"). This happened in 10/10 runs on the 7900 XT and 5/5 on WARP.S_OK.timeline::active()does not count signals still owed inLATE.No run hung. No test hit its 10 s fence-wait timeout.
From reading the code only, not tested
timeline::deliverpops entries underLATEbut signals them after unlocking. It is called both fromreap_completed(withsubmittedheld) and fromsignal_lateandvictory-finish(without it). Two callers can therefore signal values of one fence out of order, andfence::setstores the value rather than keeping the larger one. The stress test never saw this.Together with #178 (
6325dc1) and #179 (847dcbb)91a914ewithout conflicts, and the result builds.VICTORY_LATE_SIGNALS=1. All 117 tests passed in each run, apart from the same knownwatch::flakes.Not tested
I have the tests and the test-only switch on a local branch, for both this PR and main, if they are useful.
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.