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 <julian@blender.org>2020-03-17 18:40:07 +0300
committerJulian Eisel <julian@blender.org>2020-03-17 18:40:07 +0300
commit99eb95337f74f1a303c774902ea29f7d378bac1b (patch)
tree870f3cb9dc10a867fae489c20b574a0338b46fae
parent1a7135b12f06bdff98a00e55b335c89f5e43a862 (diff)
parent5d30598e3b05f89068fdd4469fe0d84bd017c290 (diff)
Merge branch 'temp-openxr-blenderside' into soc-2019-openxr
-rw-r--r--source/blender/draw/CMakeLists.txt4
-rw-r--r--source/blender/draw/DRW_engine.h4
-rw-r--r--source/blender/draw/intern/draw_manager.c18
-rw-r--r--source/blender/windowmanager/intern/wm_xr.c4
4 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index a1213be4be0..81f2214b402 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -390,4 +390,8 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
+if(WITH_XR_OPENXR)
+ add_definitions(-DWITH_XR_OPENXR)
+endif()
+
blender_add_lib(bf_draw "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index 07d6219b85e..d4d015e53ac 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -141,8 +141,8 @@ void DRW_opengl_context_disable(void);
/* Not nice to expose these. Code to render offscreen viewports can save expensive context switches
* by using this directly however. */
-void *DRW_opengl_context_get(void);
-void *DRW_gpu_context_get(void);
+void *DRW_xr_opengl_context_get(void);
+void *DRW_xr_gpu_context_get(void);
/* For garbage collection */
void DRW_cache_free_old_batches(struct Main *bmain);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index d718522bdb4..8aeb90f5f36 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2794,16 +2794,30 @@ void DRW_opengl_context_disable(void)
DRW_opengl_context_disable_ex(true);
}
-void *DRW_opengl_context_get(void)
+#ifdef WITH_XR_OPENXR
+
+/* XXX
+ * There should really be no such getter, but for VR we currently can't easily avoid it. OpenXR
+ * needs some low level info for the OpenGL context that will be used for submitting the
+ * final framebuffer. VR could in theory create its own context, but that would mean we have to
+ * switch to it just to submit the final frame, which has notable performance impact.
+ *
+ * We could "inject" a context through DRW_opengl_render_context_enable(), but that would have to
+ * work from the main thread, which is tricky to get working too. The preferable solution would be
+ * using a separate thread for VR drawing where a single context can stay active. */
+void *DRW_xr_opengl_context_get(void)
{
return DST.gl_context;
}
-void *DRW_gpu_context_get(void)
+/* XXX See comment on DRW_xr_opengl_context_get(). */
+void *DRW_xr_gpu_context_get(void)
{
return DST.gpu_context;
}
+#endif
+
void DRW_opengl_render_context_enable(void *re_gl_context)
{
/* If thread is main you should use DRW_opengl_context_enable(). */
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index be6af48f5de..7600c0b350e 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -335,7 +335,7 @@ wmSurface *wm_xr_session_surface_create(wmWindowManager *UNUSED(wm), unsigned in
data->gpu_binding_type = gpu_binding_type;
surface->customdata = data;
- surface->ghost_ctx = DRW_opengl_context_get();
+ surface->ghost_ctx = DRW_xr_opengl_context_get();
switch (gpu_binding_type) {
case GHOST_kXrGraphicsOpenGL:
@@ -347,7 +347,7 @@ wmSurface *wm_xr_session_surface_create(wmWindowManager *UNUSED(wm), unsigned in
#endif
}
- surface->gpu_ctx = DRW_gpu_context_get();
+ surface->gpu_ctx = DRW_xr_gpu_context_get();
g_xr_surface = surface;