Vello Documentation

repository·main·Indexed 26 days ago

https://github.com/linebender/vello

Vello is a GPU compute-centric 2D graphics rendering engine written in Rust that leverages wgpu to render shapes, images, gradients, and text using a PostScript-inspired API. The project includes Glifo for efficient glyph rendering, support for Noto Color Emoji (COLR and CBTF formats), and an experimental 'Sparse Strips' implementation for improved device compatibility on GPUs without compute shader support. It supports integration with Bevy, Lottie animations via velato, and SVG rendering via vello_svg, with deployment targets including WebAssembly and Android.

Tokens
23.9K
Snippets
47
Records
169
Agent score
88%

What's inside Vello

  1. Overview of Vello Sparse Strips implementation

    main

    Vello Sparse Strips is an experimental implementation of the Vello renderer designed to improve device compatibility and performance stability. It aims to run on GPUs without compute shader support (using only fragment and vertex shaders) and handle constrained memory conditions. It is based on the 'sparse rendering approach' which uses efficient tiling, sorting, and sparse strip allocation for both CPU and hybrid CPU/GPU workloads.

    Warning: This implementation is not yet suitable for production use.

  2. Overview of Glifo

    main
    Glifo provides APIs for efficiently rendering glyphs and paint styles (such as underlines). It is designed to accept glyphs and their positions to render them to a surface, utilizing caching to ensure that repeated renders of the same glyph are fast. It also supports sharing expensive data, such as hinting instances and hinted advances, between the shaper and the renderer.
  3. Understand the Vello Imaging Model and Roadmap

    main

    Vello is a GPU-accelerated 2D rendering engine designed for high-quality rendering using compute shaders. The engine is evolving to support a complete imaging model, which includes:

    • Image Support: Implementing image resources via a texture atlas workaround (due to WebGPU 1.0 limitations) to allow sampling from multiple images in a scene.
    • Rectangles: Optimized direct support for rectangles to improve UI rendering performance.
    • Glyph Run API: A dedicated API for glyph runs to move away from purely dynamic vector text rendering and enable efficient glyph caching.
    • Stroke Rework: Moving from distance-field-based strokes to an analytical approach (converting cubic Béziers to Euler spirals) to support diverse stroke styles (miter, etc.) and higher quality thin strokes.
    • Blurs and Filters: Implementation of blurs and filter effects as core imaging primitives.
    • CPU Fallback: A CPU implementation of compute stages is being developed to improve testing, debuggability, and compatibility for systems without competent GPUs or for extremely simple scenes where GPU dispatch overhead is undesirable.
  4. Understand Vello Hybrid architecture

    main

    Vello Hybrid is a hybrid CPU/GPU renderer for 2D vector graphics. It balances performance by using the CPU for path processing and initial geometry setup, while leveraging the GPU for fast rendering, compositing, and blending.

    The architecture consists of two primary components:

    • Scene: Manages the render context and performs path processing on the CPU.
    • Renderer or WebGlRenderer: Handles GPU resource management and executes draw operations.
  5. Understand Vello's rendering quality and anti-aliasing

    main

    Unlike many GPU 2D renderers that rely on fixed-function MSAA (Multi-Sample Anti-Aliasing), Vello uses a compute-centric approach where all pixels are generated by code.

    Key Quality Features:

    • Exact-area Anti-aliasing: Uses an approach similar to libart to prevent the stepping or graininess often seen with low-setting MSAA.
    • Addressing Conflation Artifacts: The architecture allows for swapping soft-alpha compositing with supersampling to eliminate seams when compositing antialiased elements.
    • Gamma Correctness: The vision includes addressing gamma-correct rendering and tone mapping to prevent text and hairline strokes from appearing weak or spindly.
    • Subpixel Rendering: Potential support for per-channel alpha compositing to enable high-quality RGB subpixel rendering for text.
  6. Understand Vello's text rendering approach

    main

    Vello (via the piet-gpu vision) aims to move away from abstracting over platform-specific text capabilities (like DirectWrite or Core Text) toward a unified, Rust-based text layout engine. This ensures consistent results across platforms and enables advanced features like hz-style justification.

    Text rendering is split into two stages:

    1. Text Layout: Determining the positioning and arrangement of characters.
    2. Glyph Painting: The actual rasterization of glyphs onto the screen.

    Currently, Vello's vision for glyph painting includes three potential sources:

    • Platform Bitmaps: High-quality, platform-native bitmaps (e.g., using subpixel RGB rendering) uploaded to a texture atlas.
    • Dynamic Vector Rendering: Rendering directly from glyph outlines, ideal for high-DPI, animations, and zoom gestures.
    • Hybrid Glyph Cache: A managed cache of vector data to balance performance and flexibility.
  7. Use vello_common for shared rendering components

    main

    The vello_common crate provides shared data structures (paths, tiles, strips), geometry processing utilities, and common logic for rendering stages. It is designed as a foundation for vello_cpu and vello_hybrid to minimize duplication.

    Note: This crate is not intended to be used on its own. You should instead use one of the renderers that depend on it. Currently, vello_cpu is the primary published renderer using this crate. If you require high-performance GPU-based 2D rendering, use the main vello crate (which does not use vello_common).

  8. Extend the Vello imaging model

    main

    Vello aims to support a modern 2D imaging model (similar to PDF, SVG, and HTML Canvas) while leveraging GPU capabilities for features that are difficult to implement efficiently in standard APIs.

    Planned/Explored Extensions:

    • Custom Shaders/Effects: Using WebGPU as a portable way to provide extension points (similar to Direct2D's Custom Effects) for things like watercolor brush strokes.
    • HDR Support: Implementing color transformations and tone mapping within the compositing pipeline.
    • Efficient Blurs: Implementing specialized shaders for common UI elements, such as highly optimized shaders for blurred rounded rectangles, to avoid the overhead of large temporary buffer allocations.
  9. Understand Vello's scene encoding and fragment API

    main
    Vello uses a "scene fragment" API rather than a traditional opaque canvas-like API. This design allows scene fragments to be built in multiple threads and then efficiently assembled into a complete scene, which is intended to enable multithreaded UI rendering. The encoding format is designed to be efficient for both CPU generation and GPU consumption. For pre-encoded assets or font glyphs, using 16-bit coordinates can provide approximately a 2x saving in data size compared to 32-bit coordinates.
  10. Explore GPU-side variable font rendering

    main

    Vello envisions offloading variable font rendering to the GPU. Because variable font technology relies on multiplying vectors of "deltas" with basis functions, it is highly suited for massively parallel GPU architectures.

    Potential Benefits:

    • Efficient Animation: Smoothly animating variable font axes.
    • Layout Optimization: Adjusting font axes dynamically to improve paragraph justification or support complex scripts (e.g., Arabic kashida) without performance penalties.