[Bf-blender-cvs] [b0a333e755a] vamr-openxr-module: Move Ghost-XR files into new VAMR-module and rename them

Julian Eisel noreply at git.blender.org
Fri Aug 30 17:57:11 CEST 2019


Commit: b0a333e755a3c034da6a19f2b9554981be06b181
Author: Julian Eisel
Date:   Fri Aug 30 16:44:02 2019 +0200
Branches: vamr-openxr-module
https://developer.blender.org/rBb0a333e755a3c034da6a19f2b9554981be06b181

Move Ghost-XR files into new VAMR-module and rename them

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

M	intern/CMakeLists.txt
A	intern/vamr/CMakeLists.txt
A	intern/vamr/VAMR_IContext.h
A	intern/vamr/VAMR_Types.h
A	intern/vamr/VAMR_capi.h
A	intern/vamr/intern/VAMR.cc
A	intern/vamr/intern/VAMR_Context.cc
A	intern/vamr/intern/VAMR_Context.h
A	intern/vamr/intern/VAMR_Event.cc
A	intern/vamr/intern/VAMR_Exception.h
A	intern/vamr/intern/VAMR_GraphicsBinding.cc
A	intern/vamr/intern/VAMR_IGraphicsBinding.h
A	intern/vamr/intern/VAMR_Session.cc
A	intern/vamr/intern/VAMR_Session.h
A	intern/vamr/intern/VAMR_intern.h
A	intern/vamr/intern/VAMR_openxr_includes.h

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

diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index b93f2057b47..0d7706438c5 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -76,3 +76,7 @@ endif()
 if(WITH_OPENVDB)
   add_subdirectory(openvdb)
 endif()
+
+if(WITH_OPENXR)
+  add_subdirectory(vamr)
+endif()
diff --git a/intern/vamr/CMakeLists.txt b/intern/vamr/CMakeLists.txt
new file mode 100644
index 00000000000..e7111301d4a
--- /dev/null
+++ b/intern/vamr/CMakeLists.txt
@@ -0,0 +1,58 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+  .
+)
+
+set(INC_SYS
+  ${OPENXR_SDK_INCLUDE_DIR}
+)
+
+set(SRC
+  intern/VAMR.cc
+  intern/VAMR_Context.cc
+  intern/VAMR_Event.cc
+  intern/VAMR_GraphicsBinding.cc
+  intern/VAMR_Session.cc
+
+  VAMR_capi.h
+  VAMR_IContext.h
+  VAMR_Types.h
+  intern/VAMR_Context.h
+  intern/VAMR_Exception.h
+  intern/VAMR_intern.h
+  intern/VAMR_IGraphicsBinding.h
+  intern/VAMR_openxr_includes.h
+  intern/VAMR_Session.h
+)
+
+if(WIN32)
+  list(APPEND LIB
+    shlwapi
+  )
+elseif(WITH_X11)
+  add_definitions(-DWITH_X11)
+endif()
+
+
+add_definitions(${GL_DEFINITIONS})
+
+include(xr_platform_defines)
+
+blender_add_lib(bf_intern_vamr "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/intern/vamr/VAMR_IContext.h b/intern/vamr/VAMR_IContext.h
new file mode 100644
index 00000000000..80feda008cf
--- /dev/null
+++ b/intern/vamr/VAMR_IContext.h
@@ -0,0 +1,42 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup VAMR
+ */
+
+#ifndef __VAMR_ICONTEXT_H__
+#define __VAMR_ICONTEXT_H__
+
+#include "VAMR_Types.h"
+
+class GHOST_IXrContext {
+ public:
+  virtual ~GHOST_IXrContext() = default;
+
+  virtual void startSession(const GHOST_XrSessionBeginInfo *begin_info) = 0;
+  virtual void endSession() = 0;
+  virtual bool isSessionRunning() const = 0;
+  virtual void drawSessionViews(void *draw_customdata) = 0;
+
+  virtual void dispatchErrorMessage(const class GHOST_XrException *) const = 0;
+
+  virtual void setGraphicsContextBindFuncs(GHOST_XrGraphicsContextBindFn bind_fn,
+                                           GHOST_XrGraphicsContextUnbindFn unbind_fn) = 0;
+  virtual void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) = 0;
+};
+
+#endif  // __VAMR_ICONTEXT_H__
diff --git a/intern/vamr/VAMR_Types.h b/intern/vamr/VAMR_Types.h
new file mode 100644
index 00000000000..2e6b1842ead
--- /dev/null
+++ b/intern/vamr/VAMR_Types.h
@@ -0,0 +1,101 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup VAMR
+ */
+
+#ifndef __VAMR_TYPES_H__
+#define __VAMR_TYPES_H__
+
+typedef struct GHOST_XrContext *GHOST_XrContextHandle;
+
+typedef enum { GHOST_kFailure = 0, GHOST_kSuccess } GHOST_TSuccess;
+
+/**
+ * The XR view (i.e. the OpenXR runtime) may require a different graphics library than OpenGL. An
+ * offscreen texture of the viewport will then be drawn into using OpenGL, but the final texture
+ * draw call will happen through another lib (say DirectX).
+ *
+ * This enum defines the possible graphics bindings to attempt to enable.
+ */
+typedef enum {
+  GHOST_kXrGraphicsUnknown = 0,
+  GHOST_kXrGraphicsOpenGL,
+#ifdef WIN32
+  GHOST_kXrGraphicsD3D11,
+#endif
+  /* For later */
+  //  GHOST_kXrGraphicsVulkan,
+} GHOST_TXrGraphicsBinding;
+/* An array of GHOST_TXrGraphicsBinding items defining the candidate bindings to use. The first
+ * available candidate will be chosen, so order defines priority. */
+typedef const GHOST_TXrGraphicsBinding *GHOST_XrGraphicsBindingCandidates;
+
+typedef struct {
+  float position[3];
+  /* Blender convention (w, x, y, z) */
+  float orientation_quat[4];
+} GHOST_XrPose;
+
+enum {
+  GHOST_kXrContextDebug = (1 << 0),
+  GHOST_kXrContextDebugTime = (1 << 1),
+};
+
+typedef struct {
+  const GHOST_XrGraphicsBindingCandidates gpu_binding_candidates;
+  unsigned int gpu_binding_candidates_count;
+
+  unsigned int context_flag;
+} GHOST_XrContextCreateInfo;
+
+typedef struct {
+  GHOST_XrPose base_pose;
+} GHOST_XrSessionBeginInfo;
+
+typedef struct {
+  int ofsx, ofsy;
+  int width, height;
+
+  GHOST_XrPose pose;
+
+  struct {
+    float angle_left, angle_right;
+    float angle_up, angle_down;
+  } fov;
+
+  /** Set if the buffer should be submitted with a srgb transfer applied. */
+  char expects_srgb_buffer;
+} GHOST_XrDrawViewInfo;
+
+typedef struct {
+  const char *user_message;
+
+  /** File path and line number the error was found at. */
+  const char *source_location;
+
+  void *customdata;
+} GHOST_XrError;
+
+typedef void (*GHOST_XrErrorHandlerFn)(const GHOST_XrError *);
+
+typedef void *(*GHOST_XrGraphicsContextBindFn)(GHOST_TXrGraphicsBinding graphics_lib);
+typedef void (*GHOST_XrGraphicsContextUnbindFn)(GHOST_TXrGraphicsBinding graphics_lib,
+                                                void *graphics_context);
+typedef void (*GHOST_XrDrawViewFn)(const GHOST_XrDrawViewInfo *draw_view, void *customdata);
+
+#endif  // __VAMR_TYPES_H__
diff --git a/intern/vamr/VAMR_capi.h b/intern/vamr/VAMR_capi.h
new file mode 100644
index 00000000000..93475467cb4
--- /dev/null
+++ b/intern/vamr/VAMR_capi.h
@@ -0,0 +1,41 @@
+#ifndef __VAMR_CAPI_H__
+#define __VAMR_CAPI_H__
+
+#include "VAMR_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* xr-context */
+
+/**
+ * Set a custom callback to be executed whenever an error occurs. Should be set before calling
+ * #GHOST_XrContextCreate().
+ */
+void GHOST_XrErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata);
+
+GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_info);
+void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_context);
+
+void GHOST_XrGraphicsContextBindFuncs(GHOST_XrContextHandle xr_context,
+                                      GHOST_XrGraphicsContextBindFn bind_fn,
+                                      GHOST_XrGraphicsContextUnbindFn unbind_fn);
+
+void GHOST_XrDrawViewFunc(GHOST_XrContextHandle xr_context, GHOST_XrDrawViewFn draw_view_fn);
+
+/* sessions */
+int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_context);
+void GHOST_XrSessionStart(GHOST_XrContextHandle xr_context,
+                          const GHOST_XrSessionBeginInfo *begin_info);
+void GHOST_XrSessionEnd(GHOST_XrContextHandle xr_context);
+void GHOST_XrSessionDrawViews(GHOST_XrContextHandle xr_context, void *customdata);
+
+/* events */
+GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // __VAMR_CAPI_H__
diff --git a/intern/vamr/intern/VAMR.cc b/intern/vamr/intern/VAMR.cc
new file mode 100644
index 00000000000..6d5e9591181
--- /dev/null
+++ b/intern/vamr/intern/VAMR.cc
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup VAMR
+ *
+ * Abstraction for XR (VR, AR, MR, ..) access via OpenXR.
+ */
+
+#include <cassert>
+#include <string>
+
+#include "VAMR_capi.h"
+
+#include "VAMR_intern.h"
+#include "VAMR_Context.h"
+#include "VAMR_Exception.h"
+
+/**
+ * \brief Initialize the window manager XR-Context.
+ * Includes setting up the OpenXR instance, querying available extensions and API layers,
+ * enabling extensions (currently graphics binding extension only) and API layers.
+ */
+GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_info)
+{
+  GHOST_XrContext *xr_context = new GHOST_XrContext(create_info);
+
+  // TODO GHOST_XrContext's should probably be owned by the GHOST_Syste

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list