WASM does not work with HDR
Hi, I have an issue when enabling HDR running in the browser. Thanks for any help.
Bevy version
Tried 0.9.1 and bleeding (cf612c8349068c2250dddf8190cd9cc5c24763d8)
Relevant system information
Chrome Version 108.0.5359.71 (Official Build) (64-bit) on Ubuntu 22.10
AdapterInfo { name: "ANGLE (Intel, Vulkan 1.3.224 (Intel(R) Xe Graphics (TGL GT2) (0x00009A49)), Intel open-source Mesa driver)", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }
What you did
checkout https://github.com/rust-adventure/bevy-examples/blob/418afebf3f411625e149a23c2a360ffeee71b2b7/examples/bloom-2d/src/main.rs and run using wasm-server-runner
cargo run --target wasm32-unknown-unknown
What went wrong
wasm.js:371 panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_texture
note: label = `main_texture_sampled`
Format Rgba16Float does not support multisampling
', /home/redspider/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs:2403:5
Stack:
Error
at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:1334/api/wasm.js:359:13)
at __wbg_new_abda76e883ba8a5f externref shim (http://localhost:1334/api/wasm.wasm:wasm-function[30763]:0xded455)
at console_error_panic_hook::hook::h83df3a0af36e2bba (http://localhost:1334/api/wasm.wasm:wasm-function[9303]:0xa71ce7)
at core::ops::function::Fn::call::h39797319ccfadbf4 (http://localhost:1334/api/wasm.wasm:wasm-function[43389]:0xe239e3)
at std::panicking::rust_panic_with_hook::hb42d415afcc11f2f (http://localhost:1334/api/wasm.wasm:wasm-function[15757]:0xc76697)
at std::panicking::begin_panic_handler::{{closure}}::h57dd84c078404aa2 (http://localhost:1334/api/wasm.wasm:wasm-function[18765]:0xd02df3)
at std::sys_common::backtrace::__rust_end_short_backtrace::hef94dcc71d3b37f5 (http://localhost:1334/api/wasm.wasm:wasm-function[27153]:0xdd0e16)
at rust_begin_unwind (http://localhost:1334/api/wasm.wasm:wasm-function[22878]:0xd84fb2)
at core::panicking::panic_fmt::h32de9c76c9d5eb0c (http://localhost:1334/api/wasm.wasm:wasm-function[25650]:0xdbbce5)
at core::ops::function::Fn::call::h811e23061157d904 (http://localhost:1334/api/wasm.wasm:wasm-function[16627]:0xca3fe2)
Additional information
Works fine when HDR is disabled or without wasm
This is a known limitation that can be worked around by disabling MSAA.
https://docs.rs/bevy/latest/bevy/prelude/struct.Camera.html#structfield.hdr
I'm not sure if this is a webgl, wgpu, or bevy limitation. Presumably, that information is in the pull request linked in those docs somewhere...
Thanks for the quick help. MSAA is not enabled by default, right? I'm not sure how I can disable it when it's not even inserted as resource, but setting it to 0 or 1 will crash with a different error:
ERROR Handling wgpu errors as fatal by default log.target = "wgpu::backend::direct";log.module_path = "wgpu::backend::direct";log.file = "/home/redspider/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs";log.line = 2402;
wasm.js:371 panicked at 'wgpu error: Validation Error
Caused by:
In Texture::create_view
TextureView mip level count + base mip level 5 must be <= Texture mip level count 4
', /home/redspider/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs:2403:5
Stack:
Error
at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:1334/api/wasm.js:359:13)
at __wbg_new_abda76e883ba8a5f externref shim (http://localhost:1334/api/wasm.wasm:wasm-function[31658]:0xef1dcb)
at console_error_panic_hook::hook::h83df3a0af36e2bba (http://localhost:1334/api/wasm.wasm:wasm-function[9505]:0xb3c672)
at core::ops::function::Fn::call::h201dd88a31d664ad (http://localhost:1334/api/wasm.wasm:wasm-function[42924]:0xf228c2)
at std::panicking::rust_panic_with_hook::hb42d415afcc11f2f (http://localhost:1334/api/wasm.wasm:wasm-function[16595]:0xd6e60c)
at std::panicking::begin_panic_handler::{{closure}}::h57dd84c078404aa2 (http://localhost:1334/api/wasm.wasm:wasm-function[19980]:0xe0dc73)
at std::sys_common::backtrace::__rust_end_short_backtrace::hef94dcc71d3b37f5 (http://localhost:1334/api/wasm.wasm:wasm-function[27984]:0xed50e8)
at rust_begin_unwind (http://localhost:1334/api/wasm.wasm:wasm-function[24261]:0xe93e55)
at core::panicking::panic_fmt::h32de9c76c9d5eb0c (http://localhost:1334/api/wasm.wasm:wasm-function[26642]:0xec2b9c)
at core::ops::function::Fn::call::h55e21fc4e37998de (http://localhost:1334/api/wasm.wasm:wasm-function[17645]:0xda62ba)
Msaa is enabled by default, inserted as a resource as part of default plugins. To disable it, insert the Msaa:Off resource.
I can't tell from that backtrace what the Texture::create_view issue is unfortunately.
Note that bloom does not work without HDR, such as on the web. It shouldn't even run any bloom code to be able to crash when HDR is disabled.
Disabling Msaa by inserting Msaa::Off still doesn't work. It gives me
wasm.js:342 ERROR Unable to create a sampled texture binding for non-zero mipmap level or array layer.This is an implementation problem of wgpu-hal/gles backend. log.target = "wgpu_hal::gles::device";log.module_path = "wgpu_hal::gles::device";log.file = "/home/redspider/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.14.1/src/gles/device.rs";log.line = 918;
I have same issue with bevy 0.9.1 when I want to run my game on browser. I disable hdr on wasm32, but got new error
source code: https://github.com/NightsWatchGames/jump-jump
Above error fixed by removing BloomSettings on wasm32.
I get the same here on 0.10 when running the bloom example, it partially works but not like the native one.
Unable to create a sampled texture binding for non-zero mipmap level or array layer.This is an implementation problem of wgpu-hal/gles backend. log.target = "wgpu_hal::gles::device";log.module_path = "wgpu_hal::gles::device";log.file = "/Users/adrian.meredith/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.15.2/src/gles/device.rs";log.line = 1067;