From 16fa6e2f62c8850e319624332ecceef835c5847b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Nov 2020 13:03:56 +0100 Subject: [PATCH] RHI: Fix attribute instancing cleanup for OpenGL ES The previous attribute instancing patch (6493b93) performed the cleanup too late for the case where the command buffer ends with an EndFrame command and core profile is used. Resetting the attribute divisors needs to be done before the vertex array is unbound. Otherwise the state will be wrong at the start of the next call to executeCommandBuffer(), which is normally the start of the next frame. Change-Id: Ic76695b4d334ed1c1e816e747417d957c387a88b Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhigles2.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 5db9ffb4440..cdeb487f1ff 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2151,6 +2151,15 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) } break; case QGles2CommandBuffer::Command::EndFrame: + if (instancedAttributesUsed) { + for (int i = 0; i < TRACKED_ATTRIB_COUNT; ++i) { + if (nonzeroAttribDivisor[i]) + f->glVertexAttribDivisor(GLuint(i), 0); + } + for (int i = TRACKED_ATTRIB_COUNT; i <= maxUntrackedInstancedAttribute; ++i) + f->glVertexAttribDivisor(GLuint(i), 0); + instancedAttributesUsed = false; + } if (vao) f->glBindVertexArray(0); break;