[Bf-blender-cvs] [342e030515a] wl_openxr: GHOST/XR: support Wayland via XrGraphicsBindingOpenGLWaylandKHR

Christian Rauch noreply at git.blender.org
Wed Jun 23 01:38:58 CEST 2021


Commit: 342e030515a6a2852003f8ed447a4773d8e75af1
Author: Christian Rauch
Date:   Wed Jun 23 00:09:18 2021 +0100
Branches: wl_openxr
https://developer.blender.org/rB342e030515a6a2852003f8ed447a4773d8e75af1

GHOST/XR: support Wayland via XrGraphicsBindingOpenGLWaylandKHR

===================================================================

M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_IXrGraphicsBinding.h
M	intern/ghost/intern/GHOST_XrContext.cpp
M	intern/ghost/intern/GHOST_XrGraphicsBinding.cpp

===================================================================

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 1815a46591a..77ec307e604 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -484,10 +484,15 @@ if(WITH_XR_OPENXR)
     )
   elseif(UNIX AND NOT APPLE)
     list(APPEND XR_PLATFORM_DEFINES -DXR_OS_LINUX)
-    if (WITH_GL_EGL)
-      list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL)
-    else()
-      list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB)
+    if (WITH_GHOST_WAYLAND)
+      list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_WAYLAND)
+    endif()
+    if (WITH_GHOST_X11)
+      if (WITH_GL_EGL)
+        list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL)
+      else()
+        list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB)
+      endif()
     endif()
   endif()
 
diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
index 5508d34e96c..a7339158dc4 100644
--- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
+++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
@@ -39,6 +39,9 @@ class GHOST_IXrGraphicsBinding {
 #elif defined(WIN32)
     XrGraphicsBindingOpenGLWin32KHR wgl;
     XrGraphicsBindingD3D11KHR d3d11;
+#endif
+#if defined(WITH_GHOST_WAYLAND)
+    XrGraphicsBindingOpenGLWaylandKHR wl;
 #endif
   } oxr_binding;
 
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index f057e679d56..2906a6b241e 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -420,7 +420,7 @@ void GHOST_XrContext::getExtensionsToEnable(
     r_ext_names.push_back(gpu_binding);
   }
 
-#if defined(WITH_GL_EGL)
+#if defined(WITH_GHOST_X11) && defined(WITH_GL_EGL)
   assert(openxr_extension_is_available(m_oxr->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME));
   r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME);
 #endif
diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index aeaa6e6b9e0..dd0205ea867 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -24,6 +24,12 @@
 
 #if defined(WITH_GL_EGL)
 #  include "GHOST_ContextEGL.h"
+#  if defined(WITH_GHOST_X11)
+#    include "GHOST_SystemX11.h"
+#  endif
+#  if defined(WITH_GHOST_WAYLAND)
+#    include "GHOST_SystemWayland.h"
+#  endif
 #elif defined(WITH_GHOST_X11)
 #  include "GHOST_ContextGLX.h"
 #elif defined(WIN32)
@@ -113,11 +119,13 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
 #  if defined(WITH_GL_EGL)
     GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
 
-    oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
-    oxr_binding.egl.getProcAddress = eglGetProcAddress;
-    oxr_binding.egl.display = ctx_egl.getDisplay();
-    oxr_binding.egl.config = ctx_egl.getConfig();
-    oxr_binding.egl.context = ctx_egl.getContext();
+    if (dynamic_cast<const GHOST_SystemX11 *const>(ctx_egl.m_system)) {
+      oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
+      oxr_binding.egl.getProcAddress = eglGetProcAddress;
+      oxr_binding.egl.display = ctx_egl.getDisplay();
+      oxr_binding.egl.config = ctx_egl.getConfig();
+      oxr_binding.egl.context = ctx_egl.getContext();
+    }
 #  else
     GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx);
     XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig);
@@ -139,6 +147,14 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
     oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC;
 #endif
 
+#if defined(WITH_GHOST_WAYLAND)
+    GHOST_ContextEGL &ctx_wl_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
+    if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_wl_egl.m_system)) {
+      oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR;
+      oxr_binding.wl.display = (struct wl_display *)ctx_wl_egl.m_nativeDisplay;
+    }
+#endif
+
     /* Generate a frame-buffer to use for blitting into the texture. */
     glGenFramebuffers(1, &m_fbo);
   }



More information about the Bf-blender-cvs mailing list