[Bf-blender-cvs] [941e1f5a987] soc-2019-openxr: Strictly follow specification to get OpenXR extension functions

Julian Eisel noreply at git.blender.org
Thu Oct 10 14:54:48 CEST 2019


Commit: 941e1f5a98756f9262213c152df287fa36d85f3e
Author: Julian Eisel
Date:   Thu Oct 10 14:47:00 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB941e1f5a98756f9262213c152df287fa36d85f3e

Strictly follow specification to get OpenXR extension functions

This fixes linking errors with the Monado runtime. The specification
says that extension functions have to be gotten through
`xrGetInstanceProcAddr()` which we did for some extensions, but not for
the graphics extensions. Worked fine earlier, but broke meanwhile.

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

M	intern/ghost/intern/GHOST_XrGraphicsBinding.cpp

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

diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index 5b98a663947..d34a1021f04 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -72,11 +72,21 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
 #else
     GHOST_ContextWGL *ctx_gl = static_cast<GHOST_ContextWGL *>(ghost_ctx);
 #endif
+    static PFN_xrGetOpenGLGraphicsRequirementsKHR s_xrGetOpenGLGraphicsRequirementsKHR_fn =
+        nullptr;
     XrGraphicsRequirementsOpenGLKHR gpu_requirements{XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR};
     const XrVersion gl_version = XR_MAKE_VERSION(
         ctx_gl->m_contextMajorVersion, ctx_gl->m_contextMinorVersion, 0);
 
-    xrGetOpenGLGraphicsRequirementsKHR(instance, system_id, &gpu_requirements);
+    if (!s_xrGetOpenGLGraphicsRequirementsKHR_fn &&
+        XR_FAILED(xrGetInstanceProcAddr(
+            instance,
+            "xrGetOpenGLGraphicsRequirementsKHR",
+            (PFN_xrVoidFunction *)&s_xrGetOpenGLGraphicsRequirementsKHR_fn))) {
+      s_xrGetOpenGLGraphicsRequirementsKHR_fn = nullptr;
+    }
+
+    s_xrGetOpenGLGraphicsRequirementsKHR_fn(instance, system_id, &gpu_requirements);
 
     if (r_requirement_info) {
       std::ostringstream strstream;
@@ -188,11 +198,18 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding {
                                 XrSystemId system_id,
                                 std::string *r_requirement_info) const override
   {
-
     GHOST_ContextD3D *ctx_dx = static_cast<GHOST_ContextD3D *>(ghost_ctx);
     XrGraphicsRequirementsD3D11KHR gpu_requirements{XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR};
 
-    xrGetD3D11GraphicsRequirementsKHR(instance, system_id, &gpu_requirements);
+    if (!s_xrGetD3D11GraphicsRequirementsKHR_fn &&
+        XR_FAILED(xrGetInstanceProcAddr(
+            instance,
+            "xrGetD3D11GraphicsRequirementsKHR",
+            (PFN_xrVoidFunction *)&s_xrGetD3D11GraphicsRequirementsKHR_fn))) {
+      s_xrGetD3D11GraphicsRequirementsKHR_fn = nullptr;
+    }
+
+    s_xrGetD3D11GraphicsRequirementsKHR_fn(instance, system_id, &gpu_requirements);
 
     if (r_requirement_info) {
       std::ostringstream strstream;



More information about the Bf-blender-cvs mailing list