diff options
author | Ray Molenkamp <github@lazydodo.com> | 2018-06-23 20:37:35 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2018-06-23 20:37:35 +0300 |
commit | 2fa231a86b4179ed513da2469df877497b346162 (patch) | |
tree | 783255c2232b8ef2919962a7e99e32214b5ddc31 /intern | |
parent | 4ddb03ba79f756524b897b57318c5be58e0b372f (diff) |
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
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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; } /** |