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.
impl AdaptiveRenderRouter
Unified 5-stage routing, probing, selection, handoff, and fault handling implementation for AdaptiveRenderRouter.
Sourcepub fn new(
config: AdaptiveRouterConfig,
host_profile: HostCapabilityProfile,
display_mode_hz: f64,
) -> Self
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.
Sourcepub fn update_environment(
&mut self,
device_id: &str,
driver_version: &str,
display_mode_hz: f64,
build_id: &str,
) -> usize
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.
Sourcepub fn cache_key_for(&self, scene_profile: SceneProfile) -> WinnerCacheKey
pub fn cache_key_for(&self, scene_profile: SceneProfile) -> WinnerCacheKey
Sourcepub fn select_startup_candidate(
&mut self,
scene_profile: SceneProfile,
) -> AdaptiveDecision
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.
Sourcepub fn on_startup_candidate_failed(
&mut self,
failed: RenderBackendCandidate,
now_ms: u64,
) -> AdaptiveDecision
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.
Sourcepub fn record_runtime_sample(&mut self, sample: TelemetrySample) -> bool
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-truewhen enqueued without overwriting an unread sample;falsewhen drop-oldest triggered.
Sourcepub fn has_probe_headroom(
&self,
is_idle: bool,
recent_frame_ms: f64,
target_interval_ms: f64,
) -> bool
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-truewhen the app is currently idle.f64- Recent active frame duration in milliseconds.f64- Target frame interval in milliseconds.
§Returns
bool-truewhen probing has sufficient headroom.
Sourcepub fn should_trigger_probe(
&mut self,
is_idle: bool,
recent_frame_ms: f64,
target_interval_ms: f64,
now_ms: u64,
) -> Result<ProbeTriggerReason, &'static str>
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-truewhen 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.
Sourcepub fn evaluate_candidates(
&mut self,
current: CandidateScore,
candidate: CandidateScore,
now_ms: u64,
) -> AdaptiveDecision
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 respectingRecommendOnlyvsAutoSwitch, consecutive wins, dwell time, and cooldown.
Sourcepub fn begin_seamless_handoff(
&mut self,
target: RenderBackendCandidate,
frame_identity: (u32, u32, f32, u64),
now_ms: u64,
state: RuntimeStateSnapshot,
) -> Result<(), VisualEquivalenceFailure>
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.
Sourcepub 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
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-CommitHandoffon exact boundary match orAbortHandoffleaving old backend active.
Sourcepub fn handle_fault(
&mut self,
fault: FaultEventKind,
window_valid: bool,
now_ms: u64,
) -> AdaptiveDecision
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-truewhen 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 onDeviceLost.
Sourcepub fn snapshot(&self) -> AdaptiveRouterSnapshot
pub fn snapshot(&self) -> AdaptiveRouterSnapshot
Sourcepub fn streak_candidate_value(&self) -> Option<RenderBackendCandidate>
pub fn streak_candidate_value(&self) -> Option<RenderBackendCandidate>
Source§impl AdaptiveRenderRouter
impl AdaptiveRenderRouter
pub fn get_config(&self) -> AdaptiveRouterConfig
pub fn get_mut_config(&mut self) -> &mut AdaptiveRouterConfig
pub fn set_config(&mut self, val: AdaptiveRouterConfig) -> &mut Self
pub fn get_host_profile(&self) -> &HostCapabilityProfile
pub fn get_mut_host_profile(&mut self) -> &mut HostCapabilityProfile
pub fn set_host_profile(&mut self, val: HostCapabilityProfile) -> &mut Self
pub fn get_winner_cache(&self) -> &WinnerCache
pub fn get_mut_winner_cache(&mut self) -> &mut WinnerCache
pub fn set_winner_cache(&mut self, val: WinnerCache) -> &mut Self
pub fn get_telemetry_queue(&self) -> &BoundedTelemetryQueue
pub fn get_mut_telemetry_queue(&mut self) -> &mut BoundedTelemetryQueue
pub fn set_telemetry_queue(&mut self, val: BoundedTelemetryQueue) -> &mut Self
pub fn get_handoff(&self) -> HandoffCoordinator
pub fn get_mut_handoff(&mut self) -> &mut HandoffCoordinator
pub fn set_handoff(&mut self, val: HandoffCoordinator) -> &mut Self
pub fn get_active_candidate(&self) -> RenderBackendCandidate
pub fn get_mut_active_candidate(&mut self) -> &mut RenderBackendCandidate
pub fn set_active_candidate(&mut self, val: RenderBackendCandidate) -> &mut Self
pub fn get_recommended_candidate(&self) -> RenderBackendCandidate
pub fn get_mut_recommended_candidate(&mut self) -> &mut RenderBackendCandidate
pub fn set_recommended_candidate( &mut self, val: RenderBackendCandidate, ) -> &mut Self
pub fn get_active_scene_profile(&self) -> SceneProfile
pub fn get_mut_active_scene_profile(&mut self) -> &mut SceneProfile
pub fn set_active_scene_profile(&mut self, val: SceneProfile) -> &mut Self
pub fn get_display_mode_hz(&self) -> f64
pub fn get_mut_display_mode_hz(&mut self) -> &mut f64
pub fn set_display_mode_hz(&mut self, val: f64) -> &mut Self
pub fn get_device_id(&self) -> &String
pub fn get_mut_device_id(&mut self) -> &mut String
pub fn set_device_id(&mut self, val: String) -> &mut Self
pub fn get_driver_version(&self) -> &String
pub fn get_mut_driver_version(&mut self) -> &mut String
pub fn set_driver_version(&mut self, val: String) -> &mut Self
pub fn get_build_id(&self) -> &String
pub fn get_mut_build_id(&mut self) -> &mut String
pub fn set_build_id(&mut self, val: String) -> &mut Self
pub fn get_last_switch_ms(&self) -> u64
pub fn get_mut_last_switch_ms(&mut self) -> &mut u64
pub fn set_last_switch_ms(&mut self, val: u64) -> &mut Self
pub fn get_has_switched_once(&self) -> bool
pub fn get_mut_has_switched_once(&mut self) -> &mut bool
pub fn set_has_switched_once(&mut self, val: bool) -> &mut Self
pub fn get_cooldown_until_ms(&self) -> u64
pub fn get_mut_cooldown_until_ms(&mut self) -> &mut u64
pub fn set_cooldown_until_ms(&mut self, val: u64) -> &mut Self
pub fn get_sustained_miss_streak(&self) -> u32
pub fn get_mut_sustained_miss_streak(&mut self) -> &mut u32
pub fn set_sustained_miss_streak(&mut self, val: u32) -> &mut Self
pub fn get_input_latency_degraded(&self) -> bool
pub fn get_mut_input_latency_degraded(&mut self) -> &mut bool
pub fn set_input_latency_degraded(&mut self, val: bool) -> &mut Self
pub fn get_mut_streak_candidate( &mut self, ) -> &mut Option<RenderBackendCandidate>
pub fn set_streak_candidate( &mut self, val: Option<RenderBackendCandidate>, ) -> &mut Self
pub fn get_streak_wins(&self) -> u32
pub fn get_mut_streak_wins(&mut self) -> &mut u32
pub fn set_streak_wins(&mut self, val: u32) -> &mut Self
pub fn get_last_valid_frame_retained(&self) -> bool
pub fn get_mut_last_valid_frame_retained(&mut self) -> &mut bool
pub fn set_last_valid_frame_retained(&mut self, val: bool) -> &mut Self
pub fn get_fault_failover_count(&self) -> u64
pub fn get_mut_fault_failover_count(&mut self) -> &mut u64
pub fn set_fault_failover_count(&mut self, val: u64) -> &mut Self
pub fn get_tagged_fault_events(&self) -> &Vec<(u64, FaultEventKind)>
pub fn get_mut_tagged_fault_events(&mut self) -> &mut Vec<(u64, FaultEventKind)>
pub fn set_tagged_fault_events( &mut self, val: Vec<(u64, FaultEventKind)>, ) -> &mut Self
pub fn get_probe_runs(&self) -> u64
pub fn get_mut_probe_runs(&mut self) -> &mut u64
pub fn set_probe_runs(&mut self, val: u64) -> &mut Self
pub fn get_probe_skips_no_headroom(&self) -> u64
pub fn get_mut_probe_skips_no_headroom(&mut self) -> &mut u64
pub fn set_probe_skips_no_headroom(&mut self, val: u64) -> &mut Self
pub fn get_cache_hits(&self) -> u64
pub fn get_mut_cache_hits(&mut self) -> &mut u64
pub fn set_cache_hits(&mut self, val: u64) -> &mut Self
pub fn get_recommendations_logged(&self) -> u64
pub fn get_mut_recommendations_logged(&mut self) -> &mut u64
pub fn set_recommendations_logged(&mut self, val: u64) -> &mut Self
pub fn get_last_decision_reason(&self) -> &'static str
pub fn get_mut_last_decision_reason(&mut self) -> &mut &'static str
pub fn set_last_decision_reason(&mut self, val: &'static str) -> &mut Self
Trait Implementations§
Source§impl Clone for AdaptiveRenderRouter
impl Clone for AdaptiveRenderRouter
Source§impl Debug for AdaptiveRenderRouter
impl Debug for AdaptiveRenderRouter
Source§impl Default for AdaptiveRenderRouter
Default adaptive router initialized for a headless software host in shadow RecommendOnly mode.
impl Default for AdaptiveRenderRouter
Default adaptive router initialized for a headless software host in shadow RecommendOnly mode.