sparse_strips: optimize drawing rectangles with active rectangular clips in place (#1926) This PR adds an optimization for drawing rectangles when there is an active rectangular clip in the clip stack. Inside of the clip stack, we now keep track whether the currently active clip path is in fact just a rectangle or some arbitary path. For vello_cpu, when drawing a rectangle we know avoid intersecting it using the strip-intersection algorithm, instead intersecting the rectangle mathematically before processing further. In Vello Hybrid, we can go a step further and now accept the GPU fast-rect path in case the currently active clip path is a rectangle! Something worth noting is that it changes the semantics of some anti-aliasing calculations, but they are now actually more correct than before for this specific case. The `clip_non_isolated_with_aa_with_rect_aa` test now correctly calculates 50% coverage instead of 25%, because we calculate the resulting rectangle by mathematically intersecting it with the clip path (therefore avoiding conflation artifacts) instead of calculating it by multiplying the conflated coverages. It does produce some inconsistency (for example, if you were to run the same test but with push_clip_path instead you would get 25% again), but this new version is technically more correct, so I think it's fine to accept? Note that whenever we call `push_clip_rect`, we still eagerly calculate the strip representation of the rectangle, even if we might not actually need it in case only rectangle are drawn. It might be possible to compute the strips lazily instead, but this sounds complicated enough that I'm going to leave this for a follow-up, if at all. As a result, when drawing thing while constraining the viewport once in the beginning (e.g. when doing dirty rectangle rendering), we are now much faster when drawing many quads! https://github.com/user-attachments/assets/1b897436-a603-42e3-bfaa-d7fa533e4050 https://github.com/user-attachments/assets/2a8be835-b6bf-4a5f-a92a-14d732ccd2b1
High-performance 2D renderers written in Rust
Vello is a project for high-performance 2D vector rendering. It contains three renderer implementations with different hardware requirements and maturity profiles.
vello_cpu is a CPU-only renderer optimized for multithreading and SIMD. It is the most mature choice when predictable CPU rendering, software rendering, or support for devices without a suitable GPU is required.
vello_gpu is a renderer that preprocesses paths on the CPU and uses the GPU for rasterization and compositing. It supports a native WebGL2 backend and a wgpu backend without requiring compute shaders. Choose it when GPU acceleration and broad GPU compatibility are important. Vello GPU is intended to become the primary renderer for production GPU use cases as it matures; Vello CPU is currently overall more mature.
The vello crate is the original compute-centric renderer. It performs most rendering work in GPU compute shaders and remains an experimental implementation for compute-capable GPUs. Its source and supporting crates live under research/.
Vello CPU and Vello GPU share the Sparse Strips architecture and common infrastructure in vello_common. See ARCHITECTURE.md for how the renderer families differ.
Run the windowed example for the renderer you want to try:
# Vello CPU cargo run -p vello_cpu_winit --release # Vello GPU cargo run -p vello_gpu_winit --release # Compute-centric research renderer cargo run -p with_winit --release
Package-specific setup and API examples are in the vello_cpu, vello_gpu, and vello READMEs.
vello_cpu/ and vello_gpu/ contain the user-facing Sparse Strips renderers.vello_common/ and vello_gpu_shaders/ support those renderers.glifo/ provides text and glyph-run support shared by both Sparse Strips renderers.vello_tests/ contains their shared development tests, snapshots, scenes, and browser tooling.research/ contains the compute-centric renderer, its encoding and shader crates, examples, tests, historical design documents, and changelog.vello_bench/ contains Sparse Strips benchmarks.Release histories are maintained in the vello changelog, vello_cpu changelog, vello_gpu changelog, and vello_common changelog.
Vello is intended to fill the same place in the graphics stack as vector renderers such as Skia, Cairo, and its predecessor project Piet. Its renderers draw shapes, images, gradients, and text using a PostScript-inspired imaging model like those behind SVG and the browser <canvas> element.
The implementations explore complementary ways to use SIMD, multithreading, and GPUs while sharing the same broader rendering goals.
This version of Vello has been verified to compile with Rust 1.89 and later.
Future versions of Vello might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases.
As time has passed, some of Vello‘s dependencies could have released versions with a higher Rust requirement. If you encounter a compilation issue due to a dependency and don’t want to upgrade your Rust toolchain, then you could downgrade the dependency.
# Use the problematic dependency's name and version cargo update -p package_name --precise 0.1.1
Discussion of Vello development happens in the Linebender Zulip, specifically the #vello channel. All public content can be read without logging in.
Contributions are welcome by pull request. The Rust code of conduct applies.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache 2.0 license, shall be licensed as noted in the License section, without any additional terms or conditions.
Licensed under either of
at your option.
In addition, all files in the research/vello_shaders/shader and research/vello_shaders/src/cpu directories and subdirectories thereof are alternatively licensed under the Unlicense (research/vello_shaders/shader/UNLICENSE or http://unlicense.org/). For clarity, these files are also licensed under either of the above licenses. The intent is for this research to be used in as broad a context as possible.
The files in subdirectories of the assets directory are licensed solely under their respective licenses, available in the LICENSE file in their directories.