Skip to main content

FramePacer

Struct FramePacer 

Source
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

Source

pub fn new() -> Self

Creates a pacer with no observed presentation feedback.

Source

pub fn record_presented(&mut self, presented_at: Instant)

Records one presented frame with the display time the backend reported for it.

Source

pub fn record_untimed_presented(&mut self)

Records one frame whose presentation completed without a reported display time.

Source

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.

Source

pub fn report(&self) -> PacingReport

Summarizes everything the underlying diagnostics recorded so far.

Source

pub fn schedule(&mut self, now: Instant) -> FrameSchedule

Schedules the frame about to be built, given the current wall-clock instant.

Trait Implementations§

Source§

impl Debug for FramePacer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FramePacer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.