Skip to content

Commit da35091

Browse files
committed
Fix doc problems
1 parent da454dd commit da35091

File tree

5 files changed

+53
-36
lines changed

5 files changed

+53
-36
lines changed

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
doc-valid-idents = ["WebGPU", ".."]
1+
doc-valid-idents = ["WebGPU", "PostScript", ".."]

ARCHITECTURE.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11

22
# Architecture
33

4-
This document should be update semi-regularly. Feel free to open an issue if it hasn't been updated in a few years.
4+
This document should be updated semi-regularly. Feel free to open an issue if it hasn't been updated in more than a year.
55

66
## Goals
77

88
The major goal of Vello is to provide a high quality GPU accelerated renderer suitable for a range of 2D graphics applications, including rendering for GUI applications, creative tools, and scientific visualization.
9-
The [roadmap for 2023](doc/roadmap_2023.md) explains the goals and plans for the next few months of development
109

1110
Vello emerges from being a research project, which attempts to answer these hypotheses:
1211

1312
- To what extent is a compute-centered approach better than rasterization ([Direct2D])?
1413
- To what extent do "advanced" GPU features (subgroups, descriptor arrays, device-scoped barriers) help?
1514
- Can we improve quality and extend the imaging model in useful ways?
1615

17-
Another goal of the overall project is to explain how the renderer is built, and to advance the state of building applications on GPU compute shaders more generally.
16+
Another goal of the overall project is to explain how the renderer is built, and to advance the state of building applications on GPU compute shaders more generally.
1817
Much of the progress on Vello is documented in blog entries.
1918
See [doc/blogs.md](doc/blogs.md) for pointers to those.
2019

2120

21+
## Roadmap
22+
23+
The [roadmap for 2023](doc/roadmap_2023.md) is still largely applicable.
24+
The "Semi-stable encoding format" section and most of the "CPU fallback" section can be considered implemented.
25+
26+
Our current priority is to fill in missing features and to fix rendering artifacts, so that Vello can reach feature parity with other 2D graphics engines.
27+
28+
2229
## File structure
2330

2431
The repository is structured as such:
2532

2633
- `crates/`
2734
- `encoding/` - Types that represent the data that needs to be rendered.
28-
- `shaders/` - Infrastructure to compile pipelines and shaders; see "Shader templating".
35+
- `shaders/` - Infrastructure to compile pipelines and shaders; see "Shader templating". Note that the `vello` crate doesn't currently import this crate (see #467).
2936
- `tests/` - Helper code for writing tests; current has a single smoke test and not much else.
3037
- `doc/` - Various documents detailing the vision for Vello as it was developed. This directory should probably be refactored away; adding to it not recommended.
3138
- `examples/` - Example projects using Vello. Each example is its own crate, with its own dependencies. The simplest example is the `shapes` one.
32-
- `integrations/vello_svg` - An SVG rendered based on vello and usvg. Used in examples. May be moved to `crates/` in the future.
33-
- `shader/` - This is where the magic happens. WGSL shaders that define the compute operations (mostly variations of prefix scan) that vello does to render a scene.
39+
- `integrations/vello_svg` - An SVG rendered based on Vello and usvg. Used in examples. May be moved to `crates/` in the future.
40+
- `shader/` - This is where the magic happens. WGSL shaders that define the compute operations (often variations of prefix sum) that Vello does to render a scene.
3441
- `shared/` - Shared types, functions and constants included in other shaders through non-standard `#import` preprocessor directives (see "Shader templating").
35-
- `src/` - Code for the main Vello crate.
42+
- `src/` - Code for the main `vello` crate.
3643
- `shaders/` - Same as `crates/shaders/` above. The duplication should eventually be removed (see #467).
37-
- `cpu_shader/` - Function that perform the same work as their equivalently-named WGSL shaders for the CPU fallbacks. The name is a bit loose, they're not "shaders" in any real sense.
44+
- `cpu_shader/` - Functions that perform the same work as their equivalently-named WGSL shaders for the CPU fallbacks. The name is a bit loose; they're "shaders" in the sense that they work on resource bindings with the exact same layout as actual GPU shaders.
3845

3946

4047
## Shader templating
4148

42-
We implement a limited, simple preprocessor for our shaders, as wgsl has insufficient code-sharing for our needs.
49+
WGSL has no meta-programming support, which limits code-sharing.
50+
We use a strategy common to many projects (eg Bevy) which is to implement a limited, simple preprocessor for our shaders.
4351

44-
This implements only classes of statements.
52+
This preprocessor implements the following directives:
4553

4654
1. `import`, which imports from `shader/shared`
4755
2. `ifdef`, `ifndef`, `else` and `endif`, as standard.
@@ -55,6 +63,11 @@ Note that new imports must currently be added to `.vscode/settings.json` for thi
5563
`wgsl-analyzer` only supports imports in very few syntactic locations, so we limit their use to these places.
5664

5765

66+
## Path encoding
67+
68+
See [Path segment encoding](./doc/pathseg.md) document.
69+
70+
5871
## Intermediary layers
5972

6073
There are multiple layers of separation between "draw shape in Scene" and "commands are sent to wgpu":
@@ -73,7 +86,7 @@ The code in `cpu_shader/*.rs` and `cpu_dispatch.rs` provides *some* support for
7386

7487
- It's called through WgpuEngine, so the dependency on wgpu is still there.
7588
- Fine rasterization (the part at the end that puts pixels on screen) doesn't work in CPU yet (see #386).
76-
- Every single wgsl shader needs a CPU equivalent, which is pretty cumbersome.
89+
- Every single WGSL shader needs a CPU equivalent, which is pretty cumbersome.
7790

7891
Still, it's useful for testing and debugging.
7992

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
</div>
1616

17-
Vello is an experimental 2d graphics rendering engine written in Rust, using [`wgpu`].
18-
It efficiently draws large 2d scenes with interactive or near-interactive performance.
17+
Vello is an experimental 2D graphics rendering engine written in Rust, with a focus on GPU compute.
18+
It can draw large 2D scenes with interactive or near-interactive performance, using [`wgpu`] for GPU access.
1919

2020
Quickstart to run an example program:
2121
```shell
@@ -24,31 +24,39 @@ cargo run -p with_winit
2424

2525
![image](https://github.com/linebender/vello/assets/8573618/cc2b742e-2135-4b70-8051-c49aeddb5d19)
2626

27-
It is used as the rendering backend for [Xilem], a native Rust GUI toolkit.
27+
It is used as the rendering backend for [Xilem], a Rust GUI toolkit.
2828

29+
> [!WARNING]
30+
> Vello can currently be considered in an alpha state. In particular, we're still working on the following:
31+
>
32+
> - [Major rendering artifacts when drawing more than 64k objects](https://github.com/linebender/vello/issues/334).
33+
> - [Implementing blur and filter effects](https://github.com/linebender/vello/issues/476).
34+
> - [Properly implenting strokes](https://github.com/linebender/vello/issues/303) and [supporting all SVG stroke caps](https://github.com/linebender/vello/issues/280).
35+
> - [Conflations artifacts](https://github.com/linebender/vello/issues/49).
36+
> - [GPU memory allocation strategy](https://github.com/linebender/vello/issues/366)
2937
3038
## Motivation
3139

32-
Vello is meant to fill the same place in the graphics stack as other vector graphics renderers like [Skia](https://skia.org/), [Cairo](https://www.cairographics.org/), and its predecessor project [Piet](https://www.cairographics.org/).
33-
On a basic level, that means it provides tools to render shapes, images, gradients, texts, etc, using a PostScript-inspired API, the same that powers SVG files and [the browser `<canvas>` element](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).
40+
Vello is meant to fill the same place in the graphics stack as other vector graphics renderers like [Skia](https://skia.org/), [Cairo](https://www.cairographics.org/), and its predecessor project [Piet](https://github.com/linebender/piet).
41+
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](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).
3442

3543
Vello's selling point is that it gets better performance than other renderers by better leveraging the GPU.
3644
In traditional PostScript renderers, some steps of the render process like sorting and clipping either need to be handled in the CPU or done through the use of intermediary textures.
37-
Vello avoids this by using prefix-scan algorithms to parallelize work that usually needs to happen in sequence, so that work can be offloaded to the GPU with minimal use of temporary buffers.
45+
Vello avoids this by using prefix-sum algorithms to parallelize work that usually needs to happen in sequence, so that work can be offloaded to the GPU with minimal use of temporary buffers.
3846

3947

4048
## Getting started
4149

4250
Vello is meant to be integrated deep in UI render stacks.
43-
While drawing in a Vello scene is easy, actually rendering that scene to a surface setting up a wgpu context, which is a non-trivial task.
51+
While drawing in a Vello scene is easy, actually rendering that scene to a surface requires setting up a wgpu context, which is a non-trivial task.
4452

4553
To use Vello as the renderer for your PDF reader / GUI toolkit / etc, your code will have to look roughly like this:
4654

4755
```rust
4856
// Initialize wgpu and get handles
4957
let device: wgpu::Device = ...;
5058
let queue: wgpu::Queue = ...;
51-
let render_surface: wpg::RenderSurface<'_> = ...;
59+
let surface: wpgu::Surface<'_> = ...;
5260
let texture_format: wgpu::TextureFormat = ...;
5361
let mut renderer = Renderer::new(
5462
&device,
@@ -62,24 +70,22 @@ let mut renderer = Renderer::new(
6270

6371
// Create scene and draw stuff in it
6472
let mut scene = vello::Scene::new();
65-
66-
let circle = vello::Circle::new((420.0, 200.0), 120.0);
67-
let circle_fill_color = vello::Color::rgb(0.9529, 0.5451, 0.6588);
6873
scene.fill(
6974
vello::peniko::Fill::NonZero,
7075
vello::Affine::IDENTITY,
71-
circle_fill_color,
76+
vello::Color::rgb8(242, 140, 168),
7277
None,
73-
&circle,
78+
&vello::Circle::new((420.0, 200.0), 120.0),
7479
);
7580

81+
// Draw more stuff
7682
scene.push_layer(...);
7783
scene.fill(...);
7884
scene.stroke(...);
7985
scene.pop_layer(...);
8086

8187
// Render to your window/buffer/etc.
82-
let surface_texture = render_state.surface.get_current_texture()
88+
let surface_texture = surface.get_current_texture()
8389
.expect("failed to get surface texture");
8490
vello::block_on_wgpu(
8591
&device,
@@ -210,7 +216,7 @@ Contributions are welcome by pull request. The [Rust code of conduct] applies.
210216

211217
Unless you explicitly state otherwise, any contribution intentionally submitted
212218
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
213-
licensed as above, without any additional terms or conditions.
219+
licensed as noted in the "License" section, without any additional terms or conditions.
214220

215221
## History
216222

src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
//!
2727
//! To use Vello as the renderer for your PDF reader / GUI toolkit / etc, your code will have to look roughly like this:
2828
//!
29-
//! ```rust
29+
//! ```ignore
3030
//! // Initialize wgpu and get handles
3131
//! let device: wgpu::Device = ...;
3232
//! let queue: wgpu::Queue = ...;
33-
//! let render_surface: wpg::RenderSurface<'_> = ...;
33+
//! let surface: wpgu::Surface<'_> = ...;
3434
//! let texture_format: wgpu::TextureFormat = ...;
3535
//! let mut renderer = Renderer::new(
3636
//! &device,
@@ -44,24 +44,22 @@
4444
//!
4545
//! // Create scene and draw stuff in it
4646
//! let mut scene = vello::Scene::new();
47-
//!
48-
//! let circle = vello::Circle::new((420.0, 200.0), 120.0);
49-
//! let circle_fill_color = vello::Color::rgb(0.9529, 0.5451, 0.6588);
5047
//! scene.fill(
5148
//! vello::peniko::Fill::NonZero,
5249
//! vello::Affine::IDENTITY,
53-
//! circle_fill_color,
50+
//! vello::Color::rgb8(242, 140, 168),
5451
//! None,
55-
//! &circle,
52+
//! &vello::Circle::new((420.0, 200.0), 120.0),
5653
//! );
5754
//!
55+
//! // Draw more stuff
5856
//! scene.push_layer(...);
5957
//! scene.fill(...);
6058
//! scene.stroke(...);
6159
//! scene.pop_layer(...);
6260
//!
6361
//! // Render to your window/buffer/etc.
64-
//! let surface_texture = render_state.surface.get_current_texture()
62+
//! let surface_texture = surface.get_current_texture()
6563
//! .expect("failed to get surface texture");
6664
//! vello::block_on_wgpu(
6765
//! &device,

src/scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Scene {
5454
self.encoding
5555
.encode_transform(Transform::from_kurbo(&transform));
5656
self.encoding.encode_fill_style(Fill::NonZero);
57-
if !self.encoding.encode_shape(shape, true) {
57+
if !self.encoding.encode_shape(clip, true) {
5858
// If the layer shape is invalid, encode a valid empty path. This suppresses
5959
// all drawing until the layer is popped.
6060
self.encoding

0 commit comments

Comments
 (0)