Skip to content

Commit

Permalink
Update wgpu to v0.19.3 and unpin web-sys. (#12247)
Browse files Browse the repository at this point in the history
This PR unpins `web-sys` so that unrelated projects that have
`bevy_render` in their workspace can finally update their `web-sys`.
More details in and fixes #12246.

* Update `wgpu` from 0.19.1 to 0.19.3.
* Remove the `web-sys` pin.
* Update docs and wasm helper to remove the now-stale
`--cfg=web_sys_unstable_apis` Rust flag.

---

Updated `wgpu` to v0.19.3 and removed `web-sys` pin.
  • Loading branch information
xStrom authored and mockersf committed Mar 2, 2024
1 parent 7caa026 commit f4df8b8
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 26 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ jobs:
target: wasm32-unknown-unknown
- name: Check wasm
run: cargo check --target wasm32-unknown-unknown
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis

markdownlint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ pbr_transmission_textures = ["bevy_internal/pbr_transmission_textures"]
# Enable some limitations to be able to use WebGL2. 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.
webgl2 = ["bevy_internal/webgl"]

# Enable support for WebGPU in Wasm. When enabled, this feature will override the `webgl2` feature and you won't be able to run Wasm builds with WebGL2, only with WebGPU. Requires the `RUSTFLAGS` environment variable to be set to `--cfg=web_sys_unstable_apis` when building.
# Enable support for WebGPU in Wasm. When enabled, this feature will override the `webgl2` feature and you won't be able to run Wasm builds with WebGL2, only with WebGPU.
webgpu = ["bevy_internal/webgpu"]

# Enables the built-in asset processor for processed assets.
Expand Down
6 changes: 2 additions & 4 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ image = { version = "0.24", default-features = false }
codespan-reporting = "0.11.0"
# `fragile-send-sync-non-atomic-wasm` feature means we can't use WASM threads for rendering
# It is enabled for now to avoid having to do a significant overhaul of the renderer just for wasm
wgpu = { version = "0.19.1", default-features = false, features = [
wgpu = { version = "0.19.3", default-features = false, features = [
"wgsl",
"dx12",
"metal",
Expand Down Expand Up @@ -105,9 +105,7 @@ naga_oil = { version = "0.13", default-features = false, features = [
[target.'cfg(target_arch = "wasm32")'.dependencies]
naga_oil = "0.13"
js-sys = "0.3"
# web-sys doesn't follow semver for the WebGPU APIs as they are unstable
# Make sure that WebGPU builds work when changing this!
web-sys = { version = "=0.3.67", features = [
web-sys = { version = "0.3.67", features = [
'Blob',
'Document',
'Element',
Expand Down
7 changes: 0 additions & 7 deletions docs-template/EXAMPLE_README.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,6 @@ ruby -run -ehttpd examples/wasm
Bevy support for WebGPU is being worked on, but is currently experimental.

To build for WebGPU, you'll need to enable the `webgpu` feature. This will override the `webgl2` feature, and builds with the `webgpu` feature enabled won't be able to run on browsers that don't support WebGPU.
WebGPU depends on unstable APIs so you will also need to pass the `web_sys_unstable_apis` flag to your builds. For example:

```sh
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build ...
```

Check `wasm-bindgen` [docs on Unstable APIs](https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html) for more details.

Bevy has an helper to build its examples:

Expand Down
2 changes: 1 addition & 1 deletion docs/cargo_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The default feature set enables most of the expected features of a game engine,
|trace_tracy_memory|Tracing support, with memory profiling, exposing a port for Tracy|
|wav|WAV audio format support|
|wayland|Wayland display server support|
|webgpu|Enable support for WebGPU in Wasm. When enabled, this feature will override the `webgl2` feature and you won't be able to run Wasm builds with WebGL2, only with WebGPU. Requires the `RUSTFLAGS` environment variable to be set to `--cfg=web_sys_unstable_apis` when building.|
|webgpu|Enable support for WebGPU in Wasm. When enabled, this feature will override the `webgl2` feature and you won't be able to run Wasm builds with WebGL2, only with WebGPU.|
|webp|WebP image format support|
|wgpu_trace|Save a trace of all wgpu calls|
|zlib|For KTX2 supercompression|
7 changes: 0 additions & 7 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,6 @@ ruby -run -ehttpd examples/wasm
Bevy support for WebGPU is being worked on, but is currently experimental.

To build for WebGPU, you'll need to enable the `webgpu` feature. This will override the `webgl2` feature, and builds with the `webgpu` feature enabled won't be able to run on browsers that don't support WebGPU.
WebGPU depends on unstable APIs so you will also need to pass the `web_sys_unstable_apis` flag to your builds. For example:

```sh
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build ...
```

Check `wasm-bindgen` [docs on Unstable APIs](https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html) for more details.

Bevy has an helper to build its examples:

Expand Down
5 changes: 1 addition & 4 deletions tools/build-wasm-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,10 @@ fn main() {
parameters.push("--features");
parameters.push(&features_string);
}
let mut cmd = cmd!(
let cmd = cmd!(
sh,
"cargo build {parameters...} --profile release --target wasm32-unknown-unknown --example {example}"
);
if matches!(cli.api, WebApi::Webgpu) {
cmd = cmd.env("RUSTFLAGS", "--cfg=web_sys_unstable_apis");
}
cmd.run().expect("Error building example");

cmd!(
Expand Down

0 comments on commit f4df8b8

Please sign in to comment.