pub struct FramePacer { /* private fields */ }Expand description
Derives display-cadence frame deltas from presented-frame feedback.
Feed every presented frame through Self::record_presented (or
Self::record_untimed_presented when presentation completed without a display time), then
ask Self::schedule when a frame is about to be built. While a cadence estimate and fresh
feedback exist, each frame delta is a whole number of display intervals: one interval
normally, more when the wall-clock gap since the previous schedule shows the display consumed
extra intervals. Without an estimate, or when feedback goes stale, deltas observably fall back
to raw wall-clock gaps.
Deltas quantize to the cadence instead of following the wall clock because a FIFO-presented backend displays exactly one frame per display interval even when frame building starts at irregular times; physically measured on the Wayland/KWin tier, presented intervals stayed within ±0.4 ms of the cadence while build starts jittered by ±7 ms, so wall-clock deltas animate that jitter onto a steady display. The same measurements showed presented feedback arrives about two frames late with drain-latency bias in its absolute placement, so this policy deliberately owns no absolute frame-start scheduling: an earlier revision that slept toward grid instants extrapolated from feedback timestamps paired whole-interval delta errors on the same tier.
Implementations§
Source§impl FramePacer
impl FramePacer
Sourcepub fn record_presented(&mut self, presented_at: Instant)
pub fn record_presented(&mut self, presented_at: Instant)
Records one presented frame with the display time the backend reported for it.
Sourcepub fn record_untimed_presented(&mut self)
pub fn record_untimed_presented(&mut self)
Records one frame whose presentation completed without a reported display time.
Sourcepub const fn resume(&mut self, now: Instant)
pub const fn resume(&mut self, now: Instant)
Re-anchors schedule gap measurement at now, discarding the time since the previous
Self::schedule call.
Call when frame production resumes after a pause so the paused interval does not enter the next frame delta as elapsed time.
Sourcepub fn report(&self) -> PacingReport
pub fn report(&self) -> PacingReport
Summarizes everything the underlying diagnostics recorded so far.
Sourcepub fn schedule(&mut self, now: Instant) -> FrameSchedule
pub fn schedule(&mut self, now: Instant) -> FrameSchedule
Schedules the frame about to be built, given the current wall-clock instant.