summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-10-15 09:58:46 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-10-15 20:09:29 +0200
commit92b9dcfe2ba602fc396a4806597b9440ed63bded (patch)
tree1e06e9d8333143ffe72b1d639e15dac4b24dd947 /src/gui
parent027d45cb57a7cf20b2714509250a87f1e8842b9c (diff)
rhi: gl: Do not let external rendering trash our vao
Task-number: QTBUG-79221 Change-Id: Ie8e6376f79c816071c12962dc054838aeaabcaa5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/rhi/qrhigles2.cpp28
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h1
2 files changed, 22 insertions, 7 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index e355979626..dec28cac9b 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -525,6 +525,11 @@ void QRhiGles2::destroy()
ensureContext();
executeDeferredReleases();
+ if (vao) {
+ f->glDeleteVertexArrays(1, &vao);
+ vao = 0;
+ }
+
for (uint shader : m_shaderCache)
f->glDeleteShader(shader);
m_shaderCache.clear();
@@ -1151,6 +1156,13 @@ const QRhiNativeHandles *QRhiGles2::nativeHandles(QRhiCommandBuffer *cb)
return nullptr;
}
+static void addBoundaryCommand(QGles2CommandBuffer *cbD, QGles2CommandBuffer::Command::Cmd type)
+{
+ QGles2CommandBuffer::Command cmd;
+ cmd.cmd = type;
+ cbD->commands.append(cmd);
+}
+
void QRhiGles2::beginExternal(QRhiCommandBuffer *cb)
{
if (ofr.active) {
@@ -1166,6 +1178,9 @@ void QRhiGles2::beginExternal(QRhiCommandBuffer *cb)
QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb);
executeCommandBuffer(cbD);
cbD->resetCommands();
+
+ if (vao)
+ f->glBindVertexArray(0);
}
void QRhiGles2::endExternal(QRhiCommandBuffer *cb)
@@ -1183,17 +1198,12 @@ void QRhiGles2::endExternal(QRhiCommandBuffer *cb)
enqueueBarriersForPass(cbD);
}
+ addBoundaryCommand(cbD, QGles2CommandBuffer::Command::ResetFrame);
+
if (cbD->currentTarget)
enqueueBindFramebuffer(cbD->currentTarget, cbD);
}
-static void addBoundaryCommand(QGles2CommandBuffer *cb, QGles2CommandBuffer::Command::Cmd type)
-{
- QGles2CommandBuffer::Command cmd;
- cmd.cmd = type;
- cb->commands.append(cmd);
-}
-
QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)
{
Q_UNUSED(flags);
@@ -1913,6 +1923,10 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
if (vao)
f->glBindVertexArray(0);
break;
+ case QGles2CommandBuffer::Command::ResetFrame:
+ if (vao)
+ f->glBindVertexArray(vao);
+ break;
case QGles2CommandBuffer::Command::Viewport:
f->glViewport(GLint(cmd.args.viewport.x), GLint(cmd.args.viewport.y), GLsizei(cmd.args.viewport.w), GLsizei(cmd.args.viewport.h));
f->glDepthRangef(cmd.args.viewport.d0, cmd.args.viewport.d1);
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index 8814d9c19d..cc945876e6 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -300,6 +300,7 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer
enum Cmd {
BeginFrame,
EndFrame,
+ ResetFrame,
Viewport,
Scissor,
BlendConstants,