Skip to main content

AdaptiveRenderRouter

Struct AdaptiveRenderRouter 

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

Unified 5-stage cross-platform adaptive render router (Startup, Runtime, Selection, Handoff, Fault).

Implementations§

Source§

impl AdaptiveRenderRouter

Unified 5-stage routing, probing, selection, handoff, and fault handling implementation for AdaptiveRenderRouter.

Source

pub fn new( config: AdaptiveRouterConfig, host_profile: HostCapabilityProfile, display_mode_hz: f64, ) -> Self

Creates a new 5-stage AdaptiveRenderRouter bound to config, host_profile, and display_mode_hz.

§Arguments
  • AdaptiveRouterConfig - Policy thresholds and rollout switch mode.
  • HostCapabilityProfile - Host channel capabilities and visual-equivalence baseline.
  • f64 - Initial display mode refresh rate in Hertz.
§Returns
  • Self - Initialized adaptive render router.
Source

pub fn update_environment( &mut self, device_id: &str, driver_version: &str, display_mode_hz: f64, build_id: &str, ) -> usize

Updates environment identity (device_id, driver_version, display_mode_hz, build_id) and invalidates stale cached winners.

§Arguments
  • &Self - Mutable router reference.
  • &str - Device identifier.
  • &str - Graphics driver version.
  • f64 - Display mode refresh rate in Hertz.
  • &str - Build identifier.
§Returns
  • usize - Number of stale winner cache entries invalidated.
Source

pub fn cache_key_for(&self, scene_profile: SceneProfile) -> WinnerCacheKey

Builds the current WinnerCacheKey for scene_profile using active device, driver, display mode, and build identity.

§Arguments
  • &Self - Router reference.
  • SceneProfile - Target scene profile.
§Returns
  • WinnerCacheKey - Exact composite cache key.
Source

pub fn select_startup_candidate( &mut self, scene_profile: SceneProfile, ) -> AdaptiveDecision

Stage 1 (Startup): selects a verified cached winner if valid, otherwise tries visually-equivalent GpuDirect first (locking single-channel hosts).

§Arguments
  • &Self - Mutable router reference.
  • SceneProfile - Initial scene workload profile.
§Returns
  • AdaptiveDecision - Startup backend selection decision.
Source

pub fn on_startup_candidate_failed( &mut self, failed: RenderBackendCandidate, now_ms: u64, ) -> AdaptiveDecision

Stage 1 (Startup failover): immediately switches from a failed startup candidate to a known-working visually-equivalent path.

§Arguments
  • &Self - Mutable router reference.
  • RenderBackendCandidate - Candidate that failed initialization or first-frame submission.
  • u64 - Current monotonic timestamp in milliseconds.
§Returns
  • AdaptiveDecision - Immediate failover decision.
Source

pub fn record_runtime_sample(&mut self, sample: TelemetrySample) -> bool

Stage 2 (Runtime): records a zero-allocation hot-path telemetry sample into BoundedTelemetryQueue and updates degradation triggers.

§Arguments
  • &Self - Mutable router reference.
  • TelemetrySample - Frame sample reusing existing callback/present timestamps.
§Returns
  • bool - true when enqueued without overwriting an unread sample; false when drop-oldest triggered.
Source

pub fn has_probe_headroom( &self, is_idle: bool, recent_frame_ms: f64, target_interval_ms: f64, ) -> bool

Returns true ONLY when the runtime is idle OR explicit frame headroom exceeds the configured threshold.

§Arguments
  • &Self - Router reference.
  • bool - true when the app is currently idle.
  • f64 - Recent active frame duration in milliseconds.
  • f64 - Target frame interval in milliseconds.
§Returns
  • bool - true when probing has sufficient headroom.
Source

pub fn should_trigger_probe( &mut self, is_idle: bool, recent_frame_ms: f64, target_interval_ms: f64, now_ms: u64, ) -> Result<ProbeTriggerReason, &'static str>

Stage 2 (Runtime): gates short candidate probing strictly on sustained degradation AND idle/explicit headroom (never probing single-channel hosts).

§Arguments
  • &Self - Mutable router reference.
  • bool - true when the UI/render loop is currently idle.
  • f64 - Recent active frame time in milliseconds.
  • f64 - Target frame interval in milliseconds.
  • u64 - Current monotonic timestamp in milliseconds.
§Returns
  • Result<ProbeTriggerReason, &'static str> - Ok(reason) when a short probe is authorized, or static suppression reason.
Source

pub fn evaluate_candidates( &mut self, current: CandidateScore, candidate: CandidateScore, now_ms: u64, ) -> AdaptiveDecision

Stage 3 (Selection): compares current and candidate under identical scene profile and refresh rate after quality, capability, and Hybrid net-gain gates.

§Arguments
  • &Self - Mutable router reference.
  • CandidateScore - Measured score of the currently active backend.
  • CandidateScore - Measured score of the probed candidate backend.
  • u64 - Current monotonic timestamp in milliseconds.
§Returns
  • AdaptiveDecision - Selection outcome respecting RecommendOnly vs AutoSwitch, consecutive wins, dwell time, and cooldown.
Source

pub fn begin_seamless_handoff( &mut self, target: RenderBackendCandidate, frame_identity: (u32, u32, f32, u64), now_ms: u64, state: RuntimeStateSnapshot, ) -> Result<(), VisualEquivalenceFailure>

Stage 4 (Handoff): initiates budget-sliced candidate warmup while keeping the current backend presenting uninterrupted.

§Arguments
  • &Self - Mutable router reference.
  • RenderBackendCandidate - Candidate backend to warm up.
  • (u32, u32, f32, u64) - Tuple (width, height, scale_factor, scene_version).
  • u64 - Monotonic start timestamp in milliseconds.
  • RuntimeStateSnapshot - Interactive runtime state snapshot that must stay invariant.
§Returns
  • Result<(), VisualEquivalenceFailure> - Ok(()) when warmup started, or visual-equivalence gate failure.
Source

pub fn commit_handoff_at_boundary( &mut self, first_frame: HandoffFrameDescriptor, current_frame: (u32, u32, f32, u64), commit_fence_id: u64, now_ms: u64, verified_score: CandidateScore, ) -> AdaptiveDecision

Stage 4 (Handoff): attempts atomic takeover at a frame boundary and updates active candidate on success (or aborts cleanly).

§Arguments
  • &Self - Mutable router reference.
  • HandoffFrameDescriptor - Candidate first-frame verification descriptor.
  • (u32, u32, f32, u64) - Live frame-boundary (width, height, scale_factor, scene_version).
  • u64 - Sync fence ID for deferred old-resource reclamation.
  • u64 - Current monotonic timestamp in milliseconds.
  • CandidateScore - Verified score of the winning candidate for cache recording.
§Returns
  • AdaptiveDecision - CommitHandoff on exact boundary match or AbortHandoff leaving old backend active.
Source

pub fn handle_fault( &mut self, fault: FaultEventKind, window_valid: bool, now_ms: u64, ) -> AdaptiveDecision

Stage 5 (Fault Handling): handles hardware/surface/driver/thermal faults explicitly, excluding them from seamless-handoff success counts.

§Arguments
  • &Self - Mutable router reference.
  • FaultEventKind - Explicit fault classification (DeviceLost, SurfaceDestroyed, DriverSuspended, ThermalThrottled).
  • bool - true when the host window remains valid and the last valid frame MUST be retained (never submitting a blank frame).
  • u64 - Current monotonic timestamp in milliseconds.
§Returns
  • AdaptiveDecision - Tagged fault response with immediate failover on DeviceLost.
Source

pub fn snapshot(&self) -> AdaptiveRouterSnapshot

Captures a compact serializable telemetry snapshot of the router and handoff coordinator state.

§Arguments
  • &Self - Router reference.
§Returns
  • AdaptiveRouterSnapshot - Snapshot embedded inside AdaptiveFrameMetrics.
Source

pub fn streak_candidate_value(&self) -> Option<RenderBackendCandidate>

Returns the candidate currently accumulating consecutive wins, if any.

§Arguments
  • &Self - Router reference.
§Returns
  • Option<RenderBackendCandidate> - Candidate on an active win streak.
Source§

impl AdaptiveRenderRouter

Source

pub fn get_config(&self) -> AdaptiveRouterConfig

Source

pub fn get_mut_config(&mut self) -> &mut AdaptiveRouterConfig

Source

pub fn set_config(&mut self, val: AdaptiveRouterConfig) -> &mut Self

Source

pub fn get_host_profile(&self) -> &HostCapabilityProfile

Source

pub fn get_mut_host_profile(&mut self) -> &mut HostCapabilityProfile

Source

pub fn set_host_profile(&mut self, val: HostCapabilityProfile) -> &mut Self

Source

pub fn get_winner_cache(&self) -> &WinnerCache

Source

pub fn get_mut_winner_cache(&mut self) -> &mut WinnerCache

Source

pub fn set_winner_cache(&mut self, val: WinnerCache) -> &mut Self

Source

pub fn get_telemetry_queue(&self) -> &BoundedTelemetryQueue

Source

pub fn get_mut_telemetry_queue(&mut self) -> &mut BoundedTelemetryQueue

Source

pub fn set_telemetry_queue(&mut self, val: BoundedTelemetryQueue) -> &mut Self

Source

pub fn get_handoff(&self) -> HandoffCoordinator

Source

pub fn get_mut_handoff(&mut self) -> &mut HandoffCoordinator

Source

pub fn set_handoff(&mut self, val: HandoffCoordinator) -> &mut Self

Source

pub fn get_active_candidate(&self) -> RenderBackendCandidate

Source

pub fn get_mut_active_candidate(&mut self) -> &mut RenderBackendCandidate

Source

pub fn set_active_candidate(&mut self, val: RenderBackendCandidate) -> &mut Self

Source

pub fn get_active_scene_profile(&self) -> SceneProfile

Source

pub fn get_mut_active_scene_profile(&mut self) -> &mut SceneProfile

Source

pub fn set_active_scene_profile(&mut self, val: SceneProfile) -> &mut Self

Source

pub fn get_display_mode_hz(&self) -> f64

Source

pub fn get_mut_display_mode_hz(&mut self) -> &mut f64

Source

pub fn set_display_mode_hz(&mut self, val: f64) -> &mut Self

Source

pub fn get_device_id(&self) -> &String

Source

pub fn get_mut_device_id(&mut self) -> &mut String

Source

pub fn set_device_id(&mut self, val: String) -> &mut Self

Source

pub fn get_driver_version(&self) -> &String

Source

pub fn get_mut_driver_version(&mut self) -> &mut String

Source

pub fn set_driver_version(&mut self, val: String) -> &mut Self

Source

pub fn get_build_id(&self) -> &String

Source

pub fn get_mut_build_id(&mut self) -> &mut String

Source

pub fn set_build_id(&mut self, val: String) -> &mut Self

Source

pub fn get_last_switch_ms(&self) -> u64

Source

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

Source

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

Source

pub fn get_has_switched_once(&self) -> bool

Source

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

Source

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

Source

pub fn get_cooldown_until_ms(&self) -> u64

Source

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

Source

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

Source

pub fn get_sustained_miss_streak(&self) -> u32

Source

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

Source

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

Source

pub fn get_input_latency_degraded(&self) -> bool

Source

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

Source

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

Source

pub fn get_mut_streak_candidate( &mut self, ) -> &mut Option<RenderBackendCandidate>

Source

pub fn set_streak_candidate( &mut self, val: Option<RenderBackendCandidate>, ) -> &mut Self

Source

pub fn get_streak_wins(&self) -> u32

Source

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

Source

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

Source

pub fn get_last_valid_frame_retained(&self) -> bool

Source

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

Source

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

Source

pub fn get_fault_failover_count(&self) -> u64

Source

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

Source

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

Source

pub fn get_tagged_fault_events(&self) -> &Vec<(u64, FaultEventKind)>

Source

pub fn get_mut_tagged_fault_events(&mut self) -> &mut Vec<(u64, FaultEventKind)>

Source

pub fn set_tagged_fault_events( &mut self, val: Vec<(u64, FaultEventKind)>, ) -> &mut Self

Source

pub fn get_probe_runs(&self) -> u64

Source

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

Source

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

Source

pub fn get_probe_skips_no_headroom(&self) -> u64

Source

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

Source

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

Source

pub fn get_cache_hits(&self) -> u64

Source

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

Source

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

Source

pub fn get_recommendations_logged(&self) -> u64

Source

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

Source

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

Source

pub fn get_last_decision_reason(&self) -> &'static str

Source

pub fn get_mut_last_decision_reason(&mut self) -> &mut &'static str

Source

pub fn set_last_decision_reason(&mut self, val: &'static str) -> &mut Self

Trait Implementations§

Source§

impl Clone for AdaptiveRenderRouter

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 Debug for AdaptiveRenderRouter

Source§

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

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

impl Default for AdaptiveRenderRouter

Default adaptive router initialized for a headless software host in shadow RecommendOnly mode.

Source§

fn default() -> Self

Creates a default headless AdaptiveRenderRouter.

§Returns
  • Self - Default adaptive render router.
Source§

impl PartialEq for AdaptiveRenderRouter

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 AdaptiveRenderRouter

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.