-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Webgpu support #8336
Webgpu support #8336
Conversation
Example |
1 similar comment
Example |
Yeeeeeeeeaaaaahhh! Much excite! :) I’ll take a look at the errors if no one else beats me to it. And you’re welcome to. |
Rather than a impl RenderPlugin for MyPlugin {
fn render_app(&self, mut render_app: &mut App) {
// put code modifying render app here.
}
fn extract_app(&self mut extract_app: &mut App) {
// put code modifying extract app here.
}
} you could not add the render and extract app until after the renderer is ready, to make it 100% clear to not modify the render app in the build function. |
Sounds good to me, to have a I'll wait for more feedback on the API which is definitely open to discussion |
Yesssssss well done! This definitely seems like the better path. I'm stoked we don't need to async-ify the entire plugin api. I'll give the pipeline / render app init apis some thought, but I'm on board for the general direction. We might even want to skip blocking on the "ideal render init api design" and do that in a follow up pr. It would be nice to get this in peoples' hands asap so we can iron out the kinks and capitalize on the "WebGPU release hype". |
Completely agree on not getting hung up too much on render app init api for this PR. It's a good discussion to have, and this PR is about making WebGPU go. :) |
remaining:
and a lot of unhelpful
which I'm hoping will be fixed by fixing other issues |
Incorrect colors should be because of the TODO left in the code here. It should be the same surface format issue as with Nvidia + Wayland. |
Awesome! Well done @mockersf ! :) |
Nice! I can confirm that fixes Nvidia + Wayland (and probably some other hardware/software combos) as well : ) |
Ho that's a nice side effect 😄 Do you know if there are issues opened? |
thanks! let's wait for this to be merged so someone can check for the two others. with gfx-rs/wgpu#3689 and a small workaround in Bevy, bloom also works 🎉 |
every example I tried seems to work now, except |
f2a6d6e
to
aecabb8
Compare
With #8446 merged and wgpu updated to 0.16, this is now ready 🎉 |
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.
I don’t have too much in the way of opinions about plugin stuff. Others should definitely review that, please. It does feel like a shame that users implementing rendering stuff have to care about that and implement finish() but maybe that’s the only way to handle it.
The rendering bits generally look fine. It’s mostly just plugin adjustment. Just a few comments.
@@ -130,7 +130,8 @@ fn downsample_first(@location(0) output_uv: vec2<f32>) -> @location(0) vec4<f32> | |||
// Lower bound of 0.0001 is to avoid propagating multiplying by 0.0 through the | |||
// downscaling and upscaling which would result in black boxes. | |||
// The upper bound is to prevent NaNs. | |||
sample = clamp(sample, vec3<f32>(0.0001), vec3<f32>(3.40282347E+38)); | |||
// with f32::MAX (E+38) Chrome fails with ":value 340282346999999984391321947108527833088.0 cannot be represented as 'f32'" | |||
sample = clamp(sample, vec3<f32>(0.0001), vec3<f32>(3.40282347E+37)); |
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.
It would be better to know what value should be used. But I guess this will do.
Should webgpu be the default? It's the easiest way to do it through rust features, and adding one to target webgl2 instead. It would probably be possible to keep webgl2 the default, but that would mean needing to disable default features to target webgpu. |
I think WebGL2 should be the default until WebGPU is more widely supported. Making it harder to target WebGPU (by requiring disabling default features) while it is still rolling out seems very reasonable to me. The alternative (forcing users onto WebGPU by default before it is widely supported) seems worse to me. |
Done! |
ec10bef
to
c6c8c22
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.
This is in a good spot now. Im stoked to finally have WebGPU support!
We should follow up with a "render plugin init" rethink.
# Objective Fixes #9121 Context: - `ImageTextureLoader` depends on `RenderDevice` to work out which compressed image formats it can support - `RenderDevice` is initialised by `RenderPlugin` - #8336 made `RenderPlugin` initialisation async - This caused `RenderDevice` to be missing at the time of `ImageTextureLoader` initialisation, which in turn meant UASTC encoded ktx2 textures were being converted to unsupported formats, and thus caused panics ## Solution - Delay `ImageTextureLoader` initialisation --- ## Changelog - Moved `ImageTextureLoader` initialisation from `ImagePlugin::build()` to `ImagePlugin::finish()` - Default to `CompressedImageFormats::NONE` if `RenderDevice` resource is missing --------- Co-authored-by: 66OJ66 <hi0obxud@anonaddy.me>
# Objective Fixes #9121 Context: - `ImageTextureLoader` depends on `RenderDevice` to work out which compressed image formats it can support - `RenderDevice` is initialised by `RenderPlugin` - #8336 made `RenderPlugin` initialisation async - This caused `RenderDevice` to be missing at the time of `ImageTextureLoader` initialisation, which in turn meant UASTC encoded ktx2 textures were being converted to unsupported formats, and thus caused panics ## Solution - Delay `ImageTextureLoader` initialisation --- ## Changelog - Moved `ImageTextureLoader` initialisation from `ImagePlugin::build()` to `ImagePlugin::finish()` - Default to `CompressedImageFormats::NONE` if `RenderDevice` resource is missing --------- Co-authored-by: 66OJ66 <hi0obxud@anonaddy.me>
# Objective Fixes #9121 Context: - `ImageTextureLoader` depends on `RenderDevice` to work out which compressed image formats it can support - `RenderDevice` is initialised by `RenderPlugin` - bevyengine/bevy#8336 made `RenderPlugin` initialisation async - This caused `RenderDevice` to be missing at the time of `ImageTextureLoader` initialisation, which in turn meant UASTC encoded ktx2 textures were being converted to unsupported formats, and thus caused panics ## Solution - Delay `ImageTextureLoader` initialisation --- ## Changelog - Moved `ImageTextureLoader` initialisation from `ImagePlugin::build()` to `ImagePlugin::finish()` - Default to `CompressedImageFormats::NONE` if `RenderDevice` resource is missing --------- Co-authored-by: 66OJ66 <hi0obxud@anonaddy.me>
Objective
Solution
For async renderer initialisation
plugin.build
ready
of all registered plugins in the same ordertrue
by defaultfinish
then allcleanup
in the same order as registeredIn the case of the renderer, to avoid anything async:
ready
will wait for the renderer to be present in the resourcefinish
will take that renderer and place it in the expected resources by other pluginsfinish
are called and they are able to set up their pipelinescleanup
is called, only custom one is still for pipeline renderingFor WebGPU support
build-wasm-example
script to support passing--api webgpu
that will build the example with WebGPU supportwasm32
Migration Guide
Plugin::setup
has been renamedPlugin::cleanup
Plugin::finish
has been added, and plugins adding pipelines should do it in this function instead ofPlugin::build