As a slight concession, create a 'fake' VAO to use when 0 is bound

* I think this is invalid in the core profile, but it's a simple workaround
  and this might be a common problem.
This commit is contained in:
baldurk
2014-12-03 14:00:23 +00:00
parent 8397aa1f28
commit 46a29c7d14
4 changed files with 22 additions and 11 deletions
+7
View File
@@ -477,6 +477,7 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs)
m_FakeBB_FBO = 0;
m_FakeBB_Color = 0;
m_FakeBB_DepthStencil = 0;
m_FakeVAO = 0;
RDCDEBUG("Debug Text enabled - for development! remove before release!");
m_pSerialiser->SetDebugText(true);
@@ -494,6 +495,12 @@ void WrappedOpenGL::Initialise(GLInitParams &params)
// deliberately want to go through our own wrappers to set up e.g. m_Textures members
WrappedOpenGL &gl = *this;
// as a concession to compatibility, generate a 'fake' VBO to act as VBO 0.
// consider making it an error/warning for programs to use this?
gl.glGenVertexArrays(1, &m_FakeVAO);
gl.glBindVertexArray(m_FakeVAO);
gl.glBindVertexArray(0);
gl.glGenFramebuffers(1, &m_FakeBB_FBO);
gl.glBindFramebuffer(eGL_FRAMEBUFFER, m_FakeBB_FBO);
+2
View File
@@ -262,6 +262,7 @@ class WrappedOpenGL
GLuint m_FakeBB_FBO;
GLuint m_FakeBB_Color;
GLuint m_FakeBB_DepthStencil;
GLuint m_FakeVAO;
bool m_DoStateVerify;
//GLRenderState *m_CurrentPipelineState;
@@ -338,6 +339,7 @@ class WrappedOpenGL
void ReadLogInitialisation();
GLuint GetFakeBBFBO() { return m_FakeBB_FBO; }
GLuint GetFakeVAO() { return m_FakeVAO; }
vector<FetchFrameRecord> &GetFrameRecord() { return m_FrameRecord; }
FetchAPIEvent GetEvent(uint32_t eventID);
+2
View File
@@ -619,6 +619,8 @@ void GLRenderState::Serialise(LogState state, void *ctx, WrappedOpenGL *gl)
if(state >= WRITING) ID = rm->GetID(VertexArrayRes(ctx, VAO));
m_pSerialiser->Serialise("GL_VERTEX_ARRAY_BINDING", ID);
if(state < WRITING && ID != ResourceId()) VAO = rm->GetLiveResource(ID).name;
if(VAO == 0) VAO = gl->GetFakeVAO();
}
{
@@ -1797,7 +1797,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribPointer(GLuint index, GLint size, GL
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
if(bid != ResourceId())
@@ -1868,7 +1868,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribIPointer(GLuint index, GLint size, G
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
if(bid != ResourceId())
@@ -1939,7 +1939,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribLPointer(GLuint index, GLint size, G
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
if(bid != ResourceId())
@@ -1999,7 +1999,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribBinding(GLuint attribindex, GLuint b
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glVertexAttribBinding(aidx, bidx);
@@ -2050,7 +2050,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribFormat(GLuint attribindex, GLint siz
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glVertexAttribFormat(Index, Size, Type, Norm, Offset);
@@ -2101,7 +2101,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribIFormat(GLuint attribindex, GLint si
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glVertexAttribIFormat(Index, Size, Type, Offset);
@@ -2152,7 +2152,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribLFormat(GLuint attribindex, GLint si
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glVertexAttribLFormat(Index, Size, Type, Offset);
@@ -2201,7 +2201,7 @@ bool WrappedOpenGL::Serialise_glVertexAttribDivisor(GLuint index, GLuint divisor
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glVertexAttribDivisor(Index, Divisor);
@@ -2249,7 +2249,7 @@ bool WrappedOpenGL::Serialise_glEnableVertexAttribArray(GLuint index)
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glEnableVertexAttribArray(Index);
@@ -2296,7 +2296,7 @@ bool WrappedOpenGL::Serialise_glDisableVertexAttribArray(GLuint index)
}
else
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
m_Real.glDisableVertexAttribArray(Index);
@@ -2387,7 +2387,7 @@ bool WrappedOpenGL::Serialise_glBindVertexArray(GLuint array)
{
if(id == ResourceId())
{
m_Real.glBindVertexArray(0);
m_Real.glBindVertexArray(m_FakeVAO);
}
else
{