Title: [238451] trunk
Revision
238451
Author
d...@apple.com
Date
2018-11-22 13:17:41 -0800 (Thu, 22 Nov 2018)

Log Message

Implement WebGPUQueue and device.getQueue()
https://bugs.webkit.org/show_bug.cgi?id=191911
<rdar://problem/46214871>

Reviewed by Antoine Quint.

Source/WebCore:

Implement WebGPUDevice::getQueue(), which creates a WebGPUQueue
instance if necessary. Also link WebGPUQueue to the existing
GPUQueue object, and expose the label IDL property.

This patch is based on some work from Justin Fan.

Test: webgpu/queue-creation.html

* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
    New files.

* Modules/webgpu/WebGPUCommandBuffer.h:
(WebCore::WebGPUCommandBuffer::commandBuffer const):
    Expose a GPUCommandBuffer getter, used when submitting (even though
    the actual GPU submission isn't implemented yet).

* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::getQueue):
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUDevice.idl:
    Implement getQueue().

* Modules/webgpu/WebGPUQueue.cpp:
(WebCore::WebGPUQueue::create):
(WebCore::WebGPUQueue::WebGPUQueue):
(WebCore::WebGPUQueue::submit):
* Modules/webgpu/WebGPUQueue.h:
(WebCore::WebGPUQueue::label const):
(WebCore::WebGPUQueue::setLabel):
* Modules/webgpu/WebGPUQueue.idl:
    New class. Mostly sends stuff onto GPUQueue.

* bindings/js/WebCoreBuiltinNames.h:
    Add WebGPUQueue.

* platform/graphics/gpu/GPUQueue.h:
* platform/graphics/gpu/cocoa/GPUQueueMetal.mm:
(WebCore::GPUQueue::create):
(WebCore::GPUQueue::submit):
(WebCore::GPUQueue::label const):
(WebCore::GPUQueue::setLabel const):
    "label" getter/setter that uses
    the underlying MTLCommandQueue label property, but prefixes
    it with a WebKit identifier, so it can be correctly
    identified in system crash logs as coming from WebGPU.

LayoutTests:

WPT-style test for queue creation.

* webgpu/queue-creation-expected.txt: Added.
* webgpu/queue-creation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238450 => 238451)


--- trunk/LayoutTests/ChangeLog	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/LayoutTests/ChangeLog	2018-11-22 21:17:41 UTC (rev 238451)
@@ -1,3 +1,16 @@
+2018-11-22  Dean Jackson  <d...@apple.com>
+
+        Implement WebGPUQueue and device.getQueue()
+        https://bugs.webkit.org/show_bug.cgi?id=191911
+        <rdar://problem/46214871>
+
+        Reviewed by Antoine Quint.
+
+        WPT-style test for queue creation.
+
+        * webgpu/queue-creation-expected.txt: Added.
+        * webgpu/queue-creation.html: Added.
+
 2018-11-22  Frederic Wang  <fw...@igalia.com>
 
         Improve fast/scrolling/scrolling-tree-includes-frame.html

Added: trunk/LayoutTests/webgpu/queue-creation-expected.txt (0 => 238451)


--- trunk/LayoutTests/webgpu/queue-creation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/queue-creation-expected.txt	2018-11-22 21:17:41 UTC (rev 238451)
@@ -0,0 +1,3 @@
+
+PASS getQueue() on WebGPUDevice 
+
Property changes on: trunk/LayoutTests/webgpu/queue-creation-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/plain \ No newline at end of property

Added: trunk/LayoutTests/webgpu/queue-creation.html (0 => 238451)


--- trunk/LayoutTests/webgpu/queue-creation.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/queue-creation.html	2018-11-22 21:17:41 UTC (rev 238451)
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<meta charset=utf-8>
+<title>Get the WebGPUDevice and ask for the WebGPUQueue</title>
+<body>
+<script src=""
+<script src=""
+<script>
+
+'use strict';
+
+promise_test(async t => {
+    assert_not_equals(window.webgpu, undefined, "window.webgpu exists");
+
+    const swapChain = document.createElement("canvas").getContext("webgpu");
+    assert_true(swapChain instanceof WebGPUSwapChain, "getContext returned a WebGPUSwapChain.");
+
+    const adapter = await window.webgpu.requestAdapter({});
+    assert_true(adapter instanceof WebGPUAdapter, "requestAdapter returned a WebGPUAdapter.");
+
+    const device = adapter.createDevice();
+    assert_true(device instanceof WebGPUDevice, "createDevice returned a WebGPUDevice.");
+
+    const queue = device.getQueue();
+    assert_true(queue instanceof WebGPUQueue, "getQueue returned a WebGPUQueue.");
+
+    queue.label = "Example label";
+    assert_equals(queue.label, "Example label", "queue.label was set.");
+}, "getQueue() on WebGPUDevice.");
+
+</script>
+</body>
Property changes on: trunk/LayoutTests/webgpu/queue-creation.html
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/CMakeLists.txt (238450 => 238451)


--- trunk/Source/WebCore/CMakeLists.txt	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-11-22 21:17:41 UTC (rev 238451)
@@ -462,6 +462,7 @@
     Modules/webgpu/WebGPUDevice.idl
     Modules/webgpu/WebGPUPipelineDescriptorBase.idl
     Modules/webgpu/WebGPUPipelineStageDescriptor.idl
+    Modules/webgpu/WebGPUQueue.idl
     Modules/webgpu/WebGPURenderPipeline.idl
     Modules/webgpu/WebGPURenderPipelineDescriptor.idl
     Modules/webgpu/WebGPURenderingContext.idl

Modified: trunk/Source/WebCore/ChangeLog (238450 => 238451)


--- trunk/Source/WebCore/ChangeLog	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/ChangeLog	2018-11-22 21:17:41 UTC (rev 238451)
@@ -1,3 +1,59 @@
+2018-11-22  Dean Jackson  <d...@apple.com>
+
+        Implement WebGPUQueue and device.getQueue()
+        https://bugs.webkit.org/show_bug.cgi?id=191911
+        <rdar://problem/46214871>
+
+        Reviewed by Antoine Quint.
+
+        Implement WebGPUDevice::getQueue(), which creates a WebGPUQueue
+        instance if necessary. Also link WebGPUQueue to the existing
+        GPUQueue object, and expose the label IDL property.
+
+        This patch is based on some work from Justin Fan.
+
+        Test: webgpu/queue-creation.html
+
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+            New files.
+
+        * Modules/webgpu/WebGPUCommandBuffer.h:
+        (WebCore::WebGPUCommandBuffer::commandBuffer const):
+            Expose a GPUCommandBuffer getter, used when submitting (even though
+            the actual GPU submission isn't implemented yet).
+
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::WebGPUDevice::getQueue):
+        * Modules/webgpu/WebGPUDevice.h:
+        * Modules/webgpu/WebGPUDevice.idl:
+            Implement getQueue().
+
+        * Modules/webgpu/WebGPUQueue.cpp:
+        (WebCore::WebGPUQueue::create):
+        (WebCore::WebGPUQueue::WebGPUQueue):
+        (WebCore::WebGPUQueue::submit):
+        * Modules/webgpu/WebGPUQueue.h:
+        (WebCore::WebGPUQueue::label const):
+        (WebCore::WebGPUQueue::setLabel):
+        * Modules/webgpu/WebGPUQueue.idl:
+            New class. Mostly sends stuff onto GPUQueue.
+
+        * bindings/js/WebCoreBuiltinNames.h:
+            Add WebGPUQueue.
+
+        * platform/graphics/gpu/GPUQueue.h:
+        * platform/graphics/gpu/cocoa/GPUQueueMetal.mm:
+        (WebCore::GPUQueue::create):
+        (WebCore::GPUQueue::submit):
+        (WebCore::GPUQueue::label const):
+        (WebCore::GPUQueue::setLabel const):
+            "label" getter/setter that uses
+            the underlying MTLCommandQueue label property, but prefixes
+            it with a WebKit identifier, so it can be correctly
+            identified in system crash logs as coming from WebGPU.
+
 2018-11-22  Zalan Bujtas  <za...@apple.com>
 
         [LFC][IFC] Merge addNonBreakableStart/NonBreakableEnd calls.

Modified: trunk/Source/WebCore/DerivedSources.make (238450 => 238451)


--- trunk/Source/WebCore/DerivedSources.make	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/DerivedSources.make	2018-11-22 21:17:41 UTC (rev 238451)
@@ -377,6 +377,7 @@
     $(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
     $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
+    $(WebCore)/Modules/webgpu/WebGPUQueue.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPURenderPipeline.idl \
@@ -388,7 +389,7 @@
     $(WebCore)/Modules/webgpu/WebGPUSwapChain.idl \
     $(WebCore)/Modules/webgpu/WebGPUTexture.idl \
     $(WebCore)/Modules/webgpu/WebGPUTextureFormatEnum.idl \
-	$(WebCore)/Modules/webgpu/WebGPUTextureView.idl \
+    $(WebCore)/Modules/webgpu/WebGPUTextureView.idl \
     $(WebCore)/Modules/websockets/CloseEvent.idl \
     $(WebCore)/Modules/websockets/WebSocket.idl \
     $(WebCore)/Modules/webvr/DOMWindowWebVR.idl \

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h (238450 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h	2018-11-22 21:17:41 UTC (rev 238451)
@@ -39,6 +39,8 @@
 public:
     static RefPtr<WebGPUCommandBuffer> create(RefPtr<GPUCommandBuffer>&&);
 
+    const GPUCommandBuffer& commandBuffer() const { return m_commandBuffer.get(); }
+
 private:
     WebGPUCommandBuffer(Ref<GPUCommandBuffer>&&);
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (238450 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2018-11-22 21:17:41 UTC (rev 238451)
@@ -35,6 +35,7 @@
 #include "Logging.h"
 #include "WebGPUCommandBuffer.h"
 #include "WebGPUPipelineStageDescriptor.h"
+#include "WebGPUQueue.h"
 #include "WebGPURenderPipeline.h"
 #include "WebGPURenderPipelineDescriptor.h"
 #include "WebGPUShaderModule.h"
@@ -124,6 +125,14 @@
     return WebGPUCommandBuffer::create(m_device->createCommandBuffer());
 }
 
+RefPtr<WebGPUQueue> WebGPUDevice::getQueue()
+{
+    if (!m_queue)
+        m_queue = WebGPUQueue::create(m_device->getQueue());
+
+    return m_queue;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGPU)

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h (238450 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2018-11-22 21:17:41 UTC (rev 238451)
@@ -29,7 +29,7 @@
 
 #include "GPUDevice.h"
 #include "WebGPUAdapter.h"
-
+#include "WebGPUQueue.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -55,13 +55,14 @@
     RefPtr<WebGPURenderPipeline> createRenderPipeline(WebGPURenderPipelineDescriptor&&) const;
 
     RefPtr<WebGPUCommandBuffer> createCommandBuffer() const;
+    RefPtr<WebGPUQueue> getQueue();
 
 private:
     WebGPUDevice(Ref<WebGPUAdapter>&&, RefPtr<GPUDevice>&&);
 
     Ref<WebGPUAdapter> m_adapter;
-
     RefPtr<GPUDevice> m_device;
+    RefPtr<WebGPUQueue> m_queue;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl (238450 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl	2018-11-22 21:17:41 UTC (rev 238451)
@@ -39,25 +39,24 @@
     // FIXME: Currently, WebGPUCommandBufferDescriptor is an empty dictionary.
     WebGPUCommandBuffer createCommandBuffer(/*WebGPUCommandBufferDescriptor descriptor*/);
 
-/* To Be Implemented:
-    WebGPUBuffer createBuffer(WebGPUBufferDescriptor descriptor);
-    WebGPUTexture createTexture(WebGPUTextureDescriptor descriptor);
-    WebGPUSampler createSampler(WebGPUSamplerDescriptor descriptor);
-
-    WebGPUBindGroupLayout createBindGroupLayout(WebGPUBindGroupLayoutDescriptor descriptor);
-    WebGPUPipelineLayout createPipelineLayout(WebGPUPipelineLayoutDescriptor descriptor);
-    WebGPUBindGroup createBindGroup(WebGPUBindGroupDescriptor descriptor);
-
-    WebGPUBlendState createBlendState(WebGPUBlendStateDescriptor descriptor);
-    WebGPUDepthStencilState createDepthStencilState(WebGPUDepthStencilStateDescriptor descriptor);
-    WebGPUInputState createInputState(WebGPUInputStateDescriptor descriptor);
-    WebGPUAttachmentState createAttachmentState(WebGPUAttachmentStateDescriptor descriptor);
-    WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);
-    WebGPUFence createFence(WebGPUFenceDescriptor descriptor);
-
     WebGPUQueue getQueue();
 
-    attribute WebGPULogCallback onLog;
-    WebGPUObjectStatusQuery getObjectStatus(StatusableObject statusableObject);
-*/
+    // FIXME: Unimplemented.
+    // WebGPUBuffer createBuffer(WebGPUBufferDescriptor descriptor);
+    // WebGPUTexture createTexture(WebGPUTextureDescriptor descriptor);
+    // WebGPUSampler createSampler(WebGPUSamplerDescriptor descriptor);
+    //
+    // WebGPUBindGroupLayout createBindGroupLayout(WebGPUBindGroupLayoutDescriptor descriptor);
+    // WebGPUPipelineLayout createPipelineLayout(WebGPUPipelineLayoutDescriptor descriptor);
+    // WebGPUBindGroup createBindGroup(WebGPUBindGroupDescriptor descriptor);
+    //
+    // WebGPUBlendState createBlendState(WebGPUBlendStateDescriptor descriptor);
+    // WebGPUDepthStencilState createDepthStencilState(WebGPUDepthStencilStateDescriptor descriptor);
+    // WebGPUInputState createInputState(WebGPUInputStateDescriptor descriptor);
+    // WebGPUAttachmentState createAttachmentState(WebGPUAttachmentStateDescriptor descriptor);
+    // WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);
+    // WebGPUFence createFence(WebGPUFenceDescriptor descriptor);
+    //
+    // attribute WebGPULogCallback onLog;
+    // WebGPUObjectStatusQuery getObjectStatus(StatusableObject statusableObject);
 };

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp (from rev 238450, trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h) (0 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp	2018-11-22 21:17:41 UTC (rev 238451)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGPUQueue.h"
+
+#if ENABLE(WEBGPU)
+
+#include "GPUCommandBuffer.h"
+#include "GPUQueue.h"
+#include "WebGPUCommandBuffer.h"
+
+namespace WebCore {
+
+RefPtr<WebGPUQueue> WebGPUQueue::create(RefPtr<GPUQueue>&& queue)
+{
+    if (!queue)
+        return nullptr;
+
+    return adoptRef(new WebGPUQueue(queue.releaseNonNull()));
+}
+
+WebGPUQueue::WebGPUQueue(Ref<GPUQueue>&& queue)
+    : m_queue(WTFMove(queue))
+{
+}
+
+void WebGPUQueue::submit(Vector<RefPtr<WebGPUCommandBuffer>>&& buffers)
+{
+    auto gpuBuffers = buffers.map([] (const auto& buffer) -> Ref<const GPUCommandBuffer> {
+        return buffer->commandBuffer();
+    });
+    m_queue->submit(WTFMove(gpuBuffers));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h (from rev 238450, trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h) (0 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h	2018-11-22 21:17:41 UTC (rev 238451)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include "GPUQueue.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class WebGPUCommandBuffer;
+
+class WebGPUQueue : public RefCounted<WebGPUQueue> {
+public:
+    static RefPtr<WebGPUQueue> create(RefPtr<GPUQueue>&&);
+
+    void submit(Vector<RefPtr<WebGPUCommandBuffer>>&&);
+
+    String label() const { return m_queue->label(); }
+    void setLabel(const String& label) { m_queue->setLabel(label); }
+
+private:
+    WebGPUQueue(Ref<GPUQueue>&&);
+
+    Ref<GPUQueue> m_queue;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.idl (from rev 238450, trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h) (0 => 238451)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.idl	2018-11-22 21:17:41 UTC (rev 238451)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+[
+    Conditional=WEBGPU,
+    EnabledAtRuntime=WebGPU,
+    ImplementationLacksVTable
+] interface WebGPUQueue {
+    void submit(sequence<WebGPUCommandBuffer> buffers);
+
+    // FIXME: Unimplemented.
+    // void signal(WebGPUFence fence, u64 signalValue);
+    // void wait(WebGPUFence fence, u64 valueToWait);
+};
\ No newline at end of file

Modified: trunk/Source/WebCore/Sources.txt (238450 => 238451)


--- trunk/Source/WebCore/Sources.txt	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/Sources.txt	2018-11-22 21:17:41 UTC (rev 238451)
@@ -305,6 +305,7 @@
 Modules/webgpu/WebGPUAdapter.cpp
 Modules/webgpu/WebGPUCommandBuffer.cpp
 Modules/webgpu/WebGPUDevice.cpp
+Modules/webgpu/WebGPUQueue.cpp
 Modules/webgpu/WebGPURenderingContext.cpp
 Modules/webgpu/WebGPURenderPipeline.cpp
 Modules/webgpu/WebGPUShaderModule.cpp
@@ -3214,6 +3215,7 @@
 JSWebGPUAdapterDescriptor.cpp
 JSWebGPUCommandBuffer.cpp
 JSWebGPUDevice.cpp
+JSWebGPUQueue.cpp
 JSWebGPUPipelineDescriptorBase.cpp
 JSWebGPUPipelineStageDescriptor.cpp
 JSWebGPURenderingContext.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238450 => 238451)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-11-22 21:17:41 UTC (rev 238451)
@@ -6940,6 +6940,11 @@
 		312FF90E21A4C33F00EB199D /* GPULegacyRenderPipelineState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPULegacyRenderPipelineState.h; sourceTree = "<group>"; };
 		312FF90F21A4C33F00EB199D /* GPULegacyCommandQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPULegacyCommandQueue.cpp; sourceTree = "<group>"; };
 		312FF91021A4C33F00EB199D /* GPULegacyFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPULegacyFunction.h; sourceTree = "<group>"; };
+		312FF93921A61C9F00EB199D /* WebGPUQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGPUQueue.h; sourceTree = "<group>"; };
+		312FF93B21A61CA000EB199D /* WebGPUQueue.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGPUQueue.idl; sourceTree = "<group>"; };
+		312FF93C21A61CA100EB199D /* WebGPUQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUQueue.cpp; sourceTree = "<group>"; };
+		312FF93D21A61F0700EB199D /* JSWebGPUQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebGPUQueue.h; path = JSWebGPUQueue.h; sourceTree = "<group>"; };
+		312FF93E21A61F0700EB199D /* JSWebGPUQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebGPUQueue.cpp; path = JSWebGPUQueue.cpp; sourceTree = "<group>"; };
 		313171541FB079D1008D91FC /* CanvasBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasBase.h; sourceTree = "<group>"; };
 		313171571FB0969E008D91FC /* CanvasBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasBase.cpp; sourceTree = "<group>"; };
 		313591001E7DDC6000F30630 /* RTCIceConnectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceConnectionState.h; sourceTree = "<group>"; };
@@ -22729,6 +22734,8 @@
 				31A0892F1E738D59003B6609 /* JSWebGPUFunction.h */,
 				31A089301E738D59003B6609 /* JSWebGPULibrary.cpp */,
 				31A089321E738D59003B6609 /* JSWebGPULibrary.h */,
+				312FF93E21A61F0700EB199D /* JSWebGPUQueue.cpp */,
+				312FF93D21A61F0700EB199D /* JSWebGPUQueue.h */,
 				31A089331E738D59003B6609 /* JSWebGPURenderCommandEncoder.cpp */,
 				31A089351E738D59003B6609 /* JSWebGPURenderCommandEncoder.h */,
 				31A089361E738D59003B6609 /* JSWebGPURenderingContext.cpp */,
@@ -25672,6 +25679,9 @@
 				D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */,
 				D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */,
 				D0C419EC2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.idl */,
+				312FF93C21A61CA100EB199D /* WebGPUQueue.cpp */,
+				312FF93921A61C9F00EB199D /* WebGPUQueue.h */,
+				312FF93B21A61CA000EB199D /* WebGPUQueue.idl */,
 				D093D2292179541600329217 /* WebGPURenderingContext.cpp */,
 				D093D225217951D400329217 /* WebGPURenderingContext.h */,
 				D093D227217951D400329217 /* WebGPURenderingContext.idl */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (238450 => 238451)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-11-22 21:17:41 UTC (rev 238451)
@@ -181,6 +181,7 @@
     macro(WebGPUAdapter) \
     macro(WebGPUDevice) \
     macro(WebGPUCommandBuffer) \
+    macro(WebGPUQueue) \
     macro(WebGPURenderingContext) \
     macro(WebGPURenderPipeline) \
     macro(WebGPUShaderStage) \

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h (238450 => 238451)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h	2018-11-22 21:17:41 UTC (rev 238451)
@@ -35,11 +35,12 @@
 
 namespace WebCore {
 
-class GPUDevice;
-
 using PlatformQueue = MTLCommandQueue;
 using PlatformQueueSmartPtr = RetainPtr<MTLCommandQueue>;
 
+class GPUCommandBuffer;
+class GPUDevice;
+
 class GPUQueue : public RefCounted<GPUQueue> {
 public:
     static RefPtr<GPUQueue> create(const GPUDevice&);
@@ -46,6 +47,11 @@
 
     PlatformQueue* platformQueue() const { return m_platformQueue.get(); }
 
+    void submit(Vector<Ref<const GPUCommandBuffer>>&&);
+
+    String label() const;
+    void setLabel(const String&) const;
+
 private:
     GPUQueue(PlatformQueueSmartPtr&&);
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm (238450 => 238451)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm	2018-11-22 20:32:52 UTC (rev 238450)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm	2018-11-22 21:17:41 UTC (rev 238451)
@@ -33,13 +33,17 @@
 
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
+#import <wtf/text/WTFString.h>
 
 namespace WebCore {
 
+static NSString * const commandQueueDefaultLabel = @"com.apple.WebKit";
+static NSString * const commandQueueLabelPrefix = @"com.apple.WebKit.";
+
 RefPtr<GPUQueue> GPUQueue::create(const GPUDevice& device)
 {
     if (!device.platformDevice()) {
-        LOG(WebGPU, "GPUQueue::create(): Invalid GPUDevice!");
+        LOG(WebGPU, "GPUQueue::create(): Invalid GPUDevice.");
         return nullptr;
     }
 
@@ -48,11 +52,12 @@
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     queue = adoptNS([device.platformDevice() newCommandQueue]);
+    [queue setLabel:commandQueueDefaultLabel];
 
     END_BLOCK_OBJC_EXCEPTIONS;
 
     if (!queue) {
-        LOG(WebGPU, "GPUQueue::create(): Unable to create MTLCommandQueue!");
+        LOG(WebGPU, "GPUQueue::create(): Unable to create MTLCommandQueue.");
         return nullptr;
     }
 
@@ -64,6 +69,33 @@
 {
 }
 
+void GPUQueue::submit(Vector<Ref<const GPUCommandBuffer>>&&)
+{
+    // FIXME: Missing implementation.
+}
+
+String GPUQueue::label() const
+{
+    if (!m_platformQueue)
+        return emptyString();
+
+    NSString *prefixedLabel = [m_platformQueue label];
+
+    if ([prefixedLabel isEqualToString:commandQueueDefaultLabel])
+        return emptyString();
+
+    ASSERT(prefixedLabel.length > commandQueueLabelPrefix.length);
+    return [prefixedLabel substringFromIndex:commandQueueLabelPrefix.length];
+}
+
+void GPUQueue::setLabel(const String& label) const
+{
+    if (label.isEmpty())
+        [m_platformQueue setLabel:commandQueueDefaultLabel];
+    else
+        [m_platformQueue setLabel:[commandQueueLabelPrefix stringByAppendingString:label]];
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGPU)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to