-
Notifications
You must be signed in to change notification settings - Fork 953
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
Allow WebGPU & WebGL in same wasm and detect WebGPU availability #5044
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.
Need to see it rebased to fully review, but some initial comments
3551f91
to
8147cfe
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.
Looks good outside of a issue with get_mapped_range
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.
Hell yes!
@Wumpf please resolve conflicts, then merge |
woo 🥳 |
This looks very handy! Is there a documented list of things the WebGL version doesn't support? I assume compute shaders is one such obvious missing feature (although I wonder if there's been any effort put towards polyfilling compute shaders with fragment shader magic?). |
@Keavon there's unfortunately no written out list since it's a bit hard to capture - some of the exact capabilities are determined at runtime. But you can check https://docs.rs/wgpu/latest/wgpu/struct.DownlevelFlags.html# for possible lacking features as well as https://docs.rs/wgpu/latest/wgpu/struct.Limits.html#method.downlevel_webgl2_defaults which lists out the reduced limits of webgl directly. |
It's almost certainly easier to polyfill them in the user's application using application specific knowledge if you need them. |
Connections
SurfaceTarget
enum #4984Shoutout to @daxpedda who did a lot of the groundwork to make this possible!
Description
Allows to compile with both webgpu & webgl backends enabled. There's a new
webgpu
feature flag that is enabled by default for this purpose. When additionally enablingwebgl
this will no longer disablewebgpu
and both features can live side by side.The WebGPU backend remains a special case in that far that an instance decides (via very simple support detection logic) upon creation if it is a WebGPU instance or a WgpuCore instance. I did a bunch of renamings in that area to make this more obvious. Also, all
as_hal
methods now return anOption
(most already did) to make it possible for them to returnNone
whenever both WebGPU & WebGL are enabled (only a WebGL/WgpuCore instance can do hal conversion). Similar patter applies to a variety of things.DRAFT until #4984 lands
(makes the diff also significantly smaller)
Testing
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.