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 <laszlo.agocs@qt.io>
This commit is contained in:
Paul Olav Tvete 2020-11-26 13:03:56 +01:00
parent 420e27c9ef
commit 16fa6e2f62

View File

@ -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;