GPU: end a late flip wait on the tick it missed, not the next #319
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/319"
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?
Imported from Marvisak/VIctory. Originally posted by xmvo on 2026-11-24T02:16:00Z.
What
frame::next_tickalways returned the next tick after now. When a frame took a little longer than one interval, its flip wait started just after the tick it should have flipped on, and so waited for the whole following interval. Frame times rounded up to whole intervals: at a 33.3 ms interval, a 40 ms frame was shown at 66.7 ms (30 fps falling straight to 15, then 10).Now a non-origin wait (flip, vblank) that begins after a tick nobody has taken yet ends immediately, on that tick. A late frame costs only its own lateness:
last(kind)advances to it),Why
A user on slower hardware saw menus at 15 fps and frame times clustered at exactly 66/100 ms, which matches this rounding.
Testing
cargo test -p victory-gpu frame: passes, with a new case added towaits_end_on_ticks_and_count_frames: a flip wait begun 25 ms after a flip at a 20 ms interval returns at once, on the next tick.Open to gating this behind a flag if you'd rather keep strict tick pacing by default.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:20:15Z.
Tested PR #319 at head
b36bd4c1d655f4d2f2069e4369a402a2828091e2(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged atb36bd4c1d655f4d2f2069e4369a402a2828091e2.cargo test --locked -p victory-gpu frame::tests— passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 43 filtered out; finished in 0.07s ); cases: frame::tests::waits_end_on_ticks_and_count_frames.Behavior covered: Checks the frame timing tests for late flip waits ending on the missed tick instead of waiting another interval.
Code: crates/victory-gpu/src/frame.rs
Imported from Marvisak/VIctory. Originally posted by etcetera-yt on 2026-11-24T05:36:29Z.
Each PR passes on its own; merged together on
main(d2a4bae), the frame-wait test fails:Both change when a frame wait ends: #174 takes the wait's tick before it sleeps, #319 ends a late flip wait on
the tick it missed rather than the next. Together a frame is counted one tick short. Whichever lands second
probably needs to rebase its tick accounting (and the test's expected count) on the other.
Merged with plain
git merge, no text conflict. Windows 10 19045, RTX 5060 Ti, Rust 1.98.1,cargo test -p victory-gpu -- --test-threads=4 waits_end.AI use: Claude Code, Claude Opus 5.5.
On a title (added after a local run)
With #174 and #319 both merged (plus #175 for Windows 10), the title never left its first black screen and the
host presented about 1,100 frames per second at 3 draws per frame. The same build with only #319 reverted runs at
30.0 fps and reaches the start screen. (RTX 5060 Ti, driver 621.14, Windows 10 19045, release build.)
Imported from Marvisak/VIctory. Originally posted by KevinPratap on 2026-11-24T07:18:10Z.
A fix for the clash with #174 reported above. With #174, a wait takes its tick inside
next_tick(before it sleeps) instead of after, so this PR's late-flip early return has to take its tick there too; otherwise nobody records it and the next flip ends on the same tick again:Verified on
main(d2a4bae) + #174 (810f442) + #319 (b36bd4c), Windows 11:On this branch alone the line is harmless (the caller's later
fetch_maxtakes the same tick), so it can go into whichever of the two lands second. AI-assisted.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:17:07Z.
Review: APPROVED
Tested
b36bd4con Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed). I ranframe::5 more times on its own and it passed every time, so the sleep-based timing in the new test looks stable here. Not tested in game.elapsed / interval + 1always picks the tick after now, so a frame that misses its tick by a little waits a whole extra interval.passed > last_tick), and never for the first tick. Each tick is still consumed once, and an on-time frame still waits, so the rate cap holds.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:26:54Z.
Heads-up: #174 changes
next_tickso the tick is taken inside it rather than inwait. With both PRs applied, this PR's early-return branch never takes its tick, andframe::tests::waits_end_on_ticks_and_count_framesfails at theLAST == flipped + 1check (verified by merging both). Whichever lands second should addlast(kind).fetch_max(passed, Ordering::Relaxed);before the earlyreturn (passed, Duration::ZERO). Details are in my review on #174.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T18:45:45Z.
Heads-up: #319 (
b36bd4c1) and #174 (882664e1) each pass onmain, but merged togetherframe::tests::waits_end_on_ticks_and_count_framesfails on every run (left: 10, right: 11atframe.rs:254).#174 moves taking the tick (
last(kind).fetch_max) intonext_tick. #319 adds an earlyreturn (passed, Duration::ZERO)for a late flip wait, before that point, so the late wait's tick is never taken. Taking it in the early return too fixes it. The tests pass (710 in the merge train):Whichever of the two lands second needs this. It is in
e3f72c57on the train branch.Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-24T20:31:42Z.
The clash is real on this head, and here is a patch that fixes it
Chasing
TEST-FRAME-WAITSin #1633 (find which pull request this test combines badly with) landed on this pair, and the answer is #174 — as @etcetera-yt, @mercuryVM, @KevinPratap and @alexdeliu already reported above. What I can add is the measured form and a fix that I ran.Reproduction, on the forge train (
KevinPratap/VIctoryforge/main, which merges #174 as5c8275aand this pull request as07a6fc0, so its tree isffe310e+ #174 + #319):Ten runs out of ten, so it is not the test's timing being flaky. The same command at
ffe310epasses five out of five, and at07a6fc0fails five out of five: this pull request's merge in forge already carries #174, and the clash appears there.Why. #174 moves the "take the tick" from
wait()intonext_tick(). This pull request's late-flip early returnreturns before that, so a wait that ends on the tick it missed never records it,
LAST[2]stays where it was, and the assertion this pull request adds (LAST[2] == flipped + 1) fails with8against9. The pull request's own doc comment already says what should happen: "A wait that comes withinlimittakes the tick here, under the clock's lock, so two threads waiting for one kind never take the same tick."Patch (against
b36bd4c1, the current head, incrates/victory-gpu/src/frame.rs):Verified with it applied:
waits_end_on_ticks_and_count_frames→ 5 passes out of 5 (0 out of 5 without it).waits_begun_together_take_different_ticks, the other test this pull request adds → still passes.cargo test -p victory-gpu --lockedon the patched forge tree → 88 passed, 0 failed, 3 ignored.The two waits that begin together still take different ticks, because the blocking path takes its tick under the same lock; only the late path, which returned without taking one, changes.
No game data is involved; this is a unit test of the frame clock.
Written with an AI assistant.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:31:01Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/frame.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T03:33:57Z.
Review: COMMENTED
Tested locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)cargo test -p victory-gpu --lib frame::fails inframe::tests::waits_end_on_ticks_and_count_framesatcrates/victory-gpu/src/frame.rs:256:9:Holding off approval until
waits_end_on_ticks_and_count_framespasses cleanly on currentmain.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-25T11:42:21Z.
Additional synthetic-clock regression coverage tested against this PR at
b36bd4c1d655f4d2f2069e4369a402a2828091e2checks multi-tick late flip/vblank waits, future origin waits, and that consumed ticks are not reused. The added test runs in an isolated process and leaves this PR's production code unchanged.The new regression fails on unchanged main (tick 106 instead of 105) and passes with this PR. Both frame tests passed together twice; workspace Clippy with and without all features, changed-file formatting and asset policy passed on the test-instrumented PR checkout, on Windows with Rust/Cargo 1.98.1.
This is additional regression coverage, not evidence of console late-flip behaviour, gameplay performance, or resolution of the #174 interaction. No full workspace suite, game or GPU execution was performed. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T15:09:59Z.
I checked the late-flip/vblank case again on
mainat63bcca4. The standalone Rust test compiled the original frame module from each revision and set the clock to the same position: tick 105 had passed, tick 106 was still in the future, and the last consumed tick was 103.On
2a4938e(before9c179ea), both zero-timeout polls chose tick 106 and consumed nothing. On63bcca4, the first poll takes tick 105 without waiting. The second poll chooses tick 106 and leaves the consumed tick at 105. The result is the same for flip and vblank. This also checks the reservation mentioned in the #174 discussion above.The late flip/vblank fix is already present in main through
9c179ea. The current implementation also allows origin polls to take a passed tick. #2877 has separate virtual-clock coverage of that origin behavior.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.