Cache invalidation properties after compositing, not before. (bug 1408781 part 2, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Fri, 20 Oct 2017 15:09:13 -0700
changeset 387492 5bf42ef768d80ebeba9f0a634a38446c33f1c125
parent 387491 97aeedf3aa5d49dd2dfc034499a76b13cea64e9f
child 387493 4588832bab797cf65523c645c6699a9f333cc226
push id32721
push userarchaeopteryx@coole-files.de
push dateSat, 21 Oct 2017 08:59:38 +0000
treeherdermozilla-central@d697979497a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1408781
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Cache invalidation properties after compositing, not before. (bug 1408781 part 2, r=mattwoodrow)
gfx/layers/mlgpu/LayerManagerMLGPU.cpp
--- a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp
+++ b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp
@@ -331,16 +331,30 @@ LayerManagerMLGPU::Composite()
   mSwapChain->Present();
 
   // We call this here to mimic the behavior in LayerManagerComposite, as to
   // not change what Talos measures. That is, we do not record an empty frame
   // as a frame, since we short-circuit at the top of this function.
   RecordFrame();
 
   mDevice->EndFrame();
+
+  // Free the old cloned property tree, then clone a new one. Note that we do
+  // this after compositing, since layer preparation actually mutates the layer
+  // tree (for example, ImageHost::mLastFrameID). We want the property tree to
+  // pick up these changes. Similarly, we are careful to not mutate the tree
+  // in any way that we *don't* want LayerProperties to catch, lest we cause
+  // extra invalidation.
+  //
+  // Note that the old Compositor performs occlusion culling directly on the
+  // shadow visible region, and does this *before* cloning layer tree
+  // properties. Advanced Layers keeps the occlusion region separate and
+  // performs invalidation against the clean layer tree.
+  mClonedLayerTreeProperties = nullptr;
+  mClonedLayerTreeProperties = LayerProperties::CloneFrom(mRoot);
 }
 
 void
 LayerManagerMLGPU::RenderLayers()
 {
   AUTO_PROFILER_LABEL("LayerManagerMLGPU::RenderLayers", GRAPHICS);
 
   // Traverse the layer tree and assign each layer to a render target.
@@ -473,30 +487,16 @@ LayerManagerMLGPU::ComputeInvalidRegion(
   // it for the next frame instead.
   if (mTarget) {
     mInvalidRegion = mTargetRect;
     mNextFrameInvalidRegion.OrWith(changed);
   } else {
     mInvalidRegion = Move(mNextFrameInvalidRegion);
     mInvalidRegion.OrWith(changed);
   }
-
-  // Free the old cloned property tree, then clone a new one. Note that we do
-  // this before compositing since our CPU-based occlusion culling will update
-  // the visible region to contain non-occluded draw rects. If a layer will not
-  // be drawn, it will have no visible region. LTI might save this, and if the
-  // layer is removed next frame, LTI will invalidate the wrong area.
-  //
-  // Instead, we always invalidate based on the full shadow tree.
-  //
-  // Note that the old compositor performs CPU-based occlusion culling *before*
-  // invalidation. This maintains consistency, but we have more accurate draw
-  // regions.
-  mClonedLayerTreeProperties = nullptr;
-  mClonedLayerTreeProperties = LayerProperties::CloneFrom(mRoot);
 }
 
 void
 LayerManagerMLGPU::AddInvalidRegion(const nsIntRegion& aRegion)
 {
   mNextFrameInvalidRegion.OrWith(aRegion);
 }