mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
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:
@@ -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()];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user