diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-04-25 16:21:00 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-01 14:28:05 +0200 |
commit | ef5a68dfa19bbdb588e9061ed788b805fc3155e1 (patch) | |
tree | 18e32d4d33444156333c8cab771def69037ab1c9 /src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | |
parent | a292bcb1438034a24e95ec08be04a76ba832d793 (diff) |
Make sure we rebuild batches properly after a Blending material change.
If a node sent DirtyGeometry and DirtyMaterial in the same round and
DirtyGeometry triggered its batch to be invalidated, we would take the
no-batch code path which did set the rebuild state to BuildBatches. This
looks ok on screen, but if the node changed from alpha to opaque, it
would not be put into an opaque batch. For things like full screen
rectangles, this can potentially hurt performance.
To prevent doing a full rebuild on any material change on batchless
items (aka all Rectangle nodes), we store the blend state of the material
in the element and do a full rebuild only when blend state changes.
Change-Id: Ifdf06fb72ef02ca47a135c821ddbcbe0d164ca29
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 791e06ece2..254f32a77c 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -606,11 +606,6 @@ void Element::computeBounds() BatchCompatibility Batch::isMaterialCompatible(Element *e) const { - // If material has changed between opaque and translucent, it is not compatible - QSGMaterial *m = e->node->activeMaterial(); - if (isOpaque != ((m->flags() & QSGMaterial::Blending) == 0)) - return BatchBreaksOnBlending; - Element *n = first; // Skip to the first node other than e which has not been removed while (n && (n == e || n->removed)) @@ -621,6 +616,7 @@ BatchCompatibility Batch::isMaterialCompatible(Element *e) const if (!n) return BatchIsCompatible; + QSGMaterial *m = e->node->activeMaterial(); QSGMaterial *nm = n->node->activeMaterial(); return (nm->type() == m->type() && nm->compare(m) == 0) ? BatchIsCompatible @@ -1185,11 +1181,12 @@ void Renderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state) if (state & QSGNode::DirtyMaterial && node->type() == QSGNode::GeometryNodeType) { Element *e = shadowNode->element(); if (e) { - if (e->batch) { - BatchCompatibility compat = e->batch->isMaterialCompatible(e); - if (compat == BatchBreaksOnBlending) - m_rebuild |= Renderer::FullRebuild; - else if (compat == BatchBreaksOnCompare) + bool blended = hasMaterialWithBlending(static_cast<QSGGeometryNode *>(node)); + 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 { m_rebuild |= Renderer::BuildBatches; |