From 4f65bb1b808b6820b3e7ff02e2f2d07f51ac5663 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 20 Jun 2018 13:39:06 +0100 Subject: [PATCH] Ensure context pair is set up before creating per-context objects * Without this, client-memory IBs/VBs will not have the correct context sharegroup set. --- renderdoc/driver/gl/gl_driver.cpp | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index a0df661e7..a320283ec 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -919,7 +919,7 @@ void WrappedOpenGL::ContextData::AssociateWindow(WrappedOpenGL *gl, void *wndHan void WrappedOpenGL::ContextData::CreateResourceRecord(WrappedOpenGL *gl, void *suppliedCtx) { - if(m_ContextDataResourceID == ResourceId::Null() || + if(m_ContextDataResourceID == ResourceId() || !gl->GetResourceManager()->HasResourceRecord(m_ContextDataResourceID)) { m_ContextDataResourceID = gl->GetResourceManager()->RegisterResource( @@ -1070,6 +1070,27 @@ void WrappedOpenGL::ActivateContext(GLWindowingData winData) ContextData &ctxdata = m_ContextData[winData.ctx]; + ctxdata.CreateResourceRecord(this, winData.ctx); + + // update thread-local context pair + { + GLContextTLSData *tlsData = (GLContextTLSData *)Threading::GetTLSValue(m_CurCtxDataTLS); + + if(tlsData) + { + tlsData->ctxPair = {winData.ctx, ShareCtx(winData.ctx)}; + tlsData->ctxRecord = ctxdata.m_ContextDataRecord; + } + else + { + tlsData = new GLContextTLSData(ContextPair({winData.ctx, ShareCtx(winData.ctx)}), + ctxdata.m_ContextDataRecord); + m_CtxDataVector.push_back(tlsData); + + Threading::SetTLSValue(m_CurCtxDataTLS, tlsData); + } + } + if(!ctxdata.built) { ctxdata.built = true; @@ -1258,27 +1279,6 @@ void WrappedOpenGL::ActivateContext(GLWindowingData winData) } } - ctxdata.CreateResourceRecord(this, winData.ctx); - - // update thread-local context pair - { - GLContextTLSData *tlsData = (GLContextTLSData *)Threading::GetTLSValue(m_CurCtxDataTLS); - - if(tlsData) - { - tlsData->ctxPair = {winData.ctx, ShareCtx(winData.ctx)}; - tlsData->ctxRecord = ctxdata.m_ContextDataRecord; - } - else - { - tlsData = new GLContextTLSData(ContextPair({winData.ctx, ShareCtx(winData.ctx)}), - ctxdata.m_ContextDataRecord); - m_CtxDataVector.push_back(tlsData); - - Threading::SetTLSValue(m_CurCtxDataTLS, tlsData); - } - } - // this is hack but GL context creation is an *utter mess*. For first-frame captures, only // consider an attribs created context, to avoid starting capturing when the user is creating // dummy contexts to be able to create the real one.