WebKit Bugzilla
Attachment 358856 Details for
Bug 193341
: [WebGPU] WebGPUBindGroup and device::createBindGroup prototype
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-193341-20190110173429.patch (text/plain), 27.29 KB, created by
Justin Fan
on 2019-01-10 17:34:30 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Justin Fan
Created:
2019-01-10 17:34:30 PST
Size:
27.29 KB
patch
obsolete
>Subversion Revision: 239839 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7f8b9e5f0355a44354b7897e14a614040c5f5f40..4fe3bf0cfb4eec8195bf3394015756d6746dc30b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2019-01-10 Justin Fan <justin_fan@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 Justin Fan <justin_fan@apple.com> > > [WebGPU] Add BindGroupBinding, BindGroupDescriptor, and BufferBinding dictionaries from API >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 1dd5329a9b596798239e7e2a71405873e402044c..f2775ebb3932a4f308be341440b13ad92d6b2ea8 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -464,6 +464,7 @@ set(WebCore_NON_SVG_IDL_FILES > 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 >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index e17c6afa7a7c013191c8c3e9757f36eb60fb3e55..8c20c49453446f531d6de917aa26f8c8f75519d4 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -375,6 +375,7 @@ JS_BINDING_IDLS = \ > $(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 \ >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b48fe1df163fc55acbcc51a7420906f2dc164f88 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.cpp >@@ -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) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0a04709553bd4e9acaf2f8a1a1458e17131bcb83 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h >@@ -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) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..290b0e12cda93a2f6d2be9ee48a7a462d7e78551 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUBindGroup.idl >@@ -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 { >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >index 2ffa3b7a6d8a9adfb37c1f44cc6699e06c7e53c5..3c4c0eb251ac7c82307faa73ff7af903ab3d75c4 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >@@ -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 @@ Ref<WebGPUPipelineLayout> WebGPUDevice::createPipelineLayout(WebGPUPipelineLayou > 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? >diff --git a/Source/WebCore/Modules/webgpu/WebGPUDevice.h b/Source/WebCore/Modules/webgpu/WebGPUDevice.h >index 44cce05ba5ce4c83ad59e444f6b6dad66d0c3b3e..8998ad63cd0f9baad06e324f5605c4e9a1bad321 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUDevice.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUDevice.h >@@ -40,6 +40,7 @@ > namespace WebCore { > > class ScriptExecutionContext; >+class WebGPUBindGroup; > class WebGPUBindGroupLayout; > class WebGPUBuffer; > class WebGPUCommandBuffer; >@@ -47,6 +48,7 @@ class WebGPUPipelineLayout; > class WebGPURenderPipeline; > class WebGPUShaderModule; > >+struct WebGPUBindGroupDescriptor; > struct WebGPUPipelineLayoutDescriptor; > struct WebGPURenderPipelineDescriptor; > struct WebGPUShaderModuleDescriptor; >@@ -62,6 +64,7 @@ public: > > 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; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUDevice.idl b/Source/WebCore/Modules/webgpu/WebGPUDevice.idl >index 7607d92e949a4be1eeb935cdda051d7b861061ea..f2b6774cd0de947bb54e849266f76abf8d7430ee 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUDevice.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPUDevice.idl >@@ -37,6 +37,7 @@ > > WebGPUBindGroupLayout createBindGroupLayout(WebGPUBindGroupLayoutDescriptor descriptor); > WebGPUPipelineLayout createPipelineLayout(WebGPUPipelineLayoutDescriptor descriptor); >+ WebGPUBindGroup createBindGroup(WebGPUBindGroupDescriptor descriptor); > > WebGPUShaderModule createShaderModule(WebGPUShaderModuleDescriptor descriptor); > WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor); >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 238ea7d338922097a66bff746ad40550dcfbca6f..840709b81226af84bc69231795924fb5fed12907 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -308,6 +308,7 @@ Modules/websockets/WorkerThreadableWebSocketChannel.cpp > Modules/webgpu/DOMWindowWebGPU.cpp > Modules/webgpu/WHLSL/WHLSLLexer.cpp > Modules/webgpu/WebGPU.cpp >+Modules/webgpu/WebGPUBindGroup.cpp > Modules/webgpu/WebGPUAdapter.cpp > Modules/webgpu/WebGPUBindGroupLayout.cpp > Modules/webgpu/WebGPUBuffer.cpp >@@ -1750,6 +1751,7 @@ platform/graphics/filters/SourceAlpha.cpp > 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 >@@ -3235,6 +3237,7 @@ JSWebAnimation.cpp > JSWebGPU.cpp > JSWebGPUAdapter.cpp > JSWebGPUAdapterDescriptor.cpp >+JSWebGPUBindGroup.cpp > JSWebGPUBindGroupBinding.cpp > JSWebGPUBindGroupDescriptor.cpp > JSWebGPUBindGroupLayout.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index b0832052e726d290a59965708378644d1e0cace7..985585ab1a0f8541dbfebd1fdb1770ee2efd53c9 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13889,6 +13889,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>"; }; >@@ -18088,6 +18093,8 @@ > children = ( > D087CE3721ACA94200BDE174 /* cocoa */, > 312FF8CE21A4C33F00EB199D /* legacy */, >+ D0BE105F21E6BAD300E42A89 /* GPUBindGroup.cpp */, >+ D0BE105E21E6BAD300E42A89 /* GPUBindGroup.h */, > D0BE104E21E695E200E42A89 /* GPUBindGroupBinding.h */, > D0BE105121E6A70E00E42A89 /* GPUBindGroupDescriptor.h */, > D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */, >@@ -25636,6 +25643,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 */, >diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >index 2ae1ecf78361d866821c6e9c83ed5c43bbec456c..555a9392b0f2ad39a097347a0f7b5068cfc8beb7 100644 >--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >@@ -190,6 +190,7 @@ namespace WebCore { > macro(WebGLVertexArrayObject) \ > macro(WebGPU) \ > macro(WebGPUAdapter) \ >+ macro(WebGPUBindGroup) \ > macro(WebGPUBindGroupLayout) \ > macro(WebGPUBuffer) \ > macro(WebGPUBufferUsage) \ >diff --git a/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp b/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..8dfd361ad9ea5c4834ddd27f797d1f609e28bc08 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp >@@ -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) >diff --git a/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h b/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h >new file mode 100644 >index 0000000000000000000000000000000000000000..eb7f29f4e127b02a7f935063000dfce24deb96f6 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h >@@ -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) >diff --git a/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h b/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h >index 91e08733c6934887421cf94a75c6636294d2349c..8248d8b8c901c53fb5432f701d280551c483ba4a 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h >@@ -33,7 +33,7 @@ > namespace WebCore { > > struct GPUBufferBinding { >- Ref<GPUBuffer> buffer; >+ Ref<const GPUBuffer> buffer; > unsigned long offset; > unsigned long size; > }; >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm >index 87680a83c0f4189882c3b849f28163fe712021b0..5a19e64178c3587dde499621ea9ee1782df98ef7 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm >@@ -51,7 +51,7 @@ static MTLDataType MTLDataTypeForBindingType(GPUBindGroupLayoutBinding::BindingT > } > > 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) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 21f778825d71b7f616592c26c2973a01df9804fc..f6d319ab503496b39c7924962b20bae43c3997d3 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2019-01-10 Justin Fan <justin_fan@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 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r239825. >diff --git a/LayoutTests/webgpu/bind-groups-expected.txt b/LayoutTests/webgpu/bind-groups-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..51eb7deb4813b3ac6ae5136d5009d2db8160a342 >--- /dev/null >+++ b/LayoutTests/webgpu/bind-groups-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Create a basic WebGPUBindGroup via WebGPUDevice. >+ >diff --git a/LayoutTests/webgpu/bind-groups.html b/LayoutTests/webgpu/bind-groups.html >new file mode 100644 >index 0000000000000000000000000000000000000000..18a8ebf6752f4a0f893c5cbdab3eadeb9a5e04d1 >--- /dev/null >+++ b/LayoutTests/webgpu/bind-groups.html >@@ -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="js/webgpu-functions.js"></script> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193341
:
358840
|
358852
| 358856