wgpu
wgpu copied to clipboard
wgpu wrongly assumes Wayland as the default EGL platform.
Description wgpu when libwayland is installed will try to use the EGL Wayland platform but fail to present to an X11 window.
Repro steps
With libwayland-client installed and a running Wayland compositor with XWayland, run WINIT_UNIX_BACKEND=x11 WGPU_BACKEND=gl cargo run --example=cube
WINIT_UNIX_BACKEND=x11
will force winit to create X11 windows.
Expected vs observed behavior wgpu should present using X11.
Extra materials
[2022-06-10T22:54:35Z ERROR wgpu_core::device] surface configuration failed: incompatible window kind
thread 'main' panicked at 'Error in Surface::configure: invalid surface', wgpu/src/backend/direct.rs:249:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Platform
Information about your OS, version of wgpu
, your tech stack, etc.
Linux, master branch, running Wayland under KDE.
RX 6700XT w/ Mesa.
System info: KDE 5.24.5 Arch Linux with kernel 5.18.1
WINIT_UNIX_BACKEND=x11 cargo run --example=hello-triangle
works just fine for me, KDE Wayland on Fedora 36 with AMDGPU Mesa. Built from master branch. Could you please provide full backtrace (RUST_BACKTRACE=1
) and more information about distro and KDE version? Are you using Vulkan or GL?
Oh I guess I didn't include all the information. This is GL by the way.
(I have edited the issue to represent that properly)
The backtrace:
[2022-06-26T19:25:08Z ERROR wgpu_core::device] surface configuration failed: incompatible window kind
thread 'main' panicked at 'Error in Surface::configure: invalid surface', wgpu/src/backend/direct.rs:275:9
stack backtrace:
0: rust_begin_unwind
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
2: wgpu::backend::direct::Context::handle_error_fatal
at ./wgpu/src/backend/direct.rs:275:9
3: <wgpu::backend::direct::Context as wgpu::Context>::surface_configure
at ./wgpu/src/backend/direct.rs:985:13
4: wgpu::Surface::configure
at ./wgpu/src/lib.rs:3465:9
5: hello_triangle::run::{{closure}}
at ./wgpu/examples/hello-triangle/main.rs:78:5
6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
7: pollster::block_on
at /home/i509vcb/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.5/src/lib.rs:125:15
8: hello_triangle::main
at ./wgpu/examples/hello-triangle/main.rs:144:9
9: core::ops::function::FnOnce::call_once
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Device select create instance%
Ah, I tested GL and see the issue! Will find everything out and hopefully prepare a fix!
I've thought about a solution for this.
The big issue is that we cannot share a context between each platform EGLDisplay.
One idea could be to have an adapter for each EGL platform display and rely on the user using surface compatability to select the right adapter. This how ever means you have two egl adapters for one physical gpu though.
The key problem is way simpler and manually created: both winit and wgpu check for Wayland availability and try to use it, but you force winit to change this, it gives you X11 window you're trying to attach to the instance created by default on Wayland.
I managed to resolve this by reinitializing the WSI when X11 surface is being created. Tidying everything up now. Thanks for your help
(The hello-triangle
example doesn't respect WGPU_BACKEND
. Edited issue description to use cube
instead, which does.)