Title: [239853] trunk
Revision
239853
Author
justin_...@apple.com
Date
2019-01-10 18:12:57 -0800 (Thu, 10 Jan 2019)

Log Message

[WebGPU] WebGPUBindGroup and device::createBindGroup prototype
https://bugs.webkit.org/show_bug.cgi?id=193341

Reviewed by Myles C. Maxfield.

Source/WebCore:

Add *GPUBindGroup class stubs and the ability to create WebGPUBindGroups via the API.

Test: bind-groups.html

* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:

* Modules/webgpu/WebGPUBindGroup.cpp:
(WebCore::WebGPUBindGroup::create):
(WebCore::WebGPUBindGroup::WebGPUBindGroup):
* Modules/webgpu/WebGPUBindGroup.h:
* Modules/webgpu/WebGPUBindGroup.idl: Enable createBindGroup().
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::BindingResourceVisitor::operator() const): Added. Validate and convert WebGPUBindGroupDescriptor to GPU* version.
(WebCore::WebGPUDevice::createBindGroup const): Added.
* Modules/webgpu/WebGPUDevice.h:
* platform/graphics/gpu/GPUBindGroup.cpp:
(WebCore::GPUBindGroup::create):
(WebCore::GPUBindGroup::GPUBindGroup):
* platform/graphics/gpu/GPUBindGroup.h:
* platform/graphics/gpu/GPUBufferBinding.h:
* platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm:
(WebCore::appendArgumentToArray): Pass RetainPtr by reference to actually update descriptor.

LayoutTests:

Small test that creates a WebGPUBindGroup.

* webgpu/bind-groups-expected.txt: Added.
* webgpu/bind-groups.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239852 => 239853)


--- trunk/LayoutTests/ChangeLog	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/LayoutTests/ChangeLog	2019-01-11 02:12:57 UTC (rev 239853)
@@ -1,3 +1,15 @@
+2019-01-10  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] WebGPUBindGroup and device::createBindGroup prototype
+        https://bugs.webkit.org/show_bug.cgi?id=193341
+
+        Reviewed by Myles C. Maxfield.
+
+        Small test that creates a WebGPUBindGroup.
+
+        * webgpu/bind-groups-expected.txt: Added.
+        * webgpu/bind-groups.html: Added.
+
 2019-01-10  Eric Carlson  <eric.carl...@apple.com>
 
         Define page media state flags for display capture.

Added: trunk/LayoutTests/webgpu/bind-groups-expected.txt (0 => 239853)


--- trunk/LayoutTests/webgpu/bind-groups-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/bind-groups-expected.txt	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,3 @@
+
+PASS Create a basic WebGPUBindGroup via WebGPUDevice. 
+

Added: trunk/LayoutTests/webgpu/bind-groups.html (0 => 239853)


--- trunk/LayoutTests/webgpu/bind-groups.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/bind-groups.html	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,30 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<meta charset=utf-8>
+<title>Create a basic WebGPUBindGroup.</title>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script>
+promise_test(async () => {
+    const device = await getBasicDevice();
+
+    // WebGPUBindGroupLayoutBindings
+    // FIXME: Also test sampled texture bindings. 
+    const bufferLayoutBinding = {
+        binding: 1,
+        visibility: WebGPUShaderStageBit.VERTEX,
+        type: "storageBuffer"
+    };
+
+    const bindGroupLayout = device.createBindGroupLayout({ bindings: [bufferLayoutBinding]});
+
+    const buffer = device.createBuffer({ size: 16, usage: WebGPUBufferUsage.STORAGE });
+    const bufferBinding = { buffer: buffer, offset: 0, size: 16 };
+    const bindGroupBinding = { binding: 1, resource: bufferBinding };
+
+    const bindGroup = device.createBindGroup({ layout: bindGroupLayout, bindings: [bindGroupBinding]});
+    assert_true(bindGroup instanceof WebGPUBindGroup, "WebGPUBindGroup successfully created.")
+}, "Create a basic WebGPUBindGroup via WebGPUDevice.")
+</script>
+</body>
\ No newline at end of file

Modified: trunk/Source/WebCore/CMakeLists.txt (239852 => 239853)


--- trunk/Source/WebCore/CMakeLists.txt	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/CMakeLists.txt	2019-01-11 02:12:57 UTC (rev 239853)
@@ -464,6 +464,7 @@
     Modules/webgpu/WebGPU.idl
     Modules/webgpu/WebGPUAdapter.idl
     Modules/webgpu/WebGPUAdapterDescriptor.idl
+    Modules/webgpu/WebGPUBindGroup.idl
     Modules/webgpu/WebGPUBindGroupBinding.idl
     Modules/webgpu/WebGPUBindGroupDescriptor.idl
     Modules/webgpu/WebGPUBindGroupLayout.idl

Modified: trunk/Source/WebCore/ChangeLog (239852 => 239853)


--- trunk/Source/WebCore/ChangeLog	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/ChangeLog	2019-01-11 02:12:57 UTC (rev 239853)
@@ -1,3 +1,37 @@
+2019-01-10  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] WebGPUBindGroup and device::createBindGroup prototype
+        https://bugs.webkit.org/show_bug.cgi?id=193341
+
+        Reviewed by Myles C. Maxfield.
+
+        Add *GPUBindGroup class stubs and the ability to create WebGPUBindGroups via the API.
+
+        Test: bind-groups.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+
+        * Modules/webgpu/WebGPUBindGroup.cpp:
+        (WebCore::WebGPUBindGroup::create):
+        (WebCore::WebGPUBindGroup::WebGPUBindGroup):
+        * Modules/webgpu/WebGPUBindGroup.h:
+        * Modules/webgpu/WebGPUBindGroup.idl: Enable createBindGroup().
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::BindingResourceVisitor::operator() const): Added. Validate and convert WebGPUBindGroupDescriptor to GPU* version.
+        (WebCore::WebGPUDevice::createBindGroup const): Added.
+        * Modules/webgpu/WebGPUDevice.h:
+        * platform/graphics/gpu/GPUBindGroup.cpp:
+        (WebCore::GPUBindGroup::create):
+        (WebCore::GPUBindGroup::GPUBindGroup):
+        * platform/graphics/gpu/GPUBindGroup.h:
+        * platform/graphics/gpu/GPUBufferBinding.h:
+        * platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm:
+        (WebCore::appendArgumentToArray): Pass RetainPtr by reference to actually update descriptor.
+
 2019-01-10  Simon Fraser  <simon.fra...@apple.com>
 
         Fix rare crash under ScrollbarThemeMac::paintScrollCorner()

Modified: trunk/Source/WebCore/DerivedSources.make (239852 => 239853)


--- trunk/Source/WebCore/DerivedSources.make	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/DerivedSources.make	2019-01-11 02:12:57 UTC (rev 239853)
@@ -375,6 +375,7 @@
     $(WebCore)/Modules/webgpu/WebGPU.idl \
     $(WebCore)/Modules/webgpu/WebGPUAdapter.idl \
     $(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \
+    $(WebCore)/Modules/webgpu/WebGPUBindGroup.idl \
     $(WebCore)/Modules/webgpu/WebGPUBindGroupBinding.idl \
     $(WebCore)/Modules/webgpu/WebGPUBindGroupDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUBindGroupLayout.idl \

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp (from rev 239852, trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h) (0 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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 "WebGPUBindGroup.h"
+
+#if ENABLE(WEBGPU)
+
+namespace WebCore {
+
+Ref<WebGPUBindGroup> WebGPUBindGroup::create(RefPtr<GPUBindGroup>&& bindGroup)
+{
+    return adoptRef(*new WebGPUBindGroup(WTFMove(bindGroup)));
+}
+
+WebGPUBindGroup::WebGPUBindGroup(RefPtr<GPUBindGroup>&& bindGroup)
+    : m_bindGroup(WTFMove(bindGroup))
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h (from rev 239852, trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h) (0 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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 "GPUBindGroup.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class WebGPUBindGroup : public RefCounted<WebGPUBindGroup> {
+public:
+    static Ref<WebGPUBindGroup> create(RefPtr<GPUBindGroup>&&);
+
+private:
+    explicit WebGPUBindGroup(RefPtr<GPUBindGroup>&&);
+
+    RefPtr<GPUBindGroup> m_bindGroup;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl (from rev 239852, trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h) (0 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 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 WebGPUBindGroup {
+};

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (239852 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-01-11 02:12:57 UTC (rev 239853)
@@ -28,13 +28,21 @@
 
 #if ENABLE(WEBGPU)
 
+#include "GPUBindGroup.h"
+#include "GPUBindGroupBinding.h"
+#include "GPUBindGroupDescriptor.h"
+#include "GPUBufferBinding.h"
 #include "GPUCommandBuffer.h"
 #include "GPUPipelineStageDescriptor.h"
 #include "GPURenderPipelineDescriptor.h"
 #include "GPUShaderModuleDescriptor.h"
 #include "Logging.h"
+#include "WebGPUBindGroup.h"
+#include "WebGPUBindGroupBinding.h"
+#include "WebGPUBindGroupDescriptor.h"
 #include "WebGPUBindGroupLayout.h"
 #include "WebGPUBuffer.h"
+#include "WebGPUBufferBinding.h"
 #include "WebGPUCommandBuffer.h"
 #include "WebGPUPipelineLayout.h"
 #include "WebGPUPipelineLayoutDescriptor.h"
@@ -44,6 +52,7 @@
 #include "WebGPURenderPipelineDescriptor.h"
 #include "WebGPUShaderModule.h"
 #include "WebGPUShaderModuleDescriptor.h"
+#include <wtf/Variant.h>
 
 namespace WebCore {
 
@@ -85,6 +94,39 @@
     return WebGPUPipelineLayout::create(WTFMove(layout));
 }
 
+Ref<WebGPUBindGroup> WebGPUDevice::createBindGroup(WebGPUBindGroupDescriptor&& descriptor) const
+{
+    if (!descriptor.layout || !descriptor.layout->bindGroupLayout()) {
+        LOG(WebGPU, "WebGPUDevice::createBindGroup: Invalid WebGPUBindGroupLayout!");
+        return WebGPUBindGroup::create(nullptr);
+    }
+
+    auto bindingResourceVisitor = WTF::makeVisitor([] (RefPtr<WebGPUTextureView> view) -> Optional<GPUBindingResource> {
+        if (view)
+            return static_cast<GPUBindingResource>(view->texture());
+        return WTF::nullopt;
+    }, [] (const WebGPUBufferBinding& binding) -> Optional<GPUBindingResource> {
+        if (binding.buffer)
+            return static_cast<GPUBindingResource>(GPUBufferBinding { binding.buffer->buffer(), binding.offset, binding.size });
+        return WTF::nullopt;
+    });
+
+    Vector<GPUBindGroupBinding> bindGroupBindings;
+    bindGroupBindings.reserveCapacity(descriptor.bindings.size());
+
+    for (const auto& binding : descriptor.bindings) {
+        auto bindingResource = WTF::visit(bindingResourceVisitor, binding.resource);
+        if (bindingResource)
+            bindGroupBindings.uncheckedAppend(GPUBindGroupBinding { binding.binding, WTFMove(bindingResource.value()) });
+        else {
+            LOG(WebGPU, "WebGPUDevice::createBindGroup: Invalid WebGPUBindingResource in WebGPUBindGroupBindings!");
+            return WebGPUBindGroup::create(nullptr);
+        }
+    }
+    auto bindGroup = GPUBindGroup::create(GPUBindGroupDescriptor { descriptor.layout->bindGroupLayout().releaseNonNull(), WTFMove(bindGroupBindings) });
+    return WebGPUBindGroup::create(WTFMove(bindGroup));
+}
+
 RefPtr<WebGPUShaderModule> WebGPUDevice::createShaderModule(WebGPUShaderModuleDescriptor&& descriptor) const
 {
     // FIXME: What can be validated here?

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h (239852 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2019-01-11 02:12:57 UTC (rev 239853)
@@ -40,6 +40,7 @@
 namespace WebCore {
 
 class ScriptExecutionContext;
+class WebGPUBindGroup;
 class WebGPUBindGroupLayout;
 class WebGPUBuffer;
 class WebGPUCommandBuffer;
@@ -47,6 +48,7 @@
 class WebGPURenderPipeline;
 class WebGPUShaderModule;
 
+struct WebGPUBindGroupDescriptor;
 struct WebGPUPipelineLayoutDescriptor;
 struct WebGPURenderPipelineDescriptor;
 struct WebGPUShaderModuleDescriptor;
@@ -62,6 +64,7 @@
 
     Ref<WebGPUBindGroupLayout> createBindGroupLayout(WebGPUBindGroupLayoutDescriptor&&) const;
     Ref<WebGPUPipelineLayout> createPipelineLayout(WebGPUPipelineLayoutDescriptor&&) const;
+    Ref<WebGPUBindGroup> createBindGroup(WebGPUBindGroupDescriptor&&) const;
 
     RefPtr<WebGPUShaderModule> createShaderModule(WebGPUShaderModuleDescriptor&&) const;
     RefPtr<WebGPURenderPipeline> createRenderPipeline(WebGPURenderPipelineDescriptor&&) const;

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl (239852 => 239853)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl	2019-01-11 02:12:57 UTC (rev 239853)
@@ -37,6 +37,7 @@
 
     WebGPUBindGroupLayout createBindGroupLayout(WebGPUBindGroupLayoutDescriptor descriptor);
     WebGPUPipelineLayout createPipelineLayout(WebGPUPipelineLayoutDescriptor descriptor);
+    WebGPUBindGroup createBindGroup(WebGPUBindGroupDescriptor descriptor);
 
     WebGPUShaderModule createShaderModule(WebGPUShaderModuleDescriptor descriptor);
     WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor);

Modified: trunk/Source/WebCore/Sources.txt (239852 => 239853)


--- trunk/Source/WebCore/Sources.txt	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/Sources.txt	2019-01-11 02:12:57 UTC (rev 239853)
@@ -321,6 +321,7 @@
 Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp
 Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp
 Modules/webgpu/WebGPU.cpp
+Modules/webgpu/WebGPUBindGroup.cpp
 Modules/webgpu/WebGPUAdapter.cpp
 Modules/webgpu/WebGPUBindGroupLayout.cpp
 Modules/webgpu/WebGPUBuffer.cpp
@@ -1763,6 +1764,7 @@
 platform/graphics/filters/SourceGraphic.cpp
 platform/graphics/filters/SpotLightSource.cpp
 
+platform/graphics/gpu/GPUBindGroup.cpp
 platform/graphics/gpu/GPUDevice.cpp
 platform/graphics/gpu/GPUPipelineLayout.cpp
 platform/graphics/gpu/legacy/GPULegacyBuffer.cpp
@@ -3248,6 +3250,7 @@
 JSWebGPU.cpp
 JSWebGPUAdapter.cpp
 JSWebGPUAdapterDescriptor.cpp
+JSWebGPUBindGroup.cpp
 JSWebGPUBindGroupBinding.cpp
 JSWebGPUBindGroupDescriptor.cpp
 JSWebGPUBindGroupLayout.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239852 => 239853)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-01-11 02:12:57 UTC (rev 239853)
@@ -13978,6 +13978,11 @@
 		D0BE105121E6A70E00E42A89 /* GPUBindGroupDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupDescriptor.h; sourceTree = "<group>"; };
 		D0BE105221E6AA0D00E42A89 /* WebGPUBindGroupDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBindGroupDescriptor.h; sourceTree = "<group>"; };
 		D0BE105321E6AA0D00E42A89 /* WebGPUBindGroupDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroupDescriptor.idl; sourceTree = "<group>"; };
+		D0BE105E21E6BAD300E42A89 /* GPUBindGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroup.h; sourceTree = "<group>"; };
+		D0BE105F21E6BAD300E42A89 /* GPUBindGroup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBindGroup.cpp; sourceTree = "<group>"; };
+		D0BE106021E6C0EB00E42A89 /* WebGPUBindGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBindGroup.h; sourceTree = "<group>"; };
+		D0BE106121E6C0EB00E42A89 /* WebGPUBindGroup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUBindGroup.cpp; sourceTree = "<group>"; };
+		D0BE106221E6C0EB00E42A89 /* WebGPUBindGroup.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroup.idl; sourceTree = "<group>"; };
 		D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUPipelineStageDescriptor.h; sourceTree = "<group>"; };
 		D0C419EC2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUPipelineStageDescriptor.idl; sourceTree = "<group>"; };
 		D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUPipelineDescriptorBase.h; sourceTree = "<group>"; };
@@ -18177,6 +18182,8 @@
 			children = (
 				D087CE3721ACA94200BDE174 /* cocoa */,
 				312FF8CE21A4C33F00EB199D /* legacy */,
+				D0BE105F21E6BAD300E42A89 /* GPUBindGroup.cpp */,
+				D0BE105E21E6BAD300E42A89 /* GPUBindGroup.h */,
 				D0BE104E21E695E200E42A89 /* GPUBindGroupBinding.h */,
 				D0BE105121E6A70E00E42A89 /* GPUBindGroupDescriptor.h */,
 				D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */,
@@ -25822,6 +25829,9 @@
 				D00F5951216FFAC2000D71DB /* WebGPUAdapter.idl */,
 				D02C26912181416D00D818E4 /* WebGPUAdapterDescriptor.h */,
 				D02C26922181416D00D818E4 /* WebGPUAdapterDescriptor.idl */,
+				D0BE106121E6C0EB00E42A89 /* WebGPUBindGroup.cpp */,
+				D0BE106021E6C0EB00E42A89 /* WebGPUBindGroup.h */,
+				D0BE106221E6C0EB00E42A89 /* WebGPUBindGroup.idl */,
 				D0BE104F21E69F8300E42A89 /* WebGPUBindGroupBinding.h */,
 				D0BE105021E69F8300E42A89 /* WebGPUBindGroupBinding.idl */,
 				D0BE105221E6AA0D00E42A89 /* WebGPUBindGroupDescriptor.h */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (239852 => 239853)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2019-01-11 02:12:57 UTC (rev 239853)
@@ -190,6 +190,7 @@
     macro(WebGLVertexArrayObject) \
     macro(WebGPU) \
     macro(WebGPUAdapter) \
+    macro(WebGPUBindGroup) \
     macro(WebGPUBindGroupLayout) \
     macro(WebGPUBuffer) \
     macro(WebGPUBufferUsage) \

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp (from rev 239852, trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h) (0 => 239853)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 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 "GPUBindGroup.h"
+
+#if ENABLE(WEBGPU)
+
+#include "GPUBindGroupBinding.h"
+#include "GPUBindGroupDescriptor.h"
+
+namespace WebCore {
+
+Ref<GPUBindGroup> GPUBindGroup::create(GPUBindGroupDescriptor&& descriptor)
+{
+    // FIXME: Unfinished stub.
+    return adoptRef(*new GPUBindGroup(WTFMove(descriptor)));
+}
+
+GPUBindGroup::GPUBindGroup(GPUBindGroupDescriptor&& descriptor)
+    : m_layout(WTFMove(descriptor.layout))
+    , m_bindings(WTFMove(descriptor.bindings))
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h (from rev 239852, trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h) (0 => 239853)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h	2019-01-11 02:12:57 UTC (rev 239853)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 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 "GPUBindGroupBinding.h"
+#include "GPUBindGroupLayout.h"
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+struct GPUBindGroupDescriptor;
+
+class GPUBindGroup : public RefCounted<GPUBindGroup> {
+public:
+    static Ref<GPUBindGroup> create(GPUBindGroupDescriptor&&);
+
+private:
+    GPUBindGroup(GPUBindGroupDescriptor&&);
+
+    Ref<GPUBindGroupLayout> m_layout;
+    Vector<GPUBindGroupBinding> m_bindings;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h (239852 => 239853)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h	2019-01-11 02:12:57 UTC (rev 239853)
@@ -33,7 +33,7 @@
 namespace WebCore {
 
 struct GPUBufferBinding {
-    Ref<GPUBuffer> buffer;
+    Ref<const GPUBuffer> buffer;
     unsigned long offset;
     unsigned long size;
 };

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm (239852 => 239853)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm	2019-01-11 01:42:34 UTC (rev 239852)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm	2019-01-11 02:12:57 UTC (rev 239853)
@@ -51,7 +51,7 @@
 }
 
 using ArgumentArray = RetainPtr<NSMutableArray<MTLArgumentDescriptor *>>;
-static void appendArgumentToArray(ArgumentArray array, RetainPtr<MTLArgumentDescriptor> argument)
+static void appendArgumentToArray(ArgumentArray& array, RetainPtr<MTLArgumentDescriptor> argument)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     if (!array)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to