rhi: gl: Reset the buffer bindings on beginExternal

Play nice with old renderers like the OpenGL paint engine for
QPainter.

When combining Qt Quick and QPainter targeting the same GL window,
calling QQuickWindow::beginExternalCommands() is not currently
sufficient to ensure problem-free operation, it also needs a
QQOpenGLUtils::resetOpenGLState() afterwards to get rid of the buffer
bindings. (which is important when using legacy code with client-side
vertex arrays) Which in turn is not what the documentation promises,
so resetting the bindings is now ensured on the rhi level when
Qt Quick calls beginExternal().

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104801
Change-Id: Ibd82753996768aad0118bff87d4e1f8bcc388c58
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2022-07-08 13:21:31 +02:00
parent 856bb38eaf
commit 4fdadd2348

View File

@ -1855,8 +1855,14 @@ void QRhiGles2::beginExternal(QRhiCommandBuffer *cb)
cbD->resetCommands();
if (vao)
if (vao) {
f->glBindVertexArray(0);
} else {
f->glBindBuffer(GL_ARRAY_BUFFER, 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
if (caps.compute)
f->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
}
}
void QRhiGles2::endExternal(QRhiCommandBuffer *cb)