Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wgpu to v0.19.3 and unpin web-sys. #12247

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,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 @@ -303,7 +303,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
2 changes: 1 addition & 1 deletion crates/bevy_color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
bytemuck = "1"
serde = "1.0"
thiserror = "1.0"
wgpu = { version = "0.19.1", default-features = false }
wgpu = { version = "0.19.3", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just specify 0.19 here and elsewhere: the minor version is actually ignored by Cargo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.19.0, 0.19.1, 0.19.2 have the problematic dependency. The 0.19.3 is a real dependency.

I assume by "ignored by Cargo" you mean that Cargo prefers the latest version by default. Because with the 0.19.3 requirement Cargo will never build with anything lower.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo does use the minor version. This is specifying at least 0.19.3.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right yep :)

encase = { version = "0.7", default-features = false }

[lints]
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 @@ -66,7 +66,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 @@ -107,9 +107,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 @@ -83,7 +83,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 @@ -583,13 +583,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 @@ -73,13 +73,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