[Bf-blender-cvs] [daba8140c22] soc-2019-openxr: Cleanup: Unused functions, add comments, sync to master
Julian Eisel
noreply at git.blender.org
Thu Aug 22 23:03:43 CEST 2019
Commit: daba8140c22837325a7d426972357d8d1d7e3758
Author: Julian Eisel
Date: Thu Aug 22 23:02:01 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rBdaba8140c22837325a7d426972357d8d1d7e3758
Cleanup: Unused functions, add comments, sync to master
===================================================================
M intern/ghost/GHOST_C-api.h
M intern/ghost/GHOST_IContext.h
M intern/ghost/GHOST_IWindow.h
M intern/ghost/intern/GHOST_C-api.cpp
M intern/ghost/intern/GHOST_Context.h
M intern/ghost/intern/GHOST_SystemWin32.h
M intern/ghost/intern/GHOST_Window.h
M intern/ghost/intern/GHOST_XrSession.cpp
M source/blender/windowmanager/intern/wm_xr.c
M source/blender/windowmanager/wm_surface.h
M tests/python/bl_load_py_modules.py
===================================================================
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 03cf3a1c7a0..1f3b013fba9 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -197,8 +197,6 @@ GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle,
GHOST_ContextHandle contexthandle);
#endif
-extern GHOST_ContextHandle GHOST_GetWindowContext(GHOST_WindowHandle windowhandle);
-
/**
* Returns the window user data.
* \param windowhandle The handle to the window
@@ -673,13 +671,6 @@ extern GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
*/
extern GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle);
-/**
- * Swaps front and back buffers of a context.
- * \param contexthandle The handle to the context
- * \return A success indicator.
- */
-extern GHOST_TSuccess GHOST_SwapContextBuffers(GHOST_ContextHandle contexthandle);
-
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
diff --git a/intern/ghost/GHOST_IContext.h b/intern/ghost/GHOST_IContext.h
index d114df428b0..33422b8e351 100644
--- a/intern/ghost/GHOST_IContext.h
+++ b/intern/ghost/GHOST_IContext.h
@@ -60,6 +60,9 @@ class GHOST_IContext {
virtual GHOST_TSuccess swapBuffers() = 0;
+ /**
+ * Returns if the window is rendered upside down compared to OpenGL.
+ */
virtual bool isUpsideDown() const = 0;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 547ae1d3ec3..a257116cba1 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -77,8 +77,6 @@ class GHOST_IWindow {
*/
virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) = 0;
- virtual class GHOST_IContext *getDrawingContext() = 0;
-
/**
* Sets the title displayed in the title bar.
* \param title The title to display in the title bar.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 898378460c6..d0f068f5e3c 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -150,13 +150,6 @@ GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle,
#endif
-GHOST_ContextHandle GHOST_GetWindowContext(GHOST_WindowHandle windowhandle)
-{
- GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
-
- return (GHOST_ContextHandle)window->getDrawingContext();
-}
-
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
const char *title,
GHOST_TInt32 left,
@@ -623,13 +616,6 @@ GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
return window->swapBuffers();
}
-GHOST_TSuccess GHOST_SwapContextBuffers(GHOST_ContextHandle contexthandle)
-{
- GHOST_IContext *context = (GHOST_IContext *)contexthandle;
-
- return context->swapBuffers();
-}
-
GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index af801112bda..a257f383518 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -120,6 +120,9 @@ class GHOST_Context : public GHOST_IContext {
return m_stereoVisual;
}
+ /**
+ * Returns if the window is rendered upside down compared to OpenGL.
+ */
inline bool isUpsideDown() const
{
return false;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index c911cafc567..34b244e46e1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -242,6 +242,11 @@ class GHOST_SystemWin32 : public GHOST_System {
*/
GHOST_TSuccess exit();
+ /**
+ * Create a new offscreen DirectX context.
+ * Never explicitly delete the window, use disposeContext() instead.
+ * \return The new context (or 0 if creation failed).
+ */
GHOST_IContext *createOffscreenContextD3D();
/**
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 59784abbae3..f559e661e09 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -221,11 +221,6 @@ class GHOST_Window : public GHOST_IWindow {
*/
virtual bool getModifiedState();
- inline GHOST_IContext *getDrawingContext()
- {
- return (GHOST_IContext *)m_context;
- }
-
/**
* Returns the type of drawing context used in this window.
* \return The current type of drawing context.
@@ -284,6 +279,9 @@ class GHOST_Window : public GHOST_IWindow {
m_userData = userData;
}
+ /**
+ * Returns if the window is rendered upside down compared to OpenGL.
+ */
bool isUpsideDown() const;
float getNativePixelSize(void)
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 3a3e2f0c795..b388ba07c0f 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -119,6 +119,15 @@ static void create_reference_space(OpenXRSessionData *oxr, const GHOST_XrPose *b
create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
#if 0
+/* Proper reference space set up is not supported yet. We simply hand OpenXR
+ * the global space as reference space and apply its pose onto the active
+ * camera matrix to get a basic viewing experience going. If there's no active
+ * camera with stick to the world origin.
+ *
+ * Once we have proper reference space set up (i.e. a way to define origin, up-
+ * direction and an initial view rotation perpendicular to the up-direction),
+ * we can hand OpenXR a proper reference pose/space.
+ */
create_info.poseInReferenceSpace.position.x = base_pose->position[0];
create_info.poseInReferenceSpace.position.y = base_pose->position[2];
create_info.poseInReferenceSpace.position.z = -base_pose->position[1];
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index 8c3139254d5..772c13089fd 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -16,6 +16,10 @@
/** \file
* \ingroup wm
+ *
+ * \name Window-Manager XR API
+ *
+ * Implements Blender specific functionality for the GHOST_Xr API.
*/
#include "BKE_context.h"
@@ -75,6 +79,10 @@ wmSurface *wm_xr_session_surface_create(wmWindowManager *, unsigned int);
/* -------------------------------------------------------------------- */
/** \name XR-Context
+ *
+ * All XR functionality is accessed through a #GHOST_XrContext handle.
+ * The lifetime of this context also determines the lifetime of the OpenXR instance, which is the
+ * representation of the OpenXR runtime connection within the application.
*
* \{ */
@@ -208,9 +216,19 @@ void wm_xr_session_toggle(bContext *C, void *xr_context_ptr)
/* -------------------------------------------------------------------- */
/** \name XR-Session Surface
+ *
+ * A wmSurface is used to manage drawing of the VR viewport. It's created and destroyed with the
+ * session.
*
* \{ */
+/**
+ * \brief Call Ghost-XR to draw a frame
+ *
+ * Draw callback for the XR-session surface. It's expected to be called on each main loop iteration
+ * and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing each view,
+ * #wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()).
+ */
static void wm_xr_session_surface_draw(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -336,6 +354,11 @@ wmSurface *wm_xr_session_surface_create(wmWindowManager *UNUSED(wm), unsigned in
*
* \{ */
+/**
+ * Proper reference space set up is not supported yet. We simply hand OpenXR the global space as
+ * reference space and apply its pose onto the active camera matrix to get a basic viewing
+ * experience going. If there's no active camera with stick to the world origin.
+ */
static void wm_xr_draw_matrices_create(const Scene *scene,
const GHOST_XrDrawViewInfo *draw_view,
const float clip_start,
@@ -371,6 +394,12 @@ static void wm_xr_draw_matrices_create(const Scene *scene,
}
}
+/**
+ * \brief Draw a viewport for a single eye.
+ *
+ * This is the main viewport drawing function for VR sessions. It's assigned to Ghost-XR as a
+ * callback (see GHOST_XrDrawViewFunc()) and executed for each view (read: eye).
+ */
GHOST_ContextHandle wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
{
bContext *C = customdata;
diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h
index a5112521fa5..98d67c55619 100644
--- a/source/blender/windowmanager/wm_surface.h
+++ b/source/blender/windowmanager/wm_surface.h
@@ -16,6 +16,10 @@
/** \file
* \ingroup wm
+ *
+ * \name WM-Surface
+ *
+ * Container to manage painting in an offscreen context.
*/
#ifndef __WM_SURFACE_H__
diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py
index 6deacef0521..d5d54660da6 100644
--- a/tests/python/bl_load_py_modules.py
+++ b/tests/python/bl_load_py_modules.py
@@ -204,8 +204,7 @@ def load_modules():
# check which filepaths we didn't load
source_files = []
for mod_dir in module_paths:
- source_files.extend(source_list(
- mod_dir, filename_check=lambda f: f.endswith(".py")))
+ source_files.extend(source_list(mod_dir, filename_check=lambda f: f.endswith(".py")))
source_files = list(set(source_files))
source_files.sort()
More information about the Bf-blender-cvs
mailing list