Bug 1501442 - Part 3: Add profiler markers for payload presentarion. r=mstange
authorBas Schouten <bschouten@mozilla.com>
Mon, 07 Jan 2019 17:40:58 +0100
changeset 509996 a123204b6b0d399a2861721a630cfbc0a6c4222f
parent 509995 76070b4feec3c735818b859e3bb577941f284c30
child 509997 e254270c043d92c273e7b5f8bf860aa14e45b432
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1501442
milestone66.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
Bug 1501442 - Part 3: Add profiler markers for payload presentarion. r=mstange
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/mlgpu/LayerManagerMLGPU.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -149,16 +149,33 @@ bool LayerManager::AreComponentAlphaLaye
 }
 
 UniquePtr<LayerUserData> LayerManager::RemoveUserData(void* aKey) {
   UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(
       mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
   return d;
 }
 
+void LayerManager::PayloadPresented() {
+  if (mPayload.Length()) {
+    TimeStamp presented = TimeStamp::Now();
+    for (CompositionPayload& payload : mPayload) {
+#if MOZ_GECKO_PROFILER
+      if (profiler_is_active()) {
+        nsPrintfCString marker(
+            "Payload Presented, type: %d latency: %dms\n",
+            int32_t(payload.mType),
+            int32_t((presented - payload.mTimeStamp).ToMilliseconds()));
+        profiler_add_marker(marker.get());
+      }
+#endif
+    }
+  }
+}
+
 //--------------------------------------------------
 // Layer
 
 Layer::Layer(LayerManager* aManager, void* aImplData)
     : mManager(aManager),
       mParent(nullptr),
       mNextSibling(nullptr),
       mPrevSibling(nullptr),
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -734,16 +734,17 @@ class LayerManager : public FrameRecorde
   void RegisterPayload(const CompositionPayload& aPayload) {
     mPayload.AppendElement(aPayload);
     MOZ_ASSERT(mPayload.Length() < 10000);
   }
   void RegisterPayload(const InfallibleTArray<CompositionPayload>& aPayload) {
     mPayload.AppendElements(aPayload);
     MOZ_ASSERT(mPayload.Length() < 10000);
   }
+  void PayloadPresented();
 
  protected:
   RefPtr<Layer> mRoot;
   gfx::UserData mUserData;
   bool mDestroyed;
   bool mSnapEffectiveTransforms;
 
   nsIntRegion mRegionToClear;
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -970,16 +970,19 @@ void LayerManagerComposite::Render(const
     mCompositor->EndFrame();
   }
 
   mCompositor->GetWidget()->PostRender(&widgetContext);
 
   mProfilerScreenshotGrabber.MaybeProcessQueue();
 
   RecordFrame();
+
+  PayloadPresented();
+
   // Our payload has now been presented.
   mPayload.Clear();
 }
 
 #if defined(MOZ_WIDGET_ANDROID)
 class ScopedCompostitorSurfaceSize {
  public:
   ScopedCompostitorSurfaceSize(CompositorOGL* aCompositor,
--- a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp
+++ b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp
@@ -300,16 +300,18 @@ void LayerManagerMLGPU::Composite() {
   //
   // 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);
 
+  PayloadPresented();
+
   mPayload.Clear();
 }
 
 void LayerManagerMLGPU::RenderLayers() {
   AUTO_PROFILER_LABEL("LayerManagerMLGPU::RenderLayers", GRAPHICS);
 
   // Traverse the layer tree and assign each layer to a render target.
   FrameBuilder builder(this, mSwapChain);