Title: [286459] trunk/Source
Revision
286459
Author
[email protected]
Date
2021-12-02 15:37:18 -0800 (Thu, 02 Dec 2021)

Log Message

[WebGPU] Hook up navigator.gpu.requestAdapter()
https://bugs.webkit.org/show_bug.cgi?id=233619

Source/WebCore:

Reviewed by Dean Jackson.

Hook up Navigator.GPU to WebKitLegacy/WebKit (via ChromeClient) so WebKit can provide a
RemoteGPUProxy "backing" object.

I have a test for this! But unfortunately I can't commit it yet because HAVE(WEBGPU_IMPLEMENTATION)
has to be off until Apple configures its internal build system. As soon as that's done, I'll add
the test for this!!! (The test passes when run locally.)

* Configurations/WebCore.xcconfig: Weak link with WebGPU.framework. This will
succeed even if WebGPU.framework doesn't exist.
* Modules/WebGPU/GPU.cpp:
(WebCore::GPU::setBacking): This is for WorkerNavigator. To create a GPU object, we have to
go through ChromeClient, which means we have to use the main thread. This means that creating
the GPU object has to be asynchronous on workers. We handle this by having
WorkerNavigator::gpu() return a shell object with no "backing," and asynchronously kick off a
task to construct a backing object and connect it to the shell object. If content calls
requestAdapter() on the shell, that function is already async, so we just fold in the wait for
the backing into the already-existing wait we have to do as a matter of course. This implements
that.
(WebCore::GPU::requestAdapter):
* Modules/WebGPU/GPU.h:
(WebCore::GPU::create):
(WebCore::GPU::backing): Deleted.
(WebCore::GPU::backing const): Deleted.
(WebCore::GPU::GPU): Deleted.
* Modules/WebGPU/GPUDevice.cpp:
(WebCore::GPUDevice::popErrorScope):
* page/Chrome.cpp:
(WebCore::Chrome::createGPUForWebGPU const): Ask WebKit / WebKitLegacy what kind of backing we
should be using.
* page/Chrome.h:
* page/ChromeClient.h:
(WebCore::ChromeClient::createGPUForWebGPU const):
* page/Navigator.cpp:
(WebCore::Navigator::gpu):
* page/Navigator.h:
* page/NavigatorBase.h:
(WebCore::NavigatorBase::gpu): Deleted.
* page/WorkerNavigator.cpp:
(WebCore::WorkerNavigator::gpu):
* page/WorkerNavigator.h:

Source/WebGPU:

Just hook up enough for Instance::requestAdapter() to not fail.

Reviewed by Dean Jackson.

* WebGPU/Adapter.mm:
(WebGPU::Adapter::getLimits):
* WebGPU/Instance.mm:
(WebGPU::Instance::requestAdapter):
(wgpuCreateInstance):
(wgpuInstanceRequestAdapter):

Source/WebKit:

Reviewed by Dean Jackson.

This hooks up a new message, GPUConnectionToWebProcess::createRemoteGPU(), which starts
the whole WebGPU GPU process infrastructure.

* Configurations/BaseTarget.xcconfig: We have to be able to #include files from WebGPU.
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::createRemoteGPU): GPUConnectionToWebProcess owns
the RemoteGPUs.
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* Sources.txt:
* WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
(WebKit::RemoteGPUProxy::RemoteGPUProxy): Creating a RemoteGPUProxy needs to send a
message to the GPU process to start the GPU process infrastructure. We block while we're
waiting for the reply from the GPU process. This was copied from RemoteGraphicsContextGL.
(WebKit::RemoteGPUProxy::gpuProcessConnectionDidClose):
* WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp: Hook up RemoteGPUProxy to WebCore.
(WebKit::WebChromeClient::createGPUForWebGPU const):
* WebProcess/WebCoreSupport/WebChromeClient.h:

Source/WebKitLegacy/mac:

Reviewed by Dean Jackson.

* Configurations/WebKitLegacy.xcconfig: We have to be able to #include files from WebGPU.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::createGPUForWebGPU const): Hook up GPUImpl to WebCore.

Source/WTF:

Reviewed by Dean Jackson.

* wtf/PlatformHave.h: Create a HAVE() macro, by default off. As we bring
more infrastructure online, this will eventually flip to on.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (286458 => 286459)


--- trunk/Source/WTF/ChangeLog	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WTF/ChangeLog	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1,3 +1,13 @@
+2021-12-02  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Hook up navigator.gpu.requestAdapter()
+        https://bugs.webkit.org/show_bug.cgi?id=233619
+
+        Reviewed by Dean Jackson.
+
+        * wtf/PlatformHave.h: Create a HAVE() macro, by default off. As we bring
+        more infrastructure online, this will eventually flip to on.
+
 2021-12-02  Wenson Hsieh  <[email protected]>
 
         [ Monterey ] fast/images/text-recognition/mac/image-overlay-text-disables-app-highlight-menu-items.html (layout-test) is a constant text failure

Modified: trunk/Source/WTF/wtf/PlatformHave.h (286458 => 286459)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1092,6 +1092,10 @@
 #define HAVE_SCENEKIT 1
 #endif
 
+#if PLATFORM(COCOA)
+#define HAVE_WEBGPU_IMPLEMENTATION 0
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000)
 #define HAVE_UNIFIED_SPEECHSYNTHESIS_FIX_FOR_81465164 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (286458 => 286459)


--- trunk/Source/WebCore/ChangeLog	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/ChangeLog	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1,3 +1,51 @@
+2021-12-02  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Hook up navigator.gpu.requestAdapter()
+        https://bugs.webkit.org/show_bug.cgi?id=233619
+
+        Reviewed by Dean Jackson.
+
+        Hook up Navigator.GPU to WebKitLegacy/WebKit (via ChromeClient) so WebKit can provide a
+        RemoteGPUProxy "backing" object.
+
+        I have a test for this! But unfortunately I can't commit it yet because HAVE(WEBGPU_IMPLEMENTATION)
+        has to be off until Apple configures its internal build system. As soon as that's done, I'll add
+        the test for this!!! (The test passes when run locally.)
+
+        * Configurations/WebCore.xcconfig: Weak link with WebGPU.framework. This will
+        succeed even if WebGPU.framework doesn't exist.
+        * Modules/WebGPU/GPU.cpp:
+        (WebCore::GPU::setBacking): This is for WorkerNavigator. To create a GPU object, we have to
+        go through ChromeClient, which means we have to use the main thread. This means that creating
+        the GPU object has to be asynchronous on workers. We handle this by having
+        WorkerNavigator::gpu() return a shell object with no "backing," and asynchronously kick off a
+        task to construct a backing object and connect it to the shell object. If content calls
+        requestAdapter() on the shell, that function is already async, so we just fold in the wait for
+        the backing into the already-existing wait we have to do as a matter of course. This implements
+        that.
+        (WebCore::GPU::requestAdapter):
+        * Modules/WebGPU/GPU.h:
+        (WebCore::GPU::create):
+        (WebCore::GPU::backing): Deleted.
+        (WebCore::GPU::backing const): Deleted.
+        (WebCore::GPU::GPU): Deleted.
+        * Modules/WebGPU/GPUDevice.cpp:
+        (WebCore::GPUDevice::popErrorScope):
+        * page/Chrome.cpp:
+        (WebCore::Chrome::createGPUForWebGPU const): Ask WebKit / WebKitLegacy what kind of backing we
+        should be using.
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::createGPUForWebGPU const):
+        * page/Navigator.cpp:
+        (WebCore::Navigator::gpu):
+        * page/Navigator.h:
+        * page/NavigatorBase.h:
+        (WebCore::NavigatorBase::gpu): Deleted.
+        * page/WorkerNavigator.cpp:
+        (WebCore::WorkerNavigator::gpu):
+        * page/WorkerNavigator.h:
+
 2021-12-02  Devin Rousso  <[email protected]>
 
         [css-values-4] Support `*vi` (inline) and `*vb` (block) viewport units

Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (286458 => 286459)


--- trunk/Source/WebCore/Configurations/WebCore.xcconfig	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig	2021-12-02 23:37:18 UTC (rev 286459)
@@ -73,6 +73,8 @@
 
 WK_ANGLE_LDFLAGS = -weak-lANGLE-shared;
 
+WK_WEBGPU_LDFLAGS = -weak_framework WebGPU;
+
 WK_APPKIT_LDFLAGS = $(WK_APPKIT_LDFLAGS_$(WK_PLATFORM_NAME));
 WK_APPKIT_LDFLAGS_macosx = -framework AppKit;
 WK_APPKIT_LDFLAGS_maccatalyst = -framework AppKit;
@@ -130,7 +132,7 @@
 WK_SCENEKIT_LDFLAGS_macosx = -weak_framework SceneKit;
 
 // FIXME: Reduce the number of allowable_clients <rdar://problem/31823969>
-OTHER_LDFLAGS = $(inherited) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) -lsqlite3 -lobjc -allowable_client WebCoreTestSupport -allowable_client WebKitLegacy -force_load $(BUILT_PRODUCTS_DIR)/libPAL.a -framework CFNetwork -framework CoreAudio -framework CoreGraphics -framework CoreText -framework Foundation -framework IOSurface -framework ImageIO -framework Metal $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH)) $(OTHER_LDFLAGS_PLATFORM_$(WK_PLATFORM_NAME)) $(WK_ANGLE_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_APPSUPPORT_LDFLAGS) $(WK_AUDIO_UNIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_UI_LDFLAGS) $(WK_DATA_DETECTORS_CORE_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_ACCELERATOR_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_NETWORK_EXTENSION_LD_FLAGS) $(WK_SYSTEM_CONFIGURATION_LDFLAGS) $(WK_CORE_IMAGE_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_SCENEKIT_LDFLAGS);
+OTHER_LDFLAGS = $(inherited) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) -lsqlite3 -lobjc -allowable_client WebCoreTestSupport -allowable_client WebKitLegacy -force_load $(BUILT_PRODUCTS_DIR)/libPAL.a -framework CFNetwork -framework CoreAudio -framework CoreGraphics -framework CoreText -framework Foundation -framework IOSurface -framework ImageIO -framework Metal $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH)) $(OTHER_LDFLAGS_PLATFORM_$(WK_PLATFORM_NAME)) $(WK_ANGLE_LDFLAGS) $(WK_WEBGPU_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_APPSUPPORT_LDFLAGS) $(WK_AUDIO_UNIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_UI_LDFLAGS) $(WK_DATA_DETECTORS_CORE_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_ACCELERATOR_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_NETWORK_EXTENSION_LD_FLAGS) $(WK_SYSTEM_CONFIGURATION_LDFLAGS) $(WK_CORE_IMAGE_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_SCENEKIT_LDFLAGS);
 
 OTHER_LDFLAGS_PLATFORM_cocoatouch = -allowable_client WebKit -allowable_client iTunesU -allowable_client Casablanca -allowable_client Remote -allowable_client TVBooks -allowable_client DumpRenderTree -allowable_client WebKitTestRunner -allowable_client TestWebKitAPI;
 OTHER_LDFLAGS_PLATFORM_macosx = -sub_library libobjc -umbrella WebKit;

Modified: trunk/Source/WebCore/Modules/WebGPU/GPU.cpp (286458 => 286459)


--- trunk/Source/WebCore/Modules/WebGPU/GPU.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/Modules/WebGPU/GPU.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -38,11 +38,27 @@
     return options->convertToBacking();
 }
 
+void GPU::setBacking(PAL::WebGPU::GPU& backing)
+{
+    m_backing = &backing;
+    while (!m_pendingRequestAdapterArguments.isEmpty()) {
+        auto arguments = m_pendingRequestAdapterArguments.takeFirst();
+        requestAdapter(arguments.options, WTFMove(arguments.promise));
+    }
+}
+
 void GPU::requestAdapter(const std::optional<GPURequestAdapterOptions>& options, RequestAdapterPromise&& promise)
 {
+    if (!m_backing) {
+        m_pendingRequestAdapterArguments.append({ options, WTFMove(promise) });
+        return;
+    }
+
     m_backing->requestAdapter(convertToBacking(options), [promise = WTFMove(promise)] (RefPtr<PAL::WebGPU::Adapter>&& adapter) mutable {
-        if (!adapter)
-            promise.resolve(nullptr);
+        if (!adapter) {
+            promise.reject(nullptr);
+            return;
+        }
         promise.resolve(GPUAdapter::create(adapter.releaseNonNull()).ptr());
     });
 }

Modified: trunk/Source/WebCore/Modules/WebGPU/GPU.h (286458 => 286459)


--- trunk/Source/WebCore/Modules/WebGPU/GPU.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/Modules/WebGPU/GPU.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -30,6 +30,7 @@
 #include "JSDOMPromiseDeferred.h"
 #include <optional>
 #include <pal/graphics/WebGPU/WebGPU.h>
+#include <wtf/Deque.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
@@ -37,24 +38,25 @@
 
 class GPU : public RefCounted<GPU> {
 public:
-    static Ref<GPU> create(Ref<PAL::WebGPU::GPU>&& backing)
+    static Ref<GPU> create()
     {
-        return adoptRef(*new GPU(WTFMove(backing)));
+        return adoptRef(*new GPU());
     }
 
     using RequestAdapterPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<GPUAdapter>>>;
     void requestAdapter(const std::optional<GPURequestAdapterOptions>&, RequestAdapterPromise&&);
 
-    PAL::WebGPU::GPU& backing() { return m_backing; }
-    const PAL::WebGPU::GPU& backing() const { return m_backing; }
+    void setBacking(PAL::WebGPU::GPU&);
 
 private:
-    GPU(Ref<PAL::WebGPU::GPU>&& backing)
-        : m_backing(WTFMove(backing))
-    {
-    }
+    GPU() = default;
 
-    Ref<PAL::WebGPU::GPU> m_backing;
+    struct PendingRequestAdapterArguments {
+        std::optional<GPURequestAdapterOptions> options;
+        RequestAdapterPromise promise;
+    };
+    Deque<PendingRequestAdapterArguments> m_pendingRequestAdapterArguments;
+    RefPtr<PAL::WebGPU::GPU> m_backing;
 };
 
 }

Modified: trunk/Source/WebCore/Modules/WebGPU/GPUDevice.cpp (286458 => 286459)


--- trunk/Source/WebCore/Modules/WebGPU/GPUDevice.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUDevice.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -204,8 +204,10 @@
 void GPUDevice::popErrorScope(ErrorScopePromise&& errorScopePromise)
 {
     m_backing->popErrorScope([promise = WTFMove(errorScopePromise)] (std::optional<PAL::WebGPU::Error>&& error) mutable {
-        if (!error)
+        if (!error) {
             promise.resolve(std::nullopt);
+            return;
+        }
         WTF::switchOn(WTFMove(*error), [&] (Ref<PAL::WebGPU::OutOfMemoryError>&& outOfMemoryError) {
             GPUError error = RefPtr<GPUOutOfMemoryError>(GPUOutOfMemoryError::create(WTFMove(outOfMemoryError)));
             promise.resolve(error);

Modified: trunk/Source/WebCore/page/Chrome.cpp (286458 => 286459)


--- trunk/Source/WebCore/page/Chrome.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/Chrome.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -546,6 +546,11 @@
 }
 #endif
 
+RefPtr<PAL::WebGPU::GPU> Chrome::createGPUForWebGPU() const
+{
+    return m_client.createGPUForWebGPU();
+}
+
 PlatformDisplayID Chrome::displayID() const
 {
     return m_page.displayID();

Modified: trunk/Source/WebCore/page/Chrome.h (286458 => 286459)


--- trunk/Source/WebCore/page/Chrome.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/Chrome.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -32,6 +32,10 @@
 OBJC_CLASS NSView;
 #endif
 
+namespace PAL::WebGPU {
+class GPU;
+}
+
 namespace WebCore {
 
 class ChromeClient;
@@ -91,6 +95,8 @@
     RefPtr<GraphicsContextGL> createGraphicsContextGL(const GraphicsContextGLAttributes&) const override;
 #endif
 
+    RefPtr<PAL::WebGPU::GPU> createGPUForWebGPU() const;
+
     PlatformDisplayID displayID() const override;
     void windowScreenDidChange(PlatformDisplayID, std::optional<FramesPerSecond>) override;
 

Modified: trunk/Source/WebCore/page/ChromeClient.h (286458 => 286459)


--- trunk/Source/WebCore/page/ChromeClient.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/ChromeClient.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -52,6 +52,7 @@
 #include "SearchPopupMenu.h"
 #include "WebCoreKeyboardUIMode.h"
 #include <_javascript_Core/ConsoleTypes.h>
+#include <pal/graphics/WebGPU/WebGPU.h>
 #include <wtf/Assertions.h>
 #include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
@@ -361,6 +362,8 @@
     virtual RefPtr<GraphicsContextGL> createGraphicsContextGL(const GraphicsContextGLAttributes& attributes, WebCore::PlatformDisplayID) const { return createWebProcessGraphicsContextGL(attributes); }
 #endif
 
+    virtual RefPtr<PAL::WebGPU::GPU> createGPUForWebGPU() const { return nullptr; }
+
     // Pass nullptr as the GraphicsLayer to detatch the root layer.
     virtual void attachRootGraphicsLayer(Frame&, GraphicsLayer*) = 0;
     virtual void attachViewOverlayGraphicsLayer(GraphicsLayer*) = 0;

Modified: trunk/Source/WebCore/page/Navigator.cpp (286458 => 286459)


--- trunk/Source/WebCore/page/Navigator.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/Navigator.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -34,6 +34,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
+#include "GPU.h"
 #include "Geolocation.h"
 #include "JSDOMPromiseDeferred.h"
 #include "LoaderStrategy.h"
@@ -347,4 +348,24 @@
 {
 }
 
+GPU* Navigator::gpu()
+{
+    if (!m_gpuForWebGPU) {
+        auto* frame = this->frame();
+        if (!frame)
+            return nullptr;
+        auto* page = frame->page();
+        if (!page)
+            return nullptr;
+        auto gpu = page->chrome().createGPUForWebGPU();
+        if (!gpu)
+            return nullptr;
+
+        m_gpuForWebGPU = GPU::create();
+        m_gpuForWebGPU->setBacking(*gpu);
+    }
+
+    return m_gpuForWebGPU.get();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Navigator.h (286458 => 286459)


--- trunk/Source/WebCore/page/Navigator.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/Navigator.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -64,6 +64,8 @@
     int maxTouchPoints() const { return 0; }
 #endif
 
+    GPU* gpu();
+
 private:
     void showShareData(ExceptionOr<ShareDataWithParsedURL&>, Ref<DeferredPromise>&&);
     explicit Navigator(ScriptExecutionContext*, DOMWindow&);
@@ -76,5 +78,6 @@
     mutable RefPtr<DOMMimeTypeArray> m_mimeTypes;
     mutable String m_userAgent;
     mutable String m_platform;
+    RefPtr<GPU> m_gpuForWebGPU;
 };
 }

Modified: trunk/Source/WebCore/page/NavigatorBase.h (286458 => 286459)


--- trunk/Source/WebCore/page/NavigatorBase.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/NavigatorBase.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -63,7 +63,6 @@
 
     StorageManager& storage();
     WebLockManager& locks();
-    GPU& gpu() { return *m_gpuForWebGPU; };
 
 protected:
     explicit NavigatorBase(ScriptExecutionContext*);
@@ -71,7 +70,6 @@
 private:
     RefPtr<StorageManager> m_storageManager;
     RefPtr<WebLockManager> m_webLockManager;
-    RefPtr<GPU> m_gpuForWebGPU;
 
 #if ENABLE(SERVICE_WORKER)
 public:

Modified: trunk/Source/WebCore/page/WorkerNavigator.cpp (286458 => 286459)


--- trunk/Source/WebCore/page/WorkerNavigator.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/WorkerNavigator.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -46,4 +46,10 @@
     return m_isOnline;
 }
 
+GPU* WorkerNavigator::gpu()
+{
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=233622 Implement this.
+    return nullptr;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/WorkerNavigator.h (286458 => 286459)


--- trunk/Source/WebCore/page/WorkerNavigator.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebCore/page/WorkerNavigator.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -39,6 +39,8 @@
     bool onLine() const final;
     void setIsOnline(bool isOnline) { m_isOnline = isOnline; }
 
+    GPU* gpu();
+
 private:
     explicit WorkerNavigator(ScriptExecutionContext&, const String&, bool isOnline);
 

Modified: trunk/Source/WebGPU/ChangeLog (286458 => 286459)


--- trunk/Source/WebGPU/ChangeLog	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebGPU/ChangeLog	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1,3 +1,19 @@
+2021-12-02  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Hook up navigator.gpu.requestAdapter()
+        https://bugs.webkit.org/show_bug.cgi?id=233619
+
+        Just hook up enough for Instance::requestAdapter() to not fail.
+
+        Reviewed by Dean Jackson.
+
+        * WebGPU/Adapter.mm:
+        (WebGPU::Adapter::getLimits):
+        * WebGPU/Instance.mm:
+        (WebGPU::Instance::requestAdapter):
+        (wgpuCreateInstance):
+        (wgpuInstanceRequestAdapter):
+
 2021-11-29  Myles C. Maxfield  <[email protected]>
 
         [WebGPU] Make WebGPU.framework's classes reference counted

Modified: trunk/Source/WebGPU/WebGPU/Adapter.mm (286458 => 286459)


--- trunk/Source/WebGPU/WebGPU/Adapter.mm	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebGPU/WebGPU/Adapter.mm	2021-12-02 23:37:18 UTC (rev 286459)
@@ -39,7 +39,7 @@
 bool Adapter::getLimits(WGPUSupportedLimits* limits)
 {
     UNUSED_PARAM(limits);
-    return false;
+    return true;
 }
 
 void Adapter::getProperties(WGPUAdapterProperties* properties)

Modified: trunk/Source/WebGPU/WebGPU/Instance.mm (286458 => 286459)


--- trunk/Source/WebGPU/WebGPU/Instance.mm	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebGPU/WebGPU/Instance.mm	2021-12-02 23:37:18 UTC (rev 286459)
@@ -52,6 +52,7 @@
 {
     UNUSED_PARAM(options);
     UNUSED_PARAM(callback);
+    callback(WGPURequestAdapterStatus_Unavailable, Adapter::create(), "Adapter");
 }
 
 } // namespace WebGPU
@@ -64,7 +65,7 @@
 WGPUInstance wgpuCreateInstance(const WGPUInstanceDescriptor* descriptor)
 {
     UNUSED_PARAM(descriptor);
-    return nullptr;
+    return new WGPUInstanceImpl { WebGPU::Instance::create() };
 }
 
 WGPUProc wgpuGetProcAddress(WGPUDevice device, const char* procName)
@@ -384,7 +385,7 @@
 
 void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions* options, WGPURequestAdapterCallback callback, void* userdata)
 {
-    return instance->instance->requestAdapter(options, [callback, userdata] (WGPURequestAdapterStatus status, Ref<WebGPU::Adapter>&& adapter, const char* message) {
+    instance->instance->requestAdapter(options, [callback, userdata] (WGPURequestAdapterStatus status, Ref<WebGPU::Adapter>&& adapter, const char* message) {
         callback(status, new WGPUAdapterImpl { WTFMove(adapter) }, message, userdata);
     });
 }

Modified: trunk/Source/WebKit/ChangeLog (286458 => 286459)


--- trunk/Source/WebKit/ChangeLog	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/ChangeLog	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1,3 +1,30 @@
+2021-12-02  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Hook up navigator.gpu.requestAdapter()
+        https://bugs.webkit.org/show_bug.cgi?id=233619
+
+        Reviewed by Dean Jackson.
+
+        This hooks up a new message, GPUConnectionToWebProcess::createRemoteGPU(), which starts
+        the whole WebGPU GPU process infrastructure.
+
+        * Configurations/BaseTarget.xcconfig: We have to be able to #include files from WebGPU.
+        * GPUProcess/GPUConnectionToWebProcess.cpp:
+        (WebKit::GPUConnectionToWebProcess::createRemoteGPU): GPUConnectionToWebProcess owns
+        the RemoteGPUs.
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/GPUConnectionToWebProcess.messages.in:
+        * Sources.txt:
+        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
+        (WebKit::RemoteGPUProxy::RemoteGPUProxy): Creating a RemoteGPUProxy needs to send a
+        message to the GPU process to start the GPU process infrastructure. We block while we're
+        waiting for the reply from the GPU process. This was copied from RemoteGraphicsContextGL.
+        (WebKit::RemoteGPUProxy::gpuProcessConnectionDidClose):
+        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp: Hook up RemoteGPUProxy to WebCore.
+        (WebKit::WebChromeClient::createGPUForWebGPU const):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
 2021-12-02  Chris Dumez  <[email protected]>
 
         [WK2] Make Web Lock API work across multiple WebProcesses

Modified: trunk/Source/WebKit/Configurations/BaseTarget.xcconfig (286458 => 286459)


--- trunk/Source/WebKit/Configurations/BaseTarget.xcconfig	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/Configurations/BaseTarget.xcconfig	2021-12-02 23:37:18 UTC (rev 286459)
@@ -47,7 +47,7 @@
 WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
 LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc;
 
-HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2 $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(SRCROOT) $(HEADER_SEARCH_PATHS);
+HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2 "$(BUILT_PRODUCTS_DIR)/usr/local/include/pal/graphics/WebGPU" $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(SRCROOT) $(HEADER_SEARCH_PATHS);
 
 OTHER_CFLAGS = $(inherited) -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
 OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders;

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (286458 => 286459)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -63,6 +63,7 @@
 #include "RemoteScrollingCoordinatorTransaction.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
+#include "WebGPUObjectHeap.h"
 #include "WebProcessMessages.h"
 #include <WebCore/LogInitialization.h>
 #include <WebCore/MockRealtimeMediaSourceCenter.h>
@@ -555,6 +556,19 @@
 }
 #endif
 
+void GPUConnectionToWebProcess::createRemoteGPU(WebGPUIdentifier identifier, RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer&& stream)
+{
+    auto it = m_remoteRenderingBackendMap.find(renderingBackendIdentifier);
+    if (it == m_remoteRenderingBackendMap.end())
+        return;
+    auto* renderingBackend = it->value.get();
+
+    auto addResult = m_remoteGPUMap.ensure(identifier, [&]() {
+        return IPC::ScopedActiveMessageReceiveQueue { RemoteGPU::create(identifier, *this, *renderingBackend, WTFMove(stream)) };
+    });
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+}
+
 void GPUConnectionToWebProcess::clearNowPlayingInfo()
 {
     m_isActiveNowPlayingProcess = false;

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (286458 => 286459)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -32,9 +32,11 @@
 #include "MessageReceiverMap.h"
 #include "RemoteAudioHardwareListenerIdentifier.h"
 #include "RemoteAudioSessionIdentifier.h"
+#include "RemoteGPU.h"
 #include "RemoteRemoteCommandListenerIdentifier.h"
 #include "RenderingBackendIdentifier.h"
 #include "ScopedActiveMessageReceiveQueue.h"
+#include "WebGPUIdentifier.h"
 #include <WebCore/LibWebRTCEnumTraits.h>
 #include <WebCore/NowPlayingManager.h>
 #include <WebCore/PageIdentifier.h>
@@ -213,6 +215,8 @@
     void releaseGraphicsContextGL(GraphicsContextGLIdentifier);
 #endif
 
+    void createRemoteGPU(WebGPUIdentifier, RenderingBackendIdentifier, IPC::StreamConnectionBuffer&&);
+
     void clearNowPlayingInfo();
     void setNowPlayingInfo(WebCore::NowPlayingInfo&&);
 
@@ -308,6 +312,8 @@
     using RemoteGraphicsContextGLMap = HashMap<GraphicsContextGLIdentifier, IPC::ScopedActiveMessageReceiveQueue<RemoteGraphicsContextGL>>;
     RemoteGraphicsContextGLMap m_remoteGraphicsContextGLMap;
 #endif
+    using RemoteGPUMap = HashMap<WebGPUIdentifier, IPC::ScopedActiveMessageReceiveQueue<RemoteGPU>>;
+    RemoteGPUMap m_remoteGPUMap;
 #if ENABLE(ENCRYPTED_MEDIA)
     std::unique_ptr<RemoteCDMFactoryProxy> m_cdmFactoryProxy;
 #endif

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (286458 => 286459)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-12-02 23:37:18 UTC (rev 286459)
@@ -29,6 +29,7 @@
     void CreateGraphicsContextGL(struct WebCore::GraphicsContextGLAttributes attributes, WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier, WebKit::RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer stream)
     void ReleaseGraphicsContextGL(WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier)
 #endif
+    void CreateRemoteGPU(WebKit::WebGPUIdentifier identifier, WebKit::RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer stream)
     void ClearNowPlayingInfo()
     void SetNowPlayingInfo(struct WebCore::NowPlayingInfo nowPlayingInfo)
 #if USE(AUDIO_SESSION)

Modified: trunk/Source/WebKit/Sources.txt (286458 => 286459)


--- trunk/Source/WebKit/Sources.txt	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/Sources.txt	2021-12-02 23:37:18 UTC (rev 286459)
@@ -860,6 +860,7 @@
 RemoteDeviceMessageReceiver.cpp
 RemoteExternalTextureMessageReceiver.cpp
 RemoteGPUMessageReceiver.cpp
+RemoteGPUProxyMessageReceiver.cpp
 RemotePipelineLayoutMessageReceiver.cpp
 RemoteQuerySetMessageReceiver.cpp
 RemoteQueueMessageReceiver.cpp

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp (286458 => 286459)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -48,11 +48,23 @@
     , m_gpuProcessConnection(&gpuProcessConnection)
     , m_streamConnection(gpuProcessConnection.connection(), defaultStreamSize)
 {
+    m_gpuProcessConnection->addClient(*this);
     m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteGPUProxy::messageReceiverName(), identifier.toUInt64(), *this);
+    connection().send(Messages::GPUConnectionToWebProcess::CreateRemoteGPU(identifier, renderingBackend, m_streamConnection.streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+    // TODO: We must wait until initialized, because at the moment we cannot receive IPC messages
+    // during wait while in synchronous stream send. Should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=217211.
+    waitUntilInitialized();
 }
 
 RemoteGPUProxy::~RemoteGPUProxy() = default;
 
+void RemoteGPUProxy::gpuProcessConnectionDidClose(GPUProcessConnection& connection)
+{
+    ASSERT(m_gpuProcessConnection);
+    ASSERT(&connection == m_gpuProcessConnection);
+    abandonGPUProcess();
+}
+
 void RemoteGPUProxy::abandonGPUProcess()
 {
     auto gpuProcessConnection = std::exchange(m_gpuProcessConnection, nullptr);

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h (286458 => 286459)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -45,7 +45,7 @@
 class DowncastConvertToBackingContext;
 }
 
-class RemoteGPUProxy final : public PAL::WebGPU::GPU, private IPC::MessageReceiver {
+class RemoteGPUProxy final : public PAL::WebGPU::GPU, private IPC::MessageReceiver, private GPUProcessConnection::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     static Ref<RemoteGPUProxy> create(GPUProcessConnection& gpuProcessConnection, WebGPU::ConvertToBackingContext& convertToBackingContext, WebGPUIdentifier identifier, RenderingBackendIdentifier renderingBackend)
@@ -72,6 +72,9 @@
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
 
+    // GPUProcessConnection::Client
+    void gpuProcessConnectionDidClose(GPUProcessConnection&) final;
+
     // Messages to be received.
     void wasCreated(bool didSucceed, IPC::Semaphore&&);
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (286458 => 286459)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-12-02 23:37:18 UTC (rev 286459)
@@ -40,6 +40,7 @@
 #include "NetworkProcessConnection.h"
 #include "PageBanner.h"
 #include "PluginView.h"
+#include "RemoteGPUProxy.h"
 #include "RemoteRenderingBackendProxy.h"
 #include "SharedBufferCopy.h"
 #include "UserData.h"
@@ -50,6 +51,7 @@
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
 #include "WebFullScreenManager.h"
+#include "WebGPUDowncastConvertToBackingContext.h"
 #include "WebHitTestResultData.h"
 #include "WebImage.h"
 #include "WebOpenPanelResultListener.h"
@@ -91,6 +93,10 @@
 #include <WebCore/Settings.h>
 #include <WebCore/TextIndicator.h>
 
+#if HAVE(WEBGPU_IMPLEMENTATION)
+#import <pal/graphics/WebGPU/Impl/WebGPUImpl.h>
+#endif
+
 #if ENABLE(APPLE_PAY_AMS_UI)
 #include <WebCore/ApplePayAMSUIRequest.h>
 #endif
@@ -945,6 +951,19 @@
 }
 #endif
 
+RefPtr<PAL::WebGPU::GPU> WebChromeClient::createGPUForWebGPU() const
+{
+#if HAVE(WEBGPU_IMPLEMENTATION)
+#if ENABLE(GPU_PROCESS)
+    return RemoteGPUProxy::create(WebProcess::singleton().ensureGPUProcessConnection(), WebGPU::DowncastConvertToBackingContext::create(), WebGPUIdentifier::generate(), m_page.ensureRemoteRenderingBackendProxy().ensureBackendCreated());
+#else
+    return PAL::WebGPU::GPUImpl::create();
+#endif
+#else
+    return nullptr;
+#endif
+}
+
 void WebChromeClient::attachRootGraphicsLayer(Frame&, GraphicsLayer* layer)
 {
     if (layer)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (286458 => 286459)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -252,6 +252,7 @@
     RefPtr<WebCore::GraphicsContextGL> createGraphicsContextGL(const WebCore::GraphicsContextGLAttributes&, WebCore::PlatformDisplayID hostWindowDisplayID) const final;
 #endif
 
+    RefPtr<PAL::WebGPU::GPU> createGPUForWebGPU() const final;
 
     CompositingTriggerFlags allowedCompositingTriggers() const final
     {

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (286458 => 286459)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-12-02 23:37:18 UTC (rev 286459)
@@ -1,3 +1,15 @@
+2021-12-02  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Hook up navigator.gpu.requestAdapter()
+        https://bugs.webkit.org/show_bug.cgi?id=233619
+
+        Reviewed by Dean Jackson.
+
+        * Configurations/WebKitLegacy.xcconfig: We have to be able to #include files from WebGPU.
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::createGPUForWebGPU const): Hook up GPUImpl to WebCore.
+
 2021-12-02  Chris Dumez  <[email protected]>
 
         [WK2] Make Web Lock API work across multiple WebProcesses

Modified: trunk/Source/WebKitLegacy/mac/Configurations/WebKitLegacy.xcconfig (286458 => 286459)


--- trunk/Source/WebKitLegacy/mac/Configurations/WebKitLegacy.xcconfig	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKitLegacy/mac/Configurations/WebKitLegacy.xcconfig	2021-12-02 23:37:18 UTC (rev 286459)
@@ -58,7 +58,7 @@
 WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
 LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc;
 
-HEADER_SEARCH_PATHS = "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" "$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKitLegacy" "$(BUILT_PRODUCTS_DIR)/usr/local/include" $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(HEADER_SEARCH_PATHS) $(SRCROOT);
+HEADER_SEARCH_PATHS = "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" "$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKitLegacy" "$(BUILT_PRODUCTS_DIR)/usr/local/include" "$(BUILT_PRODUCTS_DIR)/usr/local/include/pal/graphics/WebGPU" $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(HEADER_SEARCH_PATHS) $(SRCROOT);
 INFOPLIST_FILE = mac/Info.plist;
 INSTALL_PATH = $(INSTALL_PATH_COCOA_TOUCH_$(WK_IS_COCOA_TOUCH));
 INSTALL_PATH_COCOA_TOUCH_YES = $(WK_ALTERNATE_WEBKIT_SDK_PATH)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (286458 => 286459)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2021-12-02 23:37:18 UTC (rev 286459)
@@ -255,6 +255,8 @@
     void changeUniversalAccessZoomFocus(const WebCore::IntRect&, const WebCore::IntRect&) final;
 #endif
 
+    RefPtr<PAL::WebGPU::GPU> createGPUForWebGPU() const final;
+
 #if ENABLE(VIDEO_PRESENTATION_MODE)
     bool m_mockVideoPresentationModeEnabled { false };
 #endif

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm (286458 => 286459)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm	2021-12-02 23:26:22 UTC (rev 286458)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm	2021-12-02 23:37:18 UTC (rev 286459)
@@ -93,6 +93,10 @@
 #import <wtf/Vector.h>
 #import <wtf/text/WTFString.h>
 
+#if HAVE(WEBGPU_IMPLEMENTATION)
+#import <pal/graphics/WebGPU/Impl/WebGPUImpl.h>
+#endif
+
 #if PLATFORM(IOS_FAMILY) && ENABLE(GEOLOCATION)
 #import <WebCore/Geolocation.h>
 #endif
@@ -1153,3 +1157,12 @@
     WebCore::changeUniversalAccessZoomFocus(viewRect, selectionRect);
 }
 #endif
+
+RefPtr<PAL::WebGPU::GPU> WebChromeClient::createGPUForWebGPU() const
+{
+#if HAVE(WEBGPU_IMPLEMENTATION)
+    return PAL::WebGPU::GPUImpl::create();
+#else
+    return nullptr;
+#endif
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to