Repository navigation
Conversation
A flip (or vblank) wait always ended on the next tick after now. A frame that took a little longer than an interval therefore waited for the whole following interval: at 30 fps, a 40 ms frame was shown after 66 ms, and frame times rounded up to whole intervals (30 fps falling straight to 15, then 10). A non-origin wait that begins after a tick nobody has taken now ends at once on that tick; on-time frames are paced as before. Origin waits are unchanged.
bc05ba0 to
b36bd4c
Compare
…he next Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d, not the next" Its test fails together with 810f442 (a frame wait takes its tick before it sleeps) from another merged PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the #319 revert) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested PR #319 at head
Behavior covered: Checks the frame timing tests for late flip waits ending on the missed tick instead of waiting another interval. |
|
Each PR passes on its own; merged together on Both change when a frame wait ends: #174 takes the wait's tick before it sleeps, #319 ends a late flip wait on Merged with plain 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 |
|
A fix for the clash with #174 reported above. With #174, a wait takes its tick inside if kind != ORIGIN && passed > last_tick && passed > c.first {
+ // Taken now, as any wait takes its tick before it would sleep.
+ last(kind).fetch_max(passed, Ordering::Relaxed);
return (passed, Duration::ZERO);
}Verified on On this branch alone the line is harmless (the caller's later |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested b36bd4c on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed). I ran frame:: 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.
- The rounding bug is real.
elapsed / interval + 1always picks the tick after now, so a frame that misses its tick by a little waits a whole extra interval. - The new early return only applies to non-origin waits (flip and vblank), only when the most recently passed tick hasn't been taken (
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. - This changes pacing from strict tick-aligned to "present late frames on the missed tick". That matches how a console flip queue behaves when a frame misses vsync by less than an interval (no tearing here, since we present on our own schedule). It looks like the right trade.
No issues found.
AI-assisted (Claude Code).
… it missed, not the next Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Heads-up: #174 changes AI-assisted (Claude Code). |
|
Heads-up: #319 ( #174 moves taking the tick ( if kind != ORIGIN && passed > last_tick && passed > c.first {
last(kind).fetch_max(passed, Ordering::Relaxed);
return (passed, Duration::ZERO);
}Whichever of the two lands second needs this. It is in |
|
The clash is real on this head, and here is a patch that fixes it Chasing Reproduction, on the forge train ( Ten runs out of ten, so it is not the test's timing being flaky. The same command at Why. #174 moves the "take the tick" from if kind != ORIGIN && passed > last_tick && passed > c.first {
return (passed, Duration::ZERO);
}returns before that, so a wait that ends on the tick it missed never records it, Patch (against if kind != ORIGIN && passed > last_tick && passed > c.first {
+ // Taken here as the blocking path does: the wait that ends on this
+ // tick is the one that counted it.
+ last(kind).fetch_max(passed, Ordering::Relaxed);
return (passed, Duration::ZERO);
}Verified with it applied:
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. |
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
DenRakEiw
left a comment
There was a problem hiding this comment.
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)- Test failure:
cargo test -p victory-gpu --lib frame::fails inframe::tests::waits_end_on_ticks_and_count_framesatcrates/victory-gpu/src/frame.rs:256:9:
assertion `left == right` failed
left: 8
right: 9
Holding off approval until waits_end_on_ticks_and_count_frames passes cleanly on current main.
AI-assisted (Gemini 4 Neon).
|
Additional synthetic-clock regression coverage tested against this PR at 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. |
|
I checked the late-flip/vblank case again on On The late flip/vblank fix is already present in main through |
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.