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

Improve WebGPU unstable flags docs #10163

Merged
merged 8 commits into from
Oct 18, 2023
Merged

Conversation

mnmaita
Copy link
Member

@mnmaita mnmaita commented Oct 17, 2023

Objective

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.

@@ -539,10 +539,18 @@ ruby -run -ehttpd examples/wasm

#### WebGL2 and WebGPU

Bevy support for WebGPU is being worked on, but is currently experimental.
Bevy ships with WebGPU by default, but it is being worked on and is currently experimental.

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

Choose a reason for hiding this comment

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

I'm wondering if this statement is still true... Wouldn't WebGPU be enabled by default if one does not define any features and roll with bevy defaults? I can verify this sometime this week but if someone knows... Please leave a comment!

Copy link
Contributor

Choose a reason for hiding this comment

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

This is still true. The webgl2 feature is included in our default features.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, thanks for the heads up. I re-reviewed the default feature list and now I understand. I'll adjust the language I've introduced in the previous paragraph accordingly.

@mnmaita mnmaita added C-Docs An addition or correction to our documentation O-Web Specific to web (WASM) builds O-WebGPU Specific to the WebGPU render API labels Oct 17, 2023
@github-actions
Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@mnmaita
Copy link
Member Author

mnmaita commented Oct 17, 2023

I realized I shouldn't update the examples/README.md file itself, but a template. Wondering if said file is docs-template\EXAMPLE_README.md.tpl?

@rparrett
Copy link
Contributor

Wondering if said file is docs-template\EXAMPLE_README.md.tpl?

Yep!

Also, cargo_features.md is built using a similar process from the comments in Cargo.toml. That can be updated with cargo run -p build-templated-pages -- update features.

@mnmaita
Copy link
Member Author

mnmaita commented Oct 17, 2023

Wondering if said file is docs-template\EXAMPLE_README.md.tpl?

Yep!

Also, cargo_features.md is built using a similar process from the comments in Cargo.toml. That can be updated with cargo run -p build-templated-pages -- update features.

Thanks for clarifying! I'll make the changes tomorrow. Any suggestions to improve the language in the meantime will be welcomed.

@@ -34,7 +34,7 @@ The default feature set enables most of the expected features of a game engine,
|png|PNG image format support|
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files|
|vorbis|OGG/VORBIS audio format support|
|webgl2|Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm|
|webgl2|Given the fact that WebGPU support in Bevy is experimental, this feature will enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm. Keep in mind that that WebGPU depends on unstable APIs so you will also need to pass the `web_sys_unstable_apis` flag to your builds (e.g. `RUSTFLAGS=--cfg=web_sys_unstable_apis cargo run ...`). Check `wasm-bindgen` [docs on Unstable APIs](https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html) for more details.|
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a lot for this feature table. Maybe we could just link off to the WebGL2 and WebGPU in the examples readme?

Copy link
Contributor

@nicopap nicopap left a comment

Choose a reason for hiding this comment

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

Once @rparrett concerns are fixed, I think it can be merged.

@mnmaita
Copy link
Member Author

mnmaita commented Oct 18, 2023

@rparrett @nicopap updated both templates, rolled back a statement that was wrong and applied the suggestion.

@github-actions
Copy link
Contributor

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@mnmaita
Copy link
Member Author

mnmaita commented Oct 18, 2023

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

Weird, since I didn't change the features this time 😆

Cargo.toml Outdated
@@ -241,7 +241,7 @@ shader_format_glsl = ["bevy_internal/shader_format_glsl"]
# Enable support for shaders in SPIR-V
shader_format_spirv = ["bevy_internal/shader_format_spirv"]

# Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm
# 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](../examples/README.md) section of the examples README for more information on how to run Wasm builds with WebGPU.
Copy link
Member

Choose a reason for hiding this comment

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

this doc is published here: https://docs.rs/bevy/latest/bevy/#default-features
how does that link works from docs.rs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I didn't know this. Would linking to the file on the latest branch work better?

Copy link
Member

Choose a reason for hiding this comment

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

yup!

Copy link
Contributor

@rparrett rparrett Oct 18, 2023

Choose a reason for hiding this comment

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

oops, yeah. what about linking straight to to https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu? edit: sorry, couple minutes late to the party.

Copy link
Member Author

Choose a reason for hiding this comment

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

No prob. And how did I miss adding the reference to the heading? 🤦🏻 My bad! I'll fix both suggestions in a moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 11a1caa

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 run ...
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo run ...
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build ...

cargo run doesn't work without extra config for wasm

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 2f1d566

@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 18, 2023
@mockersf mockersf added this pull request to the merge queue Oct 18, 2023
Merged via the queue into bevyengine:main with commit 0dc7e60 Oct 18, 2023
26 checks passed
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

- Fixes bevyengine#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.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Fixes bevyengine#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.
@mnmaita mnmaita deleted the web-gpu-docs branch March 30, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Docs An addition or correction to our documentation O-Web Specific to web (WASM) builds O-WebGPU Specific to the WebGPU render API S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mention --cfg=web_sys_unstable_apis in WebGPU build instructions
4 participants