Skip to content

Commit

Permalink
Migrate the repository to a virtual workspace. (#590)
Browse files Browse the repository at this point in the history
The CI, VSCode config, `ARCHITECTURE.md` and some `README.md` links have
been updated to reflect the new directory structure.

The WGSL shaders now live in the `vello_shaders` subdirectory. Vello hot
reloading depends on our repo structure, which is fine as decided at
last office hours due to this being a development feature.

The examples continue to live in a root `examples` directory, as that is
how it remained for [Parley](https://github.com/linebender/parley) as
well. I did this for consistency and don't really feel strongly either
way if people think we should move them under `vello/examples` instead.
If we had examples without `Cargo.toml` that would make more sense, but
we don't, so ..

The repo `README.md` and the `vello` sub-directory `README.md` are exact
clones and both need updating. That is intentionally planned as
follow-up work to reduce the review friction here.
  • Loading branch information
xStrom committed Jun 3, 2024
1 parent f33c2f4 commit d2bd951
Show file tree
Hide file tree
Showing 114 changed files with 1,010 additions and 122 deletions.
4 changes: 2 additions & 2 deletions .github/copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# -g "!src/special_directory"

# Check all the standard Rust source files
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT$\n\n" --files-without-match --multiline -g "*.rs" -g "!{shader,crates/shaders/src/cpu}" .)
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT$\n\n" --files-without-match --multiline -g "*.rs" -g "!vello_shaders/{shader,src/cpu}" .)

if [ -n "$output" ]; then
echo -e "The following files lack the correct copyright header:\n"
Expand All @@ -20,7 +20,7 @@ if [ -n "$output" ]; then
fi

# Check all the shaders, both WGSL and CPU shaders in Rust, as they also have Unlicense
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT OR Unlicense$\n\n" --files-without-match --multiline -g "{shader,crates/shaders/src/cpu}/**/*.{rs,wgsl}" .)
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Vello Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT OR Unlicense$\n\n" --files-without-match --multiline -g "vello_shaders/{shader,src/cpu}/**/*.{rs,wgsl}" .)

if [ -n "$output" ]; then
echo -e "The following shader files lack the correct copyright header:\n"
Expand Down
26 changes: 13 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"wgsl-analyzer.customImports": {
"bbox": "${workspaceFolder}/shader/shared/bbox.wgsl",
"blend": "${workspaceFolder}/shader/shared/blend.wgsl",
"bump": "${workspaceFolder}/shader/shared/bump.wgsl",
"clip": "${workspaceFolder}/shader/shared/clip.wgsl",
"config": "${workspaceFolder}/shader/shared/config.wgsl",
"cubic": "${workspaceFolder}/shader/shared/cubic.wgsl",
"drawtag": "${workspaceFolder}/shader/shared/drawtag.wgsl",
"pathtag": "${workspaceFolder}/shader/shared/pathtag.wgsl",
"ptcl": "${workspaceFolder}/shader/shared/ptcl.wgsl",
"segment": "${workspaceFolder}/shader/shared/segment.wgsl",
"tile": "${workspaceFolder}/shader/shared/tile.wgsl",
"transform": "${workspaceFolder}/shader/shared/transform.wgsl",
"util": "${workspaceFolder}/shader/shared/util.wgsl"
"bbox": "${workspaceFolder}/vello_shaders/shader/shared/bbox.wgsl",
"blend": "${workspaceFolder}/vello_shaders/shader/shared/blend.wgsl",
"bump": "${workspaceFolder}/vello_shaders/shader/shared/bump.wgsl",
"clip": "${workspaceFolder}/vello_shaders/shader/shared/clip.wgsl",
"config": "${workspaceFolder}/vello_shaders/shader/shared/config.wgsl",
"cubic": "${workspaceFolder}/vello_shaders/shader/shared/cubic.wgsl",
"drawtag": "${workspaceFolder}/vello_shaders/shader/shared/drawtag.wgsl",
"pathtag": "${workspaceFolder}/vello_shaders/shader/shared/pathtag.wgsl",
"ptcl": "${workspaceFolder}/vello_shaders/shader/shared/ptcl.wgsl",
"segment": "${workspaceFolder}/vello_shaders/shader/shared/segment.wgsl",
"tile": "${workspaceFolder}/vello_shaders/shader/shared/tile.wgsl",
"transform": "${workspaceFolder}/vello_shaders/shader/shared/transform.wgsl",
"util": "${workspaceFolder}/vello_shaders/shader/shared/util.wgsl"
},
"wgsl-analyzer.diagnostics.nagaVersion": "main",
"wgsl-analyzer.preprocessor.shaderDefs": [
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 7 additions & 45 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[workspace]
resolver = "2"
members = [
"crates/encoding",
"crates/shaders",
"crates/tests",
"vello",
"vello_encoding",
"vello_shaders",
"vello_tests",

"examples/headless",
"examples/with_winit",
Expand All @@ -27,53 +28,14 @@ rust-version = "1.75"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/linebender/vello"

[package]
name = "vello"
version.workspace = true
description = "An experimental GPU compute-centric 2D renderer."
categories = ["rendering", "graphics"]
keywords = ["2d", "vector-graphics"]
exclude = ["/.github/", "/doc/", "/examples/", ".gitignore"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true

[features]
default = ["wgpu"]
# Enables GPU memory usage estimation. This performs additional computations
# in order to estimate the minimum required allocations for buffers backing
# bump-allocated GPU memory.
# TODO: Turn this into a runtime option used at resolve time and remove the feature.
bump_estimate = ["vello_encoding/bump_estimate"]
hot_reload = ["vello_shaders/compile"]
buffer_labels = []

[lints]
workspace = true

[dependencies]
vello_encoding = { workspace = true }
vello_shaders = { workspace = true }
bytemuck = { workspace = true }
skrifa = { workspace = true }
peniko = { workspace = true }
wgpu = { workspace = true, optional = true }
log = { workspace = true }
raw-window-handle = { workspace = true }
static_assertions = { workspace = true }
futures-intrusive = { workspace = true }
wgpu-profiler = { workspace = true, optional = true }
thiserror = { workspace = true }

[workspace.lints]
clippy.doc_markdown = "warn"
clippy.semicolon_if_nothing_returned = "warn"

[workspace.dependencies]
vello = { version = "0.1.0", path = "." }
vello_encoding = { version = "0.1.0", path = "crates/encoding" }
vello_shaders = { version = "0.1.0", path = "crates/shaders" }
vello = { version = "0.1.0", path = "vello" }
vello_encoding = { version = "0.1.0", path = "vello_encoding" }
vello_shaders = { version = "0.1.0", path = "vello_shaders" }
bytemuck = { version = "1.16.0", features = ["derive"] }
skrifa = "0.19.3"
peniko = "0.1.1"
Expand Down
26 changes: 0 additions & 26 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -175,28 +174,3 @@
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 Raph Levien
Copyright 2020 the Vello Authors

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ Licensed under either of

at your option.

In addition, all files in the [`shader`](https://github.com/linebender/vello/tree/main/shader) and [`src/cpu_shader`](https://github.com/linebender/vello/tree/main/src/cpu_shader)
In addition, all files in the [`vello_shaders/shader`](https://github.com/linebender/vello/tree/main/vello_shaders/shader) and [`vello_shaders/src/cpu`](https://github.com/linebender/vello/tree/main/vello_shaders/src/cpu)
directories and subdirectories thereof are alternatively licensed under
the Unlicense ([shader/UNLICENSE](https://github.com/linebender/vello/tree/main/shader/UNLICENSE) or <http://unlicense.org/>).
the Unlicense ([shader/UNLICENSE](https://github.com/linebender/vello/tree/main/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.

Expand Down
19 changes: 9 additions & 10 deletions ARCHITECTURE.md → doc/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ Our current priority is to fill in missing features and to fix rendering artifac

The repository is structured as such:

- `crates/`
- `encoding/` - Types that represent the data that needs to be rendered.
- `shaders/` - Infrastructure to preprocess and cross-compile shaders at compile time; see "Shader templating".
- `cpu/` - 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.
- `tests/` - Helper code for writing tests; current has a single smoke test and not much else.
- `doc/` - Various documents detailing the vision for Vello as it was developed. This directory should probably be refactored away; adding to it not recommended.
- `examples/` - Example projects using Vello. Each example is its own crate, with its own dependencies. The simplest example is the `shapes` one.
- `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.
- `shared/` - Shared types, functions and constants included in other shaders through non-standard `#import` preprocessor directives (see "Shader templating").
- `src/` - Code for the main `vello` crate.
- `examples/` - Example projects using Vello. Each example is its own crate, with its own dependencies. The simplest example is called `simple`.
- `vello/` - Code for the main `vello` crate.
- `vello_encoding/` - Types that represent the data that needs to be rendered.
- `vello_shaders/` - Infrastructure to preprocess and cross-compile shaders at compile time; see "Shader templating".
- `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.
- `shared/` - Shared types, functions and constants included in other shaders through non-standard `#import` preprocessor directives (see "Shader templating").
- `cpu/` - 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.
- `vello_tests/` - Helper code for writing tests; current has a single smoke test and not much else.


## Shader templating
Expand Down Expand Up @@ -81,7 +80,7 @@ In principle, other backends could consume a `Recording`, but for now the only i

### CPU rendering

The code in `cpu_shader/*.rs` and `cpu_dispatch.rs` provides *some* support for CPU-side rendering. It's in an awkward place right now:
The code in `vello_shaders/src/cpu/*.rs` and `vello_shaders/src/cpu.rs` provides *some* support for CPU-side rendering. It's in an awkward place right now:

- It's called through WgpuEngine, so the dependency on wgpu is still there.
- Fine rasterization (the part at the end that puts pixels on screen) doesn't work in CPU yet (see [#386]).
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ workspace = true
[dependencies]
# When using this example outside of the original Vello workspace,
# remove the path property of the following Vello dependency requirement.
vello = { version = "0.1.0", path = "../../" }
vello = { version = "0.1.0", path = "../../vello" }
anyhow = "1.0.83"
pollster = "0.3.0"
wgpu = "0.20.0"
Expand Down
1 change: 1 addition & 0 deletions examples/with_winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ env_logger = "0.11.3"

[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
vello = { workspace = true, features = ["hot_reload"] }
vello_shaders = { workspace = true, features = ["compile"] }
notify-debouncer-mini = "0.3.0"


Expand Down
5 changes: 1 addition & 4 deletions examples/with_winit/src/hot_reload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::path::Path;
use std::time::Duration;

use anyhow::Result;
Expand All @@ -19,9 +18,7 @@ pub(crate) fn hot_reload(mut f: impl FnMut() -> Option<()> + Send + 'static) ->
)?;

debouncer.watcher().watch(
&Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../shader")
.canonicalize()?,
vello_shaders::compile::shader_dir().as_path(),
// We currently don't support hot reloading the imports, so don't recurse into there
RecursiveMode::NonRecursive,
)?;
Expand Down
37 changes: 37 additions & 0 deletions vello/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "vello"
version.workspace = true
description = "An experimental GPU compute-centric 2D renderer."
categories = ["rendering", "graphics"]
keywords = ["2d", "vector-graphics"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true

[features]
default = ["wgpu"]
# Enables GPU memory usage estimation. This performs additional computations
# in order to estimate the minimum required allocations for buffers backing
# bump-allocated GPU memory.
# TODO: Turn this into a runtime option used at resolve time and remove the feature.
bump_estimate = ["vello_encoding/bump_estimate"]
hot_reload = ["vello_shaders/compile"]
buffer_labels = []

[lints]
workspace = true

[dependencies]
vello_encoding = { workspace = true }
vello_shaders = { workspace = true }
bytemuck = { workspace = true }
skrifa = { workspace = true }
peniko = { workspace = true }
wgpu = { workspace = true, optional = true }
log = { workspace = true }
raw-window-handle = { workspace = true }
static_assertions = { workspace = true }
futures-intrusive = { workspace = true }
wgpu-profiler = { workspace = true, optional = true }
thiserror = { workspace = true }
Loading

0 comments on commit d2bd951

Please sign in to comment.