Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2019-07-12 20:44:46 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-07-12 20:51:38 +0300
commit3a2e459f588851ca8c9553c803735d49bc3902de (patch)
tree09539e094aba131428c70b97537b1b27cfdad58d /source/blender/windowmanager/intern/wm_xr.c
parent330f062099e3c332d902f7c1667ce71b3e043af1 (diff)
Show useful error reports in case of errors.
E.g. with an active OpenXR runtime installed, but no HMD plugged in, Blender will now show: "Failed to get device information. Is a device plugged in?". In case of such errors, the VR-session will be cleanly exited, with no side effects to the rest of Blender (at least if there are no bugs). The GHOST_Xr API now allows setting a custom error handling callback which may cleanly destroy all GHOST_Xr data.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_xr.c')
-rw-r--r--source/blender/windowmanager/intern/wm_xr.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index 1a783df9376..237040a3db3 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -21,6 +21,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_report.h"
#include "BKE_screen.h"
#include "BLI_math_geom.h"
@@ -43,6 +44,8 @@
#include "MEM_guardedalloc.h"
+#include "UI_interface.h"
+
#include "WM_types.h"
#include "WM_api.h"
@@ -60,27 +63,57 @@ typedef struct {
GHOST_TXrGraphicsBinding gpu_binding_type;
} XrSurfaceData;
-bool wm_xr_context_ensure(wmWindowManager *wm)
+typedef struct {
+ wmWindowManager *wm;
+ bContext *evil_C;
+} wmXrErrorHandlerData;
+
+static void wm_xr_error_handler(const GHOST_XrError *error)
+{
+ wmXrErrorHandlerData *handler_data = error->customdata;
+ wmWindowManager *wm = handler_data->wm;
+
+ BKE_reports_clear(&wm->reports);
+ WM_report(RPT_ERROR, error->user_message);
+ WM_report_banner_show();
+ UI_popup_menu_reports(handler_data->evil_C, &wm->reports);
+
+ if (wm->xr_context) {
+ /* Just play safe and destroy the entire context. */
+ GHOST_XrContextDestroy(wm->xr_context);
+ wm->xr_context = NULL;
+ }
+}
+
+bool wm_xr_context_ensure(bContext *C, wmWindowManager *wm)
{
if (wm->xr_context) {
return true;
}
+ static wmXrErrorHandlerData error_customdata;
+
+ /* Set up error handling */
+ error_customdata.wm = wm;
+ error_customdata.evil_C = C;
+ GHOST_XrErrorHandler(wm_xr_error_handler, &error_customdata);
- const GHOST_TXrGraphicsBinding gpu_bindings_candidates[] = {
- GHOST_kXrGraphicsOpenGL,
+ {
+ const GHOST_TXrGraphicsBinding gpu_bindings_candidates[] = {
+ GHOST_kXrGraphicsOpenGL,
#ifdef WIN32
- GHOST_kXrGraphicsD3D11,
+ GHOST_kXrGraphicsD3D11,
#endif
- };
- GHOST_XrContextCreateInfo create_info = {
- .gpu_binding_candidates = gpu_bindings_candidates,
- .gpu_binding_candidates_count = ARRAY_SIZE(gpu_bindings_candidates)};
+ };
+ GHOST_XrContextCreateInfo create_info = {
+ .gpu_binding_candidates = gpu_bindings_candidates,
+ .gpu_binding_candidates_count = ARRAY_SIZE(gpu_bindings_candidates)};
- if (G.debug & G_DEBUG_XR) {
- create_info.context_flag |= GHOST_kXrContextDebug;
- }
+ if (G.debug & G_DEBUG_XR) {
+ create_info.context_flag |= GHOST_kXrContextDebug;
+ }
- wm->xr_context = GHOST_XrContextCreate(&create_info);
+ wm->xr_context = GHOST_XrContextCreate(&create_info);
+ }
return wm->xr_context != NULL;
}