Set vertex buffer/attrib offsets to 0xDEADBEEF if they're pointers

* This helps reduce noise of serialising user pointers in the capture
This commit is contained in:
baldurk
2018-10-17 11:42:49 +01:00
parent 7c31f3f171
commit bc52dd6c5f
+18 -4
View File
@@ -321,6 +321,13 @@ void GLResourceManager::ContextPrepare_InitialState(GLResource res)
GL.glBindVertexArray(res.name);
for(GLuint i = 0; i < 16; i++)
{
GLuint buffer = GetBoundVertexBuffer(i);
data.VertexBuffers[i].Buffer = BufferRes(ctx, buffer);
}
for(GLuint i = 0; i < 16; i++)
{
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_ENABLED,
@@ -338,10 +345,6 @@ void GLResourceManager::ContextPrepare_InitialState(GLResource res)
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_SIZE, (GLint *)&data.VertexAttribs[i].size);
GLuint buffer = GetBoundVertexBuffer(i);
data.VertexBuffers[i].Buffer = BufferRes(ctx, buffer);
if(HasExt[ARB_vertex_attrib_binding])
{
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_STRIDE, i, (GLint *)&data.VertexBuffers[i].Stride);
@@ -358,6 +361,7 @@ void GLResourceManager::ContextPrepare_InitialState(GLResource res)
(GLint *)&data.VertexBuffers[i].Stride);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_DIVISOR,
(GLint *)&data.VertexBuffers[i].Divisor);
data.VertexAttribs[i].vbslot = i;
data.VertexBuffers[i].Offset = 0;
void *ptr = NULL;
@@ -365,6 +369,16 @@ void GLResourceManager::ContextPrepare_InitialState(GLResource res)
data.VertexAttribs[i].offset = (uint32_t)(uintptr_t)ptr;
}
// if no buffer is bound, replace any non-zero offset with a marker value. This makes captures
// more deterministic and ensures that if we ever try to use the invalid offset/pointer then
// we crash with a known value.
if(data.VertexBuffers[data.VertexAttribs[i].vbslot].Buffer.name == 0 &&
data.VertexAttribs[i].offset > 0)
data.VertexAttribs[i].offset = 0xDEADBEEF;
if(data.VertexBuffers[i].Buffer.name == 0 && data.VertexBuffers[i].Offset > 0)
data.VertexBuffers[i].Offset = 0xDEADBEEF;
}
GLuint buffer = 0;