gfx-rs / wgpu

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

Crash with ruining examples on debug mode #5086

Open poweron0102 opened 9 months ago

poweron0102 commented 9 months ago

Description

cube

Everything works fine in release mode

Platform

OS: Fedora 39 with Wayland GPU: Intel(R) HD Graphics 620 Rust: 1.75.0

Friz64 commented 9 months ago

What happens here is that wgpu tries to initialize the Vulkan backend but fails because we enable validation layers in dev/debug mode, which are not installed on your system. If you want to fix this, install the vulkan-validation-layers package on Fedora.

With Vulkan broken, wgpu falls back to OpenGL. OpenGL works in the hello_triangle example, but interestingly not in the cube example. I can reproduce this error, but only on Wayland. Setting WAYLAND_DISPLAY= makes winit fall back to X11 and the example runs.

# wayland, broken
env WGPU_BACKEND="gl" cargo run --bin wgpu-examples cube
# x11, works
env WAYLAND_DISPLAY= WGPU_BACKEND="gl" cargo run --bin wgpu-examples cube
grovesNL commented 9 months ago

If you only see problems in the cube example, you could try renaming the cube binary to wgpu_example or something to check if it's special handling based on the binary name (at least one driver used to do this apparently)

Friz64 commented 9 months ago

Good thought, but all the examples got combined into one binary some time ago, and the specific example is now specified by a command line argument. Also happens with other examples, maybe there's a pattern.

Friz64 commented 9 months ago

Oh, the hello_triangle example runs with Vulkan even though I specified WGPU_BACKEND="gl" (verified through mangohud). So, it seems like OpenGL is just straight up broken on Wayland.

Friz64 commented 9 months ago

Bisected with env WGPU_BACKEND="gl" cargo run --bin (wgpu-examples) cube. Broken since #4634.

cwfitzgerald commented 9 months ago

Couple notes:

What happens here is that wgpu tries to initialize the Vulkan backend but fails because we enable validation layers in dev/debug mode, which are not installed on your system.

This is actually even deeper than that. We run without the validation layers fine, but this is the vulkan loader failing to initialize a layer that it thinks should be there and aborting instance creation.

Oh, the hello_triangle example runs with Vulkan even though I specified WGPU_BACKEND="gl" (verified through mangohud). So, it seems like OpenGL is just straight up broken on Wayland.

The hello-triangle example is special in that it doesn't use the standard init functions, so doesn't listen to the WGPU_BACKEND env. Maybe that should change

poweron0102 commented 9 months ago

After i install vulkan-validation-layers every thing works fine, should i close this issue?

johnbchron commented 6 months ago

Let's not because OpenGL is completely broken on OpenGL, and that seems glaring to me.