From 597230f352f19db539b34944941023ee225f8eae Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 20 May 2020 16:37:46 +0100 Subject: [PATCH] Don't restore buffer bindings if they weren't changed --- .../driver/gl/wrappers/gl_draw_funcs.cpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp index 8c4530a01..c2a07d781 100644 --- a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp @@ -1119,19 +1119,22 @@ void WrappedOpenGL::RestoreClientMemoryArrays(ClientMemoryData *clientMemoryArra if(!clientMemoryArrays) return; - // Restore the 0-buffer bindings and attrib pointers. - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ARRAY_BUFFER, 0); - - for(const ClientMemoryData::VertexAttrib &attrib : clientMemoryArrays->attribs) + if(!clientMemoryArrays->attribs.empty()) { - gl_CurChunk = GLChunk::glVertexAttribPointer; - glVertexAttribPointer(attrib.index, attrib.size, attrib.type, attrib.normalized, attrib.stride, - attrib.pointer); - } + // Restore the 0-buffer bindings and attrib pointers. + gl_CurChunk = GLChunk::glBindBuffer; + glBindBuffer(eGL_ARRAY_BUFFER, 0); - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ARRAY_BUFFER, clientMemoryArrays->prevArrayBufferBinding); + for(const ClientMemoryData::VertexAttrib &attrib : clientMemoryArrays->attribs) + { + gl_CurChunk = GLChunk::glVertexAttribPointer; + glVertexAttribPointer(attrib.index, attrib.size, attrib.type, attrib.normalized, + attrib.stride, attrib.pointer); + } + + gl_CurChunk = GLChunk::glBindBuffer; + glBindBuffer(eGL_ARRAY_BUFFER, clientMemoryArrays->prevArrayBufferBinding); + } delete clientMemoryArrays; }