Title: [291191] trunk/Source/WebKit
Revision
291191
Author
simon.fra...@apple.com
Date
2022-03-11 14:22:51 -0800 (Fri, 11 Mar 2022)

Log Message

Do buffer swapping on all RemoteLayerBackingStores before painting all of them
https://bugs.webkit.org/show_bug.cgi?id=237752

Reviewed by Tim Horton.

Buffer swapping requires sync IPC with the GPU Process, but painting can be asynchronous, so
do all the sync IPC before all the async IPC to avoid serializing everything.

During the recursive PlatformCALayerRemote::recursiveBuildTransaction() we now call
prepareToDisplay() which does the buffer swapping, and then we paint all the reachable
backing stores via RemoteLayerTreeContext::buildTransaction().

This is a 9% perf improvement on the "Images" MotionMark subtest.

* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::prepareToDisplay):
(WebKit::RemoteLayerBackingStore::display): Deleted.
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
(WebKit::RemoteLayerBackingStoreCollection::paintReachableBackingStoreContents):
(WebKit::RemoteLayerBackingStoreCollection::didFlushLayers): The local variables can
be pointers, rather than using references to pointers.
(WebKit::RemoteLayerBackingStoreCollection::markAllBackingStoreVolatile): Ditto
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::buildTransaction):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (291190 => 291191)


--- trunk/Source/WebKit/ChangeLog	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/ChangeLog	2022-03-11 22:22:51 UTC (rev 291191)
@@ -1,3 +1,34 @@
+2022-03-11  Simon Fraser  <simon.fra...@apple.com>
+
+        Do buffer swapping on all RemoteLayerBackingStores before painting all of them
+        https://bugs.webkit.org/show_bug.cgi?id=237752
+
+        Reviewed by Tim Horton.
+
+        Buffer swapping requires sync IPC with the GPU Process, but painting can be asynchronous, so
+        do all the sync IPC before all the async IPC to avoid serializing everything.
+
+        During the recursive PlatformCALayerRemote::recursiveBuildTransaction() we now call
+        prepareToDisplay() which does the buffer swapping, and then we paint all the reachable
+        backing stores via RemoteLayerTreeContext::buildTransaction().
+
+        This is a 9% perf improvement on the "Images" MotionMark subtest.
+
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::prepareToDisplay):
+        (WebKit::RemoteLayerBackingStore::display): Deleted.
+        * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
+        * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
+        (WebKit::RemoteLayerBackingStoreCollection::paintReachableBackingStoreContents):
+        (WebKit::RemoteLayerBackingStoreCollection::didFlushLayers): The local variables can
+        be pointers, rather than using references to pointers.
+        (WebKit::RemoteLayerBackingStoreCollection::markAllBackingStoreVolatile): Ditto
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::buildTransaction):
+
 2022-03-11  Per Arne Vollan  <pvol...@apple.com>
 
         [macOS] Image decoders should be restricted for Mail

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (291190 => 291191)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-03-11 22:22:51 UTC (rev 291191)
@@ -66,7 +66,7 @@
 
     void setContents(WTF::MachSendRight&& surfaceHandle);
     // Returns true if the backing store changed.
-    bool display();
+    bool prepareToDisplay();
     void paintContents();
 
     WebCore::FloatSize size() const { return m_size; }

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (291190 => 291191)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2022-03-11 22:22:51 UTC (rev 291191)
@@ -283,7 +283,7 @@
     m_paintingRects.clear();
 }
 
-bool RemoteLayerBackingStore::display()
+bool RemoteLayerBackingStore::prepareToDisplay()
 {
     ASSERT(!m_frontBufferFlushers.size());
 
@@ -325,8 +325,6 @@
     }
 
     swapBuffers();
-
-    paintContents();
     return true;
 }
 

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h (291190 => 291191)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h	2022-03-11 22:22:51 UTC (rev 291191)
@@ -59,6 +59,8 @@
     virtual WebCore::SetNonVolatileResult makeFrontBufferNonVolatile(RemoteLayerBackingStore&);
     virtual WebCore::SetNonVolatileResult swapToValidFrontBuffer(RemoteLayerBackingStore&);
 
+    void paintReachableBackingStoreContents();
+
     void willFlushLayers();
     void willCommitLayerTree(RemoteLayerTreeTransaction&);
     void didFlushLayers();

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm (291190 => 291191)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm	2022-03-11 22:22:51 UTC (rev 291191)
@@ -46,6 +46,12 @@
 
 RemoteLayerBackingStoreCollection::~RemoteLayerBackingStoreCollection() = default;
 
+void RemoteLayerBackingStoreCollection::paintReachableBackingStoreContents()
+{
+    for (auto* backingStore : m_reachableBackingStoreInLatestFlush)
+        backingStore->paintContents();
+}
+
 void RemoteLayerBackingStoreCollection::willFlushLayers()
 {
     m_inLayerFlush = true;
@@ -69,12 +75,12 @@
     m_inLayerFlush = false;
 
     Vector<RemoteLayerBackingStore*> newlyUnreachableBackingStore;
-    for (auto& backingStore : m_liveBackingStore) {
+    for (auto* backingStore : m_liveBackingStore) {
         if (!m_reachableBackingStoreInLatestFlush.contains(backingStore))
             newlyUnreachableBackingStore.append(backingStore);
     }
 
-    for (auto& backingStore : newlyUnreachableBackingStore)
+    for (auto* backingStore : newlyUnreachableBackingStore)
         backingStoreBecameUnreachable(*backingStore);
 
     if (!newlyUnreachableBackingStore.isEmpty())
@@ -172,10 +178,10 @@
     bool successfullyMadeBackingStoreVolatile = true;
     auto now = MonotonicTime::now();
 
-    for (const auto& backingStore : m_liveBackingStore)
+    for (auto* backingStore : m_liveBackingStore)
         successfullyMadeBackingStoreVolatile &= markBackingStoreVolatile(*backingStore, liveBackingStoreMarkingBehavior, now);
 
-    for (const auto& backingStore : m_unparentedBackingStore)
+    for (auto* backingStore : m_unparentedBackingStore)
         successfullyMadeBackingStoreVolatile &= markBackingStoreVolatile(*backingStore, unparentedBackingStoreMarkingBehavior, now);
 
     return successfullyMadeBackingStoreVolatile;

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp (291190 => 291191)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-03-11 22:22:51 UTC (rev 291191)
@@ -178,7 +178,7 @@
         m_properties.backingStore = nullptr;
         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
     }
-    if (m_properties.backingStore && m_properties.backingStoreAttached && m_properties.backingStore->display())
+    if (m_properties.backingStore && m_properties.backingStoreAttached && m_properties.backingStore->prepareToDisplay())
         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
 
     if (m_properties.changedProperties) {

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm (291190 => 291191)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm	2022-03-11 22:13:34 UTC (rev 291190)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm	2022-03-11 22:22:51 UTC (rev 291191)
@@ -139,6 +139,8 @@
     rootLayerRemote.recursiveBuildTransaction(*this, transaction);
     m_currentTransaction = nullptr;
 
+    m_backingStoreCollection->paintReachableBackingStoreContents();
+
     transaction.setCreatedLayers(copyToVector(m_createdLayers.values()));
     transaction.setDestroyedLayerIDs(WTFMove(m_destroyedLayers));
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to