summaryrefslogtreecommitdiffstats
path: root/src/render/backend
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-11-05 17:36:56 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-11-16 11:17:37 +0000
commit9ac41de755762e45c16c5517d0566975d44e1150 (patch)
tree6fab933b919037bdfb13b4c0275cfed23eb46cf5 /src/render/backend
parent414dfc4870914e29bd057d4e80486a46d51f1c0a (diff)
Renderer: fix empty VAO case
Under some cases a VAO could be allocated but never created as at a given point in time there was no attributes found for the current shader (which can happen if the shader isn't yet loaded). Then the next frame, the attributes would have been loaded and the VAO allocated and the renderer would assume then that the VAO had been created. Eventually that would then crash as a draw call would be performed with an empty and never created VAO. Now check that a VAO is created and if not request creation to make sure that the VAO is always created when setting the attributes/trying to draw. Change-Id: Idf3fa45fabc574c0a0e82a38283c5848b32e15a4 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/backend')
-rw-r--r--src/render/backend/renderer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 6ce491f62..308aa120b 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -874,6 +874,12 @@ void Renderer::executeCommands(const QVector<RenderCommand *> &commands)
vao = *(m_vaoManager->data(command->m_vao));
}
Q_ASSERT(vao);
+ // If the VAO hasn't been created, we create it
+ if (!vao->isCreated()) {
+ vao->create();
+ needsToBindVAO = true;
+ qCDebug(Rendering) << Q_FUNC_INFO << "Creating new VAO";
+ }
}
//// We activate the shader here
@@ -899,13 +905,9 @@ void Renderer::executeCommands(const QVector<RenderCommand *> &commands)
if (!command->m_parameterAttributeToShaderNames.isEmpty()) {
specified = true;
if (needsToBindVAO && vao) {
- if (!vao->isCreated()) {
- qCDebug(Rendering) << Q_FUNC_INFO << "Creating new VAO";
- vao->create();
- }
+ Q_ASSERT(vao->isCreated());
vao->bind();
}
-
// Update or set Attributes and Buffers for the given rGeometry and Command
indexAttribute = updateBuffersAndAttributes(rGeometry, command, primitiveCount, requiresVAOUpdate);
}
@@ -983,7 +985,7 @@ void Renderer::executeCommands(const QVector<RenderCommand *> &commands)
// We cache the VAO and release it only at the end of the exectute frame
// We try to minimize VAO binding between RenderCommands
- if (vao && vao->isCreated())
+ if (vao)
vao->release();
// Reset to the state we were in before executing the render commands