Cache invalidation properties after compositing, not before. (bug 1408781 part 2, r=mattwoodrow)
☠☠ backed out by 6975e103f753 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Fri, 20 Oct 2017 10:31:46 -0700
changeset 387351 4d2c317e39366a570ac256c5cce9f1c9d2ddafdd
parent 387350 fd03410adabaaf3c6dd158200d30690f977579e2
child 387352 facc1bc840982c80dffe8edd8af3eb4289c7b32a
push id96426
push userdanderson@mozilla.com
push dateFri, 20 Oct 2017 17:37:07 +0000
treeherdermozilla-inbound@4d2c317e3936 [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);
 }