vello_hybrid: Avoid preserving draw state in WebGL state guard (#1874)

After looking into why the initial synchronous part of the probe runs so
slowly on some devices, I noticed that a specific `getParameter` call is
the issue, forcing a flush and therefore blocking the main thread for a
very long time (more than 1 second):

<img width="867" height="275" alt="image"
src="https://github.com/user-attachments/assets/db17e0e3-5e8f-4f7a-835d-f98754e87469"
/>

Because of these footguns, we want to get rid of all `getParameter`
calls in the long term, but in order to keep the code simple this PR
only removes part of them for now. The contract is now that each method
that performs draw calls must set all of these parameters explicitly
themself, and we don't guarantee to restore the original values after
vello is done. This currently does has the consequence that we often
emit state-change calls unnecessarily (by changing the state to a value
that was already set), but optimizing this is for the future.

With this change in place, the synchronous probe part only takes a few
milliseconds now on that device!

Take this analysis with a grain of salt, but it seems like
`ACTIVE_TEXTURE` is the main hazard remaining right now:
<img width="972" height="493" alt="image"
src="https://github.com/user-attachments/assets/17a51ddf-125d-4504-bcee-2c23f852d061"
/>
2 files changed
tree: 645f41ef40d6ec5b985f5a12f528bbf338ef3c57
  1. .cargo/
  2. .github/
  3. .vscode/
  4. doc/
  5. examples/
  6. glifo/
  7. sparse_strips/
  8. vello/
  9. vello_encoding/
  10. vello_shaders/
  11. vello_tests/
  12. xtask/
  13. .clippy.toml
  14. .gitattributes
  15. .gitignore
  16. .taplo.toml
  17. .typos.toml
  18. AUTHORS
  19. Cargo.lock
  20. Cargo.toml
  21. CHANGELOG.md
  22. LICENSE-APACHE
  23. LICENSE-MIT
  24. README.md
  25. rustfmt.toml
README.md

Vello

A GPU compute-centric 2D renderer

Linebender Zulip dependency status Apache 2.0 or MIT license. wgpu version

Crates.io Docs Build status

The Vello project is a set of high-performance vector renderers written in Rust:

  • Vello is an experimental renderer with a focus on doing as much work as possible with GPU compute.
  • Vello CPU is a pure Rust, CPU-only renderer optimized for multithreading and SIMD.
  • Vello Hybrid is a renderer that does heavy pre-processing on the CPU but still does most of the work on the GPU. It aims to be the main Vello implementation for production use-cases.

Quickstart to run an example program:

cargo run -p with_winit

image

Significant changes are documented in the changelog.

Motivation

Vello is meant to fill the same place in the graphics stack as other vector graphics renderers like Skia, Cairo, and its predecessor project Piet. On a basic level, that means it provides tools to render shapes, images, gradients, text, etc, using a PostScript-inspired API, the same that powers SVG files and the browser <canvas> element.

The selling point of Vello's implementations is that they get better performance than other renderers by better leveraging the SIMD, multithreading and the GPU.

Minimum supported Rust Version (MSRV)

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

Community

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.

License

Licensed under either of

at your option.

In addition, all files in the vello_shaders/shader and vello_shaders/src/cpu directories and subdirectories thereof are alternatively licensed under the Unlicense (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 examples/assets directory are licensed solely under their respective licenses, available in the LICENSE file in their directories.