Skip to content

Commit 0dc7e60

Browse files
authored
Improve WebGPU unstable flags docs (#10163)
# Objective - Fixes #9382 ## Solution - Added a few extra notes in regards to WebGPU experimental state and the need of enabling unstable APIs through certain attribute flags in `cargo_features.md` and the examples `README.md` files.
1 parent d857cd6 commit 0dc7e60

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ shader_format_glsl = ["bevy_internal/shader_format_glsl"]
241241
# Enable support for shaders in SPIR-V
242242
shader_format_spirv = ["bevy_internal/shader_format_spirv"]
243243

244-
# Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm
244+
# Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.
245245
webgl2 = ["bevy_internal/webgl"]
246246

247247
# Enables watching the filesystem for Bevy Asset hot-reloading

docs-template/EXAMPLE_README.md.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ Bevy support for WebGPU is being worked on, but is currently experimental.
240240

241241
To build for WebGPU, you'll need to disable default features and add all those you need, making sure to omit the `webgl2` feature.
242242

243+
WebGPU depends on unstable APIs so you will also need to pass the `web_sys_unstable_apis` flag to your builds. For example:
244+
245+
```sh
246+
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build ...
247+
```
248+
249+
Check `wasm-bindgen` [docs on Unstable APIs](https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html) for more details.
250+
243251
Bevy has an helper to build its examples:
244252

245253
- Build for WebGL2: `cargo run -p build-wasm-example -- --api webgl2 load_gltf`

docs/cargo_features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The default feature set enables most of the expected features of a game engine,
3434
|png|PNG image format support|
3535
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files|
3636
|vorbis|OGG/VORBIS audio format support|
37-
|webgl2|Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm|
37+
|webgl2|Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.|
3838
|x11|X11 display server support|
3939
|zstd|For KTX2 supercompression|
4040

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,14 @@ Bevy support for WebGPU is being worked on, but is currently experimental.
544544

545545
To build for WebGPU, you'll need to disable default features and add all those you need, making sure to omit the `webgl2` feature.
546546

547+
WebGPU depends on unstable APIs so you will also need to pass the `web_sys_unstable_apis` flag to your builds. For example:
548+
549+
```sh
550+
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build ...
551+
```
552+
553+
Check `wasm-bindgen` [docs on Unstable APIs](https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html) for more details.
554+
547555
Bevy has an helper to build its examples:
548556

549557
- Build for WebGL2: `cargo run -p build-wasm-example -- --api webgl2 load_gltf`

0 commit comments

Comments
 (0)