Skip to main content

Crate vello_hybrid

Crate vello_hybrid 

Source
Expand description

A hybrid CPU/GPU renderer for 2D vector graphics.

This crate provides a rendering API that combines CPU and GPU operations for efficient vector graphics processing. The hybrid approach balances flexibility and performance by:

  • Using the CPU for path processing and initial geometry setup
  • Leveraging the GPU for fast rendering and compositing
  • Minimizing data transfer between CPU and GPU

§Key Features

  • Efficient path rendering with CPU-side processing
  • GPU-accelerated compositing and blending
  • Support for both windowed and headless rendering

§Feature Flags

  • wgpu (enabled by default): Enables the GPU rendering backend via wgpu and includes the required sparse shaders.
  • wgpu_default (enabled by default): Enables wgpu with its default hardware backends (such as Vulkan, Metal, and DX12).
  • text (enabled by default): Enables glyph rendering (Scene::glyph_run).
  • webgl: Enables the WebGL rendering backend for browser support, using GLSL shaders for compatibility.

If you need to customize the set of enabled wgpu features, disable this crate’s default features then enable its wgpu feature. You can then depend on wgpu directly, setting the specific features you require. Don’t forget to also disable wgpu’s default features.

§Architecture

The renderer is split into several key components:

  • Scene: Manages the render context and path processing on the CPU
  • Renderer or WebGlRenderer: Handles GPU resource management and executes draw operations

See the individual module documentation for more details on usage and implementation.

§Current state

Vello Hybrid is a solid GPU-accelerated 2D renderer with broad, reliable feature support. Although it does not match Vello Classic’s raw performance on dynamic and vector-heavy workloads, it provides excellent performance on workloads that benefit from GPU acceleration, such as images, gradients, and filters. Overall, we still consider it to be slightly less mature than its CPU-only counterpart Vello CPU.

Vello Hybrid remains under active development. Known limitations include:

  • The following features are not yet supported and will panic: Mask layers, complex filter graphs as well as certain blend modes for non-isolated blending.
  • Parts of the API and its documentation are still suboptimal, for example the lifecycle and ownership of external resources through Resources.
  • Some exposed features remain experimental and are not recommended for use, including glyph caching. Experimental APIs are identified in their method documentation.
  • Parts of the rendering pipeline are not yet fully optimized, particularly the wgpu backend, but also other aspects.
  • Some failures panic instead of being reported through a user-facing error.

With that said, we are continuously improving Vello Hybrid and will address these and other limitations in future releases.

Re-exports§

pub use util::DimensionConstraints;

Modules§

util
A number of utility helper methods.

Structs§

AtlasConfig
Configuration for multiple atlas support.
AtlasId
Unique identifier for an atlas.
AtlasTextureInfo
Current allocation state of the WebGL image/glyph atlas texture.
Config
Configuration for the GPU renderer.
GpuStrip
A GPU strip instance for rendering.
LayersConfig
Configuration for temporary textures used to render layers and effects.
MemorySettings
Settings controlling usage of GPU memory.
Pixmap
A pixmap of premultiplied RGBA8 values backed by u8.
ProbeResult
Probe failure output.
RenderSettings
Settings to apply to the render context.
RenderSize
Dimensions of the rendering target.
RenderTargetConfig
Options for the renderer
Renderer
Vello Hybrid’s Renderer.
Resources
Persistent resources required by Vello Hybrid for rendering.
SampleRect
A rectangular source region sampled from an image input (e.g., crate::TextureId), paired with a transform of the rectangle into the destination.
Scene
A render context for hybrid CPU/GPU rendering.
SizeU16
A size represented by two 16-bit unsigned integers.
TextureBindings
Runtime bindings for externally owned textures sampled by texture-rect draws.
TextureId
A handle to an external, user-provided texture.
WebGlPendingProbe
A WebGL probe whose pixel readback has been queued but not completed.
WebGlRenderer
Vello Hybrid’s WebGL2 Renderer.
WebGlTextureWithDimensions
Wrapper for WebGlTexture with known dimensions.

Enums§

AllocationStrategy
Strategy for allocating images across multiple atlases.
Probe
Result of running the renderer probe.
RenderError
Errors that can occur during rendering.
WebGlProbeError
Error returned while running a WebGL probe.
WebGlProbeStatus
Result of polling the WebGL probe.

Traits§

AtlasWriter
Trait for types that can write image data directly to the atlas texture.
WebGlAtlasWriter
Trait for types that can write image data directly to the atlas texture in WebGL.

Type Aliases§

GlyphRunBuilder
A glyph run builder.