Allow WebGPU & WebGL in same wasm and detect WebGPU availability#5044
Conversation
cwfitzgerald
left a comment
There was a problem hiding this comment.
Need to see it rebased to fully review, but some initial comments
3551f91 to
8147cfe
Compare
cwfitzgerald
left a comment
There was a problem hiding this comment.
Looks good outside of a issue with get_mapped_range
|
@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
SurfaceTargetenum #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
webgpufeature flag that is enabled by default for this purpose. When additionally enablingwebglthis will no longer disablewebgpuand 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_halmethods now return anOption(most already did) to make it possible for them to returnNonewhenever 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-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.