Handle implementations on capture without ARB_vertex_binding

This commit is contained in:
baldurk
2018-07-09 14:14:29 +01:00
parent eff35de81b
commit 30c8f01a25
5 changed files with 49 additions and 14 deletions
+15 -2
View File
@@ -507,7 +507,7 @@ void DoVendorChecks(GLPlatform &platform, GLWindowingData context)
RDCEraseEl(VendorCheck);
if(GL.glGetError && GL.glGetIntegeri_v)
if(GL.glGetError && GL.glGetIntegeri_v && HasExt[ARB_vertex_attrib_binding])
{
// clear all error flags.
GLenum err = eGL_NONE;
@@ -1332,11 +1332,24 @@ void ClearGLErrors()
}
}
GLint GetNumVertexBuffers()
{
GLint numBindings = 16;
// when the extension isn't present we pretend attribs == vertex buffers
if(HasExt[ARB_vertex_attrib_binding])
GL.glGetIntegerv(eGL_MAX_VERTEX_ATTRIB_BINDINGS, &numBindings);
else
GL.glGetIntegerv(eGL_MAX_VERTEX_ATTRIBS, &numBindings);
return numBindings;
}
GLuint GetBoundVertexBuffer(GLuint i)
{
GLuint buffer = 0;
if(VendorCheck[VendorCheck_AMD_vertex_buffer_query])
if(VendorCheck[VendorCheck_AMD_vertex_buffer_query] || !HasExt[ARB_vertex_attrib_binding])
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, (GLint *)&buffer);
else
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_BUFFER, i, (GLint *)&buffer);
+1
View File
@@ -492,6 +492,7 @@ const char *SamplerString(GLenum smpenum);
void ClearGLErrors();
GLuint GetBoundVertexBuffer(GLuint idx);
GLint GetNumVertexBuffers();
void GetBindpointMapping(GLuint curProg, int shadIdx, ShaderReflection *refl,
ShaderBindpointMapping &mapping);
+1 -2
View File
@@ -4435,8 +4435,7 @@ void WrappedOpenGL::AddUsage(const DrawcallDescription &d)
}
// Vertex buffers and attributes
GLint numVBufferBindings = 16;
GL.glGetIntegerv(eGL_MAX_VERTEX_ATTRIB_BINDINGS, &numVBufferBindings);
GLint numVBufferBindings = GetNumVertexBuffers();
for(GLuint i = 0; i < (GLuint)numVBufferBindings; i++)
{
+31 -8
View File
@@ -325,23 +325,46 @@ void GLResourceManager::ContextPrepare_InitialState(GLResource res)
{
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_ENABLED,
(GLint *)&data.VertexAttribs[i].enabled);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_BINDING, (GLint *)&data.VertexAttribs[i].vbslot);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_RELATIVE_OFFSET,
(GLint *)&data.VertexAttribs[i].offset);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_TYPE, (GLint *)&data.VertexAttribs[i].type);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_NORMALIZED,
(GLint *)&data.VertexAttribs[i].normalized);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_INTEGER,
(GLint *)&data.VertexAttribs[i].integer);
// no extension for this, it just appeared in GL & GLES 3.0, along with glVertexAttribIPointer
if(GLCoreVersion >= 3.0)
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_INTEGER,
(GLint *)&data.VertexAttribs[i].integer);
else
data.VertexAttribs[i].integer = 0;
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_SIZE, (GLint *)&data.VertexAttribs[i].size);
GLuint buffer = GetBoundVertexBuffer(i);
data.VertexBuffers[i].Buffer = BufferRes(ctx, buffer);
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_STRIDE, i, (GLint *)&data.VertexBuffers[i].Stride);
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_OFFSET, i, (GLint *)&data.VertexBuffers[i].Offset);
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_DIVISOR, i, (GLint *)&data.VertexBuffers[i].Divisor);
if(HasExt[ARB_vertex_attrib_binding])
{
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_STRIDE, i, (GLint *)&data.VertexBuffers[i].Stride);
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_OFFSET, i, (GLint *)&data.VertexBuffers[i].Offset);
GL.glGetIntegeri_v(eGL_VERTEX_BINDING_DIVISOR, i, (GLint *)&data.VertexBuffers[i].Divisor);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_RELATIVE_OFFSET,
(GLint *)&data.VertexAttribs[i].offset);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_BINDING, (GLint *)&data.VertexAttribs[i].vbslot);
}
else
{
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_STRIDE,
(GLint *)&data.VertexBuffers[i].Stride);
GL.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_DIVISOR,
(GLint *)&data.VertexBuffers[i].Divisor);
data.VertexBuffers[i].Offset = 0;
void *ptr = NULL;
GL.glGetVertexAttribPointerv(i, eGL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr);
data.VertexAttribs[i].offset = (uint32_t)(uintptr_t)ptr;
}
}
GLuint buffer = 0;
+1 -2
View File
@@ -41,8 +41,7 @@ void GLResourceManager::MarkVAOReferenced(GLResource res, FrameRefType ref, bool
MarkResourceFrameReferenced(res, ref == eFrameRef_Unknown ? eFrameRef_Unknown : eFrameRef_Read);
GLint numVBufferBindings = 16;
GL.glGetIntegerv(eGL_MAX_VERTEX_ATTRIB_BINDINGS, &numVBufferBindings);
GLint numVBufferBindings = GetNumVertexBuffers();
for(GLuint i = 0; i < (GLuint)numVBufferBindings; i++)
{