pub struct WgpuRenderer { /* private fields */ }Expand description
wgpu backend that renders Scene commands into a presentation surface.
The renderer owns the GPU device, queue, surface, pipeline, and transient vertex buffer. Window creation stays outside the library so each application can choose its own windowing framework.
Implementations§
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub async fn recover_device_and_surface(
&mut self,
) -> Result<(), RendererInitError>
pub async fn recover_device_and_surface( &mut self, ) -> Result<(), RendererInitError>
Requests a replacement logical device for the existing surface and recreates all renderer-owned transient pipelines and buffers.
External prepared, dynamic, particle, scalar, target, and trail
resources deliberately retain the previous renderer identity. Recreate
them with the matching restore_* methods after this call succeeds.
Targets and trails restore empty and must be redrawn.
Replaced logical devices enter a bounded quarantine until this renderer
is dropped. Some native swapchain drivers crash if a healthy previous
device is destroyed immediately after the surface migrates to its
replacement. Device recovery should therefore remain exceptional rather
than a normal quality switch. Query
WgpuRenderer::remaining_device_recoveries before attempting it.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn create_mesh3d(
&self,
source: Mesh3d,
) -> Result<RetainedMesh3d, Mesh3dResourceError>
pub fn create_mesh3d( &self, source: Mesh3d, ) -> Result<RetainedMesh3d, Mesh3dResourceError>
Uploads validated immutable topology into retained GPU buffers.
Counts, byte arithmetic, draw-count representation, and active-device buffer limits are checked before conversion staging allocation. Host staging reservation failure is returned explicitly; GPU allocation itself follows wgpu’s device-error model.
Sourcepub fn restore_mesh3d(
&self,
source: &RetainedMesh3d,
) -> Result<RetainedMesh3d, Mesh3dResourceError>
pub fn restore_mesh3d( &self, source: &RetainedMesh3d, ) -> Result<RetainedMesh3d, Mesh3dResourceError>
Restores retained topology onto this renderer after device replacement.
Sourcepub fn restore_scene3d(
&self,
scene: &mut Scene3d,
) -> Result<Scene3dRestoreReport, Mesh3dResourceError>
pub fn restore_scene3d( &self, scene: &mut Scene3d, ) -> Result<Scene3dRestoreReport, Mesh3dResourceError>
Atomically restores every stale retained mesh referenced by a 3D scene.
Distinct shared mesh resources are uploaded once. Object IDs, insertion
order, transforms, styles, visibility, scene provenance, and the next ID
remain unchanged. If any capacity or host-staging allocation fails, the
original scene is not modified. Targets remain separate resources and
must be restored with WgpuRenderer::restore_render_target3d.
Sourcepub fn create_render_target3d(
&self,
width: u32,
height: u32,
logical_viewport: LogicalViewport,
) -> Result<RenderTarget3d, Mesh3dResourceError>
pub fn create_render_target3d( &self, width: u32, height: u32, logical_viewport: LogicalViewport, ) -> Result<RenderTarget3d, Mesh3dResourceError>
Creates color/depth attachments for an explicit logical viewport.
width and height are physical target texels. Their aspect must match
logical_viewport; the resulting texels-per-logical-pixel ratio controls
wireframe width independently of the window DPI scale.
Sourcepub fn restore_render_target3d(
&self,
source: &RenderTarget3d,
) -> Result<RenderTarget3d, Mesh3dResourceError>
pub fn restore_render_target3d( &self, source: &RenderTarget3d, ) -> Result<RenderTarget3d, Mesh3dResourceError>
Restores empty color/depth attachments with the source dimensions.
Sourcepub fn render_scene3d_to_target(
&mut self,
target: &RenderTarget3d,
scene: &Scene3d,
camera: Camera3d,
) -> Result<Mesh3dRenderReport, Mesh3dRenderError>
pub fn render_scene3d_to_target( &mut self, target: &RenderTarget3d, scene: &Scene3d, camera: Camera3d, ) -> Result<Mesh3dRenderReport, Mesh3dRenderError>
Draws opaque retained objects into a reusable color/depth target.
Object insertion order does not determine visibility. Every surface writes and tests hardware depth. Model transforms are uploaded through a reusable instance buffer; retained topology is never retessellated.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn render_layered_visualization(
&mut self,
target: &RenderTarget2d,
scalar: &ScalarFieldTexture,
color_map: &ColorMap,
particles: &mut ParticleField2d,
camera: &Camera2d,
options: LayeredVisualizationOptions,
) -> Result<RenderReport, LayeredVisualizationError>
pub fn render_layered_visualization( &mut self, target: &RenderTarget2d, scalar: &ScalarFieldTexture, color_map: &ColorMap, particles: &mut ParticleField2d, camera: &Camera2d, options: LayeredVisualizationOptions, ) -> Result<RenderReport, LayeredVisualizationError>
Draws a heatmap, overlays a budgeted particle field, and presents the target with one command encoder and one queue submission.
This fused path avoids synchronously submitting each layer and leaves substantially more CPU time for an expensive host simulation. The target should have the presentation surface’s aspect ratio; lowering both dimensions proportionally bounds raster cost without changing the logical camera contract.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub async fn new(
surface_target: impl Into<SurfaceTarget<'static>>,
width: u32,
height: u32,
) -> Result<Self, RendererInitError>
pub async fn new( surface_target: impl Into<SurfaceTarget<'static>>, width: u32, height: u32, ) -> Result<Self, RendererInitError>
Creates a renderer for a window or canvas surface target.
width and height are physical surface pixels. Zero sizes are clamped
to one pixel because wgpu surfaces cannot be configured at zero size.
This convenience constructor assumes a display scale factor of 1.0;
HiDPI hosts should use WgpuRenderer::new_with_options.
Sourcepub async fn new_with_options(
surface_target: impl Into<SurfaceTarget<'static>>,
width: u32,
height: u32,
options: WgpuRendererOptions,
) -> Result<Self, RendererInitError>
pub async fn new_with_options( surface_target: impl Into<SurfaceTarget<'static>>, width: u32, height: u32, options: WgpuRendererOptions, ) -> Result<Self, RendererInitError>
Creates a renderer with explicit options.
Use this when measuring renderer throughput or when the host application needs control over presentation behavior or display scale.
Sourcepub fn logical_size(&self) -> (f32, f32)
pub fn logical_size(&self) -> (f32, f32)
Returns the render viewport size in logical screen pixels.
Scene clipping, stroke widths, shadows, and camera zoom use this logical coordinate space so their visual size remains stable across display DPI.
Sourcepub fn logical_viewport(&self) -> Result<LogicalViewport, LogicalViewportError>
pub fn logical_viewport(&self) -> Result<LogicalViewport, LogicalViewportError>
Returns the current camera viewport in logical screen pixels.
Sourcepub fn physical_to_logical_screen(
&self,
position: PhysicalScreenPosition,
) -> Result<LogicalScreenPosition, RendererCoordinateError>
pub fn physical_to_logical_screen( &self, position: PhysicalScreenPosition, ) -> Result<LogicalScreenPosition, RendererCoordinateError>
Converts a physical surface position into logical screen pixels.
Sourcepub fn logical_to_physical_screen(
&self,
position: LogicalScreenPosition,
) -> Result<PhysicalScreenPosition, RendererCoordinateError>
pub fn logical_to_physical_screen( &self, position: LogicalScreenPosition, ) -> Result<PhysicalScreenPosition, RendererCoordinateError>
Converts a logical screen position into physical surface pixels.
Sourcepub fn scale_factor(&self) -> f64
pub fn scale_factor(&self) -> f64
Returns physical surface pixels per logical screen pixel.
Sourcepub fn surface_present_mode(&self) -> RendererSurfacePresentMode
pub fn surface_present_mode(&self) -> RendererSurfacePresentMode
Returns the concrete presentation mode selected for the active surface.
RendererPresentMode::NoVsync prefers Immediate, then Mailbox, then
FIFO. This method reveals which supported fallback was configured. The
desktop compositor may still pace host redraw callbacks independently.
Sourcepub fn quarantined_device_count(&self) -> usize
pub fn quarantined_device_count(&self) -> usize
Returns previous logical devices retained for safe native-driver teardown.
Sourcepub fn max_quarantined_device_count(&self) -> usize
pub fn max_quarantined_device_count(&self) -> usize
Returns the configured maximum previous-device quarantine size.
Sourcepub fn remaining_device_recoveries(&self) -> usize
pub fn remaining_device_recoveries(&self) -> usize
Returns successful recoveries available before the bounded quarantine is full.
Sourcepub fn wait_for_gpu_idle(&self) -> Result<(), PollError>
pub fn wait_for_gpu_idle(&self) -> Result<(), PollError>
Blocks until all previously submitted GPU work has completed.
This is intended for diagnostic throughput measurements, readback, and controlled resource teardown. Calling it in an interactive frame loop defeats normal CPU/GPU pipelining.
Sourcepub fn set_scale_factor(
&mut self,
scale_factor: f64,
) -> Result<(), RendererConfigurationError>
pub fn set_scale_factor( &mut self, scale_factor: f64, ) -> Result<(), RendererConfigurationError>
Replaces display scale without changing physical surface dimensions.
Invalid values return an error and leave the current scale unchanged.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Reconfigures the surface after a host window resize.
Zero width or height is ignored because minimized windows often report
zero size and wgpu cannot configure a zero-sized surface.
Sourcepub fn resize_with_scale_factor(
&mut self,
width: u32,
height: u32,
scale_factor: f64,
) -> Result<(), RendererConfigurationError>
pub fn resize_with_scale_factor( &mut self, width: u32, height: u32, scale_factor: f64, ) -> Result<(), RendererConfigurationError>
Reconfigures physical surface size and logical-to-physical display scale.
Invalid scale returns an error without changing either value. Zero physical dimensions update the scale but leave the minimized surface configuration unchanged.
Sourcepub fn render(
&mut self,
scene: &Scene,
camera: &Camera2d,
) -> Result<RenderStatus, RendererFrameError>
pub fn render( &mut self, scene: &Scene, camera: &Camera2d, ) -> Result<RenderStatus, RendererFrameError>
Draws a scene using the supplied camera.
Scene positions and sizes are in world units unless a style explicitly
says logical screen pixels. The renderer converts world coordinates to
logical screen coordinates through Camera2d, then to normalized device
coordinates for wgpu. Scissor rectangles are converted to physical
surface pixels at the final backend boundary.
Sourcepub fn render_with_metrics(
&mut self,
scene: &Scene,
camera: &Camera2d,
) -> Result<RenderReport, RendererFrameError>
pub fn render_with_metrics( &mut self, scene: &Scene, camera: &Camera2d, ) -> Result<RenderReport, RendererFrameError>
Draws a scene and returns a CPU-side timing breakdown.
Metrics separate tessellation, buffer upload, surface acquisition, and
encode/submit/present dispatch. They do not measure GPU completion or the
monitor scanout timestamp. Use this for diagnostics; WgpuRenderer::render
is the simpler equivalent when stage timings are not needed.
Sourcepub fn prepare_scene(
&self,
scene: &Scene,
) -> Result<PreparedScene, PreparedSceneError>
pub fn prepare_scene( &self, scene: &Scene, ) -> Result<PreparedScene, PreparedSceneError>
Tessellates a scene once and uploads immutable geometry to a dedicated GPU buffer.
Preparing is appropriate for geometry that will be drawn repeatedly while only the camera or target dimensions change. Any shape, style, gradient, ordering, or clipping change requires preparing a replacement scene.
Sourcepub fn restore_prepared_scene(
&self,
source: &PreparedScene,
) -> Result<PreparedScene, PreparedSceneError>
pub fn restore_prepared_scene( &self, source: &PreparedScene, ) -> Result<PreparedScene, PreparedSceneError>
Recreates prepared GPU resources on this renderer from a retained CPU snapshot.
This supports renderer recreation after device loss without requiring the
original high-level Scene. The returned snapshot belongs to this renderer.
Sourcepub fn restore_dynamic_mesh(
&self,
source: &DynamicMesh2d,
) -> Result<DynamicMesh2d, DynamicMeshError>
pub fn restore_dynamic_mesh( &self, source: &DynamicMesh2d, ) -> Result<DynamicMesh2d, DynamicMeshError>
Recreates a dynamic mesh on this renderer from its retained CPU vertices.
Use this after recreating a renderer following device loss. The returned mesh belongs to this renderer and preserves the source mesh’s capacity so subsequent updates retain the same allocation behavior.
Sourcepub fn create_dynamic_mesh(
&self,
vertices: &[DynamicVertex2d],
) -> Result<DynamicMesh2d, DynamicMeshError>
pub fn create_dynamic_mesh( &self, vertices: &[DynamicVertex2d], ) -> Result<DynamicMesh2d, DynamicMeshError>
Creates mutable triangle-list geometry for a frequently changing visual.
The vertex count must be divisible by three. The mesh is owned by this renderer and may only be updated or drawn through it.
Sourcepub fn update_dynamic_mesh(
&self,
mesh: &mut DynamicMesh2d,
vertices: &[DynamicVertex2d],
) -> Result<(), DynamicMeshError>
pub fn update_dynamic_mesh( &self, mesh: &mut DynamicMesh2d, vertices: &[DynamicVertex2d], ) -> Result<(), DynamicMeshError>
Replaces all dynamic mesh vertices, growing GPU capacity only when needed.
Sourcepub fn update_dynamic_mesh_with_metrics(
&self,
mesh: &mut DynamicMesh2d,
vertices: &[DynamicVertex2d],
) -> Result<DynamicMeshUpdateReport, DynamicMeshError>
pub fn update_dynamic_mesh_with_metrics( &self, mesh: &mut DynamicMesh2d, vertices: &[DynamicVertex2d], ) -> Result<DynamicMeshUpdateReport, DynamicMeshError>
Replaces all dynamic mesh vertices and returns CPU-side update metrics.
Sourcepub fn update_dynamic_mesh_range(
&self,
mesh: &mut DynamicMesh2d,
first_vertex: usize,
vertices: &[DynamicVertex2d],
) -> Result<(), DynamicMeshError>
pub fn update_dynamic_mesh_range( &self, mesh: &mut DynamicMesh2d, first_vertex: usize, vertices: &[DynamicVertex2d], ) -> Result<(), DynamicMeshError>
Replaces a contiguous vertex range without reallocating the mesh buffer.
The range must stay inside the current triangle list and its length must preserve triangle alignment, so callers cannot create partial triangles.
Sourcepub fn update_dynamic_mesh_range_with_metrics(
&self,
mesh: &mut DynamicMesh2d,
first_vertex: usize,
vertices: &[DynamicVertex2d],
) -> Result<DynamicMeshUpdateReport, DynamicMeshError>
pub fn update_dynamic_mesh_range_with_metrics( &self, mesh: &mut DynamicMesh2d, first_vertex: usize, vertices: &[DynamicVertex2d], ) -> Result<DynamicMeshUpdateReport, DynamicMeshError>
Replaces a triangle-aligned range and returns CPU-side update metrics.
Sourcepub fn render_dynamic_mesh(
&mut self,
mesh: &DynamicMesh2d,
background: Color,
camera: &Camera2d,
) -> Result<RenderStatus, DynamicMeshRenderError>
pub fn render_dynamic_mesh( &mut self, mesh: &DynamicMesh2d, background: Color, camera: &Camera2d, ) -> Result<RenderStatus, DynamicMeshRenderError>
Draws dynamic triangle-list geometry with a normalized clear color.
Sourcepub fn render_dynamic_mesh_with_metrics(
&mut self,
mesh: &DynamicMesh2d,
background: Color,
camera: &Camera2d,
) -> Result<RenderReport, DynamicMeshRenderError>
pub fn render_dynamic_mesh_with_metrics( &mut self, mesh: &DynamicMesh2d, background: Color, camera: &Camera2d, ) -> Result<RenderReport, DynamicMeshRenderError>
Draws dynamic triangle-list geometry and returns per-frame CPU metrics.
Sourcepub fn create_particle_field(
&self,
instances: &[ParticleInstance2d],
) -> Result<ParticleField2d, ParticleFieldError>
pub fn create_particle_field( &self, instances: &[ParticleInstance2d], ) -> Result<ParticleField2d, ParticleFieldError>
Creates an instanced particle field owned by this renderer.
Each instance draws as one screen-space circle quad through a single GPU draw call. The retained CPU snapshot enables later restoration on a recreated renderer.
Sourcepub fn create_particle_field_with_budget(
&self,
instances: &[ParticleInstance2d],
budget: ParticleRenderBudget,
) -> Result<ParticleField2d, ParticleFieldError>
pub fn create_particle_field_with_budget( &self, instances: &[ParticleInstance2d], budget: ParticleRenderBudget, ) -> Result<ParticleField2d, ParticleFieldError>
Creates an instanced particle field with hard GPU-memory and upload limits.
Sourcepub fn set_particle_field_budget(
&self,
field: &mut ParticleField2d,
budget: ParticleRenderBudget,
) -> Result<(), ParticleFieldError>
pub fn set_particle_field_budget( &self, field: &mut ParticleField2d, budget: ParticleRenderBudget, ) -> Result<(), ParticleFieldError>
Replaces a particle field’s hard resource budget, shrinking memory when required.
Sourcepub fn update_particle_field(
&self,
field: &mut ParticleField2d,
instances: &[ParticleInstance2d],
) -> Result<ParticleStatistics, ParticleFieldError>
pub fn update_particle_field( &self, field: &mut ParticleField2d, instances: &[ParticleInstance2d], ) -> Result<ParticleStatistics, ParticleFieldError>
Replaces all particle instances, reusing GPU capacity whenever possible.
Sourcepub fn update_particle_field_with_metrics(
&self,
field: &mut ParticleField2d,
instances: &[ParticleInstance2d],
) -> Result<ParticleFieldUpdateReport, ParticleFieldError>
pub fn update_particle_field_with_metrics( &self, field: &mut ParticleField2d, instances: &[ParticleInstance2d], ) -> Result<ParticleFieldUpdateReport, ParticleFieldError>
Replaces all particle instances and returns CPU-side preparation metrics.
Sourcepub fn update_particle_field_range(
&self,
field: &mut ParticleField2d,
first_instance: usize,
instances: &[ParticleInstance2d],
) -> Result<ParticleStatistics, ParticleFieldError>
pub fn update_particle_field_range( &self, field: &mut ParticleField2d, first_instance: usize, instances: &[ParticleInstance2d], ) -> Result<ParticleStatistics, ParticleFieldError>
Replaces a contiguous particle range without reallocating its GPU buffer.
Sourcepub fn update_particle_field_range_with_metrics(
&self,
field: &mut ParticleField2d,
first_instance: usize,
instances: &[ParticleInstance2d],
) -> Result<ParticleFieldUpdateReport, ParticleFieldError>
pub fn update_particle_field_range_with_metrics( &self, field: &mut ParticleField2d, first_instance: usize, instances: &[ParticleInstance2d], ) -> Result<ParticleFieldUpdateReport, ParticleFieldError>
Replaces a particle range and returns CPU-side preparation metrics.
Sourcepub fn restore_particle_field(
&self,
source: &ParticleField2d,
) -> Result<ParticleField2d, ParticleFieldError>
pub fn restore_particle_field( &self, source: &ParticleField2d, ) -> Result<ParticleField2d, ParticleFieldError>
Recreates a particle field on this renderer from retained CPU instances.
Sourcepub fn create_scalar_field_texture(
&self,
field: ScalarField,
) -> Result<ScalarFieldTexture, ScalarFieldTextureError>
pub fn create_scalar_field_texture( &self, field: ScalarField, ) -> Result<ScalarFieldTexture, ScalarFieldTextureError>
Creates a single-channel floating-point texture from a validated scalar grid.
Sourcepub fn create_render_target(
&self,
width: u32,
height: u32,
) -> Result<RenderTarget2d, RenderTargetError>
pub fn create_render_target( &self, width: u32, height: u32, ) -> Result<RenderTarget2d, RenderTargetError>
Creates an offscreen target with physical texture dimensions.
Sourcepub fn create_trail_buffer(
&mut self,
width: u32,
height: u32,
) -> Result<TrailBuffer2d, RenderTargetError>
pub fn create_trail_buffer( &mut self, width: u32, height: u32, ) -> Result<TrailBuffer2d, RenderTargetError>
Creates an empty ping-pong target pair for temporal accumulation.
Sourcepub fn restore_render_target(
&self,
source: &RenderTarget2d,
) -> Result<RenderTarget2d, RenderTargetError>
pub fn restore_render_target( &self, source: &RenderTarget2d, ) -> Result<RenderTarget2d, RenderTargetError>
Recreates an empty target with the source dimensions after device recovery.
GPU pixels are deliberately not retained; callers redraw their source state into the restored target.
Sourcepub fn restore_trail_buffer(
&mut self,
source: &TrailBuffer2d,
) -> Result<TrailBuffer2d, RenderTargetError>
pub fn restore_trail_buffer( &mut self, source: &TrailBuffer2d, ) -> Result<TrailBuffer2d, RenderTargetError>
Recreates an empty, deterministically cleared trail buffer after recovery.
Sourcepub fn accumulate_trail_buffer(
&mut self,
trails: &mut TrailBuffer2d,
source: &RenderTarget2d,
retention: f32,
source_opacity: f32,
source_blend: BlendMode,
) -> Result<RenderReport, RenderTargetError>
pub fn accumulate_trail_buffer( &mut self, trails: &mut TrailBuffer2d, source: &RenderTarget2d, retention: f32, source_opacity: f32, source_blend: BlendMode, ) -> Result<RenderReport, RenderTargetError>
Retains one bounded frame of history and composites a fresh source target.
retention and source_opacity must be finite values in 0.0..=1.0.
The source must be a distinct target; use WgpuRenderer::clear_trail_buffer
to discard accumulated history deterministically.
Sourcepub fn clear_trail_buffer(
&mut self,
trails: &mut TrailBuffer2d,
color: Color,
) -> Result<RenderReport, RenderTargetError>
pub fn clear_trail_buffer( &mut self, trails: &mut TrailBuffer2d, color: Color, ) -> Result<RenderReport, RenderTargetError>
Clears both ping-pong targets, resetting all retained temporal history.
Sourcepub fn compose_trail_buffer(
&mut self,
trails: &TrailBuffer2d,
blend_mode: BlendMode,
opacity: f32,
background: Color,
) -> Result<RenderReport, RenderTargetError>
pub fn compose_trail_buffer( &mut self, trails: &TrailBuffer2d, blend_mode: BlendMode, opacity: f32, background: Color, ) -> Result<RenderReport, RenderTargetError>
Presents the most recently accumulated temporal target.
Sourcepub fn update_scalar_field_texture(
&self,
texture: &mut ScalarFieldTexture,
field: ScalarField,
) -> Result<ScalarFieldUploadReport, ScalarFieldTextureError>
pub fn update_scalar_field_texture( &self, texture: &mut ScalarFieldTexture, field: ScalarField, ) -> Result<ScalarFieldUploadReport, ScalarFieldTextureError>
Replaces scalar data, recreating the texture only when dimensions change.
Sourcepub fn update_scalar_field_texture_region(
&self,
texture: &mut ScalarFieldTexture,
x: usize,
y: usize,
width: usize,
height: usize,
values: &[f32],
) -> Result<ScalarFieldUploadReport, ScalarFieldTextureError>
pub fn update_scalar_field_texture_region( &self, texture: &mut ScalarFieldTexture, x: usize, y: usize, width: usize, height: usize, values: &[f32], ) -> Result<ScalarFieldUploadReport, ScalarFieldTextureError>
Updates a rectangular scalar texture region without recreating it.
Sourcepub fn restore_scalar_field_texture(
&self,
source: &ScalarFieldTexture,
) -> Result<ScalarFieldTexture, ScalarFieldTextureError>
pub fn restore_scalar_field_texture( &self, source: &ScalarFieldTexture, ) -> Result<ScalarFieldTexture, ScalarFieldTextureError>
Recreates a scalar texture on this renderer from its retained CPU grid.
Sourcepub fn render_scalar_field_texture(
&mut self,
texture: &ScalarFieldTexture,
color_map: &ColorMap,
value_range: (f32, f32),
background: Color,
) -> Result<RenderStatus, ScalarFieldRenderError>
pub fn render_scalar_field_texture( &mut self, texture: &ScalarFieldTexture, color_map: &ColorMap, value_range: (f32, f32), background: Color, ) -> Result<RenderStatus, ScalarFieldRenderError>
Draws a scalar texture across the logical viewport through a color map.
value_range maps minimum to the first color-map entry and maximum
to the last. Values outside the range clamp to those endpoints.
Sourcepub fn render_scalar_field_texture_with_metrics(
&mut self,
texture: &ScalarFieldTexture,
color_map: &ColorMap,
(minimum, maximum): (f32, f32),
background: Color,
) -> Result<RenderReport, ScalarFieldRenderError>
pub fn render_scalar_field_texture_with_metrics( &mut self, texture: &ScalarFieldTexture, color_map: &ColorMap, (minimum, maximum): (f32, f32), background: Color, ) -> Result<RenderReport, ScalarFieldRenderError>
Draws a scalar texture and returns normal CPU-side renderer metrics.
Sourcepub fn render_scalar_field_texture_with_sampling(
&mut self,
texture: &ScalarFieldTexture,
color_map: &ColorMap,
(minimum, maximum): (f32, f32),
sampling: ScalarFieldSampling,
background: Color,
) -> Result<RenderStatus, ScalarFieldRenderError>
pub fn render_scalar_field_texture_with_sampling( &mut self, texture: &ScalarFieldTexture, color_map: &ColorMap, (minimum, maximum): (f32, f32), sampling: ScalarFieldSampling, background: Color, ) -> Result<RenderStatus, ScalarFieldRenderError>
Draws a scalar texture with an explicit texel sampling mode.
Sourcepub fn render_scalar_field_texture_to_target(
&mut self,
target: &RenderTarget2d,
texture: &ScalarFieldTexture,
color_map: &ColorMap,
value_range: (f32, f32),
background: Color,
) -> Result<RenderReport, ScalarFieldRenderError>
pub fn render_scalar_field_texture_to_target( &mut self, target: &RenderTarget2d, texture: &ScalarFieldTexture, color_map: &ColorMap, value_range: (f32, f32), background: Color, ) -> Result<RenderReport, ScalarFieldRenderError>
Renders a scalar heatmap into an offscreen target instead of presenting it.
Sourcepub fn render_scalar_field_texture_to_target_with_sampling(
&mut self,
target: &RenderTarget2d,
texture: &ScalarFieldTexture,
color_map: &ColorMap,
(minimum, maximum): (f32, f32),
sampling: ScalarFieldSampling,
background: Color,
) -> Result<RenderReport, ScalarFieldRenderError>
pub fn render_scalar_field_texture_to_target_with_sampling( &mut self, target: &RenderTarget2d, texture: &ScalarFieldTexture, color_map: &ColorMap, (minimum, maximum): (f32, f32), sampling: ScalarFieldSampling, background: Color, ) -> Result<RenderReport, ScalarFieldRenderError>
Renders a scalar heatmap into a target with explicit source sampling.
Sourcepub fn compose_render_target(
&mut self,
target: &RenderTarget2d,
blend_mode: BlendMode,
opacity: f32,
background: Color,
) -> Result<RenderReport, RenderTargetError>
pub fn compose_render_target( &mut self, target: &RenderTarget2d, blend_mode: BlendMode, opacity: f32, background: Color, ) -> Result<RenderReport, RenderTargetError>
Composes a previously rendered target over the presentation surface.
Sourcepub fn render_particle_field(
&mut self,
field: &mut ParticleField2d,
background: Color,
camera: &Camera2d,
) -> Result<RenderStatus, ParticleFieldRenderError>
pub fn render_particle_field( &mut self, field: &mut ParticleField2d, background: Color, camera: &Camera2d, ) -> Result<RenderStatus, ParticleFieldRenderError>
Draws a particle field with a normalized clear color.
Sourcepub fn render_particle_field_with_metrics(
&mut self,
field: &mut ParticleField2d,
background: Color,
camera: &Camera2d,
) -> Result<RenderReport, ParticleFieldRenderError>
pub fn render_particle_field_with_metrics( &mut self, field: &mut ParticleField2d, background: Color, camera: &Camera2d, ) -> Result<RenderReport, ParticleFieldRenderError>
Draws a particle field and returns regular per-frame renderer metrics.
Sourcepub fn render_particle_field_to_target(
&mut self,
target: &RenderTarget2d,
field: &mut ParticleField2d,
camera: &Camera2d,
load: RenderTargetLoad,
) -> Result<RenderReport, ParticleFieldRenderError>
pub fn render_particle_field_to_target( &mut self, target: &RenderTarget2d, field: &mut ParticleField2d, camera: &Camera2d, load: RenderTargetLoad, ) -> Result<RenderReport, ParticleFieldRenderError>
Draws a particle field into an offscreen target.
Target dimensions may be lower than the presentation surface to bound raster cost. Camera coordinates and particle radii remain expressed in logical presentation pixels, so composing the target back to the surface preserves layout while trading only raster resolution.
Sourcepub fn render_prepared(
&mut self,
scene: &PreparedScene,
camera: &Camera2d,
) -> Result<RenderStatus, PreparedSceneRenderError>
pub fn render_prepared( &mut self, scene: &PreparedScene, camera: &Camera2d, ) -> Result<RenderStatus, PreparedSceneRenderError>
Draws geometry previously uploaded by WgpuRenderer::prepare_scene.
Camera and viewport changes are applied by the vertex shader and do not rebuild or re-upload the prepared geometry.
Sourcepub fn render_prepared_with_metrics(
&mut self,
scene: &PreparedScene,
camera: &Camera2d,
) -> Result<RenderReport, PreparedSceneRenderError>
pub fn render_prepared_with_metrics( &mut self, scene: &PreparedScene, camera: &Camera2d, ) -> Result<RenderReport, PreparedSceneRenderError>
Draws prepared geometry and reports per-frame CPU timing.
Tessellation and geometry upload durations are zero because both happened
in WgpuRenderer::prepare_scene. The camera uniform is still updated
once per frame.