Support VAO 0 being used, by creating fake resource record for it

* We pick up the properties of VAO 0 on frame capture as dirty state, and
  then replay it into the fake VAO we were already creating for VAO 0.
* Eventually this record will be entirely trimmed/ignored for programs that
  don't use VAO 0 by frame references, but for now we fetch it needlessly.
  It doesn't seem to fire any errors.
This commit is contained in:
baldurk
2014-12-26 12:04:19 +00:00
parent 47005da118
commit 3cec05c3d9
3 changed files with 20 additions and 6 deletions
+10 -1
View File
@@ -705,6 +705,12 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs)
m_ContextRecord->NumSubResources = 0;
m_ContextRecord->SpecialResource = true;
m_ContextRecord->SubResources = NULL;
// register VAO 0 as a special VAO, so that it can be tracked if the app uses it
// we immediately mark it dirty since the vertex array tracking functions expect a proper VAO
m_FakeVAOID = GetResourceManager()->RegisterResource(VertexArrayRes(NULL, 0));
GetResourceManager()->AddResourceRecord(m_FakeVAOID);
GetResourceManager()->MarkDirtyResource(m_FakeVAOID);
}
else
{
@@ -1563,6 +1569,7 @@ void WrappedOpenGL::Present(void *windowHandle)
SCOPED_SERIALISE_CONTEXT(DEVICE_INIT);
SERIALISE_ELEMENT(ResourceId, immContextId, m_ContextResourceID);
SERIALISE_ELEMENT(ResourceId, vaoId, m_FakeVAOID);
m_pFileSerialiser->Insert(scope.Get(true));
}
@@ -2012,8 +2019,10 @@ void WrappedOpenGL::ProcessChunk(uint64_t offset, GLChunkType context)
case DEVICE_INIT:
{
SERIALISE_ELEMENT(ResourceId, immContextId, ResourceId());
SERIALISE_ELEMENT(ResourceId, vaoId, ResourceId());
m_ResourceManager->AddLiveResource(immContextId, GLResource(NULL, eResSpecial, eSpecialResContext));
GetResourceManager()->AddLiveResource(immContextId, GLResource(NULL, eResSpecial, eSpecialResContext));
GetResourceManager()->AddLiveResource(vaoId, VertexArrayRes(NULL, 0));
break;
}
case GEN_TEXTURE:
+2
View File
@@ -256,6 +256,8 @@ class WrappedOpenGL
GLuint m_FakeBB_Color;
GLuint m_FakeBB_DepthStencil;
GLuint m_FakeVAO;
ResourceId m_FakeVAOID;
bool m_DoStateVerify;
//GLRenderState *m_CurrentPipelineState;
+8 -5
View File
@@ -492,7 +492,7 @@ bool GLResourceManager::Prepare_InitialState(GLResource res)
// need to be on the right context, as VAOs are never shared
void *oldctx = NULL;
if(!VendorCheck[VendorCheck_EXT_vao_shared])
if(!VendorCheck[VendorCheck_EXT_vao_shared] && res.Context)
oldctx = m_GL->SwitchToContext(res.Context);
GLuint prevVAO = 0;
@@ -531,7 +531,7 @@ bool GLResourceManager::Prepare_InitialState(GLResource res)
gl.glBindVertexArray(prevVAO);
// restore the previous context
if(!VendorCheck[VendorCheck_EXT_vao_shared])
if(!VendorCheck[VendorCheck_EXT_vao_shared] && res.Context)
m_GL->SwitchToContext(oldctx);
}
else
@@ -1325,11 +1325,14 @@ void GLResourceManager::Apply_InitialState(GLResource live, InitialContentData i
{
GLuint VAO = 0;
gl.glGetIntegerv(eGL_VERTEX_ARRAY_BINDING, (GLint *)&VAO);
gl.glBindVertexArray(live.name);
VAOInitialData *initialdata = (VAOInitialData *)initial.blob;
if(live.name == 0)
gl.glBindVertexArray(m_GL->GetFakeVAO());
else
gl.glBindVertexArray(live.name);
for(GLuint i=0; i < 16; i++)
{
VertexAttribInitialData &attrib = initialdata->VertexAttribs[i];