Commit: 2fa231a86b4179ed513da2469df877497b346162
Author: Ray Molenkamp
Date:   Sat Jun 23 11:37:35 2018 -0600
Branches: blender2.8
https://developer.blender.org/rB2fa231a86b4179ed513da2469df877497b346162

Ghost: Fix F12 render on windows.

createOffscreenContext left the new context bound to the calling thread
causing a race condition with the background thread doing the actual
rendering. see T55555 for a more detailed description of the problem.

this patch changes the behavior of createOffscreenContext to restore the
context to the calling context.

Reviewers: fclem

Differential Revision: https://developer.blender.org/D3499

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

M       intern/ghost/intern/GHOST_SystemWin32.cpp

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

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index b97bf1d089c..17c41e96be4 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -325,7 +325,8 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
        );
 
        HDC  mHDC = GetDC(wnd);
-
+       HDC  prev_hdc = wglGetCurrentDC();
+       HGLRC prev_context = wglGetCurrentContext();
 #if defined(WITH_GL_PROFILE_CORE)
        for (int minor = 5; minor >= 0; --minor) {
                        context = new GHOST_ContextWGL(
@@ -337,7 +338,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
                            GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 
                        if (context->initializeDrawingContext()) {
-                               return context;
+                               goto finished;
                        }
                        else {
                                delete context;
@@ -353,7 +354,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
                    GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
 
                if (context->initializeDrawingContext()) {
-                       return context;
+                       goto finished;
                }
                else {
                        MessageBox(
@@ -386,8 +387,9 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
 #else
 #  error // must specify either core or compat at build time
 #endif
-
-       return NULL;
+finished:
+       wglMakeCurrent(prev_hdc, prev_context);
+       return context;
 }
 
 /**

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to