[Merged by Bors] - WebGL2 support#3039
[Merged by Bors] - WebGL2 support#3039mrk-its wants to merge 8 commits intobevyengine:pipelined-renderingfrom
Conversation
| } | ||
| } | ||
|
|
||
| fn handle_initial_window_events(world: &mut World, event_loop: &EventLoop<()>) { |
There was a problem hiding this comment.
Can you do this in the winit_runner_with and keep the EventLoop argument of winit_runner_with?
There was a problem hiding this comment.
@cart ? (it is your code :) But it seems handle_initial_window_events needs to be called as is, because we need to have a window when renderer_plugin is initialized.
There was a problem hiding this comment.
Yup sadly its an order of operations thing. We need to init these windows before the RenderPlugin is setup, not before the app starts running.
| impl BevyDefault for wgpu::TextureFormat { | ||
| fn bevy_default() -> Self { | ||
| if cfg!(target_os = "android") { | ||
| if cfg!(target_os = "android") || cfg!(target_arch = "wasm32") { |
There was a problem hiding this comment.
Can we use rgba everywhere? Are there any advantages to bgra on other platforms?
There was a problem hiding this comment.
I remember hearing that a lot of hardware only supports (or prefers) bgra swap chains.
There was a problem hiding this comment.
Wgpu used to use bgra as a default in their examples, but it looks like at some point they switched to rgba. @kvark is there any reason to default to bgra at this point?
There was a problem hiding this comment.
At this point we can default to RGBA. Originally, we weren't sure if RGBA is really supported everywhere for presentation, as weird as it sounds.
| Backends::PRIMARY | ||
| } else { | ||
| Backends::GL | ||
| }; |
There was a problem hiding this comment.
Wgpu be changed to default to webgl on wasm?
There was a problem hiding this comment.
Good point, it would be great to prefer webgpu over webgl if available (probably). I'll try to figure out how to do it.
There was a problem hiding this comment.
I don't think its worth blocking on this, but I agree that its a "nice to have".
pipelined/bevy_render2/Cargo.toml
Outdated
|
|
||
| # misc | ||
| wgpu = { version = "0.11.0", features = ["spirv"] } | ||
| wgpu = { version = "0.11.0", features = ["spirv", "webgl"] } |
There was a problem hiding this comment.
Should this feature be enabled only in wasm? That's possible now with edition 2021
|
Just pushed a change to only enable the wgpu webgl feature on wasm. I think this is good to go. Some follow ups to do:
|
|
bors r+ |
# Objective Make possible to use wgpu gles backend on in the browser (wasm32 + WebGL2). ## Solution It is built on top of old @cart patch initializing windows before wgpu. Also: - initializes wgpu with `Backends::GL` and proper `wgpu::Limits` on wasm32 - changes default texture format to `wgpu::TextureFormat::Rgba8UnormSrgb` Co-authored-by: Mariusz Kryński <[email protected]>
|
Also I can confirm that bevymark_pipelined does work on wasm/webgl2 if i disable the following features: bevy_audio, bevy_dynamic_plugin, bevy_wgpu, bevy_pbr2, render, mp3 |
|
Build failed: |
|
bors r+ |
# Objective Make possible to use wgpu gles backend on in the browser (wasm32 + WebGL2). ## Solution It is built on top of old @cart patch initializing windows before wgpu. Also: - initializes wgpu with `Backends::GL` and proper `wgpu::Limits` on wasm32 - changes default texture format to `wgpu::TextureFormat::Rgba8UnormSrgb` Co-authored-by: Mariusz Kryński <[email protected]>
|
Build failed: |
| use winit::platform::unix::EventLoopExtUnix; | ||
|
|
There was a problem hiding this comment.
the cfg before should be removed also
There was a problem hiding this comment.
bawhaha well that wasn't smart of me
|
bors r+ |
# Objective Make possible to use wgpu gles backend on in the browser (wasm32 + WebGL2). ## Solution It is built on top of old @cart patch initializing windows before wgpu. Also: - initializes wgpu with `Backends::GL` and proper `wgpu::Limits` on wasm32 - changes default texture format to `wgpu::TextureFormat::Rgba8UnormSrgb` Co-authored-by: Mariusz Kryński <[email protected]>
|
Pull request successfully merged into pipelined-rendering. Build succeeded: |
This reverts commit 7d932ac.
Objective
Make possible to use wgpu gles backend on in the browser (wasm32 + WebGL2).
Solution
It is built on top of old @cart patch initializing windows before wgpu. Also:
Backends::GLand properwgpu::Limitson wasm32wgpu::TextureFormat::Rgba8UnormSrgb