godot
godot copied to clipboard
OpenXR: Add support for Wayland on Linux
Adds support for initializing OpenXR with Wayland on Linux.
Some notes about the OpenXR side of this:
- Monado is an OpenXR runtime that works on Linux
- If you run it like
QWERTY_ENABLE=1 OXR_DEBUG_GUI=1 monado-serviceit works as an OpenXR "simulator", where it'll show what the headset sees in a window and allow you to use keyboard and mouse to control the virtual headset - In the standard XR_KHR_opengl_enable extension, there is a XrGraphicsBindingOpenGLWaylandKHR struct, that supposedly allows initializing OpenXR on Wayland, however, as far as I know, it's not supported on any OpenXR runtime, and according to the Monado folks, it's insufficient to support Wayland (ie it doesn't take in enough information to make it possible to work)
- So, the Monado people created the XR_MNDX_egl_enable extension, which allows initializing OpenXR when using EGL, including on Wayland, which is currently supported on the Monado runtime, and the Pico 4 Ultra runtime. As far as I know, at the moment, this is the only way to support Wayland with OpenXR at all
- This PR adds support for the
XR_MNDX_egl_enableextension, but only for Wayland on Linux. Even though we'd theoretically be able to use it with X11 when EGL is used, or on Android, the other extensions we use for supporting those platforms work on more OpenXR runtimes (and even work with Monado too).
~~TODO:~~
- ~~Actually test it! My local machine currently uses the proprietary nvidia drivers with X11 - I'll need to get Wayland going :-)~~
- ~~Support compiling with
x11=no~~
~~Assuming I get the 2nd point going, this will supersede PR https://github.com/godotengine/godot/pull/73504~~
Supersedes https://github.com/godotengine/godot/pull/73504
Bugsquad edit: fixes #70199
This is working for me locally now!
I tested with the "Pop" desktop on Wayland, together with the Monado runtime.
If anyone wants to test themselves, you'll need to:
- Start Monado via
QWERTY_ENABLE=1 OXR_DEBUG_GUI=1 monado-service - Update your project (which uses OpenXR, of course) to use the "wayland" display server in Project Settings, and enable verbose output (to get some messages to help you know it's working)
- Run it!
You should be able to see output in the console that you ran the game from to indicate that it's using Monado, Wayland and EGL, for example, this is what I see:
odot Engine v4.4.dev.custom_build.21617c14a (2024-10-04 15:30:51 UTC) - https://godotengine.org
OpenXR: Running on OpenXR runtime: Monado(XRT) by Collabora et al 'GIT-NOTFOUND' 21.0.0
WARNING: Can't obtain the XDG decoration manager. Libdecor will be used for drawing CSDs, if available.
at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3731)
OpenGL API 3.3.0 NVIDIA 560.35.03 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 4070 Ti
OpenXR: Requested OpenGL version does not meet the minimum version this runtime supports.
- desired_version 3.3.0
- minApiVersionSupported 4.5.0
- maxApiVersionSupported 4.6.1023
OpenXR: Trying to initialize with OpenGL anyway...
INFO [xrt_gfx_provider_create_gl_egl] Extension availability:
INFO [xrt_gfx_provider_create_gl_egl] - GL_EXT_memory_object: true
INFO [xrt_gfx_provider_create_gl_egl] - GL_EXT_memory_object_fd: true
INFO [xrt_gfx_provider_create_gl_egl] - GL_EXT_memory_object_win32: false
INFO [xrt_gfx_provider_create_gl_egl] - GL_OES_EGL_image_external: false
INFO [xrt_gfx_provider_create_gl_egl] - EGL_ANDROID_get_native_client_buffer: false
INFO [xrt_gfx_provider_create_gl_egl] - EGL_ANDROID_native_fence_sync: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_EXT_image_dma_buf_import_modifiers: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_KHR_fence_sync: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_KHR_image: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_KHR_image_base: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_KHR_reusable_sync: true
INFO [xrt_gfx_provider_create_gl_egl] - EGL_KHR_wait_sync: true
INFO [xrt_gfx_provider_create_gl_egl] Using GL memory object swapchain implementation
Thank you!
Unfortunately it seems like I can't test this PR properly because my setup does not support the GL_OVR_multiview and the GL_OVR_multiview2 extensions. They got recently merged into zink (OGL-over-Vulkan) but even a HEAD build gives me errors regarding other multiview builtins which should work but they don't and I just gave up.
So testing wise I'll limit myself by saying that I can confirm that it fixes the x11=no. I gave a rough look at the code before testing and it looked fine.
I'm a bit tired so if you don't see me officially approving it now I'll do so tomorrow after taking a closer look.
Thanks!