kvark / vange-rs

Rusty Vangers clone
https://vange.rs
Apache License 2.0
427 stars 21 forks source link

WebGPU not all features supported in browser (Chrome, FF) #154

Open caiiiycuk opened 2 years ago

caiiiycuk commented 2 years ago

I created working WebGPU build, however it didn't render anything because not all features are supported by browsers.

FF Nightly 96oa1:


sampler binding 4 expects filtering = false, but given a sampler with filtering = true 2
In a set_bind_group command, caused by: bind group (1, 1, Vulkan) is invalid
command encoder is invalid

Chrome (dev) 98.0.4710.4:

1D textures aren't supported (yet).
 - While validating [TextureDescriptor "Palette"].
 - While calling [Device].CreateTexture([TextureDescriptor "Palette"]).
[Invalid Texture] is invalid.
 - While calling [Invalid Texture].CreateView([TextureViewDescriptor]).
1D textures aren't supported (yet).
 - While validating [TextureDescriptor "Color table"].
 - While calling [Device].CreateTexture([TextureDescriptor "Color table"]).
1D textures aren't supported (yet).
 - While validating [TextureDescriptor "Terrain flood"].
 - While calling [Device].CreateTexture([TextureDescriptor "Terrain flood"]).
1D textures aren't supported (yet).
 - While validating [TextureDescriptor "Terrain table"].
 - While calling [Device].CreateTexture([TextureDescriptor "Terrain table"]).
[Invalid TextureView] is invalid.
 - While validating entries[4] as a Texture
 - While validating [BindGroupDescriptor "Terrain"] against [BindGroupLayout]
 - While calling [Device].CreateBindGroup([BindGroupDescriptor "Terrain"]).
Tint WGSL reader failure:
Parser: 179:19 error: 'mat' is a reserved keyword
fn evaluate_light(mat: vec3<f32>, height_diff: f32) -> f32 {
                  ^^^

202:9 error: 'mat' is a reserved keyword
    let mat = select(vec3<f32>(1.0), vec3<f32>(5.0, 1.25, 0.5), ty == 0u);
        ^^^

289:5 error: expected identifier for struct member
    type: u32;
    ^^^^

309:8 error: expected identifier for member accessor
    pt.type = suf.high_type;
       ^^^^

320:16 error: expected identifier for member accessor
            pt.type = suf.high_type;
               ^^^^

336:30 error: expected identifier for member accessor
    return evaluate_color(pt.type, pt.tex_coord, pt.pos.z / u_Surface.texture_scale.z, lit_factor);
                             ^^^^

371:12 error: expected identifier for member accessor
    if (pt.type == c_TerrainWater) {
           ^^^^

476:9 error: expected identifier for let declaration
    let type = select(surface.low_type, surface.high_type, point.z > surface.low_alt);
        ^^^^

477:37 error: expected ')' for function call
    let frag_color = evaluate_color(type, surface.tex_coord, point.z / u_Surface.texture_scale.z, lit_factor);
caiiiycuk commented 2 years ago

For firefox it can be fixed by changins Linear to Nearest in shadwo sampler

kvark commented 2 years ago

Please try again on latest vange-rs and latest FF nightly.

caiiiycuk commented 2 years ago

Error here

        info!("Initializing the device:adapter");
        let adapter = instance.request_adapter(&wgpu::RequestAdapterOptions {
                power_preference: wgpu::PowerPreference::HighPerformance,
                compatible_surface: Some(&surface),
                force_fallback_adapter: false,
            }).await.expect("Unable to initialize GPU via the selected backend (adapter).");

stack:

panicked at 'Unable to initialize GPU via the selected backend (adapter).', bin/road/../boilerplate.rs:85:22

Stack:

init/imports.wbg.__wbg_new_693216e109162396@http://127.0.0.1:8081/road.js:1438:19
console_error_panic_hook::Error::new::h38cd73c14ad8ceb8@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[32842]:0x9cbb31
console_error_panic_hook::hook_impl::h447f30d6e3c844d9@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[4432]:0x5e45d1
console_error_panic_hook::hook::hbe3eff4fa303ec62@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[37282]:0xa0844d
core::ops::function::Fn::call::h7bdf0eade1493029@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[30612]:0x9a8d14
std::panicking::rust_panic_with_hook::hf5929c1b5a08f3d9@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[6361]:0x689eed
std::panicking::begin_panic_handler::{{closure}}::h357d41682ce6f65f@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[14326]:0x826026
std::sys_common::backtrace::__rust_end_short_backtrace::h78451e1dd249a6ac@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[38486]:0xa17601
rust_begin_unwind@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[35569]:0x9f1f9f
core::panicking::panic_fmt::h927a4041e210fb24@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[38488]:0xa1766f
core::option::expect_failed::hc9e894e3b049fef8@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[23769]:0x9263d0
core::option::Option<T>::expect::h0eef3a957e3bb44e@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[13956]:0x818e04
road::boilerplate::Harness::init_async::{{closure}}::hf3707de418fb512c@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[403]:0x1df19a
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5322177867d81536@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[7635]:0x6e45a4
road::main::run::{{closure}}::h72fb47699338e834@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[1319]:0x40baa3
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1cf90a5c62486d57@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[11331]:0x7ae285
wasm_bindgen_futures::task::singlethread::Task::run::h30a1ee5a79fc6675@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[2853]:0x52b386
wasm_bindgen_futures::queue::QueueState::run_all::h7e66d2054bbf2d17@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[3734]:0x598c4f
wasm_bindgen_futures::queue::Queue::new::{{closure}}::hdfd188b05eeeb743@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[19887]:0x8ca222
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h38b5e8c7b41892a7@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[10002]:0x76d75f
__wbg_adapter_57@http://127.0.0.1:8081/road.js:250:10
real@http://127.0.0.1:8081/road.js:199:20
promise callback*init/imports.wbg.__wbg_then_2fcac196782070cc@http://127.0.0.1:8081/road.js:1345:35
js_sys::Promise::then::he86ceb86a525cf86@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[19444]:0x8beff9
wasm_bindgen_futures::queue::Queue::push_task::hc064b39c27197bd2@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[4945]:0x615521
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::ha7da83c60b64e361@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[28019]:0x97b241
std::thread::local::LocalKey<T>::try_with::haece4cb3bd6980ff@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[9822]:0x763ffa
std::thread::local::LocalKey<T>::with::h8542f008b5907a59@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[18717]:0x8abe8c
wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::h6591a99d1b81c6d8@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[10624]:0x78cc85
wasm_bindgen_futures::task::singlethread::Task::spawn::h4a42f665c86c81fe@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[1873]:0x48af40
wasm_bindgen_futures::spawn_local::h89ca232f2bdd057f@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[16677]:0x872431
road::main::h90bc2c7d14320a46@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[11825]:0x7c42f2
core::ops::function::FnOnce::call_once::hf49a1471d2b6d367@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[35598]:0x9f2593
std::sys_common::backtrace::__rust_begin_short_backtrace::hc70451b8831d895e@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[34366]:0x9e18ad
std::rt::lang_start::{{closure}}::hefeebe429e2f16d2@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[30611]:0x9a8cc9
core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h28b5949629caeb42@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[43824]:0xa43be7
std::rt::lang_start_internal::hd46dca8dc36bc413@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[32849]:0x9cbd1c
std::rt::lang_start::h375a77e26442440b@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[21056]:0x8e7984
main@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[43396]:0xa41e00
@http://127.0.0.1:8081/road.js line 310 > WebAssembly.instantiate:wasm-function[43729]:0xa43736
init@http://127.0.0.1:8081/road.js:1513:10
async*load@http://127.0.0.1:8081/:15:13
onclick@http://127.0.0.1:8081/:1:12

Most samples from https://austin-eng.com/webgpu-samples/samples/ works for me, but not all

kvark commented 2 years ago

Strange that it's failing on the adapter selection for you if other samples aren't. There aren't many things you can do differently at this early stage.

caiiiycuk commented 2 years ago

Same here in chrome (98.0.4710.4):

road.js:1432 panicked at 'Unable to initialize GPU via the selected backend (adapter).', bin/road/../boilerplate.rs:85:22

Stack:

Error
    at imports.wbg.__wbg_new_693216e109162396 (http://127.0.0.1:8080/road.js:1438:19)
    at console_error_panic_hook::Error::new::h38cd73c14ad8ceb8 (wasm://wasm/14c6d946:wasm-function[32842]:0x9cbb31)
    at console_error_panic_hook::hook_impl::h447f30d6e3c844d9 (wasm://wasm/14c6d946:wasm-function[4432]:0x5e45d1)
    at console_error_panic_hook::hook::hbe3eff4fa303ec62 (wasm://wasm/14c6d946:wasm-function[37282]:0xa0844d)
    at core::ops::function::Fn::call::h7bdf0eade1493029 (wasm://wasm/14c6d946:wasm-function[30612]:0x9a8d14)
    at std::panicking::rust_panic_with_hook::hf5929c1b5a08f3d9 (wasm://wasm/14c6d946:wasm-function[6361]:0x689eed)
    at std::panicking::begin_panic_handler::{{closure}}::h357d41682ce6f65f (wasm://wasm/14c6d946:wasm-function[14326]:0x826026)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h78451e1dd249a6ac (wasm://wasm/14c6d946:wasm-function[38486]:0xa17601)
    at rust_begin_unwind (wasm://wasm/14c6d946:wasm-function[35569]:0x9f1f9f)
    at core::panicking::panic_fmt::h927a4041e210fb24 (wasm://wasm/14c6d946:wasm-function[38488]:0xa1766f)

hello-triangle example fails with same message. All samples from https://austin-eng.com/webgpu-samples/samples/ works

kvark commented 2 years ago

That's because you can't reasonably use WebGPU in a stable browser, since WebGPU isn't out yet. What they have in Chrome is called "Origin Trials", which means they expose it in public, but: