Skip to main content

PassManager

Struct PassManager 

Source
pub struct PassManager {
Show 18 fields pub solid_offscreen: BasicSolidRenderer, pub solid_direct: BasicSolidRenderer, pub transparent_solid_offscreen: BasicSolidRenderer, pub transparent_solid_direct: BasicSolidRenderer, pub solid_direct_no_msaa: BasicSolidRenderer, pub compositor: Compositor, pub blitter: Blitter, pub smaa: SmaaRenderer, pub mask_renderer: BasicSolidRenderer, pub blur_r8: BlurRenderer, pub shadow_comp: ShadowCompositeRenderer, pub text: TextRenderer, pub text_offscreen: TextRenderer, pub image: ImageRenderer, pub image_offscreen: ImageRenderer, pub svg_cache: SvgRasterCache, pub image_cache: ImageCache, pub intermediate_texture: Option<OwnedTexture>, /* private fields */
}

Fields§

§solid_offscreen: BasicSolidRenderer§solid_direct: BasicSolidRenderer§transparent_solid_offscreen: BasicSolidRenderer§transparent_solid_direct: BasicSolidRenderer§solid_direct_no_msaa: BasicSolidRenderer§compositor: Compositor§blitter: Blitter§smaa: SmaaRenderer§mask_renderer: BasicSolidRenderer§blur_r8: BlurRenderer§shadow_comp: ShadowCompositeRenderer§text: TextRenderer§text_offscreen: TextRenderer§image: ImageRenderer§image_offscreen: ImageRenderer§svg_cache: SvgRasterCache§image_cache: ImageCache§intermediate_texture: Option<OwnedTexture>

Implementations§

Source§

impl PassManager

Source

pub fn new(device: Arc<Device>, target_format: TextureFormat) -> Self

Source

pub fn device(&self) -> Arc<Device>

Expose the device for scenes that need to create textures.

Source

pub fn register_external_texture( &mut self, id: ExternalTextureId, view: TextureView, )

Register an externally-rendered texture for compositing in the current frame.

Source

pub fn clear_external_textures(&mut self)

Clear all registered external textures (call after frame).

Source

pub fn create_z_bind_group(&self, z_index: f32, queue: &Queue) -> BindGroup

Create a z-index bind group for the given z-index value. This is used for dynamic depth control in Phase 2.

Source

pub fn draw_image_quad( &self, encoder: &mut CommandEncoder, target_view: &TextureView, origin: [f32; 2], size: [f32; 2], tex_view: &TextureView, queue: &Queue, width: u32, height: u32, )

Render an image texture to the target at origin with size (in pixels, y-down). Expects tex_view to be created from an Rgba8UnormSrgb texture for proper sRGB sampling.

Source

pub fn rasterize_svg_to_view( &mut self, path: &Path, scale: f32, style: Option<SvgStyle>, queue: &Queue, ) -> Option<(TextureView, u32, u32)>

Rasterize an SVG file to a cached texture for the given scale. Returns a texture view and its pixel dimensions on success. Optional style parameter allows overriding fill, stroke, and stroke-width.

Source

pub fn load_image_to_view( &mut self, path: &Path, queue: &Queue, ) -> Option<(TextureView, u32, u32)>

Load a raster image (PNG/JPEG/GIF/WebP) from disk to a cached GPU texture. Returns a texture view and its pixel dimensions on success.

Source

pub fn try_get_image_view( &mut self, path: &Path, ) -> Option<(TextureView, u32, u32)>

Try to get an image from cache without blocking. Returns None if not ready.

Source

pub fn request_image_load(&mut self, path: &Path)

Request an image to be loaded. Marks it as loading if not already in cache.

Source

pub fn is_image_ready(&self, path: &Path) -> bool

Check if an image is ready in the cache.

Source

pub fn store_loaded_image( &mut self, path: &Path, tex: Arc<Texture>, width: u32, height: u32, )

Store a pre-loaded image texture in the cache.

Source

pub fn get_cached_texture( &mut self, path: &Path, ) -> Option<(Arc<Texture>, u32, u32)>

Get a cached texture directly (for updating pixel data in-place). Returns the Arc and dimensions if found.

Source

pub fn set_scale_factor(&mut self, sf: f32)

Set the platform DPI scale factor. On macOS this is used to correct radial gradient centering when using normalized UVs for fullscreen fills.

Source

pub fn set_ui_scale(&mut self, s: f32)

Set author-controlled UI scale multiplier (applies in logical mode).

Source

pub fn set_scroll_offset(&mut self, offset: [f32; 2])

Set the GPU-side scroll offset (in logical pixels, typically negative). This value is written into the viewport uniform so the GPU applies the scroll transform without rebuilding geometry.

Source

pub fn scroll_offset(&self) -> [f32; 2]

Get the current GPU-side scroll offset.

Source

pub fn set_logical_pixels(&mut self, on: bool)

Toggle logical pixel mode.

Source

pub fn alloc_targets( &self, allocator: &mut RenderAllocator, width: u32, height: u32, ) -> PassTargets

Source

pub fn ensure_intermediate_texture( &mut self, allocator: &mut RenderAllocator, width: u32, height: u32, )

Allocate or reuse intermediate texture matching the surface size. This texture is used for Vello-style smooth resizing.

Strategy: Always ensure texture matches exact size for MSAA resolve compatibility. We preserve content by using LoadOp::Load when rendering, not by keeping oversized textures.

Source

pub fn clear_intermediate_texture( &self, encoder: &mut CommandEncoder, clear_color: Color, )

Clear the intermediate texture with the specified color. This should be called before rendering to the intermediate texture.

Source

pub fn blit_to_surface( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, )

Blit the intermediate texture to the surface. This is a very fast operation that enables smooth window resizing (Vello-style).

Source

pub fn ensure_depth_texture( &mut self, allocator: &mut RenderAllocator, width: u32, height: u32, )

Ensure depth texture is allocated and matches the given dimensions. Depth texture is used for z-ordering across all element types (solids, text, images, SVGs).

Source

pub fn depth_view(&self) -> &TextureView

Get the depth texture view for use in render passes. Panics if depth texture hasn’t been allocated via ensure_depth_texture.

Source

pub fn apply_smaa( &mut self, encoder: &mut CommandEncoder, allocator: &mut RenderAllocator, src_view: &TextureView, dst_view: &TextureView, width: u32, height: u32, queue: &Queue, )

Source

pub fn draw_box_shadow( &self, encoder: &mut CommandEncoder, target_view: &TextureView, width: u32, height: u32, rrect: RoundedRect, spec: BoxShadowSpec, queue: &Queue, )

Draw a box shadow for a rounded rect using an R8 mask + separable Gaussian blur pipeline. This composes the tinted shadow beneath current content on the target view.

Source

pub fn draw_overlay_rect( &self, encoder: &mut CommandEncoder, target_view: &TextureView, width: u32, height: u32, rect: Rect, color: ColorLinPremul, queue: &Queue, )

Draw a simple overlay rectangle that darkens existing content without affecting depth. This is intended for UI overlays like modal scrims that should blend over the scene but not participate in depth testing.

Source

pub fn draw_scrim_rect( &self, encoder: &mut CommandEncoder, target_view: &TextureView, width: u32, height: u32, rect: Rect, color: ColorLinPremul, queue: &Queue, )

Draw a full-viewport scrim rectangle that blends over existing content. Unlike draw_overlay_rect, this uses a depth buffer attachment but with:

  • depth_write_enabled = false (doesn’t affect depth buffer)
  • depth_compare = Always (always passes depth test) This allows the scrim to render over all existing content while letting subsequent draws at higher z-index render on top of the scrim.

NOTE: Scrim renders directly to target without MSAA or depth attachment. The scrim pipeline uses depth_compare=Always and depth_write_enabled=false.

Source

pub fn draw_scrim_with_cutout( &mut self, encoder: &mut CommandEncoder, allocator: &mut RenderAllocator, target_view: &TextureView, width: u32, height: u32, hole: RoundedRect, color: ColorLinPremul, queue: &Queue, )

Draw a full scrim but cut out a rounded-rect hole via stencil.

Source

pub fn draw_filled_rounded_rect( &self, encoder: &mut CommandEncoder, target_view: &TextureView, width: u32, height: u32, rrect: RoundedRect, color: ColorLinPremul, queue: &Queue, )

Draw a filled rounded rectangle directly onto the target using the solid_direct pipeline. Uses premultiplied linear color.

Source

pub fn render_solids_to_offscreen( &self, encoder: &mut CommandEncoder, vp_bg: &BindGroup, targets: &PassTargets, scene: &GpuScene, clear_color: Color, queue: &Queue, )

Source

pub fn composite_to_surface( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, offscreen: &PassTargets, clear: Option<Color>, )

Source

pub fn paint_root_to_intermediate( &self, encoder: &mut CommandEncoder, bg: &Background, queue: &Queue, )

Paint background to intermediate texture instead of directly to surface. This enables smooth resizing when combined with blit_to_surface.

Source

pub fn paint_root( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, bg: &Background, queue: &Queue, )

Source

pub fn paint_root_linear_gradient_multi_to_intermediate( &self, encoder: &mut CommandEncoder, start_uv: [f32; 2], end_uv: [f32; 2], stops_in: &[(f32, ColorLinPremul)], queue: &Queue, )

Paint linear gradient to intermediate texture.

Source

pub fn paint_root_linear_gradient_multi( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, start_uv: [f32; 2], end_uv: [f32; 2], stops_in: &[(f32, ColorLinPremul)], queue: &Queue, )

Multi-stop linear gradient background

Source

pub fn paint_root_radial_gradient_multi_to_intermediate( &self, encoder: &mut CommandEncoder, center_uv: [f32; 2], radius: f32, stops_in: &[(f32, ColorLinPremul)], queue: &Queue, width: u32, height: u32, )

Paint radial gradient to intermediate texture.

Source

pub fn paint_root_radial_gradient_multi( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, center_uv: [f32; 2], radius: f32, stops_in: &[(f32, ColorLinPremul)], queue: &Queue, width: u32, height: u32, )

Multi-stop radial gradient background

Source

pub fn paint_root_color( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, color: ColorLinPremul, queue: &Queue, )

Convenience: paint a solid background color directly to the surface.

Source

pub fn paint_root_gradient( &self, encoder: &mut CommandEncoder, surface_view: &TextureView, start_uv: [f32; 2], end_uv: [f32; 2], stop0: (f32, ColorLinPremul), stop1: (f32, ColorLinPremul), queue: &Queue, )

Convenience: paint a simple 2-stop linear gradient to the surface.

Source

pub fn render_unified( &mut self, encoder: &mut CommandEncoder, allocator: &mut RenderAllocator, surface_view: &TextureView, width: u32, height: u32, scene: &GpuScene, transparent_scene: &GpuScene, transparent_batches: &[TransparentBatch], glyph_draws: &[([f32; 2], RasterizedGlyph, ColorLinPremul, i32)], svg_draws: &[(PathBuf, [f32; 2], [f32; 2], Option<SvgStyle>, i32, Transform2D, Option<Rect>)], image_draws: &[(PathBuf, [f32; 2], [f32; 2], i32, Option<Rect>)], external_texture_draws: &[ExtractedExternalTextureDraw], clear: Color, direct: bool, queue: &Queue, preserve_surface: bool, )

Unified rendering: Render all draw types (solids, text, images, SVGs) in a single pass with proper z-ordering. This is Phase 3 of the depth buffer implementation.

This method interleaves all draw calls based on z-index for optimal z-ordering performance. Draw calls are batched by material type when possible for efficiency.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,