Skip to content

Window: frames on the monitor's refreshes, no frames queued ahead - #142

Merged
boubou666 merged 1 commit into
masterfrom
claude/vsync-paced
Nov 24, 2026
Merged

boubou666 merged 1 commit into
masterfrom
claude/vsync-paced

Conversation

@boubou666

Copy link
Copy Markdown
Contributor

A game paced at 60 on its own clock and presented with vsync on a 60 Hz monitor: the two clocks drift, so every so often a picture stayed two refreshes and the next was never shown. The counter said 60, but play did not feel smooth (TTA's players). With vsync the driver also queued up to three frames ahead of the display, each a refresh of input delay.

  • Window: on vsync at the game's rate (no frames between, not lockstep, a shown window), each present is waited out (glFinish after the swap) and counted (FramePacer::displayPresents), with the steady refresh period (FramePacer::displayPeriodUs).
  • FramePacer: once that period is within 1 % of the cap's, a paced frame ends on the display's next refresh instead of the pacer's clock, bounded to 0.9..2 periods. Fast forward, a hidden window or an unsteady display keep the clock. A 59.94 Hz monitor runs the game 0.1 % slow; AudioDevice's ±1 % rate follows.
  • PS2X_NO_VSYNC_PACE=1 and PS2X_NO_SWAP_FINISH=1 keep the old ways. The window's stats line shows the locked period.

Checked: TTA's window build, played on a 60 Hz monitor: the player found it smoother. Scripted, hidden and lockstep runs take the old path (no change to captures). Applies to every port's window by default.

🤖 Generated with Claude Code

A game paced at 60 on its own clock, presented with vsync on a 60 Hz
monitor: the two clocks drift, and every so often a picture stayed two
refreshes and the next was never shown. 60 frames a second that did not
feel smooth (TTA's players). The driver also queued up to three frames
ahead of the display, each a refresh of input delay.

On vsync at the game's rate (no frames between, not lockstep, a shown
window) the window now waits each present out (glFinish after the swap)
and counts it; once their period is steady and within 1 % of the cap's,
FramePacer ends each frame on the display's next refresh instead of its
own clock (bounded to 0.9..2 periods). Fast forward, a hidden window or
an unsteady display keep the clock. PS2X_NO_VSYNC_PACE=1 and
PS2X_NO_SWAP_FINISH=1 for the old ways; the window's stats line shows
the locked period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boubou666
boubou666 merged commit 40e6830 into master Nov 24, 2026
4 checks passed
@boubou666
boubou666 deleted the claude/vsync-paced branch November 24, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant