diff options
author | Paul Lemire <paul.lemire350@gmail.com> | 2015-09-19 18:24:46 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-10-14 13:27:16 +0000 |
commit | f797fb9796adff0eb6adb705709a42320f01f713 (patch) | |
tree | c391669ea4c97b04d71a977e98dc7e9291fd9b80 /src/render | |
parent | 05902cb5bd821e9aaa851af1619ecef91f61cd6f (diff) |
RenderShaderData/UBO: improve nested shader data buffer update
Although the actual implementation is not optimal when having an array of
nested children (as we need to reupload all the children if only one of them as
changed), only trigger this update if at least one of the children was updated.
Change-Id: I0688323b78a0db70f9f0115e1e8447296506f0c8
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/materialsystem/shaderdata.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp index 6338df96b..c030225c4 100644 --- a/src/render/materialsystem/shaderdata.cpp +++ b/src/render/materialsystem/shaderdata.cpp @@ -129,25 +129,26 @@ bool ShaderData::needsUpdate(const QMatrix4x4 &viewMatrix) ++transformedIt; } } - const QHash<QString, QVariant>::const_iterator end = m_nestedShaderDataProperties.end(); QHash<QString, QVariant>::const_iterator it = m_nestedShaderDataProperties.begin(); while (it != end) { if (it.value().userType() == QMetaType::QVariantList) { QVariantList updatedNodes; + bool nestedNeedsUpdate = false; Q_FOREACH (const QVariant &v, it.value().value<QVariantList>()) { ShaderData *nested = m_manager->lookupResource(v.value<QNodeId>()); if (nested != Q_NULLPTR) { - // We need to add the nested nodes the the updated property list - // as if we need to maintain order + // We need to add the nested nodes to the updated property list + // as we need to maintain order // if node[0] doesn't need update but node[1] does, // if we only have a single element, the renderer would update element [0] - nested->needsUpdate(viewMatrix); + nestedNeedsUpdate |= nested->needsUpdate(viewMatrix); updatedNodes << v; } } - if (!updatedNodes.empty()) + // Of course we only add all the nodes if at least one of the nested nodes required and update + if (nestedNeedsUpdate && !updatedNodes.empty()) m_updatedProperties.insert(it.key(), updatedNodes); } else { ShaderData *nested = m_manager->lookupResource(it.value().value<QNodeId>()); |