-
Notifications
You must be signed in to change notification settings - Fork 1k
Optional web-specific deps for wasm32 #7565
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Before we land, as dependencies are really tricky and easy to regress, could you add dependency tests for:
- Ensuring that depending on wgpu on wasm with just the custom feature does not depend on wasm-bindgen et al.
- Ensuring that turning on either the webgl or webgpu feature does add wasm-bindgen et al.
- Ensuring turning on both ^ does not bring in wasm-bindgen on a native platform (lets say windows)
727c216
to
b8deaf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue, one question. Should we still have a web
feature on wgpu
as well to enable it with a custom backend running on the web? Might not be worth the bother.
tests/tests/wgpu-dependency/main.rs
Outdated
@@ -121,7 +121,7 @@ fn wasm32_with_webgpu_and_wgsl_does_not_depend_on_naga() { | |||
human_readable_name: "wasm32 with `webgpu` and `wgsl` feature does not depend on `naga`", | |||
target: "wasm32-unknown-unknown", | |||
packages: &["wgpu"], | |||
features: &["webgpu", "wgsl"], | |||
features: &["custom"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems errant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry for that, I must have slipped up while adding the tests below and did not notice it during the push.
28d2146
to
2f4c041
Compare
Regarding your question, I don't see what the We could add a web feature to semantically group the dependency enables instead of duplicating them for the two backends. |
The case I was thinking of was: you want a custom backend that runs on web-enabled wasm and want the web-sys types in |
wgpu/Cargo.toml
Outdated
@@ -68,7 +72,14 @@ angle = ["wgpu-core?/angle"] | |||
vulkan-portability = ["wgpu-core?/vulkan-portability"] | |||
|
|||
## Enables the GLES backend on WebAssembly only. | |||
webgl = ["wgpu-core/webgl", "dep:wgpu-hal", "dep:smallvec"] | |||
webgl = [ | |||
"wgpu-core/webgl", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wgpu-core/webgl
does enables wgpu-types/web
, but I am wondering if would be worth being explicit about this:
"wgpu-core/webgl", | |
"wgpu-core/webgl", | |
"wgpu-types/web", |
0b32f50
to
cc64df3
Compare
I've added a |
cc64df3
to
c6e0c4c
Compare
I am not quite sure how I should go about fixing the tests failing due to the custom example. This would work if only the custom example ist built. I guess I would either need to always depend on |
Maybe just tweak CI invocations by adding |
You can take some inspiration from: https://github.com/gfx-rs/wgpu/pull/7407/files |
c6e0c4c
to
98f65b5
Compare
Thanks for the hint. Wasn't quite sure whether that would be acceptable (essentially I could also just change that for that one example). But as I am not sure whether anyone else will actually use this, I did not want to add a separate matrix entry for wasm with and without web specifics. |
98f65b5
to
0c8a3e5
Compare
The root problem is #7314 |
7afc475
to
10d0d70
Compare
Connections
Related to what lead to #7533, but idependent.
Description
In the current version, the target_plaform wasm32 (without target_os emscripten) depends on web-specific dependencies. However, wasm can be used outside of the web, and wgpu can be used on wasm runtimes without javascript bindings / the webgpu backend using a custom backend.
Testing
I haven't tested emscripten or webgl (There is an idependent error when building webgl).
There might be some issues people working with emscripten/webgl might be able to detect here.
I am also not sure whether this could be simplified (the not emscripten in wgpu/Cargo.toml might be unnecessary).
Squash or Rebase?
Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
(some independent warnings)cargo xtask test
to run tests. (one naga error I don't think is related to this)CHANGELOG.md
entry.