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.
impl FramePacingController
Unified VSync pacing, double-gate elimination, clock rebasing, and in-flight tracking for FramePacingController.
Sourcepub fn new(
display_hz: f32,
native_vsync_active: bool,
user_fps_cap: Option<u32>,
max_in_flight_frames: u32,
) -> Self
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.
Sourcepub const fn active_user_fps_cap(&self) -> Option<u32>
pub const fn active_user_fps_cap(&self) -> Option<u32>
Sourcepub fn should_bypass_software_gate(&self) -> bool
pub fn should_bypass_software_gate(&self) -> bool
Sourcepub fn display_period_ns(&self) -> u64
pub fn display_period_ns(&self) -> u64
Sourcepub fn set_display_mode(&mut self, display_hz: f32, timestamp_ns: u64)
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.
Sourcepub fn rebase_clock(&mut self, timestamp_ns: u64)
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.
Sourcepub fn notify_present_completed(&mut self)
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.
Sourcepub fn evaluate(
&mut self,
trigger: FramePacingTrigger,
timestamp_ns: u64,
) -> PacingDecision
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
impl FramePacingController
pub fn get_display_hz(&self) -> f32
pub fn get_mut_display_hz(&mut self) -> &mut f32
pub fn set_display_hz(&mut self, val: f32) -> &mut Self
pub fn get_native_vsync_active(&self) -> bool
pub fn get_mut_native_vsync_active(&mut self) -> &mut bool
pub fn set_native_vsync_active(&mut self, val: bool) -> &mut Self
pub fn get_mut_user_fps_cap(&mut self) -> &mut Option<u32>
pub fn set_user_fps_cap(&mut self, val: Option<u32>) -> &mut Self
pub fn get_max_in_flight_frames(&self) -> u32
pub fn get_mut_max_in_flight_frames(&mut self) -> &mut u32
pub fn set_max_in_flight_frames(&mut self, val: u32) -> &mut Self
pub fn get_in_flight_frames(&self) -> u32
pub fn get_mut_in_flight_frames(&mut self) -> &mut u32
pub fn set_in_flight_frames(&mut self, val: u32) -> &mut Self
pub fn get_last_vsync_ns(&self) -> u64
pub fn get_mut_last_vsync_ns(&mut self) -> &mut u64
pub fn set_last_vsync_ns(&mut self, val: u64) -> &mut Self
pub fn get_last_present_ns(&self) -> u64
pub fn get_mut_last_present_ns(&mut self) -> &mut u64
pub fn set_last_present_ns(&mut self, val: u64) -> &mut Self
pub fn get_oldest_pending_input_ns(&self) -> u64
pub fn get_mut_oldest_pending_input_ns(&mut self) -> &mut u64
pub fn set_oldest_pending_input_ns(&mut self, val: u64) -> &mut Self
pub fn get_pending_input_dirty(&self) -> bool
pub fn get_mut_pending_input_dirty(&mut self) -> &mut bool
pub fn set_pending_input_dirty(&mut self, val: bool) -> &mut Self
pub fn get_pending_layout_dirty(&self) -> bool
pub fn get_mut_pending_layout_dirty(&mut self) -> &mut bool
pub fn set_pending_layout_dirty(&mut self, val: bool) -> &mut Self
pub fn get_stats(&self) -> FramePacingStats
pub fn get_mut_stats(&mut self) -> &mut FramePacingStats
pub fn set_stats(&mut self, val: FramePacingStats) -> &mut Self
Trait Implementations§
Source§impl Clone for FramePacingController
impl Clone for FramePacingController
impl Copy for FramePacingController
Source§impl Debug for FramePacingController
impl Debug for FramePacingController
Source§impl Default for FramePacingController
Default 120Hz native-VSync-driven FramePacingController.
impl Default for FramePacingController
Default 120Hz native-VSync-driven FramePacingController.