summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWieland Hagen <wieland.hagen@kdab.com>2017-01-05 15:35:06 +0700
committerWieland Hagen <wieland.hagen@kdab.com>2017-01-05 11:27:31 +0000
commit1600778e1ed5809246c6c8c90d6b22fdcbcb2abb (patch)
tree9379ef35c755203093e324a8a40bcf4ec1b88e89
parent0588a894a041af2c4d449d6257afdcfdc207fbc9 (diff)
Re-run VAO initialization next frame, if something goes wrong
Shaders might not have been compiled when the VAOs are initialized, so the vertex attributes can't be set correctly. If this happens or anything else that's not correct, make sure to re-run the whole VAO initialization process next frame. Task-number: QTBUG-56603 Change-Id: Ice8daa1732fa80dcb84dc02528360cefab74b819 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/render/backend/renderer.cpp21
-rw-r--r--src/render/backend/renderer_p.h2
2 files changed, 17 insertions, 6 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 4c8eeecc1..88bce753f 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -770,8 +770,8 @@ void Renderer::prepareCommandsSubmission(const QVector<RenderView *> &renderView
vao->bind();
// Update or set Attributes and Buffers for the given rGeometry and Command
// Note: this fills m_dirtyAttributes as well
- updateVAOWithAttributes(rGeometry, command, shader, requiresFullVAOUpdate);
- vao->setSpecified(true);
+ if (updateVAOWithAttributes(rGeometry, command, shader, requiresFullVAOUpdate))
+ vao->setSpecified(true);
}
}
@@ -1392,6 +1392,12 @@ bool Renderer::executeCommandsSubmission(const RenderView *rv)
vao = m_nodesManager->vaoManager()->data(command->m_vao);
+ // something may have went wrong when initializing the VAO
+ if (!vao->isSpecified()) {
+ allCommandsIssued = false;
+ continue;
+ }
+
{
Profiling::GLTimeRecorder recorder(Profiling::ShaderUpdate);
//// We activate the shader here
@@ -1447,26 +1453,27 @@ bool Renderer::executeCommandsSubmission(const RenderView *rv)
return allCommandsIssued;
}
-void Renderer::updateVAOWithAttributes(Geometry *geometry,
+bool Renderer::updateVAOWithAttributes(Geometry *geometry,
RenderCommand *command,
Shader *shader,
bool forceUpdate)
{
m_dirtyAttributes.reserve(m_dirtyAttributes.size() + geometry->attributes().size());
const auto attributeIds = geometry->attributes();
+
for (QNodeId attributeId : attributeIds) {
// TO DO: Improvement we could store handles and use the non locking policy on the attributeManager
Attribute *attribute = m_nodesManager->attributeManager()->lookupResource(attributeId);
if (attribute == nullptr)
- continue;
+ return false;
Buffer *buffer = m_nodesManager->bufferManager()->lookupResource(attribute->bufferId());
// Buffer update was already performed at this point
// Just make sure the attribute reference a valid buffer
if (buffer == nullptr)
- continue;
+ return false;
// Index Attribute
bool attributeWasDirty = false;
@@ -1485,6 +1492,8 @@ void Renderer::updateVAOWithAttributes(Geometry *geometry,
break;
}
}
+ if (attributeLocation < 0)
+ return false;
m_graphicsContext->specifyAttribute(attribute, buffer, attributeLocation);
}
}
@@ -1500,6 +1509,8 @@ void Renderer::updateVAOWithAttributes(Geometry *geometry,
// should remain dirty so that VAO for these commands are properly
// updated
}
+
+ return true;
}
bool Renderer::requiresVAOAttributeUpdate(Geometry *geometry,
diff --git a/src/render/backend/renderer_p.h b/src/render/backend/renderer_p.h
index cb78cbef3..9f6e8d857 100644
--- a/src/render/backend/renderer_p.h
+++ b/src/render/backend/renderer_p.h
@@ -212,7 +212,7 @@ public:
void prepareCommandsSubmission(const QVector<RenderView *> &renderViews);
bool executeCommandsSubmission(const RenderView *rv);
- void updateVAOWithAttributes(Geometry *geometry,
+ bool updateVAOWithAttributes(Geometry *geometry,
RenderCommand *command,
Shader *shader,
bool forceUpdate);