linebender / vello

An experimental GPU compute-centric 2D renderer.
http://linebender.org/vello/
Apache License 2.0
2.24k stars 125 forks source link

winit crash #326

Open ProkopRandacek opened 1 year ago

ProkopRandacek commented 1 year ago

Hi :D

I am getting a crash when I try to build the example from readme:

~/source/vello 101 % RUST_BACKTRACE=1 cargo run -p with_winit 
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     Running `target/debug/with_winit_bin`
[2023-05-28T13:36:15Z ERROR sctk_adwaita::config] XDG Settings Portal did not return response in time: timeout: 100ms, key: color-scheme
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/prokop/source/vello/src/util.rs:58:56
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::Option<T>::unwrap
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/option.rs:942:21
   4: vello::util::RenderContext::create_surface::{{closure}}
             at ./src/util.rs:58:22
   5: pollster::block_on
             at /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.3.0/src/lib.rs:128:15
   6: with_winit::run::{{closure}}
             at ./examples/with_winit/src/lib.rs:424:31
   7: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_return
             at /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform_impl/linux/wayland/event_loop/mod.rs:242:9
   8: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run
             at /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform_impl/linux/wayland/event_loop/mod.rs:223:25
   9: winit::platform_impl::platform::EventLoop<T>::run
             at /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform_impl/linux/mod.rs:792:56
  10: winit::event_loop::EventLoop<T>::run
             at /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/event_loop.rs:305:9
  11: with_winit::run
             at ./examples/with_winit/src/lib.rs:125:5
  12: with_winit::main
             at ./examples/with_winit/src/lib.rs:484:13
  13: with_winit_bin::main
             at ./examples/with_winit/src/main.rs:4:5
  14: core::ops::function::FnOnce::call_once
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: queue 0x7f4a7d1f6170 destroyed while proxies still attached:
  xdg_wm_base@20 still attached
  wl_output@14 still attached
  wl_seat@13 still attached
  xdg_activation_v1@12 still attached
  wp_viewporter@11 still attached
  zwp_text_input_manager_v3@10 still attached
  zwp_pointer_constraints_v1@9 still attached
  zwp_relative_pointer_manager_v1@8 still attached
  zxdg_decoration_manager_v1@7 still attached
  wl_subcompositor@6 still attached
  wl_compositor@5 still attached
  wl_shm@4 still attached
  wl_registry@2 still attached
~/source/vello 101 % 

Am I doing something wrong or is this a bug? Thanks for any help! I'm on alpine linux with wayland btw.

DJMcNab commented 1 year ago

Can you run the wgpu examples - that is, clone https://github.com/gfx-rs/wgpu and execute cargo run --example boids

The error you're getting is indicating that there are no GPU devices on your system which support the surface being created.

ProkopRandacek commented 1 year ago

I can run the boids example without issues from HEAD, 0.16.0 and 0.16.1

m-hugo commented 1 year ago

i coincidentally ran into it too, wgpu examples worked because they fallback to GL if vulkan isnt present, vello didn't reinstalling vulkan solved the problem

ProkopRandacek commented 1 year ago

I can confirm that my laptop doesnt support vulkan.

m-hugo commented 1 year ago

GL is not a primary WGPU backend, replace ::PRIMARY with ::GL and see if it works https://github.com/linebender/vello/blob/ea224b459c48267e0e63747c9b192d62ef432ac9/src/util.rs#L43

m-hugo commented 1 year ago

It throws a wgpu validation error on my end, not sure how much work it would be to make vello work on GL but anyways it would be nice to have better error reporting, like if backends {} else {"You need to have a Vulkan/metal/dx12 driver to run this app"}

ProkopRandacek commented 1 year ago

Chaning to ::GL did move the issue somewhere else:

~/source/vello 101 % git d
diff --git a/src/util.rs b/src/util.rs
index 87e2d35..9a28f41 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -40,7 +40,7 @@ pub struct DeviceHandle {
 impl RenderContext {
     pub fn new() -> Result<Self> {
         let instance = Instance::new(wgpu::InstanceDescriptor {
-            backends: wgpu::Backends::PRIMARY,
+            backends: wgpu::Backends::GL,
             dx12_shader_compiler: wgpu::Dx12Compiler::Fxc,
         });
         Ok(Self {
~/source/vello 0 % cargo run -p with_winit
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/with_winit_bin`
[2023-06-01T16:53:52Z ERROR sctk_adwaita::config] XDG Settings Portal did not return response in time: timeout: 100ms, key: color-scheme
Creating renderer 0
[2023-06-01T16:53:52Z ERROR wgpu_hal::gles::egl] GLES: [ShaderCompiler/Error] ID 2 : 0:688(2): error: `return' with wrong type float[4], in function `fill_path' returning float
[2023-06-01T16:53:52Z ERROR wgpu_hal::gles::egl] GLES: [ShaderCompiler/Error] ID 3 : 0:775(2): error: `return' with wrong type float[4], in function `stroke_path' returning float
[2023-06-01T16:53:52Z ERROR wgpu_hal::gles::egl] GLES: [ShaderCompiler/Error] ID 4 : 0:850(2): error: value of type float cannot be assigned to variable of type float[4]
[2023-06-01T16:53:52Z ERROR wgpu_hal::gles::egl] GLES: [ShaderCompiler/Error] ID 5 : 0:859(2): error: value of type float cannot be assigned to variable of type float[4]
[2023-06-01T16:53:52Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_compute_pipeline
      note: label = `fine`
    Internal error: 0:688(2): error: `return' with wrong type float[4], in function `fill_path' returning float
0:775(2): error: `return' with wrong type float[4], in function `stroke_path' returning float
0:850(2): error: value of type float cannot be assigned to variable of type float[4]
0:859(2): error: value of type float cannot be assigned to variable of type float[4]

', /home/prokop/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.1/src/backend/direct.rs:3019:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: queue 0x7f0519b54170 destroyed while proxies still attached:
  xdg_wm_base@20 still attached
  wl_output@14 still attached
  wl_seat@13 still attached
  xdg_activation_v1@12 still attached
  wp_viewporter@11 still attached
  zwp_text_input_manager_v3@10 still attached
  zwp_pointer_constraints_v1@9 still attached
  zwp_relative_pointer_manager_v1@8 still attached
  zxdg_decoration_manager_v1@7 still attached
  wl_subcompositor@6 still attached
  wl_compositor@5 still attached
  wl_shm@4 still attached
  wl_registry@2 still attached
~/source/vello 101 % 
simbleau commented 6 months ago

Is this still an issue? We recently updated winit.

DJMcNab commented 6 months ago

Is this not a platform/API support issue, nothing to do with winit specifically?

The initial issue is that our with_winit error handling for not supporting Vulkan is terrible, and the later comments are discussing attempting to get downlevel OpenGL working.