Skip to main content

FrameBudgetStabilizer

Struct FrameBudgetStabilizer 

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

Hysteresis-guarded zero-allocation frame-budget stabilizer comparing EWMA and p95 frame times against live 1000.0 / device_max_hz.

Defaults to 1.0 (100% maximum visual quality) and smoothly scales ONLY internal 3D/water offscreen shader/FBO workload under sustained frame-miss risk while keeping all UI, text, icons, borders, and vector art strictly 1:1 lossless physical pixels.

Implementations§

Source§

impl FrameBudgetStabilizer

Hysteresis-guarded EWMA + p95 frame-budget stabilization for FrameBudgetStabilizer.

Source

pub fn with_min_scale(min_scale: f32) -> Self

Creates a FrameBudgetStabilizer initialized at 1.0 maximum quality with explicit min_scale floor.

§Arguments
  • f32 - Minimum allowed offscreen 3D/water resolution scale floor (0.35..=1.0).
§Returns
  • Self - Initialized frame-budget stabilizer.
Source

pub fn on_viewport_or_route_changed(&mut self)

Resets transient streak and cooldown counters after a major viewport resize or route transition so quality recovers immediately when load drops.

§Arguments
  • &Self - Mutable frame-budget stabilizer.
Source

pub fn reset_to_max_quality(&mut self)

Restores full 1.0 (100% maximum visual quality) and clears sliding-window telemetry.

§Arguments
  • &Self - Mutable frame-budget stabilizer.
Source

pub fn record_frame( &mut self, wall_ms: f32, work_ms: f32, device_max_hz: f32, ) -> f32

Observes completed frame wall-clock duration wall_ms and active CPU/GPU execution duration work_ms against live device_max_hz and returns the stabilized offscreen 3D/water workload scale in [min_scale, 1.0].

§Arguments
  • &Self - Mutable frame-budget stabilizer.
  • f32 - Real wall-clock frame interval in milliseconds (dt * 1000.0).
  • f32 - Observed active CPU/GPU execution time in milliseconds (0.0 when unobservable).
  • f32 - Live maximum hardware display refresh rate in Hertz.
§Returns
  • f32 - Stabilized offscreen workload resolution scale (1.0 whenever within budget).
Source§

impl FrameBudgetStabilizer

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_sample_count(&self) -> u32

Source

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

Source

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

Source

pub fn get_write_idx(&self) -> u8

Source

pub fn get_mut_write_idx(&mut self) -> &mut u8

Source

pub fn set_write_idx(&mut self, val: u8) -> &mut Self

Source

pub fn get_ewma_frame_ms(&self) -> f32

Source

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

Source

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

Source

pub fn get_p95_frame_ms(&self) -> f32

Source

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

Source

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

Source

pub fn get_ewma_work_ms(&self) -> f32

Source

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

Source

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

Source

pub fn get_p95_work_ms(&self) -> f32

Source

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

Source

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

Source

pub fn get_target_hz(&self) -> f32

Source

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

Source

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

Source

pub fn get_workload_scale(&self) -> f32

Source

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

Source

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

Source

pub fn get_min_scale(&self) -> f32

Source

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

Source

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

Source

pub fn get_over_budget_streak(&self) -> u32

Source

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

Source

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

Source

pub fn get_under_budget_streak(&self) -> u32

Source

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

Source

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

Source

pub fn get_cooldown_frames(&self) -> u32

Source

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

Source

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

Source

pub fn get_recovery_backoff(&self) -> u32

Source

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

Source

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

Source

pub fn get_total_frames(&self) -> u64

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for FrameBudgetStabilizer

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 FrameBudgetStabilizer

Source§

impl Debug for FrameBudgetStabilizer

Source§

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

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

impl Default for FrameBudgetStabilizer

Default 100% maximum-quality FrameBudgetStabilizer.

Source§

fn default() -> Self

Creates a FrameBudgetStabilizer locked at 1.0 (100% maximum visual quality) with FRAME_BUDGET_MIN_SCALE_GPU floor.

§Returns
  • Self - Default frame-budget stabilizer.
Source§

impl PartialEq for FrameBudgetStabilizer

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 FrameBudgetStabilizer

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.