Skip to main content

FramePacingController

Struct FramePacingController 

Source
pub struct FramePacingController { /* private fields */ }
Expand description

Unified single-source frame pacing controller eliminating double-gating and preventing non-VSync events from advancing game time.

Implementations§

Source§

impl FramePacingController

Unified VSync pacing, double-gate elimination, clock rebasing, and in-flight tracking for FramePacingController.

Source

pub fn for_display_hz(display_hz: f32) -> Self

Constructs a native-VSync FramePacingController tracking display_hz uncapped with bounded in-flight frames.

§Arguments
  • f32 - Active hardware display refresh rate in Hertz.
§Returns
  • Self - Uncapped display-synchronized frame pacing controller.
Source

pub fn new( display_hz: f32, native_vsync_active: bool, user_fps_cap: Option<u32>, max_in_flight_frames: u32, ) -> Self

Constructs a FramePacingController with explicit display rate, VSync ownership, optional user FPS cap, and in-flight bound.

§Arguments
  • f32 - Active display refresh rate in Hertz.
  • bool - Whether native platform VSync already throttles presentation.
  • Option<u32> - Optional explicit user FPS cap.
  • u32 - Maximum concurrent in-flight frames (1..=4).
§Returns
  • Self - Configured frame pacing controller.
Source

pub const fn active_user_fps_cap(&self) -> Option<u32>

Returns the optional explicit user FPS cap.

§Arguments
  • &Self - Pacing controller reference.
§Returns
  • Option<u32> - Active user FPS cap if set.
Source

pub fn should_bypass_software_gate(&self) -> bool

Returns true when software sleep/deadline gating should be bypassed because native VSync already paces presentation at or below the target rate.

§Arguments
  • &Self - Pacing controller reference.
§Returns
  • bool - true when software waiting must be skipped to avoid double-gating.
Source

pub fn display_period_ns(&self) -> u64

Returns the nominal display refresh period in nanoseconds.

§Arguments
  • &Self - Pacing controller reference.
§Returns
  • u64 - Nominal VSync period in nanoseconds.
Source

pub fn set_display_mode(&mut self, display_hz: f32, timestamp_ns: u64)

Updates the display refresh rate mode and rebases the monotonic clock to avoid synthetic dt spikes.

§Arguments
  • &Self - Mutable pacing controller.
  • f32 - New active hardware refresh rate in Hertz.
  • u64 - Current monotonic timestamp in nanoseconds.
Source

pub fn on_display_mode_changed(&mut self, new_hz: f32)

Handles a dynamic OS display refresh-rate switch (e.g. ProMotion or multi-monitor drag) by clamping new_hz and resetting the monotonic timebase cleanly.

§Arguments
  • &Self - Mutable pacing controller.
  • f32 - Newly reported hardware display refresh rate in Hertz.
Source

pub fn on_resume(&mut self)

Handles application foreground resume by clearing stale VSync timestamps, resetting in-flight backpressure, and preventing post-suspend missed-VSync or dt spikes.

§Arguments
  • &Self - Mutable pacing controller.
Source

pub fn rebase_clock(&mut self, timestamp_ns: u64)

Rebases the monotonic VSync reference timestamp (e.g. after foreground resume or refresh-rate switch).

§Arguments
  • &Self - Mutable pacing controller.
  • u64 - Current monotonic timestamp in nanoseconds.
Source

pub fn notify_present_completed(&mut self)

Notifies the controller that one submitted frame finished presenting, freeing an in-flight slot.

§Arguments
  • &Self - Mutable pacing controller.
Source

pub fn evaluate( &mut self, trigger: FramePacingTrigger, timestamp_ns: u64, ) -> PacingDecision

Evaluates a scheduling trigger at monotonic timestamp_ns and returns a single authoritative PacingDecision.

§Arguments
  • &Self - Mutable pacing controller.
  • FramePacingTrigger - Incoming scheduling event kind.
  • u64 - Monotonic clock timestamp in nanoseconds.
§Returns
  • PacingDecision - Whether to step simulation, render, wait in flight, or defer to VSync.
Source§

impl FramePacingController

Source

pub fn get_display_hz(&self) -> f32

Source

pub fn get_mut_display_hz(&mut self) -> &mut f32

Source

pub fn set_display_hz(&mut self, val: f32) -> &mut Self

Source

pub fn get_native_vsync_active(&self) -> bool

Source

pub fn get_mut_native_vsync_active(&mut self) -> &mut bool

Source

pub fn set_native_vsync_active(&mut self, val: bool) -> &mut Self

Source

pub fn get_mut_user_fps_cap(&mut self) -> &mut Option<u32>

Source

pub fn set_user_fps_cap(&mut self, val: Option<u32>) -> &mut Self

Source

pub fn get_max_in_flight_frames(&self) -> u32

Source

pub fn get_mut_max_in_flight_frames(&mut self) -> &mut u32

Source

pub fn set_max_in_flight_frames(&mut self, val: u32) -> &mut Self

Source

pub fn get_in_flight_frames(&self) -> u32

Source

pub fn get_mut_in_flight_frames(&mut self) -> &mut u32

Source

pub fn set_in_flight_frames(&mut self, val: u32) -> &mut Self

Source

pub fn get_last_vsync_ns(&self) -> u64

Source

pub fn get_mut_last_vsync_ns(&mut self) -> &mut u64

Source

pub fn set_last_vsync_ns(&mut self, val: u64) -> &mut Self

Source

pub fn get_last_submitted_vsync_ns(&self) -> u64

Source

pub fn get_mut_last_submitted_vsync_ns(&mut self) -> &mut u64

Source

pub fn set_last_submitted_vsync_ns(&mut self, val: u64) -> &mut Self

Source

pub fn get_last_present_ns(&self) -> u64

Source

pub fn get_mut_last_present_ns(&mut self) -> &mut u64

Source

pub fn set_last_present_ns(&mut self, val: u64) -> &mut Self

Source

pub fn get_fixed_step_ns(&self) -> u64

Source

pub fn get_mut_fixed_step_ns(&mut self) -> &mut u64

Source

pub fn set_fixed_step_ns(&mut self, val: u64) -> &mut Self

Source

pub fn get_oldest_pending_input_ns(&self) -> u64

Source

pub fn get_mut_oldest_pending_input_ns(&mut self) -> &mut u64

Source

pub fn set_oldest_pending_input_ns(&mut self, val: u64) -> &mut Self

Source

pub fn get_pending_input_dirty(&self) -> bool

Source

pub fn get_mut_pending_input_dirty(&mut self) -> &mut bool

Source

pub fn set_pending_input_dirty(&mut self, val: bool) -> &mut Self

Source

pub fn get_pending_layout_dirty(&self) -> bool

Source

pub fn get_mut_pending_layout_dirty(&mut self) -> &mut bool

Source

pub fn set_pending_layout_dirty(&mut self, val: bool) -> &mut Self

Source

pub fn get_stats(&self) -> FramePacingStats

Source

pub fn get_mut_stats(&mut self) -> &mut FramePacingStats

Source

pub fn set_stats(&mut self, val: FramePacingStats) -> &mut Self

Trait Implementations§

Source§

impl Clone for FramePacingController

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FramePacingController

Source§

impl Debug for FramePacingController

Source§

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

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

impl Default for FramePacingController

Default high-refresh native-VSync-driven FramePacingController.

Source§

fn default() -> Self

Creates a FramePacingController configured for the default display refresh rate (120Hz) with native VSync and bounded in-flight frames.

§Returns
  • Self - Default frame pacing controller.
Source§

impl PartialEq for FramePacingController

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FramePacingController

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.