Take global GL lock when inside SwapBuffers & Start/EndFrameCapture

* If we don't have this lock, we can end up trampling serialisation
  as two threads try to serialise at once.
This commit is contained in:
baldurk
2016-11-18 18:58:55 +01:00
parent 4e6a461d32
commit 9014c5330a
3 changed files with 19 additions and 0 deletions
+5
View File
@@ -1030,6 +1030,7 @@ WrappedOpenGL::ContextData &WrappedOpenGL::GetCtxData()
}
// defined in gl_<platform>_hooks.cpp
Threading::CriticalSection &GetGLLock();
void MakeContextCurrent(GLWindowingData data);
// for 'backwards compatible' overlay rendering
@@ -2330,6 +2331,8 @@ void WrappedOpenGL::StartFrameCapture(void *dev, void *wnd)
if(m_State != WRITING_IDLE)
return;
SCOPED_LOCK(GetGLLock());
RenderDoc::Inst().SetCurrentDriver(RDC_OpenGL);
m_State = WRITING_CAPFRAME;
@@ -2386,6 +2389,8 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
if(m_State != WRITING_CAPFRAME)
return true;
SCOPED_LOCK(GetGLLock());
CaptureFailReason reason = CaptureSucceeded;
GLWindowingData prevctx = m_ActiveContexts[Threading::GetCurrentID()];
+7
View File
@@ -1065,6 +1065,8 @@ __attribute__((visibility("default"))) void glXSwapBuffers(Display *dpy, GLXDraw
if(OpenGLHook::glhooks.glXSwapBuffers_real == NULL)
OpenGLHook::glhooks.SetupExportedFunctions();
SCOPED_LOCK(glLock);
// if we use the GLXDrawable in XGetGeometry and it's a GLXWindow, then we get
// a BadDrawable error and things go south. Instead we track GLXWindows created
// in glXCreateWindow/glXDestroyWindow and look up the source window it was
@@ -1336,6 +1338,11 @@ const GLHookSet &GetRealGLFunctions()
return OpenGLHook::glhooks.GetRealGLFunctions();
}
Threading::CriticalSection &GetGLLock()
{
return glLock;
}
void MakeContextCurrent(GLWindowingData data)
{
OpenGLHook::glhooks.MakeContextCurrent(data);
+7
View File
@@ -705,6 +705,8 @@ private:
if(w != NULL && glhooks.m_HaveContextCreation)
{
SCOPED_LOCK(glLock);
RECT r;
GetClientRect(w, &r);
@@ -1307,6 +1309,11 @@ const GLHookSet &GetRealGLFunctions()
return OpenGLHook::glhooks.GetRealGLFunctions();
}
Threading::CriticalSection &GetGLLock()
{
return glLock;
}
void MakeContextCurrent(GLWindowingData data)
{
OpenGLHook::glhooks.MakeContextCurrent(data);