Title: [283814] trunk/Source/WebKit
Revision
283814
Author
mmaxfi...@apple.com
Date
2021-10-08 11:32:10 -0700 (Fri, 08 Oct 2021)

Log Message

[GPU Process] Unique RenderingResourceIdentifiers Part 4: Migrate PendingWakeupInformation to QualifiedRenderingResourceIdentifier
https://bugs.webkit.org/show_bug.cgi?id=231406
<rdar://problem/84009999>

Reviewed by Wenson Hsieh.

This starts pushing QualifiedRenderingResourceIdentifier into a few more places. It's being pushed into
PendingWakeupInformation and RemoteImageBuffer. (I can't split this patch up any further because the
pieces intermingle.)

The next step is to push QualifiedRenderingResourceIdentifier down into RemoteResourceCache.

No new tests because there is no behavior change.

* GPUProcess/graphics/RemoteImageBuffer.h:
(WebKit::RemoteImageBuffer::create):
(WebKit::RemoteImageBuffer::RemoteImageBuffer):
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::didCreateImageBufferBackend):
(WebKit::RemoteRenderingBackend::didFlush):
(WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
(WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayListWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
(WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::finalizeRenderingUpdate):
(WebKit::RemoteRenderingBackend::resumeFromPendingWakeupInformation):
* GPUProcess/graphics/RemoteRenderingBackend.h:
(WebKit::RemoteRenderingBackend::PendingWakeupInformation::shouldPerformWakeup const):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (283813 => 283814)


--- trunk/Source/WebKit/ChangeLog	2021-10-08 18:08:01 UTC (rev 283813)
+++ trunk/Source/WebKit/ChangeLog	2021-10-08 18:32:10 UTC (rev 283814)
@@ -1,3 +1,36 @@
+2021-10-08  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [GPU Process] Unique RenderingResourceIdentifiers Part 4: Migrate PendingWakeupInformation to QualifiedRenderingResourceIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=231406
+        <rdar://problem/84009999>
+
+        Reviewed by Wenson Hsieh.
+
+        This starts pushing QualifiedRenderingResourceIdentifier into a few more places. It's being pushed into
+        PendingWakeupInformation and RemoteImageBuffer. (I can't split this patch up any further because the
+        pieces intermingle.)
+
+        The next step is to push QualifiedRenderingResourceIdentifier down into RemoteResourceCache.
+
+        No new tests because there is no behavior change.
+
+        * GPUProcess/graphics/RemoteImageBuffer.h:
+        (WebKit::RemoteImageBuffer::create):
+        (WebKit::RemoteImageBuffer::RemoteImageBuffer):
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::didCreateImageBufferBackend):
+        (WebKit::RemoteRenderingBackend::didFlush):
+        (WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
+        (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayListWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
+        (WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::finalizeRenderingUpdate):
+        (WebKit::RemoteRenderingBackend::resumeFromPendingWakeupInformation):
+        * GPUProcess/graphics/RemoteRenderingBackend.h:
+        (WebKit::RemoteRenderingBackend::PendingWakeupInformation::shouldPerformWakeup const):
+
 2021-10-08  Tim Horton  <timothy_hor...@apple.com>
 
         defaultAlternateFormControlDesignEnabled() can't read UIUserInterfaceIdiom in the Web Content process

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (283813 => 283814)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2021-10-08 18:08:01 UTC (rev 283813)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2021-10-08 18:32:10 UTC (rev 283814)
@@ -45,13 +45,13 @@
     using BaseConcreteImageBuffer::putPixelBuffer;
 
 public:
-    static auto create(const WebCore::FloatSize& size, float resolutionScale, const WebCore::DestinationColorSpace& colorSpace, WebCore::PixelFormat pixelFormat, RemoteRenderingBackend& remoteRenderingBackend, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
+    static auto create(const WebCore::FloatSize& size, float resolutionScale, const WebCore::DestinationColorSpace& colorSpace, WebCore::PixelFormat pixelFormat, RemoteRenderingBackend& remoteRenderingBackend, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
     {
         return BaseConcreteImageBuffer::template create<RemoteImageBuffer>(size, resolutionScale, colorSpace, pixelFormat, nullptr, remoteRenderingBackend, renderingResourceIdentifier);
     }
 
-    RemoteImageBuffer(const WebCore::ImageBufferBackend::Parameters& parameters, std::unique_ptr<BackendType>&& backend, RemoteRenderingBackend& remoteRenderingBackend, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
-        : BaseConcreteImageBuffer(parameters, WTFMove(backend), renderingResourceIdentifier)
+    RemoteImageBuffer(const WebCore::ImageBufferBackend::Parameters& parameters, std::unique_ptr<BackendType>&& backend, RemoteRenderingBackend& remoteRenderingBackend, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
+        : BaseConcreteImageBuffer(parameters, WTFMove(backend), renderingResourceIdentifier.object())
         , m_remoteRenderingBackend(remoteRenderingBackend)
         , m_renderingResourceIdentifier(renderingResourceIdentifier)
     {
@@ -111,7 +111,7 @@
     }
 
     RemoteRenderingBackend& m_remoteRenderingBackend;
-    WebCore::RenderingResourceIdentifier m_renderingResourceIdentifier;
+    QualifiedRenderingResourceIdentifier m_renderingResourceIdentifier;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (283813 => 283814)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-10-08 18:08:01 UTC (rev 283813)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-10-08 18:32:10 UTC (rev 283814)
@@ -143,14 +143,16 @@
     return true;
 }
 
-void RemoteRenderingBackend::didCreateImageBufferBackend(ImageBufferBackendHandle handle, RenderingResourceIdentifier renderingResourceIdentifier)
+void RemoteRenderingBackend::didCreateImageBufferBackend(ImageBufferBackendHandle handle, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
-    send(Messages::RemoteRenderingBackendProxy::DidCreateImageBufferBackend(WTFMove(handle), renderingResourceIdentifier), m_renderingBackendIdentifier);
+    MESSAGE_CHECK(renderingResourceIdentifier.processIdentifier() == m_gpuConnectionToWebProcess->webProcessIdentifier(), "Sending didCreateImageBufferBackend() message to the wrong web process.");
+    send(Messages::RemoteRenderingBackendProxy::DidCreateImageBufferBackend(WTFMove(handle), renderingResourceIdentifier.object()), m_renderingBackendIdentifier);
 }
 
-void RemoteRenderingBackend::didFlush(GraphicsContextFlushIdentifier flushIdentifier, RenderingResourceIdentifier renderingResourceIdentifier)
+void RemoteRenderingBackend::didFlush(GraphicsContextFlushIdentifier flushIdentifier, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
-    send(Messages::RemoteRenderingBackendProxy::DidFlush(flushIdentifier, renderingResourceIdentifier), m_renderingBackendIdentifier);
+    MESSAGE_CHECK(renderingResourceIdentifier.processIdentifier() == m_gpuConnectionToWebProcess->webProcessIdentifier(), "Sending didFlush() message to the wrong web process.");
+    send(Messages::RemoteRenderingBackendProxy::DidFlush(flushIdentifier, renderingResourceIdentifier.object()), m_renderingBackendIdentifier);
 }
 
 void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferResourceIdentifier)
@@ -168,7 +170,7 @@
     RefPtr<ImageBuffer> imageBuffer;
 
     if (renderingMode == RenderingMode::Accelerated) {
-        if (auto acceleratedImageBuffer = AcceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier.object())) {
+        if (auto acceleratedImageBuffer = AcceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier)) {
 #if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
             // Mark the IOSurface as being owned by the WebProcess even though it was constructed by the GPUProcess so that Jetsam knows which process to kill.
             acceleratedImageBuffer->setProcessOwnership(m_gpuConnectionToWebProcess->webProcessIdentityToken());
@@ -178,7 +180,7 @@
     }
 
     if (!imageBuffer)
-        imageBuffer = UnacceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier.object());
+        imageBuffer = UnacceleratedRemoteImageBuffer::create(logicalSize, resolutionScale, colorSpace, pixelFormat, *this, imageBufferResourceIdentifier);
 
     if (!imageBuffer) {
         ASSERT_NOT_REACHED();
@@ -188,7 +190,7 @@
     m_remoteResourceCache.cacheImageBuffer(*imageBuffer);
     updateRenderingResourceRequest();
 
-    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(imageBufferResourceIdentifier.object()))
+    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(imageBufferResourceIdentifier))
         resumeFromPendingWakeupInformation();
 }
 
@@ -242,7 +244,7 @@
     }.replay();
 }
 
-RefPtr<ImageBuffer> RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists(ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle& handle, GPUProcessWakeupReason reason)
+RefPtr<ImageBuffer> RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists(ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle& handle, GPUProcessWakeupReason reason, ProcessIdentifier webProcessIdentifier)
 {
     RefPtr destination { &initialDestination };
     Ref handleProtector { handle };
@@ -283,7 +285,7 @@
                 m_pendingWakeupInfo = {{
                     handle.identifier(),
                     offset,
-                    *result.nextDestinationImageBuffer,
+                    { *result.nextDestinationImageBuffer, webProcessIdentifier },
                     reason,
                     std::nullopt,
                     RemoteRenderingBackendState::WaitingForDestinationImageBuffer
@@ -295,9 +297,9 @@
             m_pendingWakeupInfo = {{
                 handle.identifier(),
                 offset,
-                destination->renderingResourceIdentifier(),
+                { destination->renderingResourceIdentifier(), webProcessIdentifier },
                 reason,
-                result.missingCachedResourceIdentifier,
+                { { *result.missingCachedResourceIdentifier, webProcessIdentifier } },
                 RemoteRenderingBackendState::WaitingForCachedResource
             }};
         }
@@ -357,7 +359,7 @@
     MESSAGE_CHECK(initialHandle, "Missing initial shared display list handle");
 
     LOG_WITH_STREAM(SharedDisplayLists, stream << "Waking up to Items[" << itemBufferIdentifier << "] => Image(" << destinationImageBufferIdentifier.object() << ") at " << offset);
-    destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, offset, *initialHandle, reason);
+    destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, offset, *initialHandle, reason, m_gpuConnectionToWebProcess->webProcessIdentifier());
 
     // FIXME: All the callers pass m_pendingWakeupInfo's fields so the body of this function should just be this loop.
     while (destinationImageBuffer && m_pendingWakeupInfo) {
@@ -375,7 +377,7 @@
         auto offset = m_pendingWakeupInfo->offset;
         auto reason = m_pendingWakeupInfo->reason;
         m_pendingWakeupInfo = std::nullopt;
-        destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, offset, *nextHandle, reason);
+        destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, offset, *nextHandle, reason, m_gpuConnectionToWebProcess->webProcessIdentifier());
     }
     LOG_WITH_STREAM(SharedDisplayLists, stream << "Going back to sleep.");
 
@@ -385,7 +387,7 @@
         updateLastKnownState(RemoteRenderingBackendState::FinishedReplayingDisplayList);
 }
 
-void RemoteRenderingBackend::setNextItemBufferToRead(DisplayList::ItemBufferIdentifier identifier, WebCore::RenderingResourceIdentifier destinationIdentifier)
+void RemoteRenderingBackend::setNextItemBufferToRead(DisplayList::ItemBufferIdentifier identifier, QualifiedRenderingResourceIdentifier destinationIdentifier)
 {
     m_pendingWakeupInfo = {{
         identifier,
@@ -546,7 +548,7 @@
 
     m_remoteResourceCache.cacheNativeImage(*image);
 
-    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(nativeImageResourceIdentifier.object()))
+    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(nativeImageResourceIdentifier))
         resumeFromPendingWakeupInformation();
 }
 
@@ -563,7 +565,7 @@
     ASSERT(!RunLoop::isMain());
 
     m_remoteResourceCache.cacheFont(WTFMove(font));
-    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(fontResourceIdentifier.object()))
+    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(fontResourceIdentifier))
         resumeFromPendingWakeupInformation();
 }
 
@@ -591,7 +593,7 @@
 void RemoteRenderingBackend::finalizeRenderingUpdate(RenderingUpdateID renderingUpdateID)
 {
     auto shouldPerformWakeup = [&] {
-        return m_remoteResourceCache.cachedImageBuffer(m_pendingWakeupInfo->destinationImageBufferIdentifier) && m_sharedDisplayListHandles.contains(m_pendingWakeupInfo->itemBufferIdentifier);
+        return m_remoteResourceCache.cachedImageBuffer(m_pendingWakeupInfo->destinationImageBufferIdentifier.object()) && m_sharedDisplayListHandles.contains(m_pendingWakeupInfo->itemBufferIdentifier);
     };
 
     if (m_pendingWakeupInfo && shouldPerformWakeup())
@@ -626,7 +628,7 @@
 {
     auto itemBufferIdentifier = m_pendingWakeupInfo->itemBufferIdentifier;
     auto offset = m_pendingWakeupInfo->offset;
-    QualifiedRenderingResourceIdentifier destinationImageBufferIdentifier { m_pendingWakeupInfo->destinationImageBufferIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() };
+    auto destinationImageBufferIdentifier = m_pendingWakeupInfo->destinationImageBufferIdentifier;
     auto reason = m_pendingWakeupInfo->reason;
     m_pendingWakeupInfo = std::nullopt;
     wakeUpAndApplyDisplayListWithQualifiedIdentifier(itemBufferIdentifier, offset, destinationImageBufferIdentifier, reason);

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (283813 => 283814)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-10-08 18:08:01 UTC (rev 283813)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-10-08 18:32:10 UTC (rev 283814)
@@ -82,10 +82,10 @@
     bool applyMediaItem(WebCore::DisplayList::ItemHandle, WebCore::GraphicsContext&);
 
     // Messages to be sent.
-    void didCreateImageBufferBackend(ImageBufferBackendHandle, WebCore::RenderingResourceIdentifier);
-    void didFlush(WebCore::GraphicsContextFlushIdentifier, WebCore::RenderingResourceIdentifier);
+    void didCreateImageBufferBackend(ImageBufferBackendHandle, QualifiedRenderingResourceIdentifier);
+    void didFlush(WebCore::GraphicsContextFlushIdentifier, QualifiedRenderingResourceIdentifier);
 
-    void setNextItemBufferToRead(WebCore::DisplayList::ItemBufferIdentifier, WebCore::RenderingResourceIdentifier destination);
+    void setNextItemBufferToRead(WebCore::DisplayList::ItemBufferIdentifier, QualifiedRenderingResourceIdentifier destination);
 
     void didCreateMaskImageBuffer(WebCore::ImageBuffer&);
     void didResetMaskImageBuffer();
@@ -118,7 +118,7 @@
     }
 
     WebCore::DisplayList::ReplayResult submit(const WebCore::DisplayList::DisplayList&, WebCore::ImageBuffer& destination);
-    RefPtr<WebCore::ImageBuffer> nextDestinationImageBufferAfterApplyingDisplayLists(WebCore::ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle&, GPUProcessWakeupReason);
+    RefPtr<WebCore::ImageBuffer> nextDestinationImageBufferAfterApplyingDisplayLists(WebCore::ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle&, GPUProcessWakeupReason, WebCore::ProcessIdentifier webProcessIdentifier);
 
     std::optional<SharedMemory::IPCHandle> updateSharedMemoryForGetPixelBufferHelper(size_t byteCount);
     void updateRenderingResourceRequest();
@@ -180,12 +180,12 @@
     struct PendingWakeupInformation {
         WebCore::DisplayList::ItemBufferIdentifier itemBufferIdentifier;
         uint64_t offset { 0 };
-        WebCore::RenderingResourceIdentifier destinationImageBufferIdentifier;
+        QualifiedRenderingResourceIdentifier destinationImageBufferIdentifier;
         GPUProcessWakeupReason reason { GPUProcessWakeupReason::Unspecified };
-        std::optional<WebCore::RenderingResourceIdentifier> missingCachedResourceIdentifier;
+        std::optional<QualifiedRenderingResourceIdentifier> missingCachedResourceIdentifier;
         RemoteRenderingBackendState state { RemoteRenderingBackendState::Initialized };
 
-        bool shouldPerformWakeup(WebCore::RenderingResourceIdentifier identifier) const
+        bool shouldPerformWakeup(QualifiedRenderingResourceIdentifier identifier) const
         {
             return destinationImageBufferIdentifier == identifier
                 || missingCachedResourceIdentifier == identifier;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to