tree: b9319042037d969fb3f91f64b6e159774db15aed [search]
  1. src/
  2. tests/
  3. .gitignore
  4. build.rs
  5. Cargo.toml
  6. README.md
vello_gpu/examples/native_webgl/README.md

WebGL Demo

Uses Vello GPU with a native WebGL2 backend in the browser. This example does not use wgpu.

Development

Run with RUSTFLAGS="-Ctarget-feature=+simd128" cargo run_wasm -p native_webgl --release.

If you don't want to enable SIMD, you can remove the RUSTFLAGS="-Ctarget-feature=+simd128" part.

Early shader compilation

The demo starts compiling Vello‘s shaders before the WebAssembly binary is fetched. The build script writes generated/bootstrap.js, which combines the compileVelloShaders module generated by vello_gpu_shaders with src/bootstrap.js. Because the wasm-bindgen glue imports that snippet before it fetches the binary, the snippet creates the canvas and starts compiling as soon as the page loads the glue. run_interactive then adopts the compiled programs with WebGlRenderer::begin_with_precompiled, falling back to compiling them from scratch with a console warning if they can’t be adopted.

Testing

In order to test this crate, you need to have wasm-pack installed. Install it using the steps found in https://wasm-bindgen.github.io/wasm-pack/installer/.

Thereafter, for interactive test sessions, run:

wasm-pack test --chrome
# Navigate to printed URL