[Bf-blender-cvs] [b2166905056] soc-2019-openxr: Add --debug-xr commandline arg and pass on to GHOST XR contexts

Julian Eisel noreply at git.blender.org
Tue Jul 9 17:23:18 CEST 2019


Commit: b21669050567d6cbbf002b4dd5c61766ffa27499
Author: Julian Eisel
Date:   Tue Jul 9 17:20:01 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rBb21669050567d6cbbf002b4dd5c61766ffa27499

Add --debug-xr commandline arg and pass on to GHOST XR contexts

Doesn't do anything yet.

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

M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_Xr.cpp
M	intern/ghost/intern/GHOST_Xr_intern.h
M	source/blender/blenkernel/BKE_global.h
M	source/blender/windowmanager/intern/wm_xr.c
M	source/creator/CMakeLists.txt
M	source/creator/creator_args.c

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

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index c22abda60bb..41840a5f0f5 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -588,9 +588,15 @@ typedef struct {
   float orientation_quat[4];
 } GHOST_XrPose;
 
+enum {
+  GHOST_kXrContextDebug = (1 << 0),
+};
+
 typedef struct {
   const GHOST_XrGraphicsBindingCandidates gpu_binding_candidates;
   unsigned int gpu_binding_candidates_count;
+
+  unsigned int context_flag;
 } GHOST_XrContextCreateInfo;
 
 typedef struct {
diff --git a/intern/ghost/intern/GHOST_Xr.cpp b/intern/ghost/intern/GHOST_Xr.cpp
index ce39603ef94..53937732d85 100644
--- a/intern/ghost/intern/GHOST_Xr.cpp
+++ b/intern/ghost/intern/GHOST_Xr.cpp
@@ -261,6 +261,10 @@ GHOST_XrContext *GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_i
   GHOST_XrContext *xr_context = new GHOST_XrContext();
   OpenXRData *oxr = &xr_context->oxr;
 
+  if (create_info->context_flag & GHOST_kXrContextDebug) {
+    xr_context->debug = true;
+  }
+
 #ifdef USE_EXT_LAYER_PRINTS
   puts("Available OpenXR layers/extensions:");
 #endif
diff --git a/intern/ghost/intern/GHOST_Xr_intern.h b/intern/ghost/intern/GHOST_Xr_intern.h
index 2c58f776c9e..e7e4deffeb0 100644
--- a/intern/ghost/intern/GHOST_Xr_intern.h
+++ b/intern/ghost/intern/GHOST_Xr_intern.h
@@ -57,6 +57,9 @@ typedef struct GHOST_XrContext {
   /** Custom per-view draw function for Blender side drawing. */
   GHOST_XrDrawViewFn draw_view_fn;
 
+  /** Enable debug message prints and OpenXR API validation layers */
+  bool debug;
+
   /** Names of enabled extensions */
   std::vector<const char *> enabled_extensions;
   /** Names of enabled API-layers */
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index bee76c09cbc..a72c7a7be15 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -151,6 +151,7 @@ enum {
   G_DEBUG_IO = (1 << 17),                    /* IO Debugging (for Collada, ...)*/
   G_DEBUG_GPU_SHADERS = (1 << 18),           /* GLSL shaders */
   G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 19), /* force gpu workarounds bypassing detections. */
+  G_DEBUG_XR = (1 << 20),                    /* XR/OpenXR messages */
 };
 
 #define G_DEBUG_ALL \
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index 72427442816..3989487075e 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -72,10 +72,14 @@ bool wm_xr_context_ensure(wmWindowManager *wm)
       GHOST_kXrGraphicsD3D11,
 #endif
   };
-  const GHOST_XrContextCreateInfo create_info = {
+  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;
+  }
+
   wm->xr_context = GHOST_XrContextCreate(&create_info);
 
   return wm->xr_context != NULL;
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 77877ff3cca..7ba8a6867ca 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -118,6 +118,10 @@ if(WITH_FREESTYLE)
   add_definitions(-DWITH_FREESTYLE)
 endif()
 
+if(WITH_OPENXR)
+  add_definitions(-DWITH_OPENXR)
+endif()
+
 # Setup the exe sources and buildinfo
 set(SRC
   creator.c
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index f3550034a2f..8affda7189c 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -604,6 +604,9 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
   BLI_argsPrintArgDoc(ba, "--debug-gpu-shaders");
   BLI_argsPrintArgDoc(ba, "--debug-gpu-force-workarounds");
   BLI_argsPrintArgDoc(ba, "--debug-wm");
+#  ifdef WITH_OPENXR
+  BLI_argsPrintArgDoc(ba, "--debug-xr");
+#  endif
   BLI_argsPrintArgDoc(ba, "--debug-all");
   BLI_argsPrintArgDoc(ba, "--debug-io");
 
@@ -941,6 +944,13 @@ static const char arg_handle_debug_mode_generic_set_doc_wm[] =
     "\n\t"
     "Enable debug messages for the window manager, shows all operators in search, shows "
     "keymap errors.";
+#  ifdef WITH_OPENXR
+static const char arg_handle_debug_mode_generic_set_doc_xr[] =
+    "\n\t"
+    "Enable debug messages for virtual reality contexts.\n"
+    "\tEnables the OpenXR API validation layer, (OpenXR) debug messages and general information "
+    "prints.";
+#  endif
 static const char arg_handle_debug_mode_generic_set_doc_jobs[] =
     "\n\t"
     "Enable time profiling for background jobs.";
@@ -2081,6 +2091,10 @@ void main_args_setup(bContext *C, bArgs *ba)
               (void *)G_DEBUG_HANDLERS);
   BLI_argsAdd(
       ba, 1, NULL, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
+#  ifdef WITH_OPENXR
+  BLI_argsAdd(
+      ba, 1, NULL, "--debug-xr", CB_EX(arg_handle_debug_mode_generic_set, xr), (void *)G_DEBUG_XR);
+#  endif
   BLI_argsAdd(ba, 1, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL);
 
   BLI_argsAdd(ba, 1, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL);



More information about the Bf-blender-cvs mailing list