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:
authorClément Foucault <foucault.clem@gmail.com>2018-06-11 14:54:31 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-06-11 14:55:02 +0300
commitb7bf8b375767cec527b5659613dbff1903963f3c (patch)
tree604a2955651dd9ab6524916b8ef201115e856785 /source/blender/draw/intern/draw_manager.c
parent128926a41b368e166af63515370d9c9367e3dda2 (diff)
Render: Create a separate gl context for rendering.
This should take care of all the threading stability issues some people are reporting.
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r--source/blender/draw/intern/draw_manager.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 5f059f92d5f..054d070bea1 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1464,8 +1464,24 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
WM_init_opengl();
}
+ void *re_gl_context = RE_gl_context_get(render);
+ void *re_gwn_context = NULL;
+
/* Changing Context */
- DRW_opengl_context_enable();
+ if (re_gl_context != NULL) {
+ /* TODO get rid of the blocking. Only here because of the static global DST. */
+ BLI_mutex_lock(&DST.gl_context_mutex);
+ WM_opengl_context_activate(re_gl_context);
+ re_gwn_context = RE_gwn_context_get(render);
+ if (GWN_context_active_get() == NULL) {
+ GWN_context_active_set(re_gwn_context);
+ }
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+ }
+ else {
+ DRW_opengl_context_enable();
+ }
+
/* IMPORTANT: We dont support immediate mode in render mode!
* This shall remain in effect until immediate mode supports
* multiple threads. */
@@ -1533,7 +1549,17 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
GPU_framebuffer_restore();
/* Changing Context */
- DRW_opengl_context_disable();
+ if (re_gl_context != NULL) {
+ DRW_shape_cache_reset(); /* XXX fix that too. */
+ glFlush();
+ GWN_context_active_set(NULL);
+ WM_opengl_context_release(re_gl_context);
+ /* TODO get rid of the blocking. */
+ BLI_mutex_unlock(&DST.gl_context_mutex);
+ }
+ else {
+ DRW_opengl_context_disable();
+ }
#ifdef DEBUG
/* Avoid accidental reuse. */