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.
Every external retained GPU resource deliberately keeps the previous
renderer identity and is rejected until restored after this succeeds.
Restore prepared and prepared-screen scenes, dynamic meshes, particle
fields, scalar fields, 2D targets, and trails with their matching
restore_* methods. Restore images before dependent image batches;
glyph atlases before dependent glyph runs; and retained 3D meshes/scenes
before their empty 3D target. Both 2D/3D targets and trails restore
without prior pixels and must be redrawn. See each resource’s
WgpuRenderer::restore_* method for its exact retained-state contract.
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 frame_cache_budget(&self) -> FrameCacheBudget
pub fn frame_cache_budget(&self) -> FrameCacheBudget
Returns renderer-owned idle composition cache limits.
Sourcepub fn set_frame_cache_budget(&mut self, budget: FrameCacheBudget)
pub fn set_frame_cache_budget(&mut self, budget: FrameCacheBudget)
Changes limits and releases the old cache. In-flight resource retirement is handled by wgpu; the next frame warms storage under the new limits.
Sourcepub fn clear_frame_cache(&mut self)
pub fn clear_frame_cache(&mut self)
Releases cached composition allocations and GPU resource references.
Sourcepub fn frame_cache_statistics(&self) -> FrameCacheStatistics
pub fn frame_cache_statistics(&self) -> FrameCacheStatistics
Returns idle retained bytes and the previous composed frame’s cache work. This does not include queue/backend allocations, source geometry, or LUTs.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn begin_frame(
&mut self,
background: Color,
budget: FrameBudget,
) -> Result<FrameComposer<'_>, FrameComposerError>
pub fn begin_frame( &mut self, background: Color, budget: FrameBudget, ) -> Result<FrameComposer<'_>, FrameComposerError>
Begins one bounded heterogeneous frame with a single clear color.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn create_glyph_atlas(
&self,
width: u32,
height: u32,
pixels: Vec<u8>,
entries: Vec<GlyphAtlasEntry>,
budget: GlyphAtlasBudget,
) -> Result<GlyphAtlas2d, GlyphError>
pub fn create_glyph_atlas( &self, width: u32, height: u32, pixels: Vec<u8>, entries: Vec<GlyphAtlasEntry>, budget: GlyphAtlasBudget, ) -> Result<GlyphAtlas2d, GlyphError>
Creates a bounded glyph atlas from exact RGBA pixels and initial entries.
Sourcepub fn upload_glyph(
&self,
atlas: &mut GlyphAtlas2d,
entry: GlyphAtlasEntry,
pixels: &[u8],
) -> Result<GlyphUploadReport, GlyphError>
pub fn upload_glyph( &self, atlas: &mut GlyphAtlas2d, entry: GlyphAtlasEntry, pixels: &[u8], ) -> Result<GlyphUploadReport, GlyphError>
Uploads or replaces one glyph rectangle after complete metadata preflight.
Reusing an identity requires the same rectangle. Changing atlas packing is an explicit new-atlas operation so existing retained runs cannot silently sample unrelated texels.
Sourcepub fn create_glyph_run(
&self,
atlas: &GlyphAtlas2d,
glyphs: Vec<PositionedGlyph2d>,
budget: GlyphRunBudget,
) -> Result<GlyphRun2d, GlyphError>
pub fn create_glyph_run( &self, atlas: &GlyphAtlas2d, glyphs: Vec<PositionedGlyph2d>, budget: GlyphRunBudget, ) -> Result<GlyphRun2d, GlyphError>
Creates one retained instanced run from host-positioned glyph quads.
Sourcepub fn update_glyph_run(
&self,
atlas: &GlyphAtlas2d,
run: &mut GlyphRun2d,
glyphs: &[PositionedGlyph2d],
) -> Result<GlyphRunUploadReport, GlyphError>
pub fn update_glyph_run( &self, atlas: &GlyphAtlas2d, run: &mut GlyphRun2d, glyphs: &[PositionedGlyph2d], ) -> Result<GlyphRunUploadReport, GlyphError>
Updates host-shaped layout while reusing CPU and GPU capacity when possible.
Exact unchanged input uploads nothing; an empty slice clears the drawable run but retains capacity. The atlas must be the run’s original active-device atlas. All glyph sources, bounds and budget checks complete before changing drawable state. Synchronous rejection preserves the previous revision; device failure cannot roll back work already submitted to the queue.
Sourcepub fn restore_glyph_atlas(
&self,
source: &GlyphAtlas2d,
) -> Result<GlyphAtlas2d, GlyphError>
pub fn restore_glyph_atlas( &self, source: &GlyphAtlas2d, ) -> Result<GlyphAtlas2d, GlyphError>
Restores exact atlas pixels and metadata for this renderer generation.
Sourcepub fn restore_glyph_run(
&self,
atlas: &GlyphAtlas2d,
source: &GlyphRun2d,
) -> Result<GlyphRun2d, GlyphError>
pub fn restore_glyph_run( &self, atlas: &GlyphAtlas2d, source: &GlyphRun2d, ) -> Result<GlyphRun2d, GlyphError>
Restores a run against the restored copy of its original atlas.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn update_image_batch(
&self,
image: &Image2d,
batch: &mut ImageBatch2d,
sprites: &[ImageSprite2d],
) -> Result<ImageBatchUploadReport, ImageError>
pub fn update_image_batch( &self, image: &Image2d, batch: &mut ImageBatch2d, sprites: &[ImageSprite2d], ) -> Result<ImageBatchUploadReport, ImageError>
Atomically updates retained sprite descriptions from borrowed input.
Reuses both CPU arrays and the GPU buffer while capacity permits. Equal input submits no upload. Shrinking, including to zero sprites, retains capacity. Growth reserves exact bounded replacement arrays before changing drawable state. Synchronous validation/allocation errors preserve the old batch. Device failure is not a rollback of already submitted GPU work.
The original image and current renderer generation must match. The queue orders uploads after previously submitted draws; the frame borrow prevents updating a batch still referenced by an unsubmitted composer.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn create_image_rgba8(
&self,
width: u32,
height: u32,
pixels: Vec<u8>,
budget: ImageBudget,
) -> Result<Image2d, ImageError>
pub fn create_image_rgba8( &self, width: u32, height: u32, pixels: Vec<u8>, budget: ImageBudget, ) -> Result<Image2d, ImageError>
Creates an image while taking ownership of its exact recovery pixels.
Sourcepub fn create_image_rgba8_from_slice(
&self,
width: u32,
height: u32,
pixels: &[u8],
budget: ImageBudget,
) -> Result<Image2d, ImageError>
pub fn create_image_rgba8_from_slice( &self, width: u32, height: u32, pixels: &[u8], budget: ImageBudget, ) -> Result<Image2d, ImageError>
Copies a bounded byte slice into a retained image recovery snapshot.
Sourcepub fn replace_image_rgba8(
&self,
image: &mut Image2d,
width: u32,
height: u32,
pixels: Vec<u8>,
) -> Result<ImageUploadReport, ImageError>
pub fn replace_image_rgba8( &self, image: &mut Image2d, width: u32, height: u32, pixels: Vec<u8>, ) -> Result<ImageUploadReport, ImageError>
Replaces dimensions and pixels atomically after full preflight.
Sourcepub fn update_image_region(
&self,
image: &mut Image2d,
region: ImageTexelRect,
pixels: &[u8],
) -> Result<ImageUploadReport, ImageError>
pub fn update_image_region( &self, image: &mut Image2d, region: ImageTexelRect, pixels: &[u8], ) -> Result<ImageUploadReport, ImageError>
Uploads one exact row-major RGBA region and updates recovery pixels.
Sourcepub fn restore_image(&self, source: &Image2d) -> Result<Image2d, ImageError>
pub fn restore_image(&self, source: &Image2d) -> Result<Image2d, ImageError>
Recreates an exact image for this renderer from retained source bytes.
Sourcepub fn create_image_batch(
&self,
image: &Image2d,
sprites: Vec<ImageSprite2d>,
budget: ImageBatchBudget,
) -> Result<ImageBatch2d, ImageError>
pub fn create_image_batch( &self, image: &Image2d, sprites: Vec<ImageSprite2d>, budget: ImageBatchBudget, ) -> Result<ImageBatch2d, ImageError>
Creates one retained instanced batch tied to an image or atlas.
Sourcepub fn replace_image_batch(
&self,
image: &Image2d,
batch: &mut ImageBatch2d,
sprites: Vec<ImageSprite2d>,
) -> Result<ImageBatchUploadReport, ImageError>
pub fn replace_image_batch( &self, image: &Image2d, batch: &mut ImageBatch2d, sprites: Vec<ImageSprite2d>, ) -> Result<ImageBatchUploadReport, ImageError>
Updates a batch from owned input, reusing capacity when possible.
Prefer Self::update_image_batch when the host retains its input storage.
Sourcepub fn restore_image_batch(
&self,
image: &Image2d,
source: &ImageBatch2d,
) -> Result<ImageBatch2d, ImageError>
pub fn restore_image_batch( &self, image: &Image2d, source: &ImageBatch2d, ) -> Result<ImageBatch2d, ImageError>
Restores a batch against the restored copy of its original atlas.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn create_texture3d_rgba8(
&self,
width: u32,
height: u32,
pixels: Vec<u8>,
budget: ImageBudget,
) -> Result<Texture3d, Texture3dError>
pub fn create_texture3d_rgba8( &self, width: u32, height: u32, pixels: Vec<u8>, budget: ImageBudget, ) -> Result<Texture3d, Texture3dError>
Creates immutable opaque sRGB RGBA8 texels with shared nearest/linear bindings. Image/device limits and every alpha byte are validated before GPU creation.
Sourcepub fn restore_texture3d(
&self,
source: &Texture3d,
) -> Result<Texture3d, Texture3dError>
pub fn restore_texture3d( &self, source: &Texture3d, ) -> Result<Texture3d, Texture3dError>
Restores exact retained pixels on the current device. Existing handles
remain unchanged; atomic restore_scene3d restores shared textures once.
Sourcepub fn with_mesh3d_material(
&self,
mesh: &RetainedMesh3d,
material: &TextureMaterial3d,
) -> Result<RetainedMesh3d, Texture3dError>
pub fn with_mesh3d_material( &self, mesh: &RetainedMesh3d, material: &TextureMaterial3d, ) -> Result<RetainedMesh3d, Texture3dError>
Associates a shared material with a new retained mesh handle without
allocating/uploading topology. Existing clones and scene users keep
their previous material; rebind selected IDs using Scene3d::set_mesh.
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn create_mesh3d_with_budget(
&self,
source: Mesh3d,
budget: Mesh3dUploadBudget,
) -> Result<RetainedMesh3d, Mesh3dResourceError>
pub fn create_mesh3d_with_budget( &self, source: Mesh3d, budget: Mesh3dUploadBudget, ) -> Result<RetainedMesh3d, Mesh3dResourceError>
Creates an immutable revision with explicit pre-allocation byte limits.
Sourcepub fn replace_mesh3d(
&self,
mesh: &mut RetainedMesh3d,
source: Mesh3d,
budget: Mesh3dUploadBudget,
) -> Result<Mesh3dUploadReport, Mesh3dResourceError>
pub fn replace_mesh3d( &self, mesh: &mut RetainedMesh3d, source: Mesh3d, budget: Mesh3dUploadBudget, ) -> Result<Mesh3dUploadReport, Mesh3dResourceError>
Atomically replaces this retained handle with a newly uploaded revision.
Clones and scene objects referencing the previous revision are unchanged;
use Scene3d::set_mesh to rebind selected live objects. This is immutable
replacement, not a stable-capacity in-place upload. Validation/allocation
errors preserve the old handle; asynchronous device failure is separate.
In-flight work keeps its old references. Nominal transient GPU/source
overlap is at most the old revision plus the incoming configured limits.
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 and texture resources are uploaded once. Per-handle
texture/filter/tint choices remain independent when topology is shared.
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. Wholly inside objects retain their indexed topology; crossing surfaces use bounded homogeneous CPU clipping against all six frustum planes. Ambiguous classification/orientation produces an object-attributed error. Explicit display edges retain their complete interval-validated homogeneous shader clipper.
Sourcepub fn validate_scene3d_for_target(
&self,
target: &RenderTarget3d,
scene: &Scene3d,
camera: Camera3d,
budget: Mesh3dRenderBudget,
) -> Result<Mesh3dPreflightReport, Mesh3dRenderError>
pub fn validate_scene3d_for_target( &self, target: &RenderTarget3d, scene: &Scene3d, camera: Camera3d, budget: Mesh3dRenderBudget, ) -> Result<Mesh3dPreflightReport, Mesh3dRenderError>
Validates every visible object and exact generated clipping work without changing target pixels, retained resources or submitting GPU work.
This is the same authoritative preflight used by rendering. Private bounded scratch may be allocated; the report is not a reusable draw authorization after the scene, target or camera changes.
Sourcepub fn render_scene3d_to_target_with_budget(
&mut self,
target: &RenderTarget3d,
scene: &Scene3d,
camera: Camera3d,
budget: Mesh3dRenderBudget,
) -> Result<Mesh3dRenderReport, Mesh3dRenderError>
pub fn render_scene3d_to_target_with_budget( &mut self, target: &RenderTarget3d, scene: &Scene3d, camera: Camera3d, budget: Mesh3dRenderBudget, ) -> Result<Mesh3dRenderReport, Mesh3dRenderError>
Draws a scene with explicit additional clipping topology limits.
All validation, generated counts and host/GPU capacity checks complete before the first GPU write or target mutation. Numerical ambiguity is attributed to the exact visible object; aggregate capacity remains a scene-level error. Wholly inside objects retain their indexed GPU path.
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<LayeredVisualizationReport, LayeredVisualizationError>
pub fn render_layered_visualization( &mut self, target: &RenderTarget2d, scalar: &ScalarFieldTexture, color_map: &ColorMap, particles: &mut ParticleField2d, camera: &Camera2d, options: LayeredVisualizationOptions, ) -> Result<LayeredVisualizationReport, 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 set_pre_present_notify(
&mut self,
notify: impl Fn() + Send + Sync + 'static,
)
pub fn set_pre_present_notify( &mut self, notify: impl Fn() + Send + Sync + 'static, )
Installs a host callback invoked immediately before synchronized surface presentation.
A winit host should capture its Arc<Window> and call
Window::pre_present_notify from this callback. The renderer invokes
it after command submission and immediately before Queue::present,
but only when the concrete surface mode is Mailbox, FIFO, or
FIFO-relaxed. Immediate presentation deliberately remains uncapped.
Sourcepub fn clear_pre_present_notify(&mut self)
pub fn clear_pre_present_notify(&mut self)
Removes the synchronized-presentation callback, if one is installed.
Sourcepub fn adapter_name(&self) -> &str
pub fn adapter_name(&self) -> &str
Returns the active graphics adapter’s human-readable name.
Sourcepub fn adapter_backend(&self) -> &'static str
pub fn adapter_backend(&self) -> &'static str
Returns the active graphics API backend as a stable lowercase name.
Sourcepub fn adapter_vendor_id(&self) -> u32
pub fn adapter_vendor_id(&self) -> u32
Returns the PCI vendor identifier reported for the active adapter.
Sourcepub fn adapter_device_id(&self) -> u32
pub fn adapter_device_id(&self) -> u32
Returns the device identifier reported for the active adapter.
Sourcepub fn adapter_pci_bus_id(&self) -> &str
pub fn adapter_pci_bus_id(&self) -> &str
Returns the backend-reported PCI bus address for the active adapter.
Vulkan adapters expose this as domain:bus:device.function when the
driver supports VK_EXT_pci_bus_info. An empty string means that the
backend cannot identify a physical adapter instance; release evidence
must not treat model identifiers alone as instance identity.
Sourcepub fn surface_format(&self) -> TextureFormat
pub fn surface_format(&self) -> TextureFormat
Returns the texture format selected for the active presentation surface.
Sourcepub fn surface_sample_count(&self) -> u32
pub fn surface_sample_count(&self) -> u32
Returns the raster sample count selected for the active surface format.
Sourcepub fn adapter_driver(&self) -> &str
pub fn adapter_driver(&self) -> &str
Returns the driver name reported by the active graphics adapter.
Sourcepub fn adapter_driver_info(&self) -> &str
pub fn adapter_driver_info(&self) -> &str
Returns the driver version or implementation detail reported by the adapter.
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,
) -> Result<(), RendererConfigurationError>
pub fn resize( &mut self, width: u32, height: u32, ) -> Result<(), RendererConfigurationError>
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_screen_scene(
&mut self,
scene: &ScreenScene,
) -> Result<RenderStatus, RendererFrameError>
pub fn render_screen_scene( &mut self, scene: &ScreenScene, ) -> Result<RenderStatus, RendererFrameError>
Draws fixed logical-screen geometry independently of any world camera.
Sourcepub fn render_screen_scene_with_metrics(
&mut self,
scene: &ScreenScene,
) -> Result<RenderReport, RendererFrameError>
pub fn render_screen_scene_with_metrics( &mut self, scene: &ScreenScene, ) -> Result<RenderReport, RendererFrameError>
Draws fixed logical-screen geometry and returns CPU-side stage timings.
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 render_scene_in_viewport(
&mut self,
scene: &Scene,
camera: &Camera2d,
viewport: LogicalViewportRegion,
) -> Result<RenderStatus, RendererFrameError>
pub fn render_scene_in_viewport( &mut self, scene: &Scene, camera: &Camera2d, viewport: LogicalViewportRegion, ) -> Result<RenderStatus, RendererFrameError>
Draws a world scene through a camera into one bounded logical viewport.
Scene-local clips are interpreted relative to the viewport and are intersected with its physical bounds. The surface outside the viewport is cleared but receives no scene geometry.
Sourcepub fn render_scene_in_viewport_with_metrics(
&mut self,
scene: &Scene,
camera: &Camera2d,
viewport: LogicalViewportRegion,
) -> Result<RenderReport, RendererFrameError>
pub fn render_scene_in_viewport_with_metrics( &mut self, scene: &Scene, camera: &Camera2d, viewport: LogicalViewportRegion, ) -> Result<RenderReport, RendererFrameError>
Draws one bounded scene viewport and returns CPU-side stage timings.
Sourcepub fn render_scene_to_target(
&mut self,
target: &RenderTarget2d,
scene: &Scene,
camera: &Camera2d,
pixel_scale: PhysicalPerLogical,
viewport: Option<LogicalViewportRegion>,
load: RenderTargetLoad,
) -> Result<RenderReport, RenderTargetError>
pub fn render_scene_to_target( &mut self, target: &RenderTarget2d, scene: &Scene, camera: &Camera2d, pixel_scale: PhysicalPerLogical, viewport: Option<LogicalViewportRegion>, load: RenderTargetLoad, ) -> Result<RenderReport, RenderTargetError>
Renders an ordinary world scene into an offscreen target.
Target dimensions are physical texels. pixel_scale defines their
logical viewport density independently of window DPI. Scene-local clips
are relative to viewport, or to the complete logical target when no
region is supplied. load explicitly controls preservation or clearing.
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 prepare_screen_scene(
&self,
scene: &ScreenScene,
) -> Result<PreparedScreenScene, PreparedSceneError>
pub fn prepare_screen_scene( &self, scene: &ScreenScene, ) -> Result<PreparedScreenScene, PreparedSceneError>
Tessellates fixed logical-screen geometry once for repeated composition.
Sourcepub fn restore_prepared_screen_scene(
&self,
source: &PreparedScreenScene,
) -> Result<PreparedScreenScene, PreparedSceneError>
pub fn restore_prepared_screen_scene( &self, source: &PreparedScreenScene, ) -> Result<PreparedScreenScene, PreparedSceneError>
Restores prepared logical-screen geometry on a recreated renderer.
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 create_dynamic_mesh_with_budget(
&self,
vertices: &[DynamicVertex2d],
budget: DynamicMeshBudget,
) -> Result<DynamicMesh2d, DynamicMeshError>
pub fn create_dynamic_mesh_with_budget( &self, vertices: &[DynamicVertex2d], budget: DynamicMeshBudget, ) -> Result<DynamicMesh2d, DynamicMeshError>
Creates bounded mutable colored triangles for composition in a frame.
Validation and CPU reservation complete before any GPU allocation. The retained budget is also enforced by every later full or partial update.
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.
Every potentially visible triangle must remain fully inside the full
surface clip volume and have a portable projected orientation. A
hardware-clipped or ambiguous triangle returns
DynamicMeshRenderError::Frame(RendererFrameError::InvalidGeometryTransform).
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.
Full-surface clip-volume crossing and association-dependent projected
topology are rejected as
DynamicMeshRenderError::Frame(RendererFrameError::InvalidGeometryTransform).
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 retained-CPU, GPU-memory, upload, visible-instance, and visibility-work 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_screen_scene(
&mut self,
scene: &PreparedScreenScene,
) -> Result<RenderStatus, PreparedSceneRenderError>
pub fn render_prepared_screen_scene( &mut self, scene: &PreparedScreenScene, ) -> Result<RenderStatus, PreparedSceneRenderError>
Draws prepared logical-screen geometry independently of a world camera.
The prepared resource must have been built from a ScreenScene. The
renderer cannot infer the original coordinate space from raw prepared
vertices, so passing world-space geometry is a caller contract error.
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.