Skip to content

Commit feb47e7

Browse files
wip
1 parent e986f41 commit feb47e7

26 files changed

+3425
-755
lines changed

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ members = [
1717
"sparse_strips/vello_common",
1818
"sparse_strips/vello_cpu",
1919
"sparse_strips/vello_hybrid",
20+
"sparse_strips/vello_hybrid_shaders",
21+
"sparse_strips/vello_hybrid/examples/native_webgl",
2022
"sparse_strips/vello_hybrid/examples/scenes",
2123
"sparse_strips/vello_hybrid/examples/webgl",
2224
"sparse_strips/vello_hybrid/examples/winit",
@@ -113,6 +115,7 @@ vello_api = { path = "sparse_strips/vello_api", default-features = false }
113115
vello_common = { version = "0.0.1", path = "sparse_strips/vello_common", default-features = false }
114116
vello_cpu = { path = "sparse_strips/vello_cpu" }
115117
vello_hybrid = { path = "sparse_strips/vello_hybrid" }
118+
vello_hybrid_shaders = { path = "sparse_strips/vello_hybrid_shaders" }
116119
vello_hybrid_scenes = { path = "sparse_strips/vello_hybrid/examples/scenes" }
117120
vello_dev_macros = { path = "sparse_strips/vello_dev_macros" }
118121

sparse_strips/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This directory contains the core crates for the Vello rendering. Each crate serv
2222
- **`vello_common`** – Provides shared data structures and utilities for rendering.
2323
- **`vello_cpu`** – Implements a CPU-based renderer optimized for multithreading and SIMD.
2424
- **`vello_hybrid`** – A hybrid CPU/GPU renderer, balancing workload between CPU and GPU.
25+
- **`vello_hybrid_shaders`** – Provide compilation of wgsl to glsl to support the WebGL `vello_hybrid` backend.
2526

2627
## Development Status
2728

sparse_strips/vello_hybrid/Cargo.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ workspace = true
1818
bytemuck = { workspace = true, features = ["derive"] }
1919
thiserror = { workspace = true }
2020
vello_common = { workspace = true, features = ["std"] }
21-
wgpu = { workspace = true }
21+
wgpu = { workspace = true, optional = true }
22+
vello_hybrid_shaders = { workspace = true, optional = true}
23+
24+
25+
# [target.'cfg(target_arch = "wasm32")'.dependencies]
26+
js-sys = { version = "0.3.77", optional = true }
27+
web-sys = { version = "0.3.77", features = [
28+
"WebGl2RenderingContext",
29+
"WebGlProgram",
30+
"WebGlUniformLocation",
31+
"WebGlBuffer",
32+
"WebGlShader",
33+
"WebGlTexture",
34+
"WebGlFramebuffer",
35+
"WebGlVertexArrayObject",
36+
"WebGlActiveInfo"
37+
], optional = true }
38+
2239

2340
[dev-dependencies]
2441
png = { workspace = true }
2542
pollster = { workspace = true }
2643
vello_common = { workspace = true, features = ["pico_svg"] }
2744
roxmltree = "0.20.0"
45+
46+
[features]
47+
default = ["wgpu"]
48+
wgpu = ["dep:wgpu"]
49+
webgl = ["dep:js-sys", "dep:web-sys", "dep:vello_hybrid_shaders"]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[package]
2+
name = "native_webgl"
3+
version.workspace = true
4+
description = "An example showing Vello Hybrid using the WebGL2 renderer backend."
5+
edition.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
publish = false
9+
10+
[lib]
11+
crate-type = ["cdylib", "rlib"]
12+
13+
[lints]
14+
workspace = true
15+
16+
[dependencies]
17+
console_error_panic_hook = "0.1.7"
18+
console_log = "1.0"
19+
js-sys = "0.3.77"
20+
log = { workspace = true }
21+
vello_common = { workspace = true }
22+
vello_hybrid = { workspace = true, features=["webgl"] }
23+
vello_hybrid_scenes = { workspace = true }
24+
wasm-bindgen = "0.2.100"
25+
wasm-bindgen-futures = "0.4.50"
26+
web-sys = { version = "0.3.77", features = [
27+
"Window",
28+
"Document",
29+
"Element",
30+
"HtmlElement",
31+
"HtmlCanvasElement",
32+
"CssStyleDeclaration",
33+
"WebGl2RenderingContext",
34+
"MouseEvent",
35+
"WheelEvent",
36+
"KeyboardEvent",
37+
] }
38+
39+
[dev-dependencies]
40+
wasm-bindgen-test = "0.3.50"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## WebGL Demo
2+
3+
Uses Vello Hybrid with a native WebGL2 backend in the browser. This example does not use wgpu.
4+
5+
## Development
6+
7+
Run with `cargo run_wasm -p native_webgl`.
8+
9+
## Testing
10+
11+
In order to test this crate, you need to have [`wasm-pack`] installed. Install it using
12+
the steps found in https://rustwasm.github.io/wasm-pack/installer/.
13+
14+
Thereafter, for interactive test sessions, run:
15+
16+
```
17+
wasm-pack test --chrome
18+
# Navigate to printed URL
19+
```
20+
21+
[`wasm-pack`]: https://rustwasm.github.io/wasm-pack/

0 commit comments

Comments
 (0)