From 26a230ee0ed68d39d4d13bfeaafd9839ee2a2a00 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Sun, 2 Aug 2015 19:43:23 +0200 Subject: Avoid rebuiding batches during a material animation Animating a complete batch of geometries bound by property bindings will cause an unnecessary rebuild of the batch on each animation step even though it will end up with the same batch as in the previous frame. Since the invalidation happens in nodeChanged, any node change in an updatePaintNode might trigger an invalitation if it is compared with a material that hasn't been updated yet. Delay the verification of the DirtyMaterial flag until all materials have been updated, later on in visitNode, to make sure that we call compare only on up-to-date materials. Change-Id: I03c095efc20817813508d959c74b41eae57beedc Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index f49fedbbf6..6d0ed4ce9f 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -487,6 +487,11 @@ void Updater::visitGeometryNode(Node *n) if (e->batch) renderer->invalidateBatchAndOverlappingRenderOrders(e->batch); } + if (n->dirtyState & QSGNode::DirtyMaterial) { + Element *e = n->element(); + if (e->batch && e->batch->isMaterialCompatible(e) == BatchBreaksOnCompare) + renderer->invalidateBatchAndOverlappingRenderOrders(e->batch); + } } SHADOWNODE_TRAVERSE(n) visitNode(*child); @@ -1216,10 +1221,7 @@ void Renderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state) if (e->isMaterialBlended != blended) { m_rebuild |= Renderer::FullRebuild; e->isMaterialBlended = blended; - } else if (e->batch) { - if (e->batch->isMaterialCompatible(e) == BatchBreaksOnCompare) - invalidateBatchAndOverlappingRenderOrders(e->batch); - } else { + } else if (!e->batch) { m_rebuild |= Renderer::BuildBatches; } } -- cgit v1.2.3