GPUI currently implements paths in two ways: - A remnant of a Loop-Blinn shader (which doesn't quite work because the winding accumulation is missing). - Tessellating paths on the CPU with `lyon` and uploading the triangles to the GPU. Tessellated triangles have no curve coordinates, so Loop-Blinn's analytic antialiasing doesn't help them. To antialias them, we used 4x MSAA instead. This was particularly problematic: - MSAA has an enormous bandwidth and memory cost relative to the quality of the result (5 coverage levels). - Many lower-end GPUs can't afford MSAA on the main render target. So, paths rendered into a separate MSAA target, which was resolved into an intermediate texture and then drawn onto the main target. These textures cost extra memory. - The MSAA draw and resolve happened per path batch. We didn't use a single path atlas, because in principle its memory use is unbounded. This dramatically magnifies the bandwidth cost of path rendering, especially on tile-based GPUs, since every batch switches render passes mid-frame. We present a new path renderer that computes analytic coverage per pixel from the winding number. Coverage is computed as in Eric Lengyel's Slug: we cast rays leftward and upward from the pixel and count crossings with the path's curves. Crossings within the pixel contribute partial winding. GPUI paths can be larger and more complex than glyphs. But since they're built at a fixed scale in screen space, we can do some of the spatial work on the CPU: - `PathBuilder` turns each contour into closed chains of monotone quadratic curves. - The curves are binned into square cells, where each cell lists only the curves near it. Cell size is picked per path to balance binning cost against shading cost. - For each cell, the CPU computes a *backdrop* value that encodes the winding contribution of all the curves it doesn't list. - Neighboring cells with the same curve list and backdrop merge into rectangular tiles. A large rectangle becomes nine tiles: four corners, four edges, and a solid interior with no listed curves. - Each tile is one GPU instance, and the shader loops only over that tile's curves. Tiles are drawn in the main render pass alongside every other primitive. There's no MSAA, no intermediate textures, no extra render passes or resolves, and no tessellation. --- Binning has a different cost profile from tessellation: - The tessellator's work happened almost entirely in `PathBuilder::build()`. Binning depends on the display scale, so it happens in `paint_path`. Code that caches and reuses `Path`s pays binning cost on every paint. However, this doesn't seem to be a common pattern, so mitigations are deferred. - In general, fills are about as fast as before or slightly faster, while strokes are 2–8× slower. `lyon` has a dedicated stroke tessellator that emits triangles directly along the stroke. We convert the stroke to an outline with `tiny-skia`, then bin it like any other fill. Long, sprawling strokes are the worst case (a 1,000-point scribble takes about 1.5ms now vs 0.2ms before). GPU time is, generally, reduced dramatically. Measured on an Intel HD 4600: | Scene | Before | After | Change | Pixel shader invocations | |---|---|---|---|---| | `painting` example | 9,257µs | 1,928µs | −79% | 1.81M → 1.50M (−17%) | | Git Graph | 19,669µs | 3,828µs | −81% | 3.21M → 3.13M (−2%) | --- Some breaking changes were made to the API: - `Path` is no longer generic and can only be built with `PathBuilder`. Use `PathBuilder`'s equivalents of `Path`'s builder methods. - `PathBuilder` can still be populated from `lyon` path builders, but the places where `lyon`'s tessellator leaked into the API were removed. `StrokeOptions` and `FillOptions` are now GPUI types with fewer options, and `PathBuilder::build_path` is gone. - Since paths now render with analytic antialiasing, you may see conflation artifacts where MSAA didn't have any. Release Notes: - Reduced GPU usage - [GPUI] Improved path rendering performance. `Path` is no longer generic and must be built with `PathBuilder` --------- Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.