WebKit Bugzilla
Attachment 357179 Details for
Bug 192611
: [WebGPU] Vertex buffers and WebGPUInputState
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192611-20181212153751.patch (text/plain), 88.18 KB, created by
Justin Fan
on 2018-12-12 15:37:52 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Fan
Created:
2018-12-12 15:37:52 PST
Size:
88.18 KB
patch
obsolete
>Subversion Revision: 239098 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 74894db0f9c523424b12a709793683ce67610b4c..120bf87cebd9d7c3df30b8f4c4a55e154cbd0012 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,73 @@ >+2018-12-11 Justin Fan <justin_fan@apple.com> >+ >+ [WebGPU] Vertex buffers and WebGPUInputState >+ https://bugs.webkit.org/show_bug.cgi?id=192611 >+ >+ Reviewed by Dean Jackson. >+ >+ Test: webgpu/vertex-buffer-triangle-strip.html >+ >+ Basic implementation of vertex buffers with Metal shading language in WebGPU. In >+ WebGPURenderPipelineDescriptor, refactor to match updated shader stage structure and add >+ WebGPUInputStateDescriptor. Also implement WebGPURenderPassEncoder::setVertexBuffers. >+ >+ Add symbols and files for WebGPUIndexFormat, WebGPUInputStateDescriptor, WebGPUInputStepMode, >+ WebGPUVertexAttributeDescriptor, WebGPUVertexFormat, WebGPUVertexInputDescriptor: >+ * CMakeLists.txt: >+ * DerivedSources.make: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/js/WebCoreBuiltinNames.h: >+ >+ Add and implement interfaces and dictionaries for WebGPUInputState: >+ * Modules/webgpu/WebGPUBuffer.cpp: >+ (WebCore::WebGPUBuffer::WebGPUBuffer): >+ * Modules/webgpu/WebGPUBuffer.h: >+ (WebCore::WebGPUBuffer::buffer const): Added getter for backing GPUBuffer. >+ * Modules/webgpu/WebGPUBufferDescriptor.h: >+ * Modules/webgpu/WebGPUBufferDescriptor.idl: Moving WebGPUBufferUsage out into its own IDL. >+ * Modules/webgpu/WebGPUDevice.h: >+ * Modules/webgpu/WebGPUIndexFormat.h: Added. >+ * Modules/webgpu/WebGPUIndexFormat.idl: Added. >+ * Modules/webgpu/WebGPUInputStateDescriptor.h: Added. >+ * Modules/webgpu/WebGPUInputStateDescriptor.idl: Added. >+ * Modules/webgpu/WebGPUInputStepMode.h: Added. >+ * Modules/webgpu/WebGPUInputStepMode.idl: Added. >+ * Modules/webgpu/WebGPUVertexAttributeDescriptor.h: Added. >+ * Modules/webgpu/WebGPUVertexAttributeDescriptor.idl: Added. >+ * Modules/webgpu/WebGPUVertexFormat.h: Added. >+ * Modules/webgpu/WebGPUVertexFormat.idl: Added. >+ * Modules/webgpu/WebGPUVertexInputDescriptor.h: Added. >+ * Modules/webgpu/WebGPUVertexInputDescriptor.idl: Added. >+ * platform/graphics/gpu/GPUInputStateDescriptor.h: Added. >+ * platform/graphics/gpu/GPURenderPassEncoder.h: Added. >+ * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Added. >+ * platform/graphics/gpu/GPUVertexAttributeDescriptor.h: Added. >+ * platform/graphics/gpu/GPUVertexInputDescriptor.h: Added. >+ >+ Refactor to support updated structure of pipeline descriptor in sketch IDL: >+ * Modules/webgpu/WebGPUDevice.cpp: >+ (WebCore::validateAndConvertPipelineStage): >+ (WebCore::WebGPUDevice::createRenderPipeline const): >+ * Modules/webgpu/WebGPUPipelineDescriptorBase.h: >+ * Modules/webgpu/WebGPUPipelineDescriptorBase.idl: >+ * Modules/webgpu/WebGPUPipelineStageDescriptor.h: >+ * Modules/webgpu/WebGPUPipelineStageDescriptor.idl: >+ * Modules/webgpu/WebGPURenderPipelineDescriptor.h: >+ * Modules/webgpu/WebGPURenderPipelineDescriptor.idl: >+ * Modules/webgpu/WebGPUShaderStage.*: Removed. >+ >+ Add and implement setVertexBuffers: >+ * Modules/webgpu/WebGPURenderPassEncoder.cpp: >+ (WebCore::WebGPURenderPassEncoder::setVertexBuffers): Added. >+ * Modules/webgpu/WebGPURenderPassEncoder.h: >+ * Modules/webgpu/WebGPURenderPassEncoder.idl: >+ * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm: >+ (WebCore::GPURenderPassEncoder::setVertexBuffers): >+ * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: >+ (WebCore::setInputStateForPipelineDescriptor): >+ (WebCore::GPURenderPipeline::create): >+ > 2018-12-11 Justin Michaud <justin_michaud@apple.com> > > Implement feature flag for CSS Typed OM >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index cefb67febf82974131ee07b32e30ab8642de2c5f..0bdd29cde1808c25d5ce8a165455584786066fba 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -464,6 +464,9 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webgpu/WebGPUColor.idl > Modules/webgpu/WebGPUCommandBuffer.idl > Modules/webgpu/WebGPUDevice.idl >+ Modules/webgpu/WebGPUIndexFormat.idl >+ Modules/webgpu/WebGPUInputStateDescriptor.idl >+ Modules/webgpu/WebGPUInputStepMode.idl > Modules/webgpu/WebGPUPipelineDescriptorBase.idl > Modules/webgpu/WebGPUPipelineStageDescriptor.idl > Modules/webgpu/WebGPUProgrammablePassEncoder.idl >@@ -476,11 +479,13 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webgpu/WebGPURenderingContext.idl > Modules/webgpu/WebGPUShaderModule.idl > Modules/webgpu/WebGPUShaderModuleDescriptor.idl >- Modules/webgpu/WebGPUShaderStage.idl > Modules/webgpu/WebGPUSwapChain.idl > Modules/webgpu/WebGPUTexture.idl > Modules/webgpu/WebGPUTextureFormatEnum.idl > Modules/webgpu/WebGPUTextureView.idl >+ Modules/webgpu/WebGPUVertexAttributeDescriptor.idl >+ Modules/webgpu/WebGPUVertexFormat.idl >+ Modules/webgpu/WebGPUVertexInputDescriptor.idl > > Modules/websockets/CloseEvent.idl > Modules/websockets/WebSocket.idl >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index b3d4c4692fd5ddfd7ab46b90bd94c0da175aa755..f6f7e3516ae7465882cfbf30512754d9434637e6 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -381,6 +381,9 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webgpu/WebGPUColor.idl \ > $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \ > $(WebCore)/Modules/webgpu/WebGPUDevice.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUIndexFormat.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUInputStateDescriptor.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUInputStepMode.idl \ > $(WebCore)/Modules/webgpu/WebGPUQueue.idl \ > $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl \ > $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \ >@@ -393,11 +396,13 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webgpu/WebGPURenderingContext.idl \ > $(WebCore)/Modules/webgpu/WebGPUShaderModule.idl \ > $(WebCore)/Modules/webgpu/WebGPUShaderModuleDescriptor.idl \ >- $(WebCore)/Modules/webgpu/WebGPUShaderStage.idl \ > $(WebCore)/Modules/webgpu/WebGPUSwapChain.idl \ > $(WebCore)/Modules/webgpu/WebGPUTexture.idl \ > $(WebCore)/Modules/webgpu/WebGPUTextureFormatEnum.idl \ > $(WebCore)/Modules/webgpu/WebGPUTextureView.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUVertexFormat.idl \ >+ $(WebCore)/Modules/webgpu/WebGPUVertexInputDescriptor.idl \ > $(WebCore)/Modules/websockets/CloseEvent.idl \ > $(WebCore)/Modules/websockets/WebSocket.idl \ > $(WebCore)/Modules/webvr/DOMWindowWebVR.idl \ >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp b/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp >index 148daea5d1c91972ca1588f1cddf076c85827d2a..34941d0ea5f79251cb48ddebf741343f9e4ba709 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp >@@ -38,7 +38,6 @@ RefPtr<WebGPUBuffer> WebGPUBuffer::create(Ref<GPUBuffer>&& buffer) > WebGPUBuffer::WebGPUBuffer(Ref<GPUBuffer>&& buffer) > : m_buffer(WTFMove(buffer)) > { >- UNUSED_PARAM(m_buffer); > } > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBuffer.h b/Source/WebCore/Modules/webgpu/WebGPUBuffer.h >index 6336d5953ecc1de5f8439c057375c1b88e14cdde..e276425bd42b5d682fbe2428a4006e23f4923875 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUBuffer.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUBuffer.h >@@ -38,6 +38,8 @@ class WebGPUBuffer : public RefCounted<WebGPUBuffer> { > public: > static RefPtr<WebGPUBuffer> create(Ref<GPUBuffer>&&); > >+ const GPUBuffer& buffer() const { return m_buffer.get(); } >+ > JSC::ArrayBuffer* mapping() const { return m_buffer->mapping(); } > void unmap() { /* FIXME: Unimplemented stub. */ } > void destroy() { /* FIXME: Unimplemented stub. */ } >diff --git a/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h >index b303f09bb68ecc5e0b7e246ec749ca3068cd7540..c01df95084b2001a13715e098d1d90d7745e72ef 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h >@@ -33,7 +33,6 @@ namespace WebCore { > > using WebGPUBufferDescriptor = GPUBufferDescriptor; > using WebGPUBufferUsageFlags = GPUBufferUsageFlags; >-using WebGPUBufferUsage = GPUBufferUsage; > > } // namespace WebCore > >diff --git a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >index 7d6d0fc310a8cdff985ecfe37504165643b0b593..77ba4cbc08f96b1e322c69d487f705941286c438 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp >@@ -41,7 +41,6 @@ > #include "WebGPURenderPipelineDescriptor.h" > #include "WebGPUShaderModule.h" > #include "WebGPUShaderModuleDescriptor.h" >-#include "WebGPUShaderStage.h" > > namespace WebCore { > >@@ -72,59 +71,25 @@ RefPtr<WebGPUShaderModule> WebGPUDevice::createShaderModule(WebGPUShaderModuleDe > return module ? WebGPUShaderModule::create(module.releaseNonNull()) : nullptr; > } > >-RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const >+static std::optional<GPUPipelineStageDescriptor> validateAndConvertPipelineStage(const WebGPUPipelineStageDescriptor& descriptor) > { >- const char* const functionName = "WebGPUDevice::createRenderPipeline()"; >-#if LOG_DISABLED >- UNUSED_PARAM(functionName); >-#endif >+ if (!descriptor.module || !descriptor.module->module() || descriptor.entryPoint.isEmpty()) >+ return std::nullopt; > >- if (descriptor.stages.isEmpty()) { >- LOG(WebGPU, "%s: No stages in WebGPURenderPipelineDescriptor!", functionName); >- return nullptr; >- } >+ return GPUPipelineStageDescriptor { descriptor.module->module(), descriptor.entryPoint }; >+} > >- GPUPipelineStageDescriptor vertexStage; >- GPUPipelineStageDescriptor fragmentStage; >- >- for (const auto& stageDescriptor : descriptor.stages) { >- if (!stageDescriptor.module || !stageDescriptor.module->module() || stageDescriptor.entryPoint.isEmpty()) { >- LOG(WebGPU, "%s: Invalid WebGPUPipelineStageDescriptor!", functionName); >- return nullptr; >- } >- >- switch (stageDescriptor.stage) { >- case WebGPUShaderStage::VERTEX: >- if (vertexStage.module) { >- LOG(WebGPU, "%s: Multiple vertex stages in WebGPURenderPipelineDescriptor!", functionName); >- return nullptr; >- } >- >- vertexStage.module = stageDescriptor.module->module(); >- vertexStage.entryPoint = stageDescriptor.entryPoint; >- break; >- case WebGPUShaderStage::FRAGMENT: >- if (fragmentStage.module) { >- LOG(WebGPU, "%s: Multiple fragment stages in WebGPURenderPipelineDescriptor!", functionName); >- return nullptr; >- } >- >- fragmentStage.module = stageDescriptor.module->module(); >- fragmentStage.entryPoint = stageDescriptor.entryPoint; >- break; >- default: >- LOG(WebGPU, "%s: Invalid shader stage in WebGPURenderPipelineDescriptor!", functionName); >- return nullptr; >- } >- } >+RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const >+{ >+ auto vertexStage = validateAndConvertPipelineStage(descriptor.vertexStage); >+ auto fragmentStage = validateAndConvertPipelineStage(descriptor.fragmentStage); > >- // Metal (if not other APIs) requires at least the vertex shader. >- if (!vertexStage.module || vertexStage.entryPoint.isEmpty()) { >- LOG(WebGPU, "%s: Invalid vertex stage in WebGPURenderPipelineDescriptor!", functionName); >+ if (!vertexStage || !fragmentStage) { >+ LOG(WebGPU, "WebGPUDevice::createRenderPipeline(): Invalid WebGPUPipelineStageDescriptor!"); > return nullptr; > } > >- auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(vertexStage), WTFMove(fragmentStage), descriptor.primitiveTopology }); >+ auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(*vertexStage), WTFMove(*fragmentStage), descriptor.primitiveTopology, descriptor.inputState }); > return pipeline ? WebGPURenderPipeline::create(pipeline.releaseNonNull()) : nullptr; > } > >diff --git a/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h b/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h >new file mode 100644 >index 0000000000000000000000000000000000000000..94403584b5be471da6128f2e1604db9b605fe3ac >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h >@@ -0,0 +1,38 @@ >+/* >+ * 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 "GPUInputStateDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUIndexFormat = GPUIndexFormat; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.idl b/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..5256b4e54732f7d35b7b36246f44e747157c9278 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.idl >@@ -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 >+ >+typedef unsigned long u32; >+ >+[ >+ Conditional=WEBGPU, >+ DoNotCheckConstants, >+ EnabledAtRuntime=WebGPU, >+ ImplementationLacksVTable >+] interface WebGPUIndexFormat { >+ const u32 UINT16 = 0; >+ const u32 UINT32 = 1; >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d59306b9782bbcbf22e12ae9e13ec28004e437ae >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h >@@ -0,0 +1,41 @@ >+/* >+ * 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 "GPUInputStateDescriptor.h" >+#include "WebGPUVertexAttributeDescriptor.h" >+#include "WebGPUVertexInputDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUIndexFormatEnum = GPUIndexFormatEnum; >+using WebGPUInputStateDescriptor = GPUInputStateDescriptor; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..c9942412848c1aebeb9a0fcbe7a6159e51c68804 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.idl >@@ -0,0 +1,38 @@ >+/* >+ * 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 >+ >+typedef unsigned long u32; >+typedef u32 WebGPUIndexFormatEnum; >+ >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU >+] dictionary WebGPUInputStateDescriptor { >+ WebGPUIndexFormatEnum indexFormat; >+ >+ sequence<WebGPUVertexAttributeDescriptor> attributes; >+ sequence<WebGPUVertexInputDescriptor> inputs; >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h b/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h >new file mode 100644 >index 0000000000000000000000000000000000000000..1d3d342c3403efc9ae87af0ca9ebdd96cb8cc5ac >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h >@@ -0,0 +1,38 @@ >+/* >+ * 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 "GPUVertexInputDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUInputStepMode = GPUInputStepMode; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.idl b/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..300b23e90c50e2cd6b3108f139d3a5fd63880a4d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.idl >@@ -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 >+ >+typedef unsigned long u32; >+ >+[ >+ Conditional=WEBGPU, >+ DoNotCheckConstants, >+ EnabledAtRuntime=WebGPU, >+ ImplementationLacksVTable >+] interface WebGPUInputStepMode { >+ const u32 VERTEX = 0; >+ const u32 INSTANCE = 1; >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h b/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h >index 3121a9ba5683740143cec3059082bc82ca541592..52c2f9ac0fb91c407479dfefe3e8e09c20311a09 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h >@@ -27,13 +27,10 @@ > > #if ENABLE(WEBGPU) > >-#include "WebGPUPipelineStageDescriptor.h" >-#include <wtf/Vector.h> >- > namespace WebCore { > > struct WebGPUPipelineDescriptorBase { >- Vector<WebGPUPipelineStageDescriptor> stages; >+ // WebGPUPipelineLayout layout; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl b/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl >index 33f7a76617ab1959f20718869b597e7f5c2e4928..eb135b55746e46164ec6d7870d119c9a3275f111 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl >@@ -29,5 +29,4 @@ > EnabledAtRuntime=WebGPU > ] dictionary WebGPUPipelineDescriptorBase { > // WebGPUPipelineLayout layout; >- sequence<WebGPUPipelineStageDescriptor> stages; > }; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h >index 33f3ae0956500d4f7b37c5e507d087adf0ada166..45a87bd6ce55e77ac82a93874c52ac962b5631ad 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h >@@ -33,11 +33,8 @@ > > namespace WebCore { > >-using WebGPUShaderStageEnum = unsigned long; >- > struct WebGPUPipelineStageDescriptor { > const WebGPUShaderModule* module = nullptr; >- WebGPUShaderStageEnum stage; > String entryPoint; > }; > >diff --git a/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl >index 0d6b08817d92da7bccd028ac7fe3ecc1122359b4..eedaf0816f54481d37d83c674692c29b6f7ec791 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl >@@ -31,6 +31,5 @@ typedef unsigned long WebGPUShaderStageEnum; > EnabledAtRuntime=WebGPU > ] dictionary WebGPUPipelineStageDescriptor { > WebGPUShaderModule module; >- WebGPUShaderStageEnum stage; > DOMString entryPoint; > }; >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp >index 12e6903f999bc30631a790e7adb5156f00af5229..1a1c52cbc9750cb74a6db7657b2ce81d6a07081a 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp >@@ -30,6 +30,8 @@ > > #include "GPUProgrammablePassEncoder.h" > #include "GPURenderPassEncoder.h" >+#include "Logging.h" >+#include "WebGPUBuffer.h" > > namespace WebCore { > >@@ -44,6 +46,21 @@ WebGPURenderPassEncoder::WebGPURenderPassEncoder(Ref<WebGPUCommandBuffer>&& crea > { > } > >+void WebGPURenderPassEncoder::setVertexBuffers(unsigned long startSlot, Vector<RefPtr<WebGPUBuffer>>&& buffers, Vector<unsigned>&& offsets) >+{ >+ if (buffers.isEmpty() || buffers.size() != offsets.size()) { >+ LOG(WebGPU, "WebGPURenderPassEncoder::setVertexBuffers: Invalid number of buffers or offsets!"); >+ return; >+ } >+ >+ auto gpuBuffers = buffers.map([] (const auto& buffer) -> Ref<const GPUBuffer> { >+ return buffer->buffer(); >+ }); >+ >+ // FIXME: Use startSlot properly. >+ m_passEncoder->setVertexBuffers(startSlot, WTFMove(gpuBuffers), WTFMove(offsets)); >+} >+ > void WebGPURenderPassEncoder::draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance) > { > // FIXME: What kind of validation do we need to handle here? >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h >index c38c9fdce99d406d09c8b47a5419d61885c82941..31296e3e9e828e104210ed405978e2e2f31fc07f 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h >@@ -30,16 +30,20 @@ > #include "WebGPUProgrammablePassEncoder.h" > > #include <wtf/RefPtr.h> >+#include <wtf/Vector.h> > > namespace WebCore { > > class GPUProgrammablePassEncoder; > class GPURenderPassEncoder; >+class WebGPUBuffer; > > class WebGPURenderPassEncoder final : public WebGPUProgrammablePassEncoder { > public: > static RefPtr<WebGPURenderPassEncoder> create(Ref<WebGPUCommandBuffer>&&, Ref<GPURenderPassEncoder>&&); > >+ // FIXME: Last argument should be Vector<unsigned long>. Why is the generated code incorrectly assuming the IDL wants a sequence<unsigned int>? >+ void setVertexBuffers(unsigned long, Vector<RefPtr<WebGPUBuffer>>&&, Vector<unsigned>&&); > void draw(unsigned long, unsigned long, unsigned long, unsigned long); > > private: >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl >index 868f68fc4ad1fe88ae4ddd7c7e6dd5f4e962c586..d162ec528edbe1d6805446bea94faba62091e988 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl >@@ -31,12 +31,13 @@ typedef unsigned long u32; > EnabledAtRuntime=WebGPU, > JSGenerateToJSObject > ] interface WebGPURenderPassEncoder : WebGPUProgrammablePassEncoder { >+ void setVertexBuffers(u32 startSlot, sequence<WebGPUBuffer> buffers, sequence<u32> offsets); >+ > void draw(u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance); > > /* Not Yet Implemented > void setBlendColor(float r, float g, float b, float a); > void setIndexBuffer(WebGPUBuffer buffer, u32 offset); >- void setVertexBuffers(u32 startSlot, sequence<WebGPUBuffer> buffers, sequence<u32> offsets); > > void drawIndexed(u32 indexCount, u32 instanceCount, u32 firstIndex, i32 baseVertex, u32 firstInstance); > >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >index 9c2646390846dda829efcc2891368dca8994072b..c12f758a7bfce89aaa14c61d205cef93fd9a034b 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >@@ -28,14 +28,19 @@ > #if ENABLE(WEBGPU) > > #include "GPURenderPipelineDescriptor.h" >+#include "WebGPUInputStateDescriptor.h" > #include "WebGPUPipelineDescriptorBase.h" >+#include "WebGPUPipelineStageDescriptor.h" > > namespace WebCore { > > struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase { > using PrimitiveTopology = GPURenderPipelineDescriptor::PrimitiveTopology; > >+ WebGPUPipelineStageDescriptor vertexStage; >+ WebGPUPipelineStageDescriptor fragmentStage; > PrimitiveTopology primitiveTopology; >+ WebGPUInputStateDescriptor inputState; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >index 7fa544743df269f2cc38b841f28a57a2350a1594..fddb628dfa40b9052f79892185608024ee390955 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >@@ -36,11 +36,15 @@ enum WebGPUPrimitiveTopology { > Conditional=WEBGPU, > EnabledAtRuntime=WebGPU > ] dictionary WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase { >+ WebGPUPipelineStageDescriptor vertexStage; >+ WebGPUPipelineStageDescriptor fragmentStage; >+ > WebGPUPrimitiveTopology primitiveTopology; >- /* To Be Implemented: >- sequence<WebGPUBlendState> blendStates; >- WebGPUDepthStencilState depthStencilState; >- WebGPUInputState inputState; >- WebGPUAttachmentsState attachmentsState; */ >+ WebGPUInputStateDescriptor inputState; >+/* To Be Implemented: >+ sequence<WebGPUBlendStateDescriptor> blendStates; >+ WebGPUDepthStencilStateDescriptor depthStencilState; >+ WebGPUAttachmentsStateDescriptor attachmentsState; > // TODO other properties >+*/ > }; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h b/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h >deleted file mode 100644 >index 2a5130c2f1740863dcbff51e163ded7e2c9b26a1..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h >+++ /dev/null >@@ -1,43 +0,0 @@ >-/* >- * 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 <wtf/RefCounted.h> >- >-namespace WebCore { >- >-class WebGPUShaderStage : public RefCounted<WebGPUShaderStage> { >-public: >- static const unsigned long VERTEX = 0; >- static const unsigned long FRAGMENT = 1; >- static const unsigned long COMPUTE = 2; >-}; >- >-} // namespace WebCore >- >-#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl b/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl >deleted file mode 100644 >index ca37a37412d49301bbf57817e856c96d0634ce6b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl >+++ /dev/null >@@ -1,37 +0,0 @@ >-/* >- * 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 >- >-typedef unsigned long u32; >- >-[ >- Conditional=WEBGPU, >- EnabledAtRuntime=WebGPU, >- ImplementationLacksVTable >-] interface WebGPUShaderStage { >- const u32 VERTEX = 0; >- const u32 FRAGMENT = 1; >- const u32 COMPUTE = 2; >-}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e2d81a898332d3c24bac70297cc419bf76ee1cda >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h >@@ -0,0 +1,39 @@ >+/* >+ * 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 "GPUVertexAttributeDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUVertexAttributeDescriptor = GPUVertexAttributeDescriptor; >+using WebGPUVertexFormatEnum = GPUVertexFormatEnum; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..896aea3367c1768b8ebd9b633ebfd48abe073abc >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl >@@ -0,0 +1,38 @@ >+/* >+ * 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 >+ >+typedef unsigned long u32; >+typedef u32 WebGPUVertexFormatEnum; >+ >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU >+] dictionary WebGPUVertexAttributeDescriptor { >+ u32 shaderLocation; >+ u32 inputSlot; >+ u32 offset; >+ WebGPUVertexFormatEnum format; >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h b/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h >new file mode 100644 >index 0000000000000000000000000000000000000000..40786d51fe8fbbbca49d43b3b2d7d7b079cc051f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h >@@ -0,0 +1,38 @@ >+/* >+ * 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 "GPUVertexAttributeDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUVertexFormat = GPUVertexFormat; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl b/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..dcfef41af0335cf16a246bc0e2e9f39c298bc87a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl >@@ -0,0 +1,40 @@ >+/* >+ * 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 >+ >+typedef unsigned long u32; >+ >+[ >+ Conditional=WEBGPU, >+ DoNotCheckConstants, >+ EnabledAtRuntime=WebGPU, >+ ImplementationLacksVTable >+] interface WebGPUVertexFormat { >+ const u32 FLOAT_R32_G32_B32_A32 = 0; >+ const u32 FLOAT_R32_G32_B32 = 1; >+ const u32 FLOAT_R32_G32 = 2; >+ const u32 FLOAT_R32 = 3; >+ // TODO other vertex formats >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..46ed375733f6b1af7d63f92309169ba4ad8c9b91 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h >@@ -0,0 +1,39 @@ >+/* >+ * 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 "GPUVertexInputDescriptor.h" >+ >+namespace WebCore { >+ >+using WebGPUInputStepModeEnum = GPUInputStepModeEnum; >+using WebGPUVertexInputDescriptor = GPUVertexInputDescriptor; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..307e3153049e34595d1887d68886f98684d982e4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.idl >@@ -0,0 +1,36 @@ >+/* >+ * 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 >+ >+typedef unsigned long u32; >+typedef u32 WebGPUInputStepModeEnum; >+ >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU >+] dictionary WebGPUVertexInputDescriptor { >+ u32 stride; >+ WebGPUInputStepModeEnum stepMode; >+}; >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 9373a256ef1121cc42cd01b078aceb004dd81452..b4bdb25b5170687440ba663f06a09bec401e0e2f 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -3228,6 +3228,9 @@ JSWebGPUBufferUsage.cpp > JSWebGPUCommandBuffer.cpp > JSWebGPUColor.cpp > JSWebGPUDevice.cpp >+JSWebGPUIndexFormat.cpp >+JSWebGPUInputStateDescriptor.cpp >+JSWebGPUInputStepMode.cpp > JSWebGPUQueue.cpp > JSWebGPUPipelineDescriptorBase.cpp > JSWebGPUPipelineStageDescriptor.cpp >@@ -3240,11 +3243,13 @@ JSWebGPURenderPipeline.cpp > JSWebGPURenderPipelineDescriptor.cpp > JSWebGPUShaderModule.cpp > JSWebGPUShaderModuleDescriptor.cpp >-JSWebGPUShaderStage.cpp > JSWebGPUSwapChain.cpp > JSWebGPUTexture.cpp > JSWebGPUTextureFormatEnum.cpp > JSWebGPUTextureView.cpp >+JSWebGPUVertexAttributeDescriptor.cpp >+JSWebGPUVertexFormat.cpp >+JSWebGPUVertexInputDescriptor.cpp > JSWebMetalBuffer.cpp > JSWebMetalCommandBuffer.cpp > JSWebMetalCommandQueue.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index dbcb4a7ee2e67cf0c3bfca958d35c8b1e4f60150..ece99b6d79faa8ccdea6070f70b55dd9466faf98 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13798,8 +13798,14 @@ > D0615FCC217FE5C6008A48A8 /* WebGPUShaderModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUShaderModule.h; sourceTree = "<group>"; }; > D0615FCD217FE5C6008A48A8 /* WebGPUShaderModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUShaderModule.cpp; sourceTree = "<group>"; }; > D0615FCE217FE5C6008A48A8 /* WebGPUShaderModule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUShaderModule.idl; sourceTree = "<group>"; }; >- D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBufferUsage.idl; sourceTree = "<group>"; }; >- D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBufferUsage.h; sourceTree = "<group>"; }; >+ D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBufferUsage.h; sourceTree = "<group>"; }; >+ D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBufferUsage.idl; sourceTree = "<group>"; }; >+ D063AE4421C0617D000E6A35 /* WebGPUVertexFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexFormat.h; sourceTree = "<group>"; }; >+ D063AE4521C0617D000E6A35 /* WebGPUVertexFormat.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexFormat.idl; sourceTree = "<group>"; }; >+ D063AE4621C06626000E6A35 /* WebGPUInputStepMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUInputStepMode.h; sourceTree = "<group>"; }; >+ D063AE4721C06626000E6A35 /* WebGPUInputStepMode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUInputStepMode.idl; sourceTree = "<group>"; }; >+ D063AE4821C066DB000E6A35 /* WebGPUIndexFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUIndexFormat.h; sourceTree = "<group>"; }; >+ D063AE4921C066DB000E6A35 /* WebGPUIndexFormat.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUIndexFormat.idl; sourceTree = "<group>"; }; > D06C0D8D0CFD11460065F43F /* RemoveFormatCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoveFormatCommand.h; sourceTree = "<group>"; }; > D06C0D8E0CFD11460065F43F /* RemoveFormatCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveFormatCommand.cpp; sourceTree = "<group>"; }; > D07DEAB70A36554A00CA30F8 /* InsertListCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InsertListCommand.cpp; sourceTree = "<group>"; }; >@@ -13830,8 +13836,6 @@ > D0BD4F5B1408850F006839B6 /* DictationCommandIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictationCommandIOS.h; 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>"; }; >- D0C419EE2183D9C8009EC1DE /* WebGPUShaderStage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUShaderStage.h; sourceTree = "<group>"; }; >- D0C419EF2183D9C8009EC1DE /* WebGPUShaderStage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUShaderStage.idl; sourceTree = "<group>"; }; > D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUPipelineDescriptorBase.h; sourceTree = "<group>"; }; > D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUPipelineDescriptorBase.idl; sourceTree = "<group>"; }; > D0C419F22183EFEC009EC1DE /* WebGPURenderPipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPipelineDescriptor.h; sourceTree = "<group>"; }; >@@ -13853,6 +13857,15 @@ > D0D8648E21B70676003C983C /* WebGPUBuffer.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBuffer.idl; sourceTree = "<group>"; }; > D0D8649121B760C4003C983C /* GPUBufferMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBufferMetal.mm; sourceTree = "<group>"; }; > D0D8649221B760F2003C983C /* GPUBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; }; >+ D0D8649321BA173D003C983C /* WebGPUInputStateDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUInputStateDescriptor.h; sourceTree = "<group>"; }; >+ D0D8649421BA173D003C983C /* WebGPUInputStateDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUInputStateDescriptor.idl; sourceTree = "<group>"; }; >+ D0D8649521BA18F4003C983C /* WebGPUVertexAttributeDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexAttributeDescriptor.h; sourceTree = "<group>"; }; >+ D0D8649621BA18F4003C983C /* WebGPUVertexAttributeDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexAttributeDescriptor.idl; sourceTree = "<group>"; }; >+ D0D8649721BA19A7003C983C /* WebGPUVertexInputDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexInputDescriptor.h; sourceTree = "<group>"; }; >+ D0D8649821BA19A7003C983C /* WebGPUVertexInputDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexInputDescriptor.idl; sourceTree = "<group>"; }; >+ D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUInputStateDescriptor.h; sourceTree = "<group>"; }; >+ D0D8649B21BA1C2D003C983C /* GPUVertexAttributeDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUVertexAttributeDescriptor.h; sourceTree = "<group>"; }; >+ D0D8649C21BA1CE8003C983C /* GPUVertexInputDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUVertexInputDescriptor.h; sourceTree = "<group>"; }; > D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSwapChain.h; sourceTree = "<group>"; }; > D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUSwapChain.cpp; sourceTree = "<group>"; }; > D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSwapChain.idl; sourceTree = "<group>"; }; >@@ -18024,6 +18037,7 @@ > 312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */, > 312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */, > 312FF8BE21A4C2F100EB199D /* GPUDevice.h */, >+ D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */, > 312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */, > 312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */, > D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */, >@@ -18038,6 +18052,8 @@ > 312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */, > 312FF8C521A4C2F400EB199D /* GPUTexture.h */, > 312FF8C321A4C2F300EB199D /* GPUTextureFormatEnum.h */, >+ D0D8649B21BA1C2D003C983C /* GPUVertexAttributeDescriptor.h */, >+ D0D8649C21BA1CE8003C983C /* GPUVertexInputDescriptor.h */, > 498770D71242C535002226BA /* Texture.cpp */, > 498770D81242C535002226BA /* Texture.h */, > 498770D91242C535002226BA /* TilingData.cpp */, >@@ -25515,6 +25531,10 @@ > D0D8648E21B70676003C983C /* WebGPUBuffer.idl */, > D0D8648221B61727003C983C /* WebGPUBufferDescriptor.h */, > D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */, >+ D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */, >+ D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */, >+ D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */, >+ D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */, > D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */, > D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */, > D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */, >@@ -25523,6 +25543,12 @@ > D00F595321701D8C000D71DB /* WebGPUDevice.cpp */, > D00F595221701D8C000D71DB /* WebGPUDevice.h */, > D00F595421701D8C000D71DB /* WebGPUDevice.idl */, >+ D063AE4821C066DB000E6A35 /* WebGPUIndexFormat.h */, >+ D063AE4921C066DB000E6A35 /* WebGPUIndexFormat.idl */, >+ D0D8649321BA173D003C983C /* WebGPUInputStateDescriptor.h */, >+ D0D8649421BA173D003C983C /* WebGPUInputStateDescriptor.idl */, >+ D063AE4621C06626000E6A35 /* WebGPUInputStepMode.h */, >+ D063AE4721C06626000E6A35 /* WebGPUInputStepMode.idl */, > D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */, > D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */, > D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */, >@@ -25553,8 +25579,6 @@ > D0615FCE217FE5C6008A48A8 /* WebGPUShaderModule.idl */, > D060D8872182697000339318 /* WebGPUShaderModuleDescriptor.h */, > D060D88421825D5F00339318 /* WebGPUShaderModuleDescriptor.idl */, >- D0C419EE2183D9C8009EC1DE /* WebGPUShaderStage.h */, >- D0C419EF2183D9C8009EC1DE /* WebGPUShaderStage.idl */, > D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */, > D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */, > D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */, >@@ -25566,8 +25590,12 @@ > D0EACF882193EE4E000FA75C /* WebGPUTextureView.cpp */, > D0EACF872193EE4E000FA75C /* WebGPUTextureView.h */, > D0EACF892193EE4E000FA75C /* WebGPUTextureView.idl */, >- D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */, >- D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */, >+ D0D8649521BA18F4003C983C /* WebGPUVertexAttributeDescriptor.h */, >+ D0D8649621BA18F4003C983C /* WebGPUVertexAttributeDescriptor.idl */, >+ D063AE4421C0617D000E6A35 /* WebGPUVertexFormat.h */, >+ D063AE4521C0617D000E6A35 /* WebGPUVertexFormat.idl */, >+ D0D8649721BA19A7003C983C /* WebGPUVertexInputDescriptor.h */, >+ D0D8649821BA19A7003C983C /* WebGPUVertexInputDescriptor.idl */, > ); > path = webgpu; > sourceTree = "<group>"; >diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >index d256827eb8dfcc87f31f0644b488acc424b47acd..e0b397f3ddd643e7e4e13fc9853e5e01d1b1fcf1 100644 >--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >@@ -193,16 +193,18 @@ namespace WebCore { > macro(WebGPUBufferUsage) \ > macro(WebGPUCommandBuffer) \ > macro(WebGPUDevice) \ >+ macro(WebGPUIndexFormat) \ >+ macro(WebGPUInputStepMode) \ > macro(WebGPUQueue) \ > macro(WebGPUProgrammablePassEncoder) \ > macro(WebGPURenderingContext) \ > macro(WebGPURenderPassEncoder) \ > macro(WebGPURenderPipeline) \ >- macro(WebGPUShaderStage) \ > macro(WebGPUShaderModule) \ > macro(WebGPUSwapChain) \ > macro(WebGPUTexture) \ > macro(WebGPUTextureView) \ >+ macro(WebGPUVertexFormat) \ > macro(WebMetalBuffer) \ > macro(WebMetalCommandBuffer) \ > macro(WebMetalCommandQueue) \ >diff --git a/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fa784773ca585842ec5dd9cf0c5d685f41105a57 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 "GPUVertexAttributeDescriptor.h" >+#include "GPUVertexInputDescriptor.h" >+ >+#include <wtf/RefCounted.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+using GPUIndexFormatEnum = unsigned long; >+ >+class GPUIndexFormat : public RefCounted<GPUIndexFormat> { >+public: >+ enum Enum : GPUIndexFormatEnum { >+ Uint16 = 0, >+ Uint32 = 1 >+ }; >+}; >+ >+struct GPUInputStateDescriptor { >+ GPUIndexFormatEnum indexFormat; >+ >+ Vector<GPUVertexAttributeDescriptor> attributes; >+ Vector<GPUVertexInputDescriptor> inputs; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h >index 3b64d044ca5e9c1abda0ade274fb21bcb9f00435..c9071cbf61f5a3c2aaeaedb9bfc10cb16430f768 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h >@@ -32,11 +32,13 @@ > #include <wtf/RefCounted.h> > #include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >+#include <wtf/Vector.h> > > OBJC_PROTOCOL(MTLRenderCommandEncoder); > > namespace WebCore { > >+class GPUBuffer; > class GPUCommandBuffer; > class GPURenderPipeline; > >@@ -51,6 +53,7 @@ public: > > void setPipeline(Ref<GPURenderPipeline>&&) final; > >+ void setVertexBuffers(unsigned long, Vector<Ref<const GPUBuffer>>&&, Vector<unsigned>&&); > void draw(unsigned long, unsigned long, unsigned long, unsigned long); > > private: >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >index 14ec7d2f97ebc44c7b36b95ee4a5ca3bccd9bd28..5b43b1ee1bfca8770b4b038897d7215c32b6ac0e 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >@@ -27,6 +27,7 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUInputStateDescriptor.h" > #include "GPUPipelineDescriptorBase.h" > #include "GPUPipelineStageDescriptor.h" > >@@ -46,6 +47,7 @@ struct GPURenderPipelineDescriptor { > GPUPipelineStageDescriptor vertexStage; > GPUPipelineStageDescriptor fragmentStage; > PrimitiveTopology primitiveTopology; >+ GPUInputStateDescriptor inputState; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d58d6dda1ca7cfc15791e2625fb18635930f42eb >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h >@@ -0,0 +1,55 @@ >+/* >+ * 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 <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+using GPUVertexFormatEnum = unsigned long; >+ >+class GPUVertexFormat : public RefCounted<GPUVertexFormat> { >+public: >+ enum Enum : GPUVertexFormatEnum { >+ FloatR32G32B32A32 = 0, >+ FloatR32G32B32 = 1, >+ FloatR32G32 = 2, >+ FloatR32 = 3 >+ }; >+}; >+ >+struct GPUVertexAttributeDescriptor { >+ unsigned long shaderLocation; >+ unsigned long inputSlot; >+ unsigned long offset; >+ GPUVertexFormatEnum format; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0619b226e83b591579c18d2520e841b39bbd0ebb >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h >@@ -0,0 +1,51 @@ >+/* >+ * 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 <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+using GPUInputStepModeEnum = unsigned long; >+ >+class GPUInputStepMode : public RefCounted<GPUInputStepMode> { >+public: >+ enum Enum : GPUInputStepModeEnum { >+ Vertex = 0, >+ Instance = 1 >+ }; >+}; >+ >+struct GPUVertexInputDescriptor { >+ unsigned long stride; >+ GPUInputStepModeEnum stepMode; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >index 2c582b0b32d8d412d8cd654a469aa7e6b9da7a48..5a73bee5bd5b09d79b15d68a0683f5872f4d2dc1 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >@@ -28,6 +28,7 @@ > > #if ENABLE(WEBGPU) > >+#import "GPUBuffer.h" > #import "GPUCommandBuffer.h" > #import "GPURenderPassDescriptor.h" > #import "GPURenderPipeline.h" >@@ -83,6 +84,13 @@ void GPURenderPassEncoder::setPipeline(Ref<GPURenderPipeline>&& pipeline) > m_pipeline = WTFMove(pipeline); > } > >+void GPURenderPassEncoder::setVertexBuffers(unsigned long index, Vector<Ref<const GPUBuffer>>&& buffers, Vector<unsigned>&& offsets) >+{ >+ ASSERT(buffers.size() && offsets.size() == buffers.size()); >+ // FIXME: Only worry about the first buffer for now, and treat startSlot as the index. >+ [m_platformRenderPassEncoder setVertexBuffer:buffers[0]->platformBuffer() offset:offsets[0] atIndex:index]; >+} >+ > static MTLPrimitiveType primitiveTypeForGPUPrimitiveTopology(PrimitiveTopology type) > { > switch (type) { >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >index a8065febbad4783703bbb6e2ccc1af9c54de0485..c81983622b75795d4ab1300c755c82a3a0e13595 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >@@ -32,6 +32,7 @@ > > #import <Metal/Metal.h> > #import <wtf/BlockObjCExceptions.h> >+#import <wtf/Optional.h> > > namespace WebCore { > >@@ -82,6 +83,84 @@ static bool setFunctionsForPipelineDescriptor(const char* const functionName, MT > return true; > } > >+static std::optional<MTLVertexFormat> validateAndConvertVertexFormatToMTLVertexFormat(GPUVertexFormatEnum format) >+{ >+ switch (format) { >+ case GPUVertexFormat::FloatR32G32B32A32: >+ return MTLVertexFormatFloat4; >+ case GPUVertexFormat::FloatR32G32B32: >+ return MTLVertexFormatFloat3; >+ case GPUVertexFormat::FloatR32G32: >+ return MTLVertexFormatFloat2; >+ case GPUVertexFormat::FloatR32: >+ return MTLVertexFormatFloat; >+ default: >+ return std::nullopt; >+ } >+} >+ >+static std::optional<MTLVertexStepFunction> validateAndConvertStepModeToMTLStepFunction(GPUInputStepModeEnum mode) >+{ >+ switch (mode) { >+ case GPUInputStepMode::Vertex: >+ return MTLVertexStepFunctionPerVertex; >+ case GPUInputStepMode::Instance: >+ return MTLVertexStepFunctionPerInstance; >+ default: >+ return std::nullopt; >+ } >+} >+ >+static bool setInputStateForPipelineDescriptor(const char* const functionName, MTLRenderPipelineDescriptor *mtlDescriptor, const GPURenderPipelineDescriptor& descriptor) >+{ >+#if LOG_DISABLED >+ UNUSED_PARAM(functionName); >+#endif >+ auto mtlVertexDescriptor = adoptNS([MTLVertexDescriptor new]); >+ >+ // Populate vertex attributes, if any. >+ const auto& attributes = descriptor.inputState.attributes; >+ >+ // FIXME: What kind of validation is needed here? >+ MTLVertexAttributeDescriptorArray *attributeArray = mtlVertexDescriptor.get().attributes; >+ >+ for (size_t i = 0; i < attributes.size(); ++i) { >+ auto mtlFormat = validateAndConvertVertexFormatToMTLVertexFormat(attributes[i].format); >+ if (!mtlFormat) { >+ LOG(WebGPU, "%s: Invalid WebGPUVertexFormatEnum for vertex attribute!", functionName); >+ return false; >+ } >+ >+ MTLVertexAttributeDescriptor *mtlAttributeDesc = [attributeArray objectAtIndexedSubscript:i]; >+ mtlAttributeDesc.format = *mtlFormat; >+ mtlAttributeDesc.offset = attributes[i].offset; >+ mtlAttributeDesc.bufferIndex = attributes[i].shaderLocation; >+ [mtlVertexDescriptor.get().attributes setObject:mtlAttributeDesc atIndexedSubscript:i]; >+ } >+ >+ // Populate vertex buffer layouts, if any. >+ const auto& inputs = descriptor.inputState.inputs; >+ >+ MTLVertexBufferLayoutDescriptorArray *layoutArray = mtlVertexDescriptor.get().layouts; >+ >+ for (size_t j = 0; j < inputs.size(); ++j) { >+ auto mtlStepFunction = validateAndConvertStepModeToMTLStepFunction(inputs[j].stepMode); >+ if (!mtlStepFunction) { >+ LOG(WebGPU, "%s: Invalid WebGPUInputStepMode for vertex input!", functionName); >+ return false; >+ } >+ >+ MTLVertexBufferLayoutDescriptor *mtlLayoutDesc = [layoutArray objectAtIndexedSubscript:j]; >+ mtlLayoutDesc.stepFunction = *mtlStepFunction; >+ mtlLayoutDesc.stride = inputs[j].stride; >+ [mtlVertexDescriptor.get().layouts setObject:mtlLayoutDesc atIndexedSubscript:j]; >+ } >+ >+ mtlDescriptor.vertexDescriptor = mtlVertexDescriptor.get(); >+ >+ return true; >+} >+ > RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPURenderPipelineDescriptor&& descriptor) > { > const char* const functionName = "GPURenderPipeline::create()"; >@@ -104,7 +183,8 @@ RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPU > return nullptr; > } > >- if (!setFunctionsForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor)) >+ if (!setFunctionsForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor) >+ || !setInputStateForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor)) > return nullptr; > > // FIXME: Get the pixelFormat as configured for the context/CAMetalLayer. >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 5462e48844f2a304ee64cdc962f3689302ebb272..95d7f8bac178ff6b81cc0c4fe1d4a0aa24a1beae 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,26 @@ >+2018-12-11 Justin Fan <justin_fan@apple.com> >+ >+ [WebGPU] Vertex buffers and WebGPUInputState >+ https://bugs.webkit.org/show_bug.cgi?id=192611 >+ >+ Reviewed by Dean Jackson. >+ >+ Added variation of simple-triangle-strip to use a vertex buffer. Refactored aforementioned >+ test to share code with new test. >+ >+ * webgpu/js/basic-webgpu-functions.js: >+ (setUpPipelineDescriptor): >+ * webgpu/js/webgpu-functions.js: Added. >+ (async.getBasicDevice): >+ (createBasicContext): >+ (createBasicPipeline): >+ (beginBasicRenderPass): >+ * webgpu/render-pipelines-expected.txt: >+ * webgpu/render-pipelines.html: >+ * webgpu/simple-triangle-strip.html: >+ * webgpu/vertex-buffer-triangle-strip-expected.html: Added. >+ * webgpu/vertex-buffer-triangle-strip.html: Added. >+ > 2018-12-10 Ryosuke Niwa <rniwa@webkit.org> > > connectedCallback is invoked during the removal of the element inside another element's connectedCallback >diff --git a/LayoutTests/webgpu/js/basic-webgpu-functions.js b/LayoutTests/webgpu/js/basic-webgpu-functions.js >index b3cbbc21bd49c281e2a0a9f0f11d5a3a20470141..0d0870262f7009e1a3d930eed4dae49e00099c6f 100644 >--- a/LayoutTests/webgpu/js/basic-webgpu-functions.js >+++ b/LayoutTests/webgpu/js/basic-webgpu-functions.js >@@ -90,19 +90,18 @@ function setUpModule() { > > function setUpPipelineDescriptor() { > vertexStageDescriptor = { >- module: shaderModule, >- stage: WebGPUShaderStage.VERTEX, >+ module: shaderModule, > entryPoint: "vertex_main" > }; > > fragmentStageDescriptor = { > module: shaderModule, >- stage: WebGPUShaderStage.FRAGMENT, > entryPoint: "fragment_main" > }; > > pipelineDescriptor = { >- stages: [vertexStageDescriptor, fragmentStageDescriptor], >+ vertexStage: vertexStageDescriptor, >+ fragmentStage: fragmentStageDescriptor, > primitiveTopology: "triangleList" > }; > } >diff --git a/LayoutTests/webgpu/js/webgpu-functions.js b/LayoutTests/webgpu/js/webgpu-functions.js >new file mode 100644 >index 0000000000000000000000000000000000000000..e9ae83862ba1e85168ae70a0763a838a498ec6dd >--- /dev/null >+++ b/LayoutTests/webgpu/js/webgpu-functions.js >@@ -0,0 +1,52 @@ >+async function getBasicDevice() { >+ // FIXME: requestAdapter should take a WebGPUAdapterDescriptor. >+ const adapter = await window.webgpu.requestAdapter({}); >+ const device = adapter.createDevice(); >+ return device; >+} >+ >+function createBasicContext(canvas, device) { >+ const context = canvas.getContext("webgpu"); >+ // FIXME: Implement and specify a WebGPUTextureUsageEnum. >+ context.configure({ device: device, format:"B8G8R8A8Unorm", width: canvas.width, height: canvas.height }); >+ return context; >+} >+ >+function createBasicPipeline(shaderModule, device, inputStateDescriptor) { >+ vertexStageDescriptor = { >+ module: shaderModule, >+ entryPoint: "vertex_main" >+ }; >+ >+ fragmentStageDescriptor = { >+ module: shaderModule, >+ entryPoint: "fragment_main" >+ }; >+ >+ pipelineDescriptor = { >+ vertexStage: vertexStageDescriptor, >+ fragmentStage: fragmentStageDescriptor, >+ primitiveTopology: "triangleStrip", >+ inputState: inputStateDescriptor >+ }; >+ >+ return device.createRenderPipeline(pipelineDescriptor); >+} >+ >+function beginBasicRenderPass(context, commandBuffer) { >+ const basicAttachment = { >+ attachment: context.getNextTexture().createDefaultTextureView(), >+ clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 } >+ } >+ >+ // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. >+ return commandBuffer.beginRenderPass({ colorAttachments : [basicAttachment] }); >+} >+ >+function encodeBasicCommands(renderPassEncoder, renderPipeline, vertexBuffer) { >+ if (vertexBuffer) >+ renderPassEncoder.setVertexBuffers(0, [vertexBuffer], [0]); >+ renderPassEncoder.setPipeline(renderPipeline); >+ renderPassEncoder.draw(4, 1, 0, 0); >+ return renderPassEncoder.endPass(); >+} >\ No newline at end of file >diff --git a/LayoutTests/webgpu/render-pipelines-expected.txt b/LayoutTests/webgpu/render-pipelines-expected.txt >index b6d86b0acaae26ed5f8adb75857cdf889e6364f6..f250926214960f9a753d4d7b1b56044d9bad7472 100644 >--- a/LayoutTests/webgpu/render-pipelines-expected.txt >+++ b/LayoutTests/webgpu/render-pipelines-expected.txt >@@ -3,7 +3,6 @@ PASS WebGPURenderPipeline with invalid WebGPURenderPipelineDescriptor was not cr > PASS WebGPURenderPipeline with invalid shader module was not created. > PASS WebGPURenderPipeline with invalid vertex shader stage was not created. > PASS WebGPURenderPipeline with invalid vertex shader entry point was not created. >-PASS WebGPURenderPipeline with invalid WebGPUShaderStageEnum was not created. > All tests complete. > PASS successfullyParsed is true > >diff --git a/LayoutTests/webgpu/render-pipelines.html b/LayoutTests/webgpu/render-pipelines.html >index a3b929ecd875cd0aa536d7d1b530f151bd6709cb..6cb4befaa1d749a37795fc405fefbcae99a975c4 100644 >--- a/LayoutTests/webgpu/render-pipelines.html >+++ b/LayoutTests/webgpu/render-pipelines.html >@@ -19,43 +19,32 @@ function setUpBadPipelines() { > checkBadRenderPipeline({}, "WebGPURenderPipelineDescriptor"); > > let noModuleVertexDescriptor = { >- stage: WebGPUShaderStage.VERTEX, > entryPoint: "vertex_main" > } > let noModulePipelineDescriptor = { >- stages: [noModuleVertexDescriptor, fragmentStageDescriptor], >+ vertexStage: noModuleVertexDescriptor, >+ fragmentStage: fragmentStageDescriptor, > primitiveTopology: "triangleList" > } > checkBadRenderPipeline(noModulePipelineDescriptor, "shader module"); > > // A (Metal) renderpipeline must have a vertex function. > let noVertexPipelineDescriptor = { >- stages: [fragmentStageDescriptor], >+ fragmentStage: fragmentStageDescriptor, > primitiveTopology: "triangleList" > } > checkBadRenderPipeline(noVertexPipelineDescriptor, "vertex shader stage") > > let badEntryPointDescriptor = { >- module: shaderModule, >- stage: WebGPUShaderStage.VERTEX, >+ module: shaderModule, > entryPoint: "Vertex_Main" > }; > let badEntryPointPipelineDescsriptor = { >- stages: [badEntryPointDescriptor, fragmentStageDescriptor], >+ vertexStage: badEntryPointDescriptor, >+ fragmentStage: fragmentStageDescriptor, > primitiveTopology: "triangleList" > } > checkBadRenderPipeline(badEntryPointPipelineDescsriptor, "vertex shader entry point"); >- >- let badStageEnumDescriptor = { >- module: shaderModule, >- stage: WebGPUShaderStage.COMPUTE, >- entryPoint: "vertex_main" >- }; >- let badStageEnumPipelineDescriptor = { >- stages: [badStageEnumDescriptor, fragmentStageDescriptor], >- primitiveTopology: "triangleList" >- } >- checkBadRenderPipeline(badStageEnumPipelineDescriptor, "WebGPUShaderStageEnum"); > } > > runWebGPUTests([setUpPipeline, setUpBadPipelines]); >diff --git a/LayoutTests/webgpu/simple-triangle-strip.html b/LayoutTests/webgpu/simple-triangle-strip.html >index d76ffddd9a54f572f0250ec74d0f6173b5c57d6b..30aa4f1c2168eb3661a0c548fd2dfb5229d2560c 100644 >--- a/LayoutTests/webgpu/simple-triangle-strip.html >+++ b/LayoutTests/webgpu/simple-triangle-strip.html >@@ -5,6 +5,7 @@ > <link rel="match" href="simple-triangle-strip-expected.html"> > <p>Pass if square canvas below is completely green.</p> > <canvas width="400" height="400"></canvas> >+<script src="js/webgpu-functions.js"></script> > <script> > const shaderCode = ` > #include <metal_stdlib> >@@ -41,57 +42,6 @@ fragment float4 fragment_main(Vertex vertexIn [[stage_in]]) > } > ` > >-async function getBasicDevice() { >- // FIXME: requestAdapter should take a WebGPUAdapterDescriptor. >- const adapter = await window.webgpu.requestAdapter({}); >- const device = adapter.createDevice(); >- return device; >-} >- >-function createBasicContext(canvas, device) { >- const context = canvas.getContext("webgpu"); >- // FIXME: Implement and specify a WebGPUTextureUsageEnum. >- context.configure({ device: device, format:"B8G8R8A8Unorm", width: canvas.width, height: canvas.height }); >- return context; >-} >- >-function createBasicPipeline(shaderModule, device) { >- vertexStageDescriptor = { >- module: shaderModule, >- stage: WebGPUShaderStage.VERTEX, >- entryPoint: "vertex_main" >- }; >- >- fragmentStageDescriptor = { >- module: shaderModule, >- stage: WebGPUShaderStage.FRAGMENT, >- entryPoint: "fragment_main" >- }; >- >- pipelineDescriptor = { >- stages: [vertexStageDescriptor, fragmentStageDescriptor], >- primitiveTopology: "triangleStrip" >- }; >- >- return device.createRenderPipeline(pipelineDescriptor); >-} >- >-function beginBasicRenderPass(context, commandBuffer) { >- const basicAttachment = { >- attachment: context.getNextTexture().createDefaultTextureView(), >- clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 } >- } >- >- // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. >- return commandBuffer.beginRenderPass({ colorAttachments : [basicAttachment] }); >-} >- >-function encodeBasicCommands(renderPassEncoder, renderPipeline) { >- renderPassEncoder.setPipeline(renderPipeline); >- renderPassEncoder.draw(4, 1, 0, 0); >- return renderPassEncoder.endPass(); >-} >- > async function test() { > const device = await getBasicDevice(); > const canvas = document.querySelector("canvas"); >diff --git a/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html b/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..886f13e8120397a5cc6336c9e2a485e778ba9932 >--- /dev/null >+++ b/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html >@@ -0,0 +1,12 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>HTML Reference File</title> >+<p>Pass if square canvas below is completely green.</p> >+<canvas width="400" height="400"></canvas> >+<script> >+const canvas = document.querySelector("canvas"); >+const context = canvas.getContext('2d'); >+ >+context.fillStyle = 'rgb(0, 255, 0)'; >+context.fillRect(0, 0, canvas.width, canvas.height); >+</script> >\ No newline at end of file >diff --git a/LayoutTests/webgpu/vertex-buffer-triangle-strip.html b/LayoutTests/webgpu/vertex-buffer-triangle-strip.html >new file mode 100644 >index 0000000000000000000000000000000000000000..742b484f56212283b7e40d958b62814980bad531 >--- /dev/null >+++ b/LayoutTests/webgpu/vertex-buffer-triangle-strip.html >@@ -0,0 +1,96 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>WebGPU Hello Triangles</title> >+<meta name="assert" content="WebGPU correctly renders a green canvas."> >+<link rel="match" href="vertex-buffer-triangle-strip-expected.html"> >+<p>Pass if square canvas below is completely green.</p> >+<canvas width="400" height="400"></canvas> >+<script src="js/webgpu-functions.js"></script> >+<script> >+const shaderCode = ` >+#include <metal_stdlib> >+ >+using namespace metal; >+ >+struct Vertex >+{ >+ float4 position [[position]]; >+}; >+ >+vertex Vertex vertex_main(const device Vertex* vertex_array [[buffer(0)]], uint vid [[vertex_id]]) >+{ >+ return vertex_array[vid]; >+} >+ >+fragment float4 fragment_main(Vertex vertexIn [[stage_in]]) >+{ >+ return float4(0.0, 1.0, 0.0, 1.0); >+} >+` >+ >+function createVertexBuffer(device) { >+ const bufferSize = 4 * 4 * 4; >+ const buffer = device.createBuffer({ size: bufferSize, usage: WebGPUBufferUsage.MAP_WRITE }); >+ >+ let arrayBuffer = buffer.mapping; >+ let floatArray = new Float32Array(arrayBuffer); >+ >+ floatArray[0] = -1; >+ floatArray[1] = 1; >+ floatArray[2] = 0; >+ floatArray[3] = 1; >+ >+ floatArray[4] = -1; >+ floatArray[5] = -1; >+ floatArray[6] = 0; >+ floatArray[7] = 1; >+ >+ floatArray[8] = 1; >+ floatArray[9] = 1; >+ floatArray[10] = 0; >+ floatArray[11] = 1; >+ >+ floatArray[12] = 1; >+ floatArray[13] = -1; >+ floatArray[14] = 0; >+ floatArray[15] = 1; >+ >+ return buffer; >+} >+ >+function createInputStateDescriptor() { >+ return { >+ indexFormat: WebGPUIndexFormat.UINT32, >+ attributes: [{ >+ shaderLocation: 0, >+ inputSlot: 0, >+ offset: 0, >+ format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32 >+ }], >+ inputs: [{ >+ stride: 4 * 4, >+ stepMode: WebGPUInputStepMode.VERTEX >+ }] >+ } >+} >+ >+async function test() { >+ const device = await getBasicDevice(); >+ const canvas = document.querySelector("canvas"); >+ const context = createBasicContext(canvas, device); >+ // FIXME: Replace with non-MSL shaders. >+ const shaderModule = device.createShaderModule({ code: shaderCode }); >+ const vertexBuffer = createVertexBuffer(device); >+ const inputStateDescriptor = createInputStateDescriptor(); >+ const pipeline = createBasicPipeline(shaderModule, device, inputStateDescriptor); >+ const commandBuffer = device.createCommandBuffer(); >+ const passEncoder = beginBasicRenderPass(context, commandBuffer); >+ const endCommandBuffer = encodeBasicCommands(passEncoder, pipeline, vertexBuffer); >+ const queue = device.getQueue(); >+ >+ queue.submit([endCommandBuffer]); >+ context.present(); >+} >+ >+test(); >+</script> >\ 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 192611
:
357100
|
357102
|
357104
|
357160
|
357164
| 357179