Skip to main content

Renderer

Struct Renderer 

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

Unified single-backend rendering facade orchestrating lazy Software, Hardware, and Hybrid execution.

Implementations§

Source§

impl Renderer

Single-backend pipeline construction, live mode switching, and frame rendering for Renderer.

Source

pub fn new( platform: PlatformKind, capabilities: PlatformCapabilities, width: u32, height: u32, config: RenderConfig, ) -> Self

Creates a Renderer instantiating strictly ONE active backend for platform and config.

§Arguments
  • PlatformKind - Active execution platform.
  • PlatformCapabilities - Hardware capabilities reported by the platform backend.
  • u32 - Initial physical width.
  • u32 - Initial physical height.
  • RenderConfig - Requested rendering configuration.
§Returns
  • Self - Initialized single-backend renderer facade with zero eager fallback allocation.
Source

pub fn with_display_hz( platform: PlatformKind, capabilities: PlatformCapabilities, width: u32, height: u32, config: RenderConfig, display_refresh_hz: f32, ) -> Self

Creates a Renderer bound to live display_refresh_hz and instantiating strictly ONE active backend.

§Arguments
  • PlatformKind - Active execution platform.
  • PlatformCapabilities - Hardware capabilities reported by the platform backend.
  • u32 - Initial physical width.
  • u32 - Initial physical height.
  • RenderConfig - Requested rendering configuration.
  • f32 - Live native display refresh rate in Hertz.
§Returns
  • Self - Initialized single-backend renderer facade.
Source

pub fn active_backend_ref(&self) -> &ActiveRenderBackend

Returns an immutable reference to the single active rendering backend enum.

§Arguments
  • &Self - Renderer reference.
§Returns
  • &ActiveRenderBackend - Active backend variant.
Source

pub fn software(&self) -> Option<&SoftwareRenderer>

Returns a reference to the active or lazily-instantiated SoftwareRenderer, if one exists.

§Arguments
  • &Self - Renderer reference.
§Returns
  • Option<&SoftwareRenderer> - Software renderer reference when active or lazily allocated.
Source

pub fn hardware(&self) -> Option<&HardwareRenderer>

Returns a reference to the active HardwareRenderer when hardware mode is active.

§Arguments
  • &Self - Renderer reference.
§Returns
  • Option<&HardwareRenderer> - Active hardware renderer, or None when inactive.
Source

pub fn hybrid(&self) -> Option<&HybridRenderer>

Returns a reference to the active HybridRenderer when hybrid mode is active.

§Arguments
  • &Self - Renderer reference.
§Returns
  • Option<&HybridRenderer> - Active hybrid renderer, or None when inactive.
Source

pub fn has_fallback_software(&self) -> bool

Returns true when the lazy CPU fallback SoftwareRenderer has been instantiated.

§Arguments
  • &Self - Renderer reference.
§Returns
  • bool - Whether fallback_software is currently allocated.
Source

pub fn allocated_cpu_framebuffer_bytes(&self) -> usize

Returns total CPU RGBA8 framebuffer bytes currently allocated across active and fallback renderers (0 in GPU direct-draw mode).

§Arguments
  • &Self - Renderer reference.
§Returns
  • usize - Total allocated CPU framebuffer pixel bytes.
Source

pub fn get_mut_software(&mut self) -> &mut SoftwareRenderer

Returns a mutable reference to the active software renderer, lazily instantiating fallback_software only when in hardware mode.

§Arguments
  • &Self - Mutable renderer.
§Returns
  • &mut SoftwareRenderer - Mutable software renderer reference.
Source

pub fn set_timing_telemetry_enabled(&mut self, enabled: bool)

Updates whether timing instrumentation (Instant::now) is active inside software band scheduling.

§Arguments
  • &Self - Mutable renderer.
  • bool - true to enable per-dispatch microsecond timing instrumentation.
Source

pub fn set_high_frequency_active(&mut self, active: bool)

Updates adaptive worker-pool spin behavior for active animation/scroll vs idle periods.

§Arguments
  • &Self - Mutable renderer.
  • bool - true during active animation or scrolling; false when idle to drop worker spin to 0.
Source

pub fn set_direct_gpu_present(&mut self, enabled: bool)

Enables or disables direct GPU rendering without steady-state CPU RGBA readback mirroring.

§Arguments
  • &Self - Mutable renderer.
  • bool - true for GPU direct-draw (zero CPU RGBA mirror); false to enable software readback mirror.
Source

pub fn set_display_refresh_rate_hz(&mut self, display_refresh_hz: f32)

Synchronizes the fallback policy engine with the active native display refresh rate in Hertz.

§Arguments
  • &Self - Mutable renderer.
  • f32 - Active display refresh rate in Hertz.
Source

pub fn adaptive_router_snapshot(&self) -> AdaptiveRouterSnapshot

Returns a compact serializable telemetry snapshot of the active AdaptiveRenderRouter.

§Arguments
  • &Self - Renderer reference.
§Returns
  • AdaptiveRouterSnapshot - Current adaptive router and handoff snapshot.
Source

pub fn adaptive_switch_mode(&self) -> AdaptiveSwitchMode

Returns the active rollout switch mode (RecommendOnly vs AutoSwitch) on AdaptiveRenderRouter.

§Arguments
  • &Self - Renderer reference.
§Returns
  • AdaptiveSwitchMode - Active rollout switch policy.
Source

pub fn set_adaptive_switch_mode(&mut self, mode: AdaptiveSwitchMode)

Updates the rollout switch mode (RecommendOnly vs AutoSwitch) on both RenderConfig and the live AdaptiveRenderRouter.

§Arguments
  • &Self - Mutable renderer reference.
  • AdaptiveSwitchMode - Requested rollout switch policy.
Source

pub fn adaptive_frame_metrics(&self) -> AdaptiveFrameMetrics

Returns the most recent truthful AdaptiveFrameMetrics snapshot synchronized with the live router state.

§Arguments
  • &Self - Renderer reference.
§Returns
  • AdaptiveFrameMetrics - Truthful per-frame adaptive observability snapshot.
Source

pub fn apply_adaptive_candidate( &mut self, platform: PlatformKind, capabilities: PlatformCapabilities, candidate: RenderBackendCandidate, )

Applies an adaptive candidate selection to the active pipeline, aligning direct_gpu_present strictly with GPU-first selection.

§Arguments
  • &Self - Mutable renderer reference.
  • PlatformKind - Active platform kind.
  • PlatformCapabilities - Host hardware capabilities.
  • RenderBackendCandidate - Candidate backend to activate.
Source

pub fn semantics_contract(&self, scale_factor: f32) -> RenderSemanticsContract

Captures the active visual semantics contract verifying zero quality degradation across fallback transitions.

§Arguments
  • &Self - Renderer reference.
  • f32 - Active display scale factor.
§Returns
  • RenderSemanticsContract - Immutable visual fidelity snapshot.
Source

pub fn capture_reference_framebuffer( &mut self, damage: DamageRegion, ) -> &Framebuffer

Captures an on-demand CPU reference framebuffer for pixel-parity verification even while direct GPU draw is enabled.

§Arguments
  • &Self - Mutable renderer.
  • DamageRegion - Damage region to rasterize into the reference framebuffer.
§Returns
  • &Framebuffer - Rendered full-fidelity CPU reference RGBA8 framebuffer.
Source

pub fn apply_fallback_trigger( &mut self, trigger: FallbackTrigger, now_ms: u64, ) -> FallbackAction

Evaluates trigger through FallbackPolicyEngine and applies strictly non-degrading cache trimming or CPU reference switching.

§Arguments
  • &Self - Mutable renderer.
  • FallbackTrigger - Runtime pressure, frame overrun, or GPU fault trigger.
  • u64 - Monotonic clock timestamp in milliseconds.
§Returns
  • FallbackAction - Strictly non-degrading action applied.
Source

pub fn resolve_mode_and_backend( platform: PlatformKind, capabilities: PlatformCapabilities, config: RenderConfig, ) -> (RenderMode, GraphicsBackend)

Resolves (RenderMode, GraphicsBackend) deterministically from platform capabilities and user preference.

§Arguments
  • PlatformKind - Target platform.
  • PlatformCapabilities - Hardware support flags.
  • RenderConfig - User configuration.
§Returns
  • (RenderMode, GraphicsBackend) - Concrete resolved mode and backend.
Source

pub fn switch_mode( &mut self, platform: PlatformKind, capabilities: PlatformCapabilities, mode: RenderMode, )

Dynamically switches the active rendering mode at runtime, instantiating only the target backend and transferring the shared glyph atlas.

§Arguments
  • &Self - Mutable renderer.
  • PlatformKind - Active platform kind.
  • PlatformCapabilities - Platform hardware capabilities.
  • RenderMode - Target render mode.
Source

pub fn render_frame( &mut self, tree: &SceneTree, viewport: Size, scale_factor: f32, clear_color: Color, layout_stats: LayoutStats, damage: DamageRegion, ) -> Result<FrameStats, PlatformError>

Compiles tree into a DisplayList, executes the active render backend, and returns FrameStats.

§Arguments
  • &Self - Mutable renderer.
  • &SceneTree - Laid-out scene tree.
  • Size - Logical viewport dimensions.
  • f32 - Active DPI scale factor.
  • Color - Surface clear color.
  • LayoutStats - Telemetry from the layout pass.
  • DamageRegion - Damaged screen region.
§Returns
  • Result<FrameStats, PlatformError> - Frame performance and pixel-hash telemetry.
Source

pub fn render_frame_composite_aware( &mut self, tree: &SceneTree, params: &FrameRenderParams, composite_only: bool, ) -> Result<FrameStats, PlatformError>

Compiles tree into a DisplayList, honoring composite-only fast paths and non-degrading CPU reference fallback on unsupported GPU effects.

§Arguments
  • &Self - Mutable renderer.
  • &SceneTree - Laid-out scene tree.
  • &FrameRenderParams - Viewport, DPI, clear color, layout stats, and damage bundle.
  • bool - Whether only composite/scroll properties changed with zero layout or paint mutations.
§Returns
  • Result<FrameStats, PlatformError> - Frame performance, direct-draw, fallback, and pixel-hash telemetry.
Source

pub fn with_direct_gpu_submission<R, F>( &mut self, clear_color: Color, callback: F, ) -> Option<R>
where F: FnOnce(&GpuFrameSubmission) -> R,

Executes callback with a borrowed GpuFrameSubmission built via O(1) pointer swaps, eliminating per-frame GpuBatch, DirectGpuScenePass, and multi-MB atlas Vec<u8> clones while restoring all buffers intact immediately after presentation.

§Arguments
  • &Self - Mutable renderer reference.
  • Color - Surface clear color for the active frame.
  • F - Synchronous presentation closure borrowing &GpuFrameSubmission.
§Returns
  • Option<R> - Presentation callback result when hardware or hybrid batches are ready.
Source

pub fn build_direct_gpu_submission( &mut self, clear_color: Color, ) -> Option<GpuFrameSubmission>

Builds a direct-GPU GpuFrameSubmission payload from the active HardwareRenderer or HybridRenderer for PlatformBackend::present_gpu_frame.

§Arguments
  • &Self - Mutable renderer reference.
  • Color - Surface clear color for the active frame.
§Returns
  • Option<GpuFrameSubmission> - Direct-GPU frame submission when hardware or hybrid batches are ready.
Source

pub fn recover_gpu_present_fault(&mut self, damage: DamageRegion) -> bool

Handles a GPU presentation DeviceLost or SurfaceError by invoking FallbackPolicyEngine, AdaptiveExecutionRouter fault failover, and rendering a non-degrading CPU software fallback framebuffer.

§Arguments
  • &Self - Mutable renderer reference.
  • DamageRegion - Frame damage region for software fallback recovery.
§Returns
  • bool - true when the CPU software fallback framebuffer is ready for immediate presentation.
Source

pub fn render_with( &mut self, tree: &SceneTree, params: &FrameRenderParams, ) -> Result<FrameStats, PlatformError>

Renders tree using a compact FrameRenderParams descriptor and returns FrameStats.

§Arguments
  • &Self - Mutable renderer.
  • &SceneTree - Laid-out scene tree.
  • &FrameRenderParams - Viewport, DPI, clear color, layout stats, and damage bundle.
§Returns
  • Result<FrameStats, PlatformError> - Frame performance and pixel-hash telemetry.
Source

pub fn record_skipped_frame(&mut self) -> FrameStats

Advances the frame counter for an undamaged idle frame without rasterizing or hashing pixels and drops worker spin to 0.

§Arguments
  • &Self - Mutable renderer.
§Returns
  • FrameStats - Lightweight telemetry preserving the last rendered frame_hash with zero shaded pixels.
Source

pub fn paint_fragment_cache_stats(&self) -> (u64, u64, u64, u64)

Returns cumulative cross-frame PaintFragmentCache telemetry (whole_list_hits, fragment_hits, fragment_misses, fragment_evictions).

§Arguments
  • &Self - Renderer reference.
§Returns
  • (u64, u64, u64, u64) - Tuple of whole-list hits, fragment hits, misses, and evictions.
Source

pub fn framebuffer(&self) -> Option<&Framebuffer>

Returns a reference to the latest CPU-accessible Framebuffer for software/hybrid/readback presentation (None when GPU direct-draw is active with 0 CPU FB bytes).

§Arguments
  • &Self - Renderer reference.
§Returns
  • Option<&Framebuffer> - Active RGBA8 framebuffer if resident in host memory.
Source§

impl Renderer

Source

pub fn get_config(&self) -> RenderConfig

Source

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

Source

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

Source

pub fn get_active_mode(&self) -> RenderMode

Source

pub fn get_mut_active_mode(&mut self) -> &mut RenderMode

Source

pub fn set_active_mode(&mut self, val: RenderMode) -> &mut Self

Source

pub fn get_active_backend(&self) -> GraphicsBackend

Source

pub fn get_mut_active_backend(&mut self) -> &mut GraphicsBackend

Source

pub fn set_active_backend(&mut self, val: GraphicsBackend) -> &mut Self

Source

pub fn get_active_platform(&self) -> PlatformKind

Source

pub fn get_font_service(&self) -> &FontAtlasService

Source

pub fn get_mut_font_service(&mut self) -> &mut FontAtlasService

Source

pub fn set_font_service(&mut self, val: FontAtlasService) -> &mut Self

Source

pub fn get_surface_width(&self) -> u32

Source

pub fn get_surface_height(&self) -> u32

Source

pub fn get_display_list(&self) -> &DisplayList

Source

pub fn get_mut_display_list(&mut self) -> &mut DisplayList

Source

pub fn set_display_list(&mut self, val: DisplayList) -> &mut Self

Source

pub fn get_frame_index(&self) -> u64

Source

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

Source

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

Source

pub fn get_compute_pixel_hash(&self) -> bool

Source

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

Source

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

Source

pub fn get_telemetry_enabled(&self) -> bool

Source

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

Source

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

Source

pub fn get_last_stats(&self) -> FrameStats

Source

pub fn get_mut_last_stats(&mut self) -> &mut FrameStats

Source

pub fn set_last_stats(&mut self, val: FrameStats) -> &mut Self

Source

pub fn get_fallback_policy(&self) -> &FallbackPolicyEngine

Source

pub fn get_mut_fallback_policy(&mut self) -> &mut FallbackPolicyEngine

Source

pub fn set_fallback_policy(&mut self, val: FallbackPolicyEngine) -> &mut Self

Source

pub fn get_composite_fast_path_frames(&self) -> u64

Source

pub fn get_cpu_fallback_frames(&self) -> u64

Source

pub fn get_adaptive_router(&self) -> &AdaptiveRenderRouter

Source

pub fn get_mut_adaptive_router(&mut self) -> &mut AdaptiveRenderRouter

Source

pub fn set_adaptive_router(&mut self, val: AdaptiveRenderRouter) -> &mut Self

Source

pub fn get_last_adaptive_metrics(&self) -> AdaptiveFrameMetrics

Source

pub fn get_mut_last_adaptive_metrics(&mut self) -> &mut AdaptiveFrameMetrics

Source

pub fn set_last_adaptive_metrics( &mut self, val: AdaptiveFrameMetrics, ) -> &mut Self

Source

pub fn get_execution_router(&self) -> &AdaptiveExecutionRouter

Source

pub fn get_mut_execution_router(&mut self) -> &mut AdaptiveExecutionRouter

Source

pub fn set_execution_router( &mut self, val: AdaptiveExecutionRouter, ) -> &mut Self

Source

pub fn get_render_graph(&self) -> &RenderGraph

Source

pub fn get_mut_render_graph(&mut self) -> &mut RenderGraph

Source

pub fn set_render_graph(&mut self, val: RenderGraph) -> &mut Self

Source

pub fn get_last_scale_bits(&self) -> u32

Trait Implementations§

Source§

impl Debug for Renderer

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Renderer

§

impl Freeze for Renderer
where *const SoftwareRenderer is !null: Freeze, PhantomData<SoftwareRenderer>: Freeze, *const HardwareRenderer is !null: Freeze, PhantomData<HardwareRenderer>: Freeze, *const HybridRenderer is !null: Freeze, PhantomData<HybridRenderer>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<u64>: Freeze, PhantomData<(GlyphKey, RasterizedGlyph)>: Freeze, PhantomData<AsciiGlyphStyleTable>: Freeze, PhantomData<(u64, usize)>: Freeze, PhantomData<DpiAtlasSnapshot>: Freeze, PhantomData<ShapingRunSlot>: Freeze, PhantomData<LineBreakSlot>: Freeze, PhantomData<u32>: Freeze, PhantomData<RetainedPaintFragment>: Freeze, PhantomData<CachedDrawCommand>: Freeze, PhantomData<DrawCommand>: Freeze, *const GpuOceanScenePass is !null: Freeze, PhantomData<GpuOceanScenePass>: Freeze, *const GpuWorld3dScenePass is !null: Freeze, PhantomData<GpuWorld3dScenePass>: Freeze, PhantomData<String>: Freeze, PhantomData<(i32, usize, NodeId)>: Freeze, PhantomData<NodeId>: Freeze, PhantomData<CandidateCapabilities>: Freeze, PhantomData<(WinnerCacheKey, WinnerCacheEntry)>: Freeze, PhantomData<TelemetrySample>: Freeze, PhantomData<(u64, FaultEventKind)>: Freeze, &'static str: Freeze, PhantomData<DirtyBufferSpan>: Freeze, PhantomData<GpuPrimitiveInstance>: Freeze, PhantomData<(GlyphKey, GpuGlyphPlacement)>: Freeze, PhantomData<PixelDirtyRect>: Freeze, PhantomData<RenderGraphPassKind>: Freeze, *const GpuFrameSubmission is !null: Freeze, PhantomData<GpuFrameSubmission>: Freeze, PhantomData<GpuBatch>: Freeze,

§

impl Move for Renderer

§

impl RefUnwindSafe for Renderer

§

impl Send for Renderer
where BoxRaw<SoftwareRenderer>: Send, BoxRaw<HardwareRenderer>: Send, BoxRaw<HybridRenderer>: Send, RawVecInner: Send, Arc<[u8]>: Send, Arc<Vec<u8>>: Send, BoxRaw<GpuOceanScenePass>: Send, BoxRaw<GpuWorld3dScenePass>: Send, RawTable<(WinnerCacheKey, WinnerCacheEntry)>: Send, &'static str: Send, RawTable<(GlyphKey, GpuGlyphPlacement)>: Send, BoxRaw<GpuFrameSubmission>: Send,

§

impl Sync for Renderer
where BoxRaw<SoftwareRenderer>: Sync, BoxRaw<HardwareRenderer>: Sync, BoxRaw<HybridRenderer>: Sync, RawVecInner: Sync, Arc<[u8]>: Sync, Arc<Vec<u8>>: Sync, BoxRaw<GpuOceanScenePass>: Sync, BoxRaw<GpuWorld3dScenePass>: Sync, RawTable<(WinnerCacheKey, WinnerCacheEntry)>: Sync, RawTable<(GlyphKey, GpuGlyphPlacement)>: Sync, BoxRaw<GpuFrameSubmission>: Sync,

§

impl Unpin for Renderer

§

impl UnsafeUnpin for Renderer
where *const SoftwareRenderer is !null: UnsafeUnpin, PhantomData<SoftwareRenderer>: UnsafeUnpin, *const HardwareRenderer is !null: UnsafeUnpin, PhantomData<HardwareRenderer>: UnsafeUnpin, *const HybridRenderer is !null: UnsafeUnpin, PhantomData<HybridRenderer>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<u64>: UnsafeUnpin, PhantomData<(GlyphKey, RasterizedGlyph)>: UnsafeUnpin, PhantomData<AsciiGlyphStyleTable>: UnsafeUnpin, PhantomData<(u64, usize)>: UnsafeUnpin, PhantomData<DpiAtlasSnapshot>: UnsafeUnpin, PhantomData<ShapingRunSlot>: UnsafeUnpin, PhantomData<LineBreakSlot>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<RetainedPaintFragment>: UnsafeUnpin, PhantomData<CachedDrawCommand>: UnsafeUnpin, PhantomData<DrawCommand>: UnsafeUnpin, *const GpuOceanScenePass is !null: UnsafeUnpin, PhantomData<GpuOceanScenePass>: UnsafeUnpin, *const GpuWorld3dScenePass is !null: UnsafeUnpin, PhantomData<GpuWorld3dScenePass>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<(i32, usize, NodeId)>: UnsafeUnpin, PhantomData<NodeId>: UnsafeUnpin, PhantomData<CandidateCapabilities>: UnsafeUnpin, PhantomData<(WinnerCacheKey, WinnerCacheEntry)>: UnsafeUnpin, PhantomData<TelemetrySample>: UnsafeUnpin, PhantomData<(u64, FaultEventKind)>: UnsafeUnpin, &'static str: UnsafeUnpin, PhantomData<DirtyBufferSpan>: UnsafeUnpin, PhantomData<GpuPrimitiveInstance>: UnsafeUnpin, PhantomData<(GlyphKey, GpuGlyphPlacement)>: UnsafeUnpin, PhantomData<PixelDirtyRect>: UnsafeUnpin, PhantomData<RenderGraphPassKind>: UnsafeUnpin, *const GpuFrameSubmission is !null: UnsafeUnpin, PhantomData<GpuFrameSubmission>: UnsafeUnpin, PhantomData<GpuBatch>: UnsafeUnpin,

§

impl UnwindSafe for Renderer

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> 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, 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.