From d2bd95145dd73bb569209ce918dbf55bf103f881 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Mon, 3 Jun 2024 14:44:52 +0200 Subject: [PATCH] Migrate the repository to a virtual workspace. (#590) 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. --- .github/copyright.sh | 4 +- .vscode/settings.json | 26 +- Cargo.lock | 1 + Cargo.toml | 52 +-- LICENSE-APACHE | 26 -- LICENSE-MIT | 2 +- README.md | 4 +- ARCHITECTURE.md => doc/ARCHITECTURE.md | 19 +- examples/simple/Cargo.toml | 2 +- examples/with_winit/Cargo.toml | 1 + examples/with_winit/src/hot_reload.rs | 5 +- vello/Cargo.toml | 37 +++ vello/LICENSE-APACHE | 176 +++++++++++ vello/LICENSE-MIT | 25 ++ vello/README.md | 296 ++++++++++++++++++ {src => vello/src}/glyph.rs | 0 {src => vello/src}/lib.rs | 0 {src => vello/src}/recording.rs | 0 {src => vello/src}/render.rs | 0 {src => vello/src}/scene.rs | 0 {src => vello/src}/shaders.rs | 5 +- {src => vello/src}/util.rs | 0 {src => vello/src}/wgpu_engine.rs | 0 .../encoding => vello_encoding}/Cargo.toml | 0 vello_encoding/LICENSE-APACHE | 176 +++++++++++ vello_encoding/LICENSE-MIT | 25 ++ {crates/encoding => vello_encoding}/README.md | 0 .../src/binning.rs | 0 .../encoding => vello_encoding}/src/clip.rs | 0 .../encoding => vello_encoding}/src/config.rs | 0 .../encoding => vello_encoding}/src/draw.rs | 0 .../src/encoding.rs | 0 .../src/estimate.rs | 0 .../encoding => vello_encoding}/src/glyph.rs | 0 .../src/glyph_cache.rs | 0 .../src/image_cache.rs | 0 .../encoding => vello_encoding}/src/lib.rs | 0 .../encoding => vello_encoding}/src/mask.rs | 0 .../encoding => vello_encoding}/src/math.rs | 0 .../encoding => vello_encoding}/src/monoid.rs | 0 .../encoding => vello_encoding}/src/path.rs | 0 .../src/ramp_cache.rs | 0 .../src/resolve.rs | 0 {crates/shaders => vello_shaders}/Cargo.toml | 0 vello_shaders/LICENSE-APACHE | 176 +++++++++++ vello_shaders/LICENSE-MIT | 25 ++ {crates/shaders => vello_shaders}/README.md | 0 {crates/shaders => vello_shaders}/build.rs | 16 +- {shader => vello_shaders/shader}/UNLICENSE | 0 .../shader}/backdrop.wgsl | 0 .../shader}/backdrop_dyn.wgsl | 0 .../shader}/bbox_clear.wgsl | 0 {shader => vello_shaders/shader}/binning.wgsl | 0 .../shader}/clip_leaf.wgsl | 0 .../shader}/clip_reduce.wgsl | 0 {shader => vello_shaders/shader}/coarse.wgsl | 0 .../shader}/draw_leaf.wgsl | 0 .../shader}/draw_reduce.wgsl | 0 {shader => vello_shaders/shader}/fine.wgsl | 0 {shader => vello_shaders/shader}/flatten.wgsl | 0 .../shader}/path_count.wgsl | 0 .../shader}/path_count_setup.wgsl | 0 .../shader}/path_tiling.wgsl | 0 .../shader}/path_tiling_setup.wgsl | 0 .../shader}/pathtag_reduce.wgsl | 0 .../shader}/pathtag_reduce2.wgsl | 0 .../shader}/pathtag_scan.wgsl | 0 .../shader}/pathtag_scan1.wgsl | 0 {shader => vello_shaders/shader}/permutations | 0 .../shader}/shared/bbox.wgsl | 0 .../shader}/shared/blend.wgsl | 0 .../shader}/shared/bump.wgsl | 0 .../shader}/shared/clip.wgsl | 0 .../shader}/shared/config.wgsl | 0 .../shader}/shared/cubic.wgsl | 0 .../shader}/shared/drawtag.wgsl | 0 .../shader}/shared/pathtag.wgsl | 0 .../shader}/shared/ptcl.wgsl | 0 .../shader}/shared/segment.wgsl | 0 .../shader}/shared/tile.wgsl | 0 .../shader}/shared/transform.wgsl | 0 .../shader}/shared/util.wgsl | 0 .../shader}/tile_alloc.wgsl | 0 .../src/compile/mod.rs | 17 +- .../src/compile/msl.rs | 0 .../src/compile/permutations.rs | 0 .../src/compile/preprocess.rs | 0 {crates/shaders => vello_shaders}/src/cpu.rs | 0 .../src/cpu/backdrop.rs | 0 .../src/cpu/bbox_clear.rs | 0 .../src/cpu/binning.rs | 0 .../src/cpu/clip_leaf.rs | 0 .../src/cpu/clip_reduce.rs | 0 .../src/cpu/coarse.rs | 0 .../src/cpu/draw_leaf.rs | 0 .../src/cpu/draw_reduce.rs | 0 .../src/cpu/euler.rs | 0 .../shaders => vello_shaders}/src/cpu/fine.rs | 0 .../src/cpu/flatten.rs | 0 .../src/cpu/path_count.rs | 0 .../src/cpu/path_count_setup.rs | 0 .../src/cpu/path_tiling.rs | 0 .../src/cpu/path_tiling_setup.rs | 0 .../src/cpu/pathtag_reduce.rs | 0 .../src/cpu/pathtag_scan.rs | 0 .../src/cpu/tile_alloc.rs | 0 .../shaders => vello_shaders}/src/cpu/util.rs | 0 {crates/shaders => vello_shaders}/src/lib.rs | 16 + .../shaders => vello_shaders}/src/types.rs | 0 {crates/tests => vello_tests}/Cargo.toml | 0 {crates/tests => vello_tests}/build.rs | 0 .../debug_outputs/.gitignore | 0 {crates/tests => vello_tests}/src/lib.rs | 0 {crates/tests => vello_tests}/tests/smoke.rs | 0 114 files changed, 1010 insertions(+), 122 deletions(-) rename ARCHITECTURE.md => doc/ARCHITECTURE.md (80%) create mode 100644 vello/Cargo.toml create mode 100644 vello/LICENSE-APACHE create mode 100644 vello/LICENSE-MIT create mode 100644 vello/README.md rename {src => vello/src}/glyph.rs (100%) rename {src => vello/src}/lib.rs (100%) rename {src => vello/src}/recording.rs (100%) rename {src => vello/src}/render.rs (100%) rename {src => vello/src}/scene.rs (100%) rename {src => vello/src}/shaders.rs (99%) rename {src => vello/src}/util.rs (100%) rename {src => vello/src}/wgpu_engine.rs (100%) rename {crates/encoding => vello_encoding}/Cargo.toml (100%) create mode 100644 vello_encoding/LICENSE-APACHE create mode 100644 vello_encoding/LICENSE-MIT rename {crates/encoding => vello_encoding}/README.md (100%) rename {crates/encoding => vello_encoding}/src/binning.rs (100%) rename {crates/encoding => vello_encoding}/src/clip.rs (100%) rename {crates/encoding => vello_encoding}/src/config.rs (100%) rename {crates/encoding => vello_encoding}/src/draw.rs (100%) rename {crates/encoding => vello_encoding}/src/encoding.rs (100%) rename {crates/encoding => vello_encoding}/src/estimate.rs (100%) rename {crates/encoding => vello_encoding}/src/glyph.rs (100%) rename {crates/encoding => vello_encoding}/src/glyph_cache.rs (100%) rename {crates/encoding => vello_encoding}/src/image_cache.rs (100%) rename {crates/encoding => vello_encoding}/src/lib.rs (100%) rename {crates/encoding => vello_encoding}/src/mask.rs (100%) rename {crates/encoding => vello_encoding}/src/math.rs (100%) rename {crates/encoding => vello_encoding}/src/monoid.rs (100%) rename {crates/encoding => vello_encoding}/src/path.rs (100%) rename {crates/encoding => vello_encoding}/src/ramp_cache.rs (100%) rename {crates/encoding => vello_encoding}/src/resolve.rs (100%) rename {crates/shaders => vello_shaders}/Cargo.toml (100%) create mode 100644 vello_shaders/LICENSE-APACHE create mode 100644 vello_shaders/LICENSE-MIT rename {crates/shaders => vello_shaders}/README.md (100%) rename {crates/shaders => vello_shaders}/build.rs (82%) rename {shader => vello_shaders/shader}/UNLICENSE (100%) rename {shader => vello_shaders/shader}/backdrop.wgsl (100%) rename {shader => vello_shaders/shader}/backdrop_dyn.wgsl (100%) rename {shader => vello_shaders/shader}/bbox_clear.wgsl (100%) rename {shader => vello_shaders/shader}/binning.wgsl (100%) rename {shader => vello_shaders/shader}/clip_leaf.wgsl (100%) rename {shader => vello_shaders/shader}/clip_reduce.wgsl (100%) rename {shader => vello_shaders/shader}/coarse.wgsl (100%) rename {shader => vello_shaders/shader}/draw_leaf.wgsl (100%) rename {shader => vello_shaders/shader}/draw_reduce.wgsl (100%) rename {shader => vello_shaders/shader}/fine.wgsl (100%) rename {shader => vello_shaders/shader}/flatten.wgsl (100%) rename {shader => vello_shaders/shader}/path_count.wgsl (100%) rename {shader => vello_shaders/shader}/path_count_setup.wgsl (100%) rename {shader => vello_shaders/shader}/path_tiling.wgsl (100%) rename {shader => vello_shaders/shader}/path_tiling_setup.wgsl (100%) rename {shader => vello_shaders/shader}/pathtag_reduce.wgsl (100%) rename {shader => vello_shaders/shader}/pathtag_reduce2.wgsl (100%) rename {shader => vello_shaders/shader}/pathtag_scan.wgsl (100%) rename {shader => vello_shaders/shader}/pathtag_scan1.wgsl (100%) rename {shader => vello_shaders/shader}/permutations (100%) rename {shader => vello_shaders/shader}/shared/bbox.wgsl (100%) rename {shader => vello_shaders/shader}/shared/blend.wgsl (100%) rename {shader => vello_shaders/shader}/shared/bump.wgsl (100%) rename {shader => vello_shaders/shader}/shared/clip.wgsl (100%) rename {shader => vello_shaders/shader}/shared/config.wgsl (100%) rename {shader => vello_shaders/shader}/shared/cubic.wgsl (100%) rename {shader => vello_shaders/shader}/shared/drawtag.wgsl (100%) rename {shader => vello_shaders/shader}/shared/pathtag.wgsl (100%) rename {shader => vello_shaders/shader}/shared/ptcl.wgsl (100%) rename {shader => vello_shaders/shader}/shared/segment.wgsl (100%) rename {shader => vello_shaders/shader}/shared/tile.wgsl (100%) rename {shader => vello_shaders/shader}/shared/transform.wgsl (100%) rename {shader => vello_shaders/shader}/shared/util.wgsl (100%) rename {shader => vello_shaders/shader}/tile_alloc.wgsl (100%) rename {crates/shaders => vello_shaders}/src/compile/mod.rs (91%) rename {crates/shaders => vello_shaders}/src/compile/msl.rs (100%) rename {crates/shaders => vello_shaders}/src/compile/permutations.rs (100%) rename {crates/shaders => vello_shaders}/src/compile/preprocess.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/backdrop.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/bbox_clear.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/binning.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/clip_leaf.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/clip_reduce.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/coarse.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/draw_leaf.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/draw_reduce.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/euler.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/fine.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/flatten.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/path_count.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/path_count_setup.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/path_tiling.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/path_tiling_setup.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/pathtag_reduce.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/pathtag_scan.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/tile_alloc.rs (100%) rename {crates/shaders => vello_shaders}/src/cpu/util.rs (100%) rename {crates/shaders => vello_shaders}/src/lib.rs (79%) rename {crates/shaders => vello_shaders}/src/types.rs (100%) rename {crates/tests => vello_tests}/Cargo.toml (100%) rename {crates/tests => vello_tests}/build.rs (100%) rename {crates/tests => vello_tests}/debug_outputs/.gitignore (100%) rename {crates/tests => vello_tests}/src/lib.rs (100%) rename {crates/tests => vello_tests}/tests/smoke.rs (100%) diff --git a/.github/copyright.sh b/.github/copyright.sh index b090c0879..07de4c95f 100755 --- a/.github/copyright.sh +++ b/.github/copyright.sh @@ -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" @@ -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" diff --git a/.vscode/settings.json b/.vscode/settings.json index bda7c8724..6be52f083 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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": [ diff --git a/Cargo.lock b/Cargo.lock index 9f9b7e345..e3801f004 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3099,6 +3099,7 @@ dependencies = [ "tracing-subscriber", "tracing_android_trace", "vello", + "vello_shaders", "wasm-bindgen-futures", "web-sys", "web-time", diff --git a/Cargo.toml b/Cargo.toml index dca66e61f..90691de3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", @@ -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" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index d64569567..d9a10c0d8 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -1,4 +1,3 @@ - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -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. diff --git a/LICENSE-MIT b/LICENSE-MIT index 3530c97d9..48ff8e414 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -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 diff --git a/README.md b/README.md index 077c024bf..f9e27ee0f 100644 --- a/README.md +++ b/README.md @@ -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 ). +the Unlicense ([shader/UNLICENSE](https://github.com/linebender/vello/tree/main/vello_shaders/shader/UNLICENSE) or ). 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. diff --git a/ARCHITECTURE.md b/doc/ARCHITECTURE.md similarity index 80% rename from ARCHITECTURE.md rename to doc/ARCHITECTURE.md index 7abbe3740..f0650f5ee 100644 --- a/ARCHITECTURE.md +++ b/doc/ARCHITECTURE.md @@ -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 @@ -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]). diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml index 5591b598a..927f48550 100644 --- a/examples/simple/Cargo.toml +++ b/examples/simple/Cargo.toml @@ -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" diff --git a/examples/with_winit/Cargo.toml b/examples/with_winit/Cargo.toml index b80eb37f4..a189f62e6 100644 --- a/examples/with_winit/Cargo.toml +++ b/examples/with_winit/Cargo.toml @@ -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" diff --git a/examples/with_winit/src/hot_reload.rs b/examples/with_winit/src/hot_reload.rs index ba17897c0..e9dd3a28e 100644 --- a/examples/with_winit/src/hot_reload.rs +++ b/examples/with_winit/src/hot_reload.rs @@ -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; @@ -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, )?; diff --git a/vello/Cargo.toml b/vello/Cargo.toml new file mode 100644 index 000000000..4d721ac8a --- /dev/null +++ b/vello/Cargo.toml @@ -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 } diff --git a/vello/LICENSE-APACHE b/vello/LICENSE-APACHE new file mode 100644 index 000000000..d9a10c0d8 --- /dev/null +++ b/vello/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/vello/LICENSE-MIT b/vello/LICENSE-MIT new file mode 100644 index 000000000..48ff8e414 --- /dev/null +++ b/vello/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright 2020 the Vello Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/vello/README.md b/vello/README.md new file mode 100644 index 000000000..f9e27ee0f --- /dev/null +++ b/vello/README.md @@ -0,0 +1,296 @@ +
+ +# Vello + +**An experimental GPU compute-centric 2D renderer** + +[![Linebender Zulip](https://img.shields.io/badge/Linebender-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu) +[![dependency status](https://deps.rs/repo/github/linebender/vello/status.svg)](https://deps.rs/repo/github/linebender/vello) +[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license) +[![wgpu version](https://img.shields.io/badge/wgpu-v0.20.0-orange.svg)](https://crates.io/crates/wgpu) + +[![Crates.io](https://img.shields.io/crates/v/vello.svg)](https://crates.io/crates/vello) +[![Docs](https://docs.rs/vello/badge.svg)](https://docs.rs/vello) +[![Build status](https://github.com/linebender/vello/workflows/CI/badge.svg)](https://github.com/linebender/vello/actions) + +
+ +Vello is an experimental 2D graphics rendering engine written in Rust, with a focus on GPU compute. +It can draw large 2D scenes with interactive or near-interactive performance, using [`wgpu`] for GPU access. + +Quickstart to run an example program: + +```shell +cargo run -p with_winit +``` + +![image](https://github.com/linebender/vello/assets/8573618/cc2b742e-2135-4b70-8051-c49aeddb5d19) + +It is used as the rendering backend for [Xilem], a Rust GUI toolkit. + +> [!WARNING] +> Vello can currently be considered in an alpha state. In particular, we're still working on the following: +> +> - [Implementing blur and filter effects](https://github.com/linebender/vello/issues/476). +> - [Conflations artifacts](https://github.com/linebender/vello/issues/49). +> - [GPU memory allocation strategy](https://github.com/linebender/vello/issues/366) +> - [Glyph caching](https://github.com/linebender/vello/issues/204) + +## Motivation + +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). +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 `` element](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D). + +Vello's selling point is that it gets better performance than other renderers by better leveraging the GPU. +In traditional PostScript-style 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. +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. + +This means that Vello needs a GPU with support for compute shaders to run. + +## Getting started + +Vello is meant to be integrated deep in UI render stacks. +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. + +To use Vello as the renderer for your PDF reader / GUI toolkit / etc, your code will have to look roughly like this: + +```rust +// Initialize wgpu and get handles +let (width, height) = ...; +let device: wgpu::Device = ...; +let queue: wgpu::Queue = ...; +let surface: wgpu::Surface<'_> = ...; +let texture_format: wgpu::TextureFormat = ...; +let mut renderer = Renderer::new( + &device, + RendererOptions { + surface_format: Some(texture_format), + use_cpu: false, + antialiasing_support: vello::AaSupport::all(), + num_init_threads: NonZeroUsize::new(1), + }, +).expect("Failed to create renderer"); + +// Create scene and draw stuff in it +let mut scene = vello::Scene::new(); +scene.fill( + vello::peniko::Fill::NonZero, + vello::Affine::IDENTITY, + vello::Color::rgb8(242, 140, 168), + None, + &vello::Circle::new((420.0, 200.0), 120.0), +); + +// Draw more stuff +scene.push_layer(...); +scene.fill(...); +scene.stroke(...); +scene.pop_layer(...); + +// Render to your window/buffer/etc. +let surface_texture = surface.get_current_texture() + .expect("failed to get surface texture"); +renderer + .render_to_surface( + &device, + &queue, + &scene, + &surface_texture, + &vello::RenderParams { + base_color: Color::BLACK, // Background color + width, + height, + antialiasing_method: AaConfig::Msaa16, + }, + ) + .expect("Failed to render to surface"); +surface_texture.present(); +``` + +See the [`examples/`](https://github.com/linebender/vello/tree/main/examples) folder to see how that code integrates with frameworks like winit and bevy. + +## Performance + +We've observed 177 fps for the paris-30k test scene on an M1 Max, at a resolution of 1600 pixels square, which is excellent performance and represents something of a best case for the engine. + +More formal benchmarks are on their way. + +## Integrations + +### SVG + +A separate Linebender integration for rendering SVG files is available through the [`vello_svg`](https://github.com/linebender/vello_svg) crate. + +### Lottie + +A separate Linebender integration for playing Lottie animations is available through the [`velato`](https://github.com/linebender/velato) crate. + +## Examples + +Our examples are provided in separate packages in the [`examples`](https://github.com/linebender/vello/tree/main/examples) folder. +This allows them to have independent dependencies and faster builds. +Examples must be selected using the `--package` (or `-p`) Cargo flag. + +### Winit + +Our [winit] example ([examples/with_winit](https://github.com/linebender/vello/tree/main/examples/with_winit)) demonstrates rendering to a [winit] window. +By default, this renders the [GhostScript Tiger] as well as all SVG files you add in the [examples/assets/downloads/](https://github.com/linebender/vello/tree/main/examples/assets/downloads) directory. +A custom list of SVG file paths (and directories to render all SVG files from) can be provided as arguments instead. +It also includes a collection of test scenes showing the capabilities of `vello`, which can be shown with `--test-scenes`. + +```shell +cargo run -p with_winit +``` + + + +### Bevy + +There is a separate community integration for rendering raw scenes or Lottie and SVG files in [Bevy] through [`bevy_vello`](https://github.com/loopystudios/bevy_vello). + +## Platforms + +We aim to target all environments which can support WebGPU with the [default limits](https://www.w3.org/TR/webgpu/#limits). +We defer to [`wgpu`] for this support. +Other platforms are more tricky, and may require special building/running procedures. + +### Web + +Because Vello relies heavily on compute shaders, we rely on the emerging WebGPU standard to run on the web. +Until browser support becomes widespread, it will probably be necessary to use development browser versions (e.g. Chrome Canary) and explicitly enable WebGPU. + +The following command builds and runs a web version of the [winit demo](#winit). +This uses [`cargo-run-wasm`](https://github.com/rukai/cargo-run-wasm) to build the example for web, and host a local server for it + +```shell +# Make sure the Rust toolchain supports the wasm32 target +rustup target add wasm32-unknown-unknown + +# The binary name must also be explicitly provided as it differs from the package name +cargo run_wasm -p with_winit --bin with_winit_bin +``` + +There is also a web demo [available here](https://linebender.github.io/vello) on supporting web browsers. + +> [!WARNING] +> The web is not currently a primary target for Vello, and WebGPU implementations are incomplete, so you might run into issues running this example. + +### Android + +The [`with_winit`](#winit) example supports running on Android, using [cargo apk](https://crates.io/crates/cargo-apk). + +```shell +cargo apk run -p with_winit +``` + +> [!TIP] +> cargo apk doesn't support running in release mode without configuration. +> See [their crates page docs](https://crates.io/crates/cargo-apk) (around `package.metadata.android.signing.`). +> +> See also [cargo-apk#16](https://github.com/rust-mobile/cargo-apk/issues/16). +> To run in release mode, you must add the following to `examples/with_winit/Cargo.toml` (changing `$HOME` to your home directory): + +```toml +[package.metadata.android.signing.release] +path = "$HOME/.android/debug.keystore" +keystore_password = "android" +``` + +> [!NOTE] +> As `cargo apk` does not allow passing command line arguments or environment variables to the app when ran, these can be embedded into the +> program at compile time (currently for Android only) +> `with_winit` currently supports the environment variables: +> +> - `VELLO_STATIC_LOG`, which is equivalent to `RUST_LOG` +> - `VELLO_STATIC_ARGS`, which is equivalent to passing in command line arguments + +For example (with unix shell environment variable syntax): + +```sh +VELLO_STATIC_LOG="vello=trace" VELLO_STATIC_ARGS="--test-scenes" cargo apk run -p with_winit --lib +``` + +## Minimum supported Rust Version (MSRV) + +This version of Vello has been verified to compile with **Rust 1.75** 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. + +
+Click here if compiling fails. + +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. + +```sh +# 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](https://xi.zulipchat.com/), specifically the [#gpu stream](https://xi.zulipchat.com/#narrow/stream/197075-gpu). 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. + +## History + +Vello was previously known as `piet-gpu`. +This prior incarnation used a custom cross-API hardware abstraction layer, called `piet-gpu-hal`, instead of [`wgpu`]. + +An archive of this version can be found in the branches [`custom-hal-archive-with-shaders`] and [`custom-hal-archive`]. +This succeeded the previous prototype, [piet-metal], and included work adapted from [piet-dx12]. + +The decision to lay down `piet-gpu-hal` in favor of WebGPU is discussed in detail in the blog post [Requiem for piet-gpu-hal]. + +A [vision](https://github.com/linebender/vello/tree/main/doc/vision.md) document dated December 2020 explained the longer-term goals of the project, and how we might get there. +Many of these items are out-of-date or completed, but it still may provide some useful background. + +## Related projects + +Vello takes inspiration from many other rendering projects, including: + +- [Pathfinder](https://github.com/servo/pathfinder) +- [Spinel](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/src/graphics/lib/compute/spinel/) +- [Forma](https://github.com/google/forma) +- [Massively Parallel Vector Graphics](https://w3.impa.br/~diego/projects/GanEtAl14/) +- [Random-access rendering of general vector graphics](https://hhoppe.com/proj/ravg/) + +## License + +Licensed under either of + +- Apache License, Version 2.0 + ([LICENSE-APACHE](LICENSE-APACHE) or ) +- MIT license + ([LICENSE-MIT](LICENSE-MIT) or ) + +at your option. + +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/vello_shaders/shader/UNLICENSE) or ). +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`](https://github.com/linebender/vello/tree/main/examples/assets) directory are licensed solely under +their respective licenses, available in the `LICENSE` file in their directories. + +[piet-metal]: https://github.com/linebender/piet-metal +[`wgpu`]: https://wgpu.rs/ +[Xilem]: https://github.com/linebender/xilem/ +[rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct +[`custom-hal-archive-with-shaders`]: https://github.com/linebender/piet-gpu/tree/custom-hal-archive-with-shaders +[`custom-hal-archive`]: https://github.com/linebender/piet-gpu/tree/custom-hal-archive +[piet-dx12]: https://github.com/bzm3r/piet-dx12 +[GhostScript tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg +[winit]: https://github.com/rust-windowing/winit +[Bevy]: https://bevyengine.org/ +[Requiem for piet-gpu-hal]: https://raphlinus.github.io/rust/gpu/2023/01/07/requiem-piet-gpu-hal.html diff --git a/src/glyph.rs b/vello/src/glyph.rs similarity index 100% rename from src/glyph.rs rename to vello/src/glyph.rs diff --git a/src/lib.rs b/vello/src/lib.rs similarity index 100% rename from src/lib.rs rename to vello/src/lib.rs diff --git a/src/recording.rs b/vello/src/recording.rs similarity index 100% rename from src/recording.rs rename to vello/src/recording.rs diff --git a/src/render.rs b/vello/src/render.rs similarity index 100% rename from src/render.rs rename to vello/src/render.rs diff --git a/src/scene.rs b/vello/src/scene.rs similarity index 100% rename from src/scene.rs rename to vello/src/scene.rs diff --git a/src/shaders.rs b/vello/src/shaders.rs similarity index 99% rename from src/shaders.rs rename to vello/src/shaders.rs index e844595be..abba984bc 100644 --- a/src/shaders.rs +++ b/vello/src/shaders.rs @@ -60,10 +60,7 @@ pub fn full_shaders( //let force_gpu_from = Some("binning"); #[cfg(feature = "hot_reload")] - let mut shaders = vello_shaders::compile::ShaderInfo::from_dir(concat!( - env!("CARGO_MANIFEST_DIR"), - "/shader" - )); + let mut shaders = vello_shaders::compile::ShaderInfo::from_default(); #[cfg(not(feature = "hot_reload"))] let shaders = vello_shaders::SHADERS; diff --git a/src/util.rs b/vello/src/util.rs similarity index 100% rename from src/util.rs rename to vello/src/util.rs diff --git a/src/wgpu_engine.rs b/vello/src/wgpu_engine.rs similarity index 100% rename from src/wgpu_engine.rs rename to vello/src/wgpu_engine.rs diff --git a/crates/encoding/Cargo.toml b/vello_encoding/Cargo.toml similarity index 100% rename from crates/encoding/Cargo.toml rename to vello_encoding/Cargo.toml diff --git a/vello_encoding/LICENSE-APACHE b/vello_encoding/LICENSE-APACHE new file mode 100644 index 000000000..d9a10c0d8 --- /dev/null +++ b/vello_encoding/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/vello_encoding/LICENSE-MIT b/vello_encoding/LICENSE-MIT new file mode 100644 index 000000000..48ff8e414 --- /dev/null +++ b/vello_encoding/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright 2020 the Vello Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/crates/encoding/README.md b/vello_encoding/README.md similarity index 100% rename from crates/encoding/README.md rename to vello_encoding/README.md diff --git a/crates/encoding/src/binning.rs b/vello_encoding/src/binning.rs similarity index 100% rename from crates/encoding/src/binning.rs rename to vello_encoding/src/binning.rs diff --git a/crates/encoding/src/clip.rs b/vello_encoding/src/clip.rs similarity index 100% rename from crates/encoding/src/clip.rs rename to vello_encoding/src/clip.rs diff --git a/crates/encoding/src/config.rs b/vello_encoding/src/config.rs similarity index 100% rename from crates/encoding/src/config.rs rename to vello_encoding/src/config.rs diff --git a/crates/encoding/src/draw.rs b/vello_encoding/src/draw.rs similarity index 100% rename from crates/encoding/src/draw.rs rename to vello_encoding/src/draw.rs diff --git a/crates/encoding/src/encoding.rs b/vello_encoding/src/encoding.rs similarity index 100% rename from crates/encoding/src/encoding.rs rename to vello_encoding/src/encoding.rs diff --git a/crates/encoding/src/estimate.rs b/vello_encoding/src/estimate.rs similarity index 100% rename from crates/encoding/src/estimate.rs rename to vello_encoding/src/estimate.rs diff --git a/crates/encoding/src/glyph.rs b/vello_encoding/src/glyph.rs similarity index 100% rename from crates/encoding/src/glyph.rs rename to vello_encoding/src/glyph.rs diff --git a/crates/encoding/src/glyph_cache.rs b/vello_encoding/src/glyph_cache.rs similarity index 100% rename from crates/encoding/src/glyph_cache.rs rename to vello_encoding/src/glyph_cache.rs diff --git a/crates/encoding/src/image_cache.rs b/vello_encoding/src/image_cache.rs similarity index 100% rename from crates/encoding/src/image_cache.rs rename to vello_encoding/src/image_cache.rs diff --git a/crates/encoding/src/lib.rs b/vello_encoding/src/lib.rs similarity index 100% rename from crates/encoding/src/lib.rs rename to vello_encoding/src/lib.rs diff --git a/crates/encoding/src/mask.rs b/vello_encoding/src/mask.rs similarity index 100% rename from crates/encoding/src/mask.rs rename to vello_encoding/src/mask.rs diff --git a/crates/encoding/src/math.rs b/vello_encoding/src/math.rs similarity index 100% rename from crates/encoding/src/math.rs rename to vello_encoding/src/math.rs diff --git a/crates/encoding/src/monoid.rs b/vello_encoding/src/monoid.rs similarity index 100% rename from crates/encoding/src/monoid.rs rename to vello_encoding/src/monoid.rs diff --git a/crates/encoding/src/path.rs b/vello_encoding/src/path.rs similarity index 100% rename from crates/encoding/src/path.rs rename to vello_encoding/src/path.rs diff --git a/crates/encoding/src/ramp_cache.rs b/vello_encoding/src/ramp_cache.rs similarity index 100% rename from crates/encoding/src/ramp_cache.rs rename to vello_encoding/src/ramp_cache.rs diff --git a/crates/encoding/src/resolve.rs b/vello_encoding/src/resolve.rs similarity index 100% rename from crates/encoding/src/resolve.rs rename to vello_encoding/src/resolve.rs diff --git a/crates/shaders/Cargo.toml b/vello_shaders/Cargo.toml similarity index 100% rename from crates/shaders/Cargo.toml rename to vello_shaders/Cargo.toml diff --git a/vello_shaders/LICENSE-APACHE b/vello_shaders/LICENSE-APACHE new file mode 100644 index 000000000..d9a10c0d8 --- /dev/null +++ b/vello_shaders/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/vello_shaders/LICENSE-MIT b/vello_shaders/LICENSE-MIT new file mode 100644 index 000000000..48ff8e414 --- /dev/null +++ b/vello_shaders/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright 2020 the Vello Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/crates/shaders/README.md b/vello_shaders/README.md similarity index 100% rename from crates/shaders/README.md rename to vello_shaders/README.md diff --git a/crates/shaders/build.rs b/vello_shaders/build.rs similarity index 82% rename from crates/shaders/build.rs rename to vello_shaders/build.rs index de46700b7..4334aef77 100644 --- a/crates/shaders/build.rs +++ b/vello_shaders/build.rs @@ -8,7 +8,7 @@ mod types; use std::env; use std::fmt::Write; -use std::path::{Path, PathBuf}; +use std::path::Path; use compile::ShaderInfo; @@ -16,19 +16,9 @@ fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("shaders.rs"); - println!("cargo:rerun-if-changed=../../shader"); + println!("cargo:rerun-if-changed={}", compile::shader_dir().display()); - // The shaders are defined under the workspace root and not in this crate so we need to locate - // them somehow. Cargo doesn't define an environment variable that points at the root workspace - // directory. In hermetic build environments that don't support relative paths (such as Bazel) - // we support supplying a `WORKSPACE_MANIFEST_FILE` that is expected to be an absolute path to - // the Cargo.toml file at the workspace root. If that's not present, we use a relative path. - let workspace_dir = env::var("WORKSPACE_MANIFEST_FILE") - .ok() - .and_then(|p| Path::new(&p).parent().map(|p| p.to_owned())) - .unwrap_or(PathBuf::from("../../")); - let shader_dir = Path::new(&workspace_dir).join("shader"); - let mut shaders = compile::ShaderInfo::from_dir(shader_dir); + let mut shaders = compile::ShaderInfo::from_default(); // Drop the HashMap and sort by name so that we get deterministic order. let mut shaders = shaders.drain().collect::>(); diff --git a/shader/UNLICENSE b/vello_shaders/shader/UNLICENSE similarity index 100% rename from shader/UNLICENSE rename to vello_shaders/shader/UNLICENSE diff --git a/shader/backdrop.wgsl b/vello_shaders/shader/backdrop.wgsl similarity index 100% rename from shader/backdrop.wgsl rename to vello_shaders/shader/backdrop.wgsl diff --git a/shader/backdrop_dyn.wgsl b/vello_shaders/shader/backdrop_dyn.wgsl similarity index 100% rename from shader/backdrop_dyn.wgsl rename to vello_shaders/shader/backdrop_dyn.wgsl diff --git a/shader/bbox_clear.wgsl b/vello_shaders/shader/bbox_clear.wgsl similarity index 100% rename from shader/bbox_clear.wgsl rename to vello_shaders/shader/bbox_clear.wgsl diff --git a/shader/binning.wgsl b/vello_shaders/shader/binning.wgsl similarity index 100% rename from shader/binning.wgsl rename to vello_shaders/shader/binning.wgsl diff --git a/shader/clip_leaf.wgsl b/vello_shaders/shader/clip_leaf.wgsl similarity index 100% rename from shader/clip_leaf.wgsl rename to vello_shaders/shader/clip_leaf.wgsl diff --git a/shader/clip_reduce.wgsl b/vello_shaders/shader/clip_reduce.wgsl similarity index 100% rename from shader/clip_reduce.wgsl rename to vello_shaders/shader/clip_reduce.wgsl diff --git a/shader/coarse.wgsl b/vello_shaders/shader/coarse.wgsl similarity index 100% rename from shader/coarse.wgsl rename to vello_shaders/shader/coarse.wgsl diff --git a/shader/draw_leaf.wgsl b/vello_shaders/shader/draw_leaf.wgsl similarity index 100% rename from shader/draw_leaf.wgsl rename to vello_shaders/shader/draw_leaf.wgsl diff --git a/shader/draw_reduce.wgsl b/vello_shaders/shader/draw_reduce.wgsl similarity index 100% rename from shader/draw_reduce.wgsl rename to vello_shaders/shader/draw_reduce.wgsl diff --git a/shader/fine.wgsl b/vello_shaders/shader/fine.wgsl similarity index 100% rename from shader/fine.wgsl rename to vello_shaders/shader/fine.wgsl diff --git a/shader/flatten.wgsl b/vello_shaders/shader/flatten.wgsl similarity index 100% rename from shader/flatten.wgsl rename to vello_shaders/shader/flatten.wgsl diff --git a/shader/path_count.wgsl b/vello_shaders/shader/path_count.wgsl similarity index 100% rename from shader/path_count.wgsl rename to vello_shaders/shader/path_count.wgsl diff --git a/shader/path_count_setup.wgsl b/vello_shaders/shader/path_count_setup.wgsl similarity index 100% rename from shader/path_count_setup.wgsl rename to vello_shaders/shader/path_count_setup.wgsl diff --git a/shader/path_tiling.wgsl b/vello_shaders/shader/path_tiling.wgsl similarity index 100% rename from shader/path_tiling.wgsl rename to vello_shaders/shader/path_tiling.wgsl diff --git a/shader/path_tiling_setup.wgsl b/vello_shaders/shader/path_tiling_setup.wgsl similarity index 100% rename from shader/path_tiling_setup.wgsl rename to vello_shaders/shader/path_tiling_setup.wgsl diff --git a/shader/pathtag_reduce.wgsl b/vello_shaders/shader/pathtag_reduce.wgsl similarity index 100% rename from shader/pathtag_reduce.wgsl rename to vello_shaders/shader/pathtag_reduce.wgsl diff --git a/shader/pathtag_reduce2.wgsl b/vello_shaders/shader/pathtag_reduce2.wgsl similarity index 100% rename from shader/pathtag_reduce2.wgsl rename to vello_shaders/shader/pathtag_reduce2.wgsl diff --git a/shader/pathtag_scan.wgsl b/vello_shaders/shader/pathtag_scan.wgsl similarity index 100% rename from shader/pathtag_scan.wgsl rename to vello_shaders/shader/pathtag_scan.wgsl diff --git a/shader/pathtag_scan1.wgsl b/vello_shaders/shader/pathtag_scan1.wgsl similarity index 100% rename from shader/pathtag_scan1.wgsl rename to vello_shaders/shader/pathtag_scan1.wgsl diff --git a/shader/permutations b/vello_shaders/shader/permutations similarity index 100% rename from shader/permutations rename to vello_shaders/shader/permutations diff --git a/shader/shared/bbox.wgsl b/vello_shaders/shader/shared/bbox.wgsl similarity index 100% rename from shader/shared/bbox.wgsl rename to vello_shaders/shader/shared/bbox.wgsl diff --git a/shader/shared/blend.wgsl b/vello_shaders/shader/shared/blend.wgsl similarity index 100% rename from shader/shared/blend.wgsl rename to vello_shaders/shader/shared/blend.wgsl diff --git a/shader/shared/bump.wgsl b/vello_shaders/shader/shared/bump.wgsl similarity index 100% rename from shader/shared/bump.wgsl rename to vello_shaders/shader/shared/bump.wgsl diff --git a/shader/shared/clip.wgsl b/vello_shaders/shader/shared/clip.wgsl similarity index 100% rename from shader/shared/clip.wgsl rename to vello_shaders/shader/shared/clip.wgsl diff --git a/shader/shared/config.wgsl b/vello_shaders/shader/shared/config.wgsl similarity index 100% rename from shader/shared/config.wgsl rename to vello_shaders/shader/shared/config.wgsl diff --git a/shader/shared/cubic.wgsl b/vello_shaders/shader/shared/cubic.wgsl similarity index 100% rename from shader/shared/cubic.wgsl rename to vello_shaders/shader/shared/cubic.wgsl diff --git a/shader/shared/drawtag.wgsl b/vello_shaders/shader/shared/drawtag.wgsl similarity index 100% rename from shader/shared/drawtag.wgsl rename to vello_shaders/shader/shared/drawtag.wgsl diff --git a/shader/shared/pathtag.wgsl b/vello_shaders/shader/shared/pathtag.wgsl similarity index 100% rename from shader/shared/pathtag.wgsl rename to vello_shaders/shader/shared/pathtag.wgsl diff --git a/shader/shared/ptcl.wgsl b/vello_shaders/shader/shared/ptcl.wgsl similarity index 100% rename from shader/shared/ptcl.wgsl rename to vello_shaders/shader/shared/ptcl.wgsl diff --git a/shader/shared/segment.wgsl b/vello_shaders/shader/shared/segment.wgsl similarity index 100% rename from shader/shared/segment.wgsl rename to vello_shaders/shader/shared/segment.wgsl diff --git a/shader/shared/tile.wgsl b/vello_shaders/shader/shared/tile.wgsl similarity index 100% rename from shader/shared/tile.wgsl rename to vello_shaders/shader/shared/tile.wgsl diff --git a/shader/shared/transform.wgsl b/vello_shaders/shader/shared/transform.wgsl similarity index 100% rename from shader/shared/transform.wgsl rename to vello_shaders/shader/shared/transform.wgsl diff --git a/shader/shared/util.wgsl b/vello_shaders/shader/shared/util.wgsl similarity index 100% rename from shader/shared/util.wgsl rename to vello_shaders/shader/shared/util.wgsl diff --git a/shader/tile_alloc.wgsl b/vello_shaders/shader/tile_alloc.wgsl similarity index 100% rename from shader/tile_alloc.wgsl rename to vello_shaders/shader/tile_alloc.wgsl diff --git a/crates/shaders/src/compile/mod.rs b/vello_shaders/src/compile/mod.rs similarity index 91% rename from crates/shaders/src/compile/mod.rs rename to vello_shaders/src/compile/mod.rs index ea6bbb2ea..ab0d9c9e3 100644 --- a/crates/shaders/src/compile/mod.rs +++ b/vello_shaders/src/compile/mod.rs @@ -5,7 +5,8 @@ use naga::front::wgsl; use naga::valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags}; use naga::{AddressSpace, ArraySize, ImageClass, Module, StorageAccess, WithSpan}; use std::collections::{HashMap, HashSet}; -use std::path::Path; +use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use thiserror::Error; pub mod permutations; @@ -129,6 +130,11 @@ impl ShaderInfo { }) } + /// Same as [`ShaderInfo::from_dir`] but uses the default shader directory provided by [`shader_dir`]. + pub fn from_default() -> HashMap { + ShaderInfo::from_dir(shader_dir()) + } + pub fn from_dir(shader_dir: impl AsRef) -> HashMap { use std::fs; let shader_dir = shader_dir.as_ref(); @@ -198,3 +204,12 @@ fn postprocess(wgsl: &str) -> String { } output } + +/// Returns the absolute path to the directory containing the WGSL shaders. +/// +/// The path is determined at compile time and is likely only valid on the compiling machine. +// NOTE: Embedding build environment info into the code makes reproducible builds trickier. +pub fn shader_dir() -> &'static PathBuf { + static SHADER_DIR: OnceLock = OnceLock::new(); + SHADER_DIR.get_or_init(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("shader")) +} diff --git a/crates/shaders/src/compile/msl.rs b/vello_shaders/src/compile/msl.rs similarity index 100% rename from crates/shaders/src/compile/msl.rs rename to vello_shaders/src/compile/msl.rs diff --git a/crates/shaders/src/compile/permutations.rs b/vello_shaders/src/compile/permutations.rs similarity index 100% rename from crates/shaders/src/compile/permutations.rs rename to vello_shaders/src/compile/permutations.rs diff --git a/crates/shaders/src/compile/preprocess.rs b/vello_shaders/src/compile/preprocess.rs similarity index 100% rename from crates/shaders/src/compile/preprocess.rs rename to vello_shaders/src/compile/preprocess.rs diff --git a/crates/shaders/src/cpu.rs b/vello_shaders/src/cpu.rs similarity index 100% rename from crates/shaders/src/cpu.rs rename to vello_shaders/src/cpu.rs diff --git a/crates/shaders/src/cpu/backdrop.rs b/vello_shaders/src/cpu/backdrop.rs similarity index 100% rename from crates/shaders/src/cpu/backdrop.rs rename to vello_shaders/src/cpu/backdrop.rs diff --git a/crates/shaders/src/cpu/bbox_clear.rs b/vello_shaders/src/cpu/bbox_clear.rs similarity index 100% rename from crates/shaders/src/cpu/bbox_clear.rs rename to vello_shaders/src/cpu/bbox_clear.rs diff --git a/crates/shaders/src/cpu/binning.rs b/vello_shaders/src/cpu/binning.rs similarity index 100% rename from crates/shaders/src/cpu/binning.rs rename to vello_shaders/src/cpu/binning.rs diff --git a/crates/shaders/src/cpu/clip_leaf.rs b/vello_shaders/src/cpu/clip_leaf.rs similarity index 100% rename from crates/shaders/src/cpu/clip_leaf.rs rename to vello_shaders/src/cpu/clip_leaf.rs diff --git a/crates/shaders/src/cpu/clip_reduce.rs b/vello_shaders/src/cpu/clip_reduce.rs similarity index 100% rename from crates/shaders/src/cpu/clip_reduce.rs rename to vello_shaders/src/cpu/clip_reduce.rs diff --git a/crates/shaders/src/cpu/coarse.rs b/vello_shaders/src/cpu/coarse.rs similarity index 100% rename from crates/shaders/src/cpu/coarse.rs rename to vello_shaders/src/cpu/coarse.rs diff --git a/crates/shaders/src/cpu/draw_leaf.rs b/vello_shaders/src/cpu/draw_leaf.rs similarity index 100% rename from crates/shaders/src/cpu/draw_leaf.rs rename to vello_shaders/src/cpu/draw_leaf.rs diff --git a/crates/shaders/src/cpu/draw_reduce.rs b/vello_shaders/src/cpu/draw_reduce.rs similarity index 100% rename from crates/shaders/src/cpu/draw_reduce.rs rename to vello_shaders/src/cpu/draw_reduce.rs diff --git a/crates/shaders/src/cpu/euler.rs b/vello_shaders/src/cpu/euler.rs similarity index 100% rename from crates/shaders/src/cpu/euler.rs rename to vello_shaders/src/cpu/euler.rs diff --git a/crates/shaders/src/cpu/fine.rs b/vello_shaders/src/cpu/fine.rs similarity index 100% rename from crates/shaders/src/cpu/fine.rs rename to vello_shaders/src/cpu/fine.rs diff --git a/crates/shaders/src/cpu/flatten.rs b/vello_shaders/src/cpu/flatten.rs similarity index 100% rename from crates/shaders/src/cpu/flatten.rs rename to vello_shaders/src/cpu/flatten.rs diff --git a/crates/shaders/src/cpu/path_count.rs b/vello_shaders/src/cpu/path_count.rs similarity index 100% rename from crates/shaders/src/cpu/path_count.rs rename to vello_shaders/src/cpu/path_count.rs diff --git a/crates/shaders/src/cpu/path_count_setup.rs b/vello_shaders/src/cpu/path_count_setup.rs similarity index 100% rename from crates/shaders/src/cpu/path_count_setup.rs rename to vello_shaders/src/cpu/path_count_setup.rs diff --git a/crates/shaders/src/cpu/path_tiling.rs b/vello_shaders/src/cpu/path_tiling.rs similarity index 100% rename from crates/shaders/src/cpu/path_tiling.rs rename to vello_shaders/src/cpu/path_tiling.rs diff --git a/crates/shaders/src/cpu/path_tiling_setup.rs b/vello_shaders/src/cpu/path_tiling_setup.rs similarity index 100% rename from crates/shaders/src/cpu/path_tiling_setup.rs rename to vello_shaders/src/cpu/path_tiling_setup.rs diff --git a/crates/shaders/src/cpu/pathtag_reduce.rs b/vello_shaders/src/cpu/pathtag_reduce.rs similarity index 100% rename from crates/shaders/src/cpu/pathtag_reduce.rs rename to vello_shaders/src/cpu/pathtag_reduce.rs diff --git a/crates/shaders/src/cpu/pathtag_scan.rs b/vello_shaders/src/cpu/pathtag_scan.rs similarity index 100% rename from crates/shaders/src/cpu/pathtag_scan.rs rename to vello_shaders/src/cpu/pathtag_scan.rs diff --git a/crates/shaders/src/cpu/tile_alloc.rs b/vello_shaders/src/cpu/tile_alloc.rs similarity index 100% rename from crates/shaders/src/cpu/tile_alloc.rs rename to vello_shaders/src/cpu/tile_alloc.rs diff --git a/crates/shaders/src/cpu/util.rs b/vello_shaders/src/cpu/util.rs similarity index 100% rename from crates/shaders/src/cpu/util.rs rename to vello_shaders/src/cpu/util.rs diff --git a/crates/shaders/src/lib.rs b/vello_shaders/src/lib.rs similarity index 79% rename from crates/shaders/src/lib.rs rename to vello_shaders/src/lib.rs index b8083ed79..a45cc6d46 100644 --- a/crates/shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -1,6 +1,22 @@ // Copyright 2023 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT +//! This is a utility library to help integrate the [Vello] shader modules into any renderer +//! project. It provides the necessary metadata to construct the individual compute pipelines +//! on any GPU API while leaving the responsibility of all API interactions +//! (such as resource management and command encoding) up to the client. +//! +//! The shaders can be pre-compiled to any target shading language at build time based on +//! feature flags. Currently only WGSL and Metal Shading Language are supported. +//! +//! Your first choice should be to use the build time generated [`SHADERS`]. +//! +//! Alternatively you could use runtime compiled shaders via the [`compile`] module +//! by enabling the `compile` feature. This option is useful for active development +//! as it enables you to do hot reloading of shaders. +//! +//! [Vello]: https://github.com/linebender/vello + mod types; #[cfg(feature = "compile")] diff --git a/crates/shaders/src/types.rs b/vello_shaders/src/types.rs similarity index 100% rename from crates/shaders/src/types.rs rename to vello_shaders/src/types.rs diff --git a/crates/tests/Cargo.toml b/vello_tests/Cargo.toml similarity index 100% rename from crates/tests/Cargo.toml rename to vello_tests/Cargo.toml diff --git a/crates/tests/build.rs b/vello_tests/build.rs similarity index 100% rename from crates/tests/build.rs rename to vello_tests/build.rs diff --git a/crates/tests/debug_outputs/.gitignore b/vello_tests/debug_outputs/.gitignore similarity index 100% rename from crates/tests/debug_outputs/.gitignore rename to vello_tests/debug_outputs/.gitignore diff --git a/crates/tests/src/lib.rs b/vello_tests/src/lib.rs similarity index 100% rename from crates/tests/src/lib.rs rename to vello_tests/src/lib.rs diff --git a/crates/tests/tests/smoke.rs b/vello_tests/tests/smoke.rs similarity index 100% rename from crates/tests/tests/smoke.rs rename to vello_tests/tests/smoke.rs