pub struct WgpuWindowPresenter { /* private fields */ }Expand description
Hardware wgpu window surface presenter managing 3D rendering, hardware 2D/stencil-clip
Wgpu2DRenderer batches, offscreen 3D scene caching, and cached 2D HUD compositing.
Implementations§
Source§impl WgpuWindowPresenter
impl WgpuWindowPresenter
Sourcepub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
pub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
Creates an offscreen-capable WgpuWindowPresenter with BGRA8 pixel format matching Cairo.
Sourcepub unsafe fn from_raw_handles(
window_handle: RawWindowHandle,
display_handle: RawDisplayHandle,
width: u32,
height: u32,
present_mode: PresentMode,
) -> Result<Self, String>
pub unsafe fn from_raw_handles( window_handle: RawWindowHandle, display_handle: RawDisplayHandle, width: u32, height: u32, present_mode: PresentMode, ) -> Result<Self, String>
Creates a WgpuWindowPresenter bound directly to a native window/display handle pair.
§Safety
window_handle and display_handle must remain valid for the lifetime of this presenter.
pub fn renderer_mut(&mut self) -> &mut Wgpu3DRenderer
pub fn renderer_2d(&self) -> &Wgpu2DRenderer
pub fn renderer_2d_mut(&mut self) -> &mut Wgpu2DRenderer
pub fn batch_collector(&self) -> &UnifiedGpuCollector
pub fn last_batch_summary(&self) -> GpuBatchSummary
pub fn stencil_clip_pipeline(&self) -> &GpuStencilClipPipeline
pub fn active_wgpu_present_mode(&self) -> Option<PresentMode>
Sourcepub fn scene3d_cache_stats(&self) -> (u64, u64)
pub fn scene3d_cache_stats(&self) -> (u64, u64)
Returns (hits, misses) for the offscreen Scene3D color attachment cache.
Sourcepub fn gpu_memory_bytes(&self) -> u64
pub fn gpu_memory_bytes(&self) -> u64
Total allocated GPU VRAM bytes across 3D targets, tile atlases, 2D buffers, and cached overlays.
Sourcepub fn gpu_telemetry(&mut self) -> PlatformGpuTelemetry
pub fn gpu_telemetry(&mut self) -> PlatformGpuTelemetry
Snapshots hardware GPU pass timings, Scene3D cache hit/miss counts, and VRAM bytes.
Sourcepub fn render_viewports_cached_to_view(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
target_view: &TextureView,
width: u32,
height: u32,
format: TextureFormat,
draw_overlay: bool,
) -> bool
pub fn render_viewports_cached_to_view( &mut self, viewports: &[([f32; 4], &Scene3D)], target_view: &TextureView, width: u32, height: u32, format: TextureFormat, draw_overlay: bool, ) -> bool
Renders viewports using the offscreen Scene3D color attachment cache into target_view
and composites the optional 2D UI overlay on top. Returns true on a 3D cache hit.
pub fn surface_size(&self) -> (u32, u32)
pub fn has_surface(&self) -> bool
pub fn resize(&mut self, width: u32, height: u32)
Sourcepub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
pub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
Uploads a new cached 2D UI HUD overlay (BGRA8 pixels matching Cairo ARgb32).
Called only when 2D layout/DOM paint_dirty repaints; unchanged camera-only 3D frames
reuse this GPU texture with zero CPU work.
Sourcepub fn upload_ui_overlay_bgra_rects(
&mut self,
width: u32,
height: u32,
stride: usize,
bgra: &[u8],
rects: &[(u32, u32, u32, u32)],
scratch: &mut Vec<u8>,
)
pub fn upload_ui_overlay_bgra_rects( &mut self, width: u32, height: u32, stride: usize, bgra: &[u8], rects: &[(u32, u32, u32, u32)], scratch: &mut Vec<u8>, )
Uploads only damaged sub-rectangles of the 2D UI HUD overlay texture, avoiding full-frame 8 MB CPU-to-GPU transfers when only small labels or HUD counters changed.
Sourcepub fn present_to_surface(
&mut self,
scene: &Scene3D,
viewport: Option<[f32; 4]>,
draw_overlay: bool,
) -> Result<(), String>
pub fn present_to_surface( &mut self, scene: &Scene3D, viewport: Option<[f32; 4]>, draw_overlay: bool, ) -> Result<(), String>
Presents scene directly to the swapchain surface and composites cached 2D UI overlay if enabled.
Sourcepub fn present_viewports_to_surface(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
draw_overlay: bool,
) -> Result<(), String>
pub fn present_viewports_to_surface( &mut self, viewports: &[([f32; 4], &Scene3D)], draw_overlay: bool, ) -> Result<(), String>
Presents one or more 3D viewports directly into the single swapchain frame and composites the cached 2D UI overlay once on top before presenting.
Sourcepub fn present_viewports_to_surface_timed(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
draw_overlay: bool,
) -> Result<(Duration, Duration), String>
pub fn present_viewports_to_surface_timed( &mut self, viewports: &[([f32; 4], &Scene3D)], draw_overlay: bool, ) -> Result<(Duration, Duration), String>
Presents one or more 3D viewports directly into the swapchain frame and returns
(wgpu_submit_duration, swapchain_present_duration).
Sourcepub fn present_display_list_to_surface(
&mut self,
list: &DisplayList,
logical_width: f32,
logical_height: f32,
dpr: f32,
damage: Option<Rect>,
clear_color: [f32; 4],
) -> Result<GpuBatchSummary, String>
pub fn present_display_list_to_surface( &mut self, list: &DisplayList, logical_width: f32, logical_height: f32, dpr: f32, damage: Option<Rect>, clear_color: [f32; 4], ) -> Result<GpuBatchSummary, String>
Presents an entire DisplayList (2D quads, vector paths with caps/joins, dashed strokes,
Slug text, polygonal GpuStencilClipPipeline masks, and any interleaved DrawViewport3D)
directly onto the hardware wgpu::Surface swapchain via UnifiedGpuCollector + Wgpu2DRenderer.
Sourcepub fn present_display_list_to_surface_timed(
&mut self,
list: &DisplayList,
logical_width: f32,
logical_height: f32,
dpr: f32,
damage: Option<Rect>,
clear_color: [f32; 4],
) -> Result<(GpuBatchSummary, Duration, Duration, Duration), String>
pub fn present_display_list_to_surface_timed( &mut self, list: &DisplayList, logical_width: f32, logical_height: f32, dpr: f32, damage: Option<Rect>, clear_color: [f32; 4], ) -> Result<(GpuBatchSummary, Duration, Duration, Duration), String>
Presents an entire DisplayList onto the swapchain and returns
(summary, raster_2d_collect_dur, wgpu_submit_dur, swapchain_present_dur).
Sourcepub fn present_overlay_to_surface(
&mut self,
clear_color: [f32; 4],
) -> Result<(), String>
pub fn present_overlay_to_surface( &mut self, clear_color: [f32; 4], ) -> Result<(), String>
Presents the cached ui_overlay texture directly onto the swapchain surface.
Sourcepub fn render_display_list_offscreen_bgra(
&mut self,
list: &DisplayList,
width: u32,
height: u32,
dpr: f32,
damage: Option<Rect>,
clear_color: [f32; 4],
readback: bool,
) -> Result<(GpuBatchSummary, Vec<u8>), String>
pub fn render_display_list_offscreen_bgra( &mut self, list: &DisplayList, width: u32, height: u32, dpr: f32, damage: Option<Rect>, clear_color: [f32; 4], readback: bool, ) -> Result<(GpuBatchSummary, Vec<u8>), String>
Renders a DisplayList (pure 2D or hybrid 3D+2D) via UnifiedGpuCollector,
GpuStencilClipPipeline, and Wgpu2DRenderer into an offscreen BGRA8 target,
returning raw BGRA8 pixels when readback is true.
Sourcepub fn render_offscreen_bgra(
&mut self,
scene: &Scene3D,
width: u32,
height: u32,
readback: bool,
) -> Result<Vec<u8>, String>
pub fn render_offscreen_bgra( &mut self, scene: &Scene3D, width: u32, height: u32, readback: bool, ) -> Result<Vec<u8>, String>
Offscreen render returning BGRA8 pixels (or empty vec if readback == false).
Sourcepub fn render_viewports_cached_offscreen_bgra(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
width: u32,
height: u32,
composite_overlay: bool,
) -> Result<Vec<u8>, String>
pub fn render_viewports_cached_offscreen_bgra( &mut self, viewports: &[([f32; 4], &Scene3D)], width: u32, height: u32, composite_overlay: bool, ) -> Result<Vec<u8>, String>
Renders 3D viewports through the offscreen Scene3D cache and composites the 2D UI overlay, reading back BGRA8 pixels for headless verification and benchmarking.