mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-04 04:45:48 +00:00
fixed a problem with wglMakeCurrent failing
the issue of deleted DC making backdoor context
This commit is contained in:
@@ -567,14 +567,16 @@ bool GLResourceManager::Prepare_InitialState(GLResource res)
|
||||
|
||||
ContextShareGroup *shareGroup = (ContextShareGroup *)res.ContextShareGroup;
|
||||
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = shareGroup->m_BackDoor;
|
||||
m_Driver->m_Platform.MakeContextCurrent(shareGroup->m_BackDoor);
|
||||
if(m_Driver->m_Platform.MakeContextCurrent(shareGroup->m_BackDoor))
|
||||
{
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = shareGroup->m_BackDoor;
|
||||
|
||||
ContextPrepare_InitialState(res);
|
||||
ContextPrepare_InitialState(res);
|
||||
|
||||
// restore the context
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = oldContextData;
|
||||
m_Driver->m_Platform.MakeContextCurrent(oldContextData);
|
||||
// restore the context
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = oldContextData;
|
||||
m_Driver->m_Platform.MakeContextCurrent(oldContextData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1813,18 +1815,19 @@ bool GLResourceManager::Serialise_InitialState(WriteSerialiser &ser, ResourceId
|
||||
|
||||
GLWindowingData backdoor = ((ContextShareGroup *)res.ContextShareGroup)->m_BackDoor;
|
||||
|
||||
m_Driver->m_Platform.MakeContextCurrent(backdoor);
|
||||
if(m_Driver->m_Platform.MakeContextCurrent(backdoor))
|
||||
{
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = backdoor;
|
||||
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = backdoor;
|
||||
bool success = Serialise_InitialState<WriteSerialiser>(ser, id, record, initial);
|
||||
|
||||
bool success = Serialise_InitialState<WriteSerialiser>(ser, id, record, initial);
|
||||
// restore the context
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = oldContextData;
|
||||
|
||||
// restore the context
|
||||
m_Driver->m_ActiveContexts[Threading::GetCurrentID()] = oldContextData;
|
||||
m_Driver->m_Platform.MakeContextCurrent(oldContextData);
|
||||
|
||||
m_Driver->m_Platform.MakeContextCurrent(oldContextData);
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
return Serialise_InitialState<WriteSerialiser>(ser, id, record, initial);
|
||||
|
||||
@@ -145,12 +145,17 @@ bool GLResourceManager::ResourceTypeRelease(GLResource res)
|
||||
{
|
||||
ContextShareGroup *contextShareGroup = (ContextShareGroup *)res.ContextShareGroup;
|
||||
|
||||
m_Driver->m_Platform.MakeContextCurrent(contextShareGroup->m_BackDoor);
|
||||
if(m_Driver->m_Platform.MakeContextCurrent(contextShareGroup->m_BackDoor))
|
||||
{
|
||||
m_Driver->ReleaseResource(res);
|
||||
|
||||
m_Driver->ReleaseResource(res);
|
||||
|
||||
// restore the context
|
||||
m_Driver->m_Platform.MakeContextCurrent(m_Driver->m_ActiveContexts[Threading::GetCurrentID()]);
|
||||
// restore the context
|
||||
m_Driver->m_Platform.MakeContextCurrent(m_Driver->m_ActiveContexts[Threading::GetCurrentID()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Driver->QueueResourceRelease(res);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -45,6 +45,25 @@ class WGLPlatform : public GLPlatform
|
||||
if(!WGL.wglCreateContextAttribsARB)
|
||||
return ret;
|
||||
|
||||
// the reason we have to create an entire window and DC is because the share DC (and window)
|
||||
// can be destroyed after we make a clone, which causes the DC (and window) we hold on to,
|
||||
// to become invalid.
|
||||
if(!RegisterClass())
|
||||
return ret;
|
||||
|
||||
HWND wnd =
|
||||
CreateWindowW(WINDOW_CLASS_NAME, L"", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||
|
||||
HDC dc = GetDC(wnd);
|
||||
|
||||
int pf = GetPixelFormat(share.DC);
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
DescribePixelFormat(share.DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
SetPixelFormat(dc, pf, &pfd);
|
||||
|
||||
const int attribs[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB,
|
||||
3,
|
||||
@@ -58,7 +77,13 @@ class WGLPlatform : public GLPlatform
|
||||
0,
|
||||
};
|
||||
|
||||
ret.ctx = WGL.wglCreateContextAttribsARB(share.DC, share.ctx, attribs);
|
||||
HGLRC rc = WGL.wglCreateContextAttribsARB(dc, share.ctx, attribs);
|
||||
|
||||
ShowWindow(wnd, SW_HIDE);
|
||||
|
||||
ret.wnd = wnd;
|
||||
ret.DC = dc;
|
||||
ret.ctx = rc;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -66,7 +91,11 @@ class WGLPlatform : public GLPlatform
|
||||
void DeleteClonedContext(GLWindowingData context)
|
||||
{
|
||||
if(context.ctx && WGL.wglDeleteContext)
|
||||
{
|
||||
WGL.wglDeleteContext(context.ctx);
|
||||
::ReleaseDC(context.wnd, context.DC);
|
||||
::DestroyWindow(context.wnd);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteReplayContext(GLWindowingData context)
|
||||
|
||||
Reference in New Issue
Block a user