GPU: end a late flip wait on the tick it missed, not the next #319
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!319
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@xmvo on GitHub · 2026-11-24 02:16 UTC · original
xmvo:gpu/late-flip-waits→main· +28 −2 · 1 files · 1 commits · openWhat
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.
@jeremygold02 on GitHub · 2026-11-24 04:20 UTC · original
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
@etcetera-yt on GitHub · 2026-11-24 05:36 UTC · original
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.)
@KevinPratap on GitHub · 2026-11-24 07:18 UTC · original
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.@mercuryVM on GitHub · 2026-11-24 08:26 UTC · original
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).
@alexdeliu on GitHub · 2026-11-24 18:45 UTC · original
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.@fiestorra on GitHub · 2026-11-24 20:31 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 00:31 UTC · original · edited 2026-11-25 15:56 UTC
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
@oddmaniv on GitHub · 2026-11-25 11:42 UTC · original
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.
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.