[Bf-blender-cvs] [b0845fc1332] soc-2019-openxr: Fix some issues, improve error message

Julian Eisel noreply at git.blender.org
Sat Jul 13 16:23:17 CEST 2019


Commit: b0845fc1332bf242237fe858803bcebe87ffd7b3
Author: Julian Eisel
Date:   Sat Jul 13 16:15:21 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rBb0845fc1332bf242237fe858803bcebe87ffd7b3

Fix some issues, improve error message

Fixes:
* Destruct surface when destroying session on error. Fixes null pointer
  dereference when trying to draw the surface on next redraw.
* Fix trying to enable same extensions/API-layers multiple times due to
  static array usage not being cleared after error.
* Null pointer dereference with OpenGL drawing

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

M	intern/ghost/intern/GHOST_XrContext.cpp
M	intern/ghost/intern/GHOST_XrSession.cpp
M	release/scripts/addons
M	source/blender/windowmanager/intern/wm_xr.c

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

diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 2e49c6ec85a..2da82ec2488 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -334,6 +334,8 @@ void GHOST_XrContext::getAPILayersToEnable(std::vector<const char *> &r_ext_name
 {
   static std::vector<std::string> try_layers;
 
+  try_layers.clear();
+
   XR_DEBUG_ONLY_CALL(this, try_layers.push_back("XR_APILAYER_LUNARG_core_validation"));
 
   r_ext_names.reserve(try_layers.size());
@@ -372,6 +374,8 @@ void GHOST_XrContext::getExtensionsToEnable(std::vector<const char *> &r_ext_nam
   const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(m_gpu_binding_type);
   static std::vector<std::string> try_ext;
 
+  try_ext.clear();
+
   /* Try enabling debug extension */
 #ifndef WIN32
   XR_DEBUG_ONLY_CALL(this, try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME));
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 8ff812be1ce..986e119ea90 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -64,6 +64,8 @@ GHOST_XrSession::~GHOST_XrSession()
 {
   // TODO OpenXR calls here can fail, but we should not throw an exception in the destructor.
 
+  unbindGraphicsContext();
+
   for (XrSwapchain &swapchain : m_oxr->swapchains) {
     xrDestroySwapchain(swapchain);
   }
@@ -163,7 +165,10 @@ void GHOST_XrSession::start(const GHOST_XrSessionBeginInfo *begin_info)
   create_info.next = &m_gpu_binding->oxr_binding;
 
   CHECK_XR(xrCreateSession(m_context->getInstance(), &create_info, &m_oxr->session),
-           "Failed to create VR session.");
+           "Failed to create VR session. The OpenXR runtime may have additional requirements for "
+           "the graphics driver that are not met. Other causes are possible too however.\nTip: "
+           "The --debug-xr command line option for Blender might allow the runtime to output "
+           "detailed error information to the command line.");
 
   prepareDrawing();
   create_reference_space(m_oxr.get(), &begin_info->base_pose);
diff --git a/release/scripts/addons b/release/scripts/addons
index f54338c63ba..e829f3ddffd 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit f54338c63ba36cbbe83161c0b3d4d2b1aa01c4a9
+Subproject commit e829f3ddffd2980876027c8d0069cddcfa9911a2
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index 237040a3db3..f3c5d415d32 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -279,7 +279,8 @@ static GHOST_ContextHandle wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view
 
   wmViewport(&rect);
   GPU_viewport_draw_to_screen(viewport, &rect);
-  if (GHOST_isUpsideDownContext(g_xr_surface->secondary_ghost_ctx)) {
+  if (g_xr_surface->secondary_ghost_ctx &&
+      GHOST_isUpsideDownContext(g_xr_surface->secondary_ghost_ctx)) {
     GPU_texture_bind(texture, 0);
     wm_draw_upside_down(draw_view->width, draw_view->height);
     GPU_texture_unbind(texture);



More information about the Bf-blender-cvs mailing list