Only create client memory VBOs the first time context is activated.

Also added corresponding deletion code in WrappedOpenGL::DeleteContext.
This commit is contained in:
Michael Rennie
2017-04-26 10:47:08 +01:00
committed by Baldur Karlsson
parent 59536d4db0
commit 34d692330e
2 changed files with 19 additions and 9 deletions
+18 -9
View File
@@ -1099,6 +1099,9 @@ void WrappedOpenGL::DeleteContext(void *contextHandle)
m_Real.glDeleteTextures(1, &ctxdata.GlyphTexture);
}
if(ctxdata.m_ClientMemoryVBOs[0])
glDeleteBuffers(ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs), ctxdata.m_ClientMemoryVBOs);
for(auto it = m_LastContexts.begin(); it != m_LastContexts.end(); ++it)
{
if(it->ctx == contextHandle)
@@ -1471,6 +1474,21 @@ void WrappedOpenGL::ActivateContext(GLWindowingData winData)
DoVendorChecks(gl, m_Platform, winData);
}
}
if(m_State >= WRITING)
{
GLuint prevArrayBuffer = 0;
glGetIntegerv(eGL_ARRAY_BUFFER_BINDING, (GLint *)&prevArrayBuffer);
// Initialize VBOs used in case we copy from client memory.
glGenBuffers(ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs), ctxdata.m_ClientMemoryVBOs);
for(size_t i = 0; i < ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs); i++)
{
glBindBuffer(eGL_ARRAY_BUFFER, ctxdata.m_ClientMemoryVBOs[i]);
glBufferData(eGL_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW);
}
glBindBuffer(eGL_ARRAY_BUFFER, prevArrayBuffer);
}
}
if(m_State >= WRITING)
@@ -1478,15 +1496,6 @@ void WrappedOpenGL::ActivateContext(GLWindowingData winData)
m_Internal = m_Real;
glEmulate::EmulateRequiredExtensions(&m_Real, &m_Internal);
// Initialize VBOs used in case we copy from client memory.
glGenBuffers(ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs), ctxdata.m_ClientMemoryVBOs);
for(size_t i = 0; i < ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs); i++)
{
glBindBuffer(eGL_ARRAY_BUFFER, ctxdata.m_ClientMemoryVBOs[i]);
glBufferData(eGL_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW);
}
glBindBuffer(eGL_ARRAY_BUFFER, 0);
}
}
}
+1
View File
@@ -389,6 +389,7 @@ private:
m_Renderbuffer = ResourceId();
m_TextureUnit = 0;
m_ProgramPipeline = m_Program = 0;
RDCEraseEl(m_ClientMemoryVBOs);
}
void *ctx;