gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.7k stars 931 forks source link

WebGL2 'Tex storage 2D multisample is not supported' (again) #5263

Open kpreid opened 9 months ago

kpreid commented 9 months ago

Description Panic (not a validation error) in webgl backend.

This is probably similar to #2149 (fixed) but with different descriptor parameters. May also be related to #2117.

Repro steps Create a WebGL2 device and run:

device.create_texture(&wgpu::TextureDescriptor {
    label: Some("linear_scene_texture"),
    size: wgpu::Extent3d {
        width: 1,
        height: 1,
        depth_or_array_layers: 1,
    },
    mip_level_count: 1,
    sample_count: 4,
    dimension: wgpu::TextureDimension::D2,
    format: wgpu::TextureFormat::Rgba8UnormSrgb,
    view_formats: &[],
    usage: wgpu::TextureUsages::RENDER_ATTACHMENT.union(wgpu::TextureUsages::TEXTURE_BINDING),
});

Expected vs observed behavior Should succeed (or give a validation error about a missing downlevel feature). Instead, an internal panic occurs:

panicked at /Users/kpreid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glow-0.13.1/src/web_sys.rs:3184:9:
Tex storage 2D multisample is not supported

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f/<@http://127.0.0.1:61003/wasm-bindgen-test:1925:21
logError@http://127.0.0.1:61003/wasm-bindgen-test:235:18
__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://127.0.0.1:61003/wasm-bindgen-test:1924:66
console_error_panic_hook::hook::h16e832bc4e5d4faa@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[2968]:0x4e6958
wasm_bindgen_test::__rt::Context::new::{{closure}}::{{closure}}::h58827ee108067191@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[11720]:0x6f0177
std::panicking::rust_panic_with_hook::h1e6ac5d404b8e31b@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[7039]:0x669545
std::panicking::begin_panic_handler::{{closure}}::h24b0f4622f2766a5@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[7915]:0x694bb7
std::sys_common::backtrace::__rust_end_short_backtrace::h19f35d272c126e7c@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[14341]:0x700568
rust_begin_unwind@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[10563]:0x6dfabd
core::panicking::panic_fmt::h87755523850ece9e@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[10984]:0x6e6319
<glow::web::Context as glow::HasContext>::tex_storage_2d_multisample::hedab99aca7d5fe2e@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[10946]:0x6e59b9
wgpu_hal::gles::device::<impl wgpu_hal::Device<wgpu_hal::gles::Api> for wgpu_hal::gles::Device>::create_texture::hfddd871b8b97a22b@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[1080]:0x3101c6
wgpu_core::device::resource::Device<A>::create_texture::h831fc234b3169444@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[592]:0x1d1364
wgpu_core::device::global::<impl wgpu_core::global::Global<G>>::device_create_texture::h19cbfa00d9cf52d5@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[2049]:0x43faf3
<wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::device_create_texture::h6c2328633317308c@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[858]:0x29e956
<T as wgpu::context::DynContext>::device_create_texture::h9388e274def060ba@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[6726]:0x657ba9
wgpu::Device::create_texture::hb0b87d6854cd124c@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[5586]:0x6098fd
<wasm_bindgen_test::__rt::TestFuture<F> as core::future::future::Future>::poll::{{closure}}::{{closure}}::h8b4a7b29cae36f16@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[587]:0x1cc6d6
wasm_bindgen::convert::closures::invoke0_mut::h4d8f7648f8b0c150@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[12594]:0x6f8707
__wbg_adapter_713@http://127.0.0.1:61003/wasm-bindgen-test:432:10
cb0@http://127.0.0.1:61003/wasm-bindgen-test:1870:28
window.__wbg_test_invoke@http://127.0.0.1:61003/:38:38
__wbg_get_imports/imports.wbg.__wbg_wbgtestinvoke_85678161858c6b20/<@http://127.0.0.1:61003/wasm-bindgen-test:1875:30
handleError@http://127.0.0.1:61003/wasm-bindgen-test:308:18
__wbg_get_imports/imports.wbg.__wbg_wbgtestinvoke_85678161858c6b20@http://127.0.0.1:61003/wasm-bindgen-test:1863:76
wasm_bindgen_test::__rt::__wbg_test_invoke::h3e5fb0ad5f733b5b@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[10839]:0x6e3f8d
<wasm_bindgen_test::__rt::TestFuture<F> as core::future::future::Future>::poll::h1c07b07e05ea84cb@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[4214]:0x588315
<wasm_bindgen_test::__rt::ExecuteTests as core::future::future::Future>::poll::hc0a737e2228ffe78@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[725]:0x24503b
wasm_bindgen_futures::future_to_promise::{{closure}}::{{closure}}::h7e5e6075f00de12b@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[2004]:0x435c8d
wasm_bindgen_futures::task::singlethread::Task::run::hb8702dfe5565c1a7@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[7598]:0x686628
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h754efa4fae0fb2cd@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[3834]:0x55c354
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h47789b6676bee545@http://127.0.0.1:61003/wasm-bindgen-test_bg.wasm:wasm-function[12497]:0x6f7bc6
__wbg_adapter_35@http://127.0.0.1:61003/wasm-bindgen-test:257:10
real@http://127.0.0.1:61003/wasm-bindgen-test:218:20

Platform

kpreid commented 4 months ago

This seems to no longer panic with wgpu 22.0.0, though I haven't rerun the above reduced test case.

kpreid commented 4 months ago

Correction to above comment: I observed my application no longer panicking because WebGPU is more available. It still panics on the WebGL2 backend. Sorry for the noise.