WebKit Bugzilla
Attachment 361814 Details for
Bug 194458
: [Web GPU] DepthStencilAttachment implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-194458-20190212112942.patch (text/plain), 71.51 KB, created by
Justin Fan
on 2019-02-12 11:29:42 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Justin Fan
Created:
2019-02-12 11:29:42 PST
Size:
71.51 KB
patch
obsolete
>Subversion Revision: 241201 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b7b3ff3623837c2e4189270c8238ff76ce82707b..da50847cc1493abf4b895a4b111d735285ee8bde 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,54 @@ >+2019-02-08 Justin Fan <justin_fan@apple.com> >+ >+ [Web GPU] DepthStencilAttachment implementation >+ https://bugs.webkit.org/show_bug.cgi?id=194458 >+ <rdar://problem/47932446> >+ >+ Reviewed by Dean Jackson. >+ >+ Implement ability to provide a depth attachment to the render pass encoder. Also implement >+ GPULoad/StoreOp and update color attachments' implementation for full functionality. >+ >+ Test: webgpu/depth-enabled-triangle-strip.html >+ >+ Update project files for new symbols: >+ * CMakeLists.txt: >+ * DerivedSources-input.xcfilelist: >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ >+ * Modules/webgpu/GPUColor.idl: Renamed from WebGPUColor.idl >+ * Modules/webgpu/GPULoadOp.idl: Added. Interface for attachment operation enum. >+ * Modules/webgpu/GPUStoreOp.idl: Ditto. >+ * Modules/webpug/WebGPUColor.h: Removed. >+ * Modules/webgpu/WebGPUCommandBuffer.cpp: Refactored descriptor validation logic out of this file. >+ (WebCore::WebGPUCommandBuffer::beginRenderPass): >+ * Modules/webgpu/WebGPURenderPassDescriptor.cpp: Added. Now owns code for validating descriptors. >+ (WebCore::WebGPURenderPassDescriptor::validateAndConvertToGPUVersion const): >+ * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h/idl: Removed. Code moved into WebGPURenderPassDescriptor. >+ * Modules/webgpu/WebGPURenderPassDescriptor.h: Move sub-descriptor definitions into this file. >+ * Modules/webgpu/WebGPURenderPassDescriptor.idl: Ditto. >+ * Modules/webgpu/WebGPURenderPipelineDescriptor.h: Make depthStencilState optional to match API update. >+ * Modules/webgpu/WebGPURenderPipelineDescriptor.idl: Ditto. >+ * Modules/webgpu/WebGPUTextureView.h: >+ * platform/graphics/gpu/GPULoadOp.h: Added. >+ * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Removed (moved into GPURenderPassDescriptor). >+ * platform/graphics/gpu/GPURenderPassDescriptor.h: Mirror WebGPU* changes. >+ * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Make depthStencilState optional. >+ (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor): >+ * platform/graphics/gpu/GPUStoreOp.h: Added. >+ * platform/graphics/gpu/GPUTexture.h: >+ * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm: >+ (WebCore::loadActionForGPULoadOp): Added. >+ (WebCore::storeActionForGPUStoreOp): Added. >+ (WebCore::populateMtlColorAttachmentsArray): Added. Create all expected color attachments, rather than just the first. >+ (WebCore::populateMtlDepthStencilAttachment): Added. >+ (WebCore::GPURenderPassEncoder::create): >+ * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: Make depthStencilState optional. >+ (WebCore::GPURenderPipeline::create): >+ > 2019-02-08 Youenn Fablet <youenn@apple.com> > > Running RTCRtpSender.getCapabilities("video") before initial offer breaks VP8 >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 502974ba7ff8abf70f52fee326d0bc5bdc7d33cf..b2f7d51324e35011cb825e0f9c800037587758aa 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -462,10 +462,13 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webdriver/NavigatorWebDriver.idl > > Modules/webgpu/DOMWindowWebGPU.idl >+ Modules/webgpu/GPUColor.idl > Modules/webgpu/GPUCompareFunction.idl > Modules/webgpu/GPUDepthStencilStateDescriptor.idl > Modules/webgpu/GPUExtent3D.idl >+ Modules/webgpu/GPULoadOp.idl > Modules/webgpu/GPURequestAdapterOptions.idl >+ Modules/webgpu/GPUStoreOp.idl > Modules/webgpu/GPUTextureDescriptor.idl > Modules/webgpu/GPUTextureDimension.idl > Modules/webgpu/GPUTextureFormat.idl >@@ -482,7 +485,6 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webgpu/WebGPUBufferBinding.idl > Modules/webgpu/WebGPUBufferDescriptor.idl > Modules/webgpu/WebGPUBufferUsage.idl >- Modules/webgpu/WebGPUColor.idl > Modules/webgpu/WebGPUCommandBuffer.idl > Modules/webgpu/WebGPUDevice.idl > Modules/webgpu/WebGPUIndexFormat.idl >@@ -494,7 +496,6 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/webgpu/WebGPUPipelineStageDescriptor.idl > Modules/webgpu/WebGPUProgrammablePassEncoder.idl > Modules/webgpu/WebGPUQueue.idl >- Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl > Modules/webgpu/WebGPURenderPassDescriptor.idl > Modules/webgpu/WebGPURenderPassEncoder.idl > Modules/webgpu/WebGPURenderPipeline.idl >diff --git a/Source/WebCore/DerivedSources-input.xcfilelist b/Source/WebCore/DerivedSources-input.xcfilelist >index 4c3bc74d45ec52a5f0aa0ec4f2fd20b77a397527..d409cb81c0d16b57af980fe5c782cf1545df3a40 100644 >--- a/Source/WebCore/DerivedSources-input.xcfilelist >+++ b/Source/WebCore/DerivedSources-input.xcfilelist >@@ -321,10 +321,13 @@ $(PROJECT_DIR)/Modules/webdatabase/SQLTransactionCallback.idl > $(PROJECT_DIR)/Modules/webdatabase/SQLTransactionErrorCallback.idl > $(PROJECT_DIR)/Modules/webdriver/NavigatorWebDriver.idl > $(PROJECT_DIR)/Modules/webgpu/DOMWindowWebGPU.idl >+$(PROJECT_DIR)/Modules/webgpu/GPUColor.idl > $(PROJECT_DIR)/Modules/webgpu/GPUCompareFunction.idl > $(PROJECT_DIR)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl > $(PROJECT_DIR)/Modules/webgpu/GPUExtent3D.idl >+$(PROJECT_DIR)/Modules/webgpu/GPULoadOp.idl > $(PROJECT_DIR)/Modules/webgpu/GPURequestAdapterOptions.idl >+$(PROJECT_DIR)/Modules/webgpu/GPUStoreOp.idl > $(PROJECT_DIR)/Modules/webgpu/GPUTextureDescriptor.idl > $(PROJECT_DIR)/Modules/webgpu/GPUTextureDimension.idl > $(PROJECT_DIR)/Modules/webgpu/GPUTextureFormat.idl >diff --git a/Source/WebCore/DerivedSources-output.xcfilelist b/Source/WebCore/DerivedSources-output.xcfilelist >index 22fcf27376744b61fd4fc72f94e467f8615c4626..eeea5fe8f50f44601078b513e01e5607b282d198 100644 >--- a/Source/WebCore/DerivedSources-output.xcfilelist >+++ b/Source/WebCore/DerivedSources-output.xcfilelist >@@ -578,14 +578,20 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFaceSet.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFaceSet.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGCObservation.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGCObservation.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPULoadOp.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPULoadOp.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUStoreOp.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUStoreOp.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDescriptor.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDescriptor.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDimension.cpp >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index 0547279a42c115200703507f662378a54993f7f6..22927ed676f01c8e172dfaa08bee6e2acc5eb667 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -372,10 +372,13 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webdatabase/SQLTransactionErrorCallback.idl \ > $(WebCore)/Modules/webdriver/NavigatorWebDriver.idl \ > $(WebCore)/Modules/webgpu/DOMWindowWebGPU.idl \ >+ $(WebCore)/Modules/webgpu/GPUColor.idl \ > $(WebCore)/Modules/webgpu/GPUCompareFunction.idl \ > $(WebCore)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl \ > $(WebCore)/Modules/webgpu/GPUExtent3D.idl \ >+ $(WebCore)/Modules/webgpu/GPULoadOp.idl \ > $(WebCore)/Modules/webgpu/GPURequestAdapterOptions.idl \ >+ $(WebCore)/Modules/webgpu/GPUStoreOp.idl \ > $(WebCore)/Modules/webgpu/GPUTextureDescriptor.idl \ > $(WebCore)/Modules/webgpu/GPUTextureDimension.idl \ > $(WebCore)/Modules/webgpu/GPUTextureFormat.idl \ >@@ -392,7 +395,6 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webgpu/WebGPUBufferBinding.idl \ > $(WebCore)/Modules/webgpu/WebGPUBufferDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPUBufferUsage.idl \ >- $(WebCore)/Modules/webgpu/WebGPUColor.idl \ > $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \ > $(WebCore)/Modules/webgpu/WebGPUDevice.idl \ > $(WebCore)/Modules/webgpu/WebGPUIndexFormat.idl \ >@@ -404,7 +406,6 @@ JS_BINDING_IDLS = \ > $(WebCore)/Modules/webgpu/WebGPUPipelineLayoutDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPUProgrammablePassEncoder.idl \ >- $(WebCore)/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPURenderPassDescriptor.idl \ > $(WebCore)/Modules/webgpu/WebGPURenderPassEncoder.idl \ > $(WebCore)/Modules/webgpu/WebGPURenderPipeline.idl \ >diff --git a/Source/WebCore/Modules/webgpu/GPUColor.idl b/Source/WebCore/Modules/webgpu/GPUColor.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..962cc435d7a5f4339860ebcea226dec85f1ec9b8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/GPUColor.idl >@@ -0,0 +1,35 @@ >+/* >+ * 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 >+] dictionary GPUColor { >+ float r; >+ float g; >+ float b; >+ float a; >+}; >diff --git a/Source/WebCore/Modules/webgpu/GPULoadOp.idl b/Source/WebCore/Modules/webgpu/GPULoadOp.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..48eff8f8fd6634a08ecb09575606eec2051c0ca3 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/GPULoadOp.idl >@@ -0,0 +1,33 @@ >+/* >+ * 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 >+] enum GPULoadOp { >+ "clear", >+ "load" >+}; >diff --git a/Source/WebCore/Modules/webgpu/GPUStoreOp.idl b/Source/WebCore/Modules/webgpu/GPUStoreOp.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..f7d11c905cbeb9f3c03a4138ab53f16416dd5e90 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/GPUStoreOp.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 >+] enum GPUStoreOp { >+ "store" >+}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUColor.h b/Source/WebCore/Modules/webgpu/WebGPUColor.h >deleted file mode 100644 >index 8cc96dd6fed373af1808330f349525fb66e95771..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUColor.h >+++ /dev/null >@@ -1,38 +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 "GPUColor.h" >- >-namespace WebCore { >- >-using WebGPUColor = GPUColor; >- >-} // namespace WebCore >- >-#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPUColor.idl b/Source/WebCore/Modules/webgpu/WebGPUColor.idl >deleted file mode 100644 >index e613c2b5106caaeff58ebc66cb2244c2ef50b3db..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPUColor.idl >+++ /dev/null >@@ -1,35 +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 >- >-[ >- Conditional=WEBGPU, >- EnabledAtRuntime=WebGPU >-] dictionary WebGPUColor { >- float r; >- float g; >- float b; >- float a; >-}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp b/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp >index 1a41053eeb3f59cafc6444b7a0dfee750d9eebab..43a86e7db81de60353ae9c042735d589d08c89e2 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp >+++ b/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp >@@ -28,11 +28,8 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandBuffer.h" > #include "GPURenderPassDescriptor.h" > #include "GPURenderPassEncoder.h" >-#include "GPURenderPipeline.h" >-#include "Logging.h" > #include "WebGPURenderPassDescriptor.h" > #include "WebGPURenderPassEncoder.h" > >@@ -50,23 +47,11 @@ WebGPUCommandBuffer::WebGPUCommandBuffer(Ref<GPUCommandBuffer>&& buffer) > > RefPtr<WebGPURenderPassEncoder> WebGPUCommandBuffer::beginRenderPass(WebGPURenderPassDescriptor&& descriptor) > { >- // FIXME: Improve error checking as WebGPURenderPassDescriptor is implemented. >- if (descriptor.colorAttachments.isEmpty()) { >- LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachments specified for WebGPURenderPassDescriptor!"); >+ auto gpuDescriptor = descriptor.validateAndConvertToGPUVersion(); >+ if (!gpuDescriptor) > return nullptr; >- } > >- GPURenderPassDescriptor gpuRenderPassDescriptor; >- >- for (const auto& colorAttachment : descriptor.colorAttachments) { >- if (!colorAttachment.attachment) { >- LOG(WebGPU, "WebGPUCommandBuffer::create(): Invalid attachment in WebGPURenderPassColorAttachmentDescriptor!"); >- return nullptr; >- } >- gpuRenderPassDescriptor.colorAttachments.append(GPURenderPassColorAttachmentDescriptor { colorAttachment.attachment->texture(), colorAttachment.clearColor }); >- } >- >- if (auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(gpuRenderPassDescriptor))) >+ if (auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(*gpuDescriptor))) > return WebGPURenderPassEncoder::create(*this, encoder.releaseNonNull()); > return nullptr; > } >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h >deleted file mode 100644 >index ab72b553df0e892780226a4dd5461bee4df36299..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.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 "WebGPUColor.h" >-#include "WebGPUTextureView.h" >- >-namespace WebCore { >- >-struct WebGPURenderPassColorAttachmentDescriptor { >- RefPtr<WebGPUTextureView> attachment; >- >- WebGPUColor clearColor; >-}; >- >-} // namespace WebCore >- >-#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl >deleted file mode 100644 >index 58c5cc8c863abe6e667d77641576d68ad4fd861b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.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 >- >-[ >- Conditional=WEBGPU, >- EnabledAtRuntime=WebGPU >-] dictionary WebGPURenderPassColorAttachmentDescriptor { >- WebGPUTextureView attachment; >- >- // Not Yet Implemented >- // WebGPULoadOp loadOp; >- // WebGPUStoreOp storeOp; >- WebGPUColor clearColor; >-}; >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f688be7e60d80199e2dd2a08de39c25b132c179a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp >@@ -0,0 +1,81 @@ >+/* >+ * 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 "WebGPURenderPassDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#include "GPURenderPassDescriptor.h" >+#include "Logging.h" >+ >+namespace WebCore { >+ >+GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor(Ref<GPUTexture>&& texture, GPULoadOp load, GPUStoreOp store, GPUColor color) >+ : GPURenderPassColorAttachmentDescriptorBase { load, store, color } >+ , attachment(WTFMove(texture)) >+{ >+} >+ >+GPURenderPassDepthStencilAttachmentDescriptor::GPURenderPassDepthStencilAttachmentDescriptor(Ref<GPUTexture>&& texture, GPULoadOp load, GPUStoreOp store, float depth) >+ : GPURenderPassDepthStencilAttachmentDescriptorBase { load, store, depth } >+ , attachment(WTFMove(texture)) >+{ >+} >+ >+Optional<GPURenderPassDescriptor> WebGPURenderPassDescriptor::validateAndConvertToGPUVersion() const >+{ >+ // FIXME: Improve error checking as WebGPURenderPassDescriptor is added to spec. >+ if (colorAttachments.isEmpty()) { >+ LOG(WebGPU, "GPURenderPassDescriptor: No color attachments specified for GPURenderPassDescriptor!"); >+ return WTF::nullopt; >+ } >+ >+ Vector<GPURenderPassColorAttachmentDescriptor> gpuColorAttachments; >+ >+ for (const auto& colorAttachment : colorAttachments) { >+ if (!colorAttachment.attachment) { >+ LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassColorAttachmentDescriptor!"); >+ return WTF::nullopt; >+ } >+ gpuColorAttachments.append(GPURenderPassColorAttachmentDescriptor(colorAttachment.attachment->texture(), colorAttachment.loadOp, colorAttachment.storeOp, colorAttachment.clearColor)); >+ } >+ >+ Optional<GPURenderPassDepthStencilAttachmentDescriptor> gpuDepthAttachment; >+ >+ if (depthStencilAttachment) { >+ if (!depthStencilAttachment->attachment) { >+ LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassDepthStencilAttachmentDescriptor!"); >+ return WTF::nullopt; >+ } >+ gpuDepthAttachment = GPURenderPassDepthStencilAttachmentDescriptor(depthStencilAttachment->attachment->texture(), depthStencilAttachment->depthLoadOp, depthStencilAttachment->depthStoreOp, depthStencilAttachment->clearDepth); >+ } >+ >+ return GPURenderPassDescriptor { WTFMove(gpuColorAttachments), WTFMove(gpuDepthAttachment) }; >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h >index c19230c0cf0b0dc2f12faac220e1a835c39c76b7..da9b1f7e67cbcd097ade37b61612e6c77668e75d 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h >@@ -27,14 +27,29 @@ > > #if ENABLE(WEBGPU) > >-#include "WebGPURenderPassColorAttachmentDescriptor.h" >- >+#include "GPURenderPassDescriptor.h" >+#include "WebGPUTextureView.h" >+#include <wtf/Optional.h> >+#include <wtf/RefPtr.h> > #include <wtf/Vector.h> > > namespace WebCore { > >+struct GPURenderPassDescriptor; >+ >+struct WebGPURenderPassColorAttachmentDescriptor : GPURenderPassColorAttachmentDescriptorBase { >+ RefPtr<WebGPUTextureView> attachment; >+}; >+ >+struct WebGPURenderPassDepthStencilAttachmentDescriptor : GPURenderPassDepthStencilAttachmentDescriptorBase { >+ RefPtr<WebGPUTextureView> attachment; >+}; >+ > struct WebGPURenderPassDescriptor { >+ Optional<GPURenderPassDescriptor> validateAndConvertToGPUVersion() const; >+ > Vector<WebGPURenderPassColorAttachmentDescriptor> colorAttachments; >+ Optional<WebGPURenderPassDepthStencilAttachmentDescriptor> depthStencilAttachment; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl >index b7ade3c4c6bd05f943a355753121cdf2db9763aa..f38f2e32cccd8a31ee826a2a6642e6bba3c77d96 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl >@@ -24,10 +24,41 @@ > */ > // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl > >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU, >+ ImplementedAs=WebGPURenderPassColorAttachmentDescriptor >+] dictionary GPURenderPassColorAttachmentDescriptor { >+ WebGPUTextureView attachment; >+ // GPUTextureView? resolveTarget; >+ >+ GPULoadOp loadOp; >+ GPUStoreOp storeOp; >+ GPUColor clearColor; >+}; >+ >+[ >+ Conditional=WEBGPU, >+ EnabledAtRuntime=WebGPU, >+ ImplementedAs=WebGPURenderPassDepthStencilAttachmentDescriptor >+] dictionary GPURenderPassDepthStencilAttachmentDescriptor { >+ WebGPUTextureView attachment; >+ >+ GPULoadOp depthLoadOp; >+ GPUStoreOp depthStoreOp; >+ float clearDepth; >+ >+/* Not yet implemented >+ GPULoadOp stencilLoadOp; >+ GPUStoreOp stencilStoreOp; >+ u32 clearStencil; >+*/ >+}; >+ > [ > Conditional=WEBGPU, > EnabledAtRuntime=WebGPU > ] dictionary WebGPURenderPassDescriptor { >- sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments; >- // WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment; >+ sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments; >+ GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment; > }; >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >index 04ea6882be811a6582cfd58a1d31cfecea38610c..f95657b24e4a8b8c6242077413fb045b222eccab 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h >@@ -32,6 +32,7 @@ > #include "WebGPUInputStateDescriptor.h" > #include "WebGPUPipelineDescriptorBase.h" > #include "WebGPUPipelineStageDescriptor.h" >+#include <wtf/Optional.h> > > namespace WebCore { > >@@ -41,7 +42,7 @@ struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase { > WebGPUPipelineStageDescriptor vertexStage; > WebGPUPipelineStageDescriptor fragmentStage; > PrimitiveTopology primitiveTopology; >- GPUDepthStencilStateDescriptor depthStencilState; >+ Optional<GPUDepthStencilStateDescriptor> depthStencilState; > WebGPUInputStateDescriptor inputState; > }; > >diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >index 12bd71d373949aa4bf85eed692d3e0c0ba7d8eb9..0ffe8a1fc480fa0b18daff399e77e547584b578f 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >+++ b/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl >@@ -40,7 +40,7 @@ enum WebGPUPrimitiveTopology { > WebGPUPipelineStageDescriptor fragmentStage; > > WebGPUPrimitiveTopology primitiveTopology; >- GPUDepthStencilStateDescriptor depthStencilState; >+ GPUDepthStencilStateDescriptor? depthStencilState; > WebGPUInputStateDescriptor inputState; > /* To Be Implemented: > sequence<WebGPUBlendStateDescriptor> blendStates; >diff --git a/Source/WebCore/Modules/webgpu/WebGPUTextureView.h b/Source/WebCore/Modules/webgpu/WebGPUTextureView.h >index fbeb8bc665604277e0df39503f8791beca092adb..123f440cafba91287482d3145ec1d69317ecd366 100644 >--- a/Source/WebCore/Modules/webgpu/WebGPUTextureView.h >+++ b/Source/WebCore/Modules/webgpu/WebGPUTextureView.h >@@ -28,7 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "GPUTexture.h" >- >+#include <wtf/Ref.h> > #include <wtf/RefCounted.h> > > namespace WebCore { >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 7aeccf700fe3be564caf02ea8c41d9a30cd38dd8..f630c470da26cacd192d26fe5d1da9ef770ab11f 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -357,6 +357,7 @@ Modules/webgpu/WebGPUQueue.cpp > Modules/webgpu/WebGPUPipelineLayout.cpp > Modules/webgpu/WebGPUProgrammablePassEncoder.cpp > Modules/webgpu/WebGPURenderingContext.cpp >+Modules/webgpu/WebGPURenderPassDescriptor.cpp > Modules/webgpu/WebGPURenderPassEncoder.cpp > Modules/webgpu/WebGPURenderPipeline.cpp > Modules/webgpu/WebGPUShaderModule.cpp >@@ -2764,10 +2765,13 @@ JSFillMode.cpp > JSFocusEvent.cpp > JSFontFace.cpp > JSFontFaceSet.cpp >+JSGPUColor.cpp > JSGPUCompareFunction.cpp > JSGPUDepthStencilStateDescriptor.cpp > JSGPUExtent3D.cpp >+JSGPULoadOp.cpp > JSGPURequestAdapterOptions.cpp >+JSGPUStoreOp.cpp > JSGPUTextureDescriptor.cpp > JSGPUTextureDimension.cpp > JSGPUTextureFormat.cpp >@@ -3312,7 +3316,6 @@ JSWebGPUBuffer.cpp > JSWebGPUBufferBinding.cpp > JSWebGPUBufferDescriptor.cpp > JSWebGPUBufferUsage.cpp >-JSWebGPUColor.cpp > JSWebGPUCommandBuffer.cpp > JSWebGPUDevice.cpp > JSWebGPUIndexFormat.cpp >@@ -3325,7 +3328,6 @@ JSWebGPUPipelineLayoutDescriptor.cpp > JSWebGPUPipelineStageDescriptor.cpp > JSWebGPUProgrammablePassEncoder.cpp > JSWebGPURenderingContext.cpp >-JSWebGPURenderPassColorAttachmentDescriptor.cpp > JSWebGPURenderPassDescriptor.cpp > JSWebGPURenderPassEncoder.cpp > JSWebGPURenderPipeline.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 0273cbbabf40606b43b16487110be5b2f56ab477..dd6bec254f87256a9cd2cbb4322fcf21cdd82b99 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13934,12 +13934,7 @@ > D000EBA111BDAFD400C47726 /* FrameLoaderStateMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameLoaderStateMachine.h; sourceTree = "<group>"; }; > D000ED2511C1B9CD00C47726 /* SubframeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubframeLoader.cpp; sourceTree = "<group>"; }; > D000ED2611C1B9CD00C47726 /* SubframeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubframeLoader.h; sourceTree = "<group>"; }; >- D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPURenderPassColorAttachmentDescriptor.h; sourceTree = "<group>"; }; > D001D9AB21B0C7BF0023B9BC /* GPUColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUColor.h; sourceTree = "<group>"; }; >- D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUColor.h; sourceTree = "<group>"; }; >- D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUColor.idl; sourceTree = "<group>"; }; >- D001D9B021B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPassColorAttachmentDescriptor.h; sourceTree = "<group>"; }; >- D001D9B121B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassColorAttachmentDescriptor.idl; sourceTree = "<group>"; }; > D003287921C8645B00622AA6 /* WebGPUBindGroupLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBindGroupLayout.h; sourceTree = "<group>"; }; > D003287A21C8645B00622AA6 /* WebGPUBindGroupLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUBindGroupLayout.cpp; sourceTree = "<group>"; }; > D003287B21C8645B00622AA6 /* WebGPUBindGroupLayout.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroupLayout.idl; sourceTree = "<group>"; }; >@@ -13960,6 +13955,7 @@ > D00F595421701D8C000D71DB /* WebGPUDevice.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUDevice.idl; sourceTree = "<group>"; }; > D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpaceSplitString.cpp; sourceTree = "<group>"; }; > D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpaceSplitString.h; sourceTree = "<group>"; }; >+ D01B811222125AFC00627B6C /* GPUColor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUColor.idl; sourceTree = "<group>"; }; > D0232B5821CB49B7009483B9 /* GPUBindGroupLayoutMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBindGroupLayoutMetal.mm; sourceTree = "<group>"; }; > D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupLayout.h; sourceTree = "<group>"; }; > D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUExtent3D.h; sourceTree = "<group>"; }; >@@ -14087,6 +14083,12 @@ > D087CE3E21ACA94200BDE174 /* GPUSwapChainMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUSwapChainMetal.mm; sourceTree = "<group>"; }; > D087CE3F21ACA94200BDE174 /* GPUTextureMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; }; > D087CE4021ACA94200BDE174 /* GPUShaderModuleMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUShaderModuleMetal.mm; sourceTree = "<group>"; }; >+ D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPULoadOp.idl; sourceTree = "<group>"; }; >+ D08AA02F220D0BD50058C502 /* GPULoadOp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPULoadOp.h; sourceTree = "<group>"; }; >+ D08AA031220D0CE60058C502 /* GPUStoreOp.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUStoreOp.idl; sourceTree = "<group>"; }; >+ D08AA032220D0D0B0058C502 /* GPUStoreOp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUStoreOp.h; sourceTree = "<group>"; }; >+ D08AA036220D19DA0058C502 /* WebGPURenderPassDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassDescriptor.idl; sourceTree = "<group>"; }; >+ D08AA037220D1D050058C502 /* WebGPURenderPassDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderPassDescriptor.cpp; sourceTree = "<group>"; }; > D093D225217951D400329217 /* WebGPURenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderingContext.h; sourceTree = "<group>"; }; > D093D227217951D400329217 /* WebGPURenderingContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderingContext.idl; sourceTree = "<group>"; }; > D093D2292179541600329217 /* WebGPURenderingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderingContext.cpp; sourceTree = "<group>"; }; >@@ -14162,7 +14164,6 @@ > D0EACF882193EE4E000FA75C /* WebGPUTextureView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUTextureView.cpp; sourceTree = "<group>"; }; > D0EACF892193EE4E000FA75C /* WebGPUTextureView.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUTextureView.idl; sourceTree = "<group>"; }; > D0EACF8C219403C9000FA75C /* WebGPURenderPassDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPassDescriptor.h; sourceTree = "<group>"; }; >- D0EACF8D219403C9000FA75C /* WebGPURenderPassDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassDescriptor.idl; sourceTree = "<group>"; }; > D0EACF8E21940A22000FA75C /* WebGPURenderPassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPassEncoder.h; sourceTree = "<group>"; }; > D0EACF8F21940A22000FA75C /* WebGPURenderPassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderPassEncoder.cpp; sourceTree = "<group>"; }; > D0EACF9021940A22000FA75C /* WebGPURenderPassEncoder.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassEncoder.idl; sourceTree = "<group>"; }; >@@ -18486,6 +18487,7 @@ > D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */, > D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */, > D0F7559F2203BA1400118058 /* GPULimits.h */, >+ D08AA02F220D0BD50058C502 /* GPULoadOp.h */, > 312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */, > D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */, > D003288621C9A4E500622AA6 /* GPUPipelineLayout.h */, >@@ -18493,7 +18495,6 @@ > 312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */, > D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */, > 312FF8C121A4C2F200EB199D /* GPUQueue.h */, >- D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */, > D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */, > D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */, > 312FF8B921A4C2EF00EB199D /* GPURenderPipeline.h */, >@@ -18501,6 +18502,7 @@ > D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */, > 312FF8BB21A4C2F000EB199D /* GPUShaderModule.h */, > 312FF8C021A4C2F200EB199D /* GPUShaderModuleDescriptor.h */, >+ D08AA032220D0D0B0058C502 /* GPUStoreOp.h */, > 312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */, > 312FF8C521A4C2F400EB199D /* GPUTexture.h */, > D026F48C220A5BAD00AC5F49 /* GPUTextureDescriptor.h */, >@@ -26073,10 +26075,13 @@ > D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */, > D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */, > D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */, >+ D01B811222125AFC00627B6C /* GPUColor.idl */, > D03C849E21FFCF000002227F /* GPUCompareFunction.idl */, > D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */, > D026F480220A2B7000AC5F49 /* GPUExtent3D.idl */, >+ D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */, > D02C26922181416D00D818E4 /* GPURequestAdapterOptions.idl */, >+ D08AA031220D0CE60058C502 /* GPUStoreOp.idl */, > D026F48B220A5B0B00AC5F49 /* GPUTextureDescriptor.idl */, > D026F489220A539800AC5F49 /* GPUTextureDimension.idl */, > D0EACFAE219E30FD000FA75C /* GPUTextureFormat.idl */, >@@ -26110,8 +26115,6 @@ > D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */, > D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */, > D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */, >- D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */, >- D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */, > D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */, > D0EACF7621937228000FA75C /* WebGPUCommandBuffer.h */, > D0EACF7821937228000FA75C /* WebGPUCommandBuffer.idl */, >@@ -26142,10 +26145,9 @@ > D093D2292179541600329217 /* WebGPURenderingContext.cpp */, > D093D225217951D400329217 /* WebGPURenderingContext.h */, > D093D227217951D400329217 /* WebGPURenderingContext.idl */, >- D001D9B021B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.h */, >- D001D9B121B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.idl */, >+ D08AA037220D1D050058C502 /* WebGPURenderPassDescriptor.cpp */, > D0EACF8C219403C9000FA75C /* WebGPURenderPassDescriptor.h */, >- D0EACF8D219403C9000FA75C /* WebGPURenderPassDescriptor.idl */, >+ D08AA036220D19DA0058C502 /* WebGPURenderPassDescriptor.idl */, > D0EACF8F21940A22000FA75C /* WebGPURenderPassEncoder.cpp */, > D0EACF8E21940A22000FA75C /* WebGPURenderPassEncoder.h */, > D0EACF9021940A22000FA75C /* WebGPURenderPassEncoder.idl */, >diff --git a/Source/WebCore/platform/graphics/gpu/GPULoadOp.h b/Source/WebCore/platform/graphics/gpu/GPULoadOp.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ea24eef5274fbc0ad7674f6bc56e8f196e1c9612 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPULoadOp.h >@@ -0,0 +1,39 @@ >+/* >+ * 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) >+ >+namespace WebCore { >+ >+enum class GPULoadOp { >+ Clear, >+ Load >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h >deleted file mode 100644 >index b9d4602a0a885afd8ebc88f9954d4cb60ea86e9a..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.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 "GPUColor.h" >-#include "GPUTexture.h" >- >-namespace WebCore { >- >-struct GPURenderPassColorAttachmentDescriptor { >- Ref<GPUTexture> attachment; >- >- GPUColor clearColor; >-}; >- >-} // namespace WebCore >- >-#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >index edce9dee4b925534caf1dc59c8bda204235b6240..f4ac69aa45bbc77ed4bbdcbfab7a0f308dc5bc86 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >@@ -27,14 +27,44 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassColorAttachmentDescriptor.h" >- >+#include "GPUColor.h" >+#include "GPULoadOp.h" >+#include "GPUStoreOp.h" >+#include "GPUTexture.h" >+#include <wtf/Optional.h> > #include <wtf/Vector.h> > > namespace WebCore { > >+struct GPURenderPassColorAttachmentDescriptorBase { >+ GPULoadOp loadOp; >+ GPUStoreOp storeOp; >+ GPUColor clearColor; >+}; >+ >+struct GPURenderPassColorAttachmentDescriptor final : GPURenderPassColorAttachmentDescriptorBase { >+ GPURenderPassColorAttachmentDescriptor(Ref<GPUTexture>&&, GPULoadOp, GPUStoreOp, GPUColor); >+ >+ Ref<GPUTexture> attachment; >+}; >+ >+struct GPURenderPassDepthStencilAttachmentDescriptorBase { >+ GPULoadOp depthLoadOp; >+ GPUStoreOp depthStoreOp; >+ float clearDepth; >+ >+ // FIXME: Add stencil support. >+}; >+ >+struct GPURenderPassDepthStencilAttachmentDescriptor final : GPURenderPassDepthStencilAttachmentDescriptorBase { >+ GPURenderPassDepthStencilAttachmentDescriptor(Ref<GPUTexture>&&, GPULoadOp, GPUStoreOp, float); >+ >+ Ref<GPUTexture> attachment; >+}; >+ > struct GPURenderPassDescriptor { > Vector<GPURenderPassColorAttachmentDescriptor> colorAttachments; >+ Optional<GPURenderPassDepthStencilAttachmentDescriptor> depthStencilAttachment; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >index 627531b76bb27ec6d25bf46b38ba1bde94a76c05..a8f59acc566453c41af73f9a39eea33e221d6df5 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >@@ -31,7 +31,7 @@ > #include "GPUInputStateDescriptor.h" > #include "GPUPipelineDescriptorBase.h" > #include "GPUPipelineStageDescriptor.h" >- >+#include <wtf/Optional.h> > #include <wtf/Vector.h> > > namespace WebCore { >@@ -45,7 +45,7 @@ struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase { > TriangleStrip > }; > >- GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, PrimitiveTopology topology, GPUDepthStencilStateDescriptor&& depth, GPUInputStateDescriptor&& input) >+ GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, PrimitiveTopology topology, Optional<GPUDepthStencilStateDescriptor>&& depth, GPUInputStateDescriptor&& input) > : GPUPipelineDescriptorBase { WTFMove(layout) } > , vertexStage(WTFMove(vertex)) > , fragmentStage(WTFMove(fragment)) >@@ -58,7 +58,7 @@ struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase { > GPUPipelineStageDescriptor vertexStage; > GPUPipelineStageDescriptor fragmentStage; > PrimitiveTopology primitiveTopology; >- GPUDepthStencilStateDescriptor depthStencilState; >+ Optional<GPUDepthStencilStateDescriptor> depthStencilState; > GPUInputStateDescriptor inputState; > }; > >diff --git a/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h b/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h >new file mode 100644 >index 0000000000000000000000000000000000000000..62783248913e451dc36a47ab5f0e23ca24adc30f >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h >@@ -0,0 +1,38 @@ >+/* >+ * 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) >+ >+namespace WebCore { >+ >+enum class GPUStoreOp { >+ Store >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTexture.h b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >index 502b12bb8797705619936ab20d1fef778f5a4c32..55d1e3c82897e345f9b3a72768750ad54a347a27 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTexture.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >@@ -27,8 +27,8 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/Ref.h> > #include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > > OBJC_PROTOCOL(MTLTexture); >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >index 5a8c8d2b3ee0d05f08dad6195d18275856218e4d..92e2acf50ce1ae0afffe6dcf35a86ae6ce8ac083 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm >@@ -40,29 +40,113 @@ > > namespace WebCore { > >+static MTLLoadAction loadActionForGPULoadOp(GPULoadOp op) >+{ >+ switch (op) { >+ case GPULoadOp::Clear: >+ return MTLLoadActionClear; >+ case GPULoadOp::Load: >+ return MTLLoadActionLoad; >+ } >+ >+ ASSERT_NOT_REACHED(); >+} >+ >+static MTLStoreAction storeActionForGPUStoreOp(GPUStoreOp op) >+{ >+ switch (op) { >+ case GPUStoreOp::Store: >+ return MTLStoreActionStore; >+ } >+ >+ ASSERT_NOT_REACHED(); >+} >+ >+static bool populateMtlColorAttachmentsArray(MTLRenderPassColorAttachmentDescriptorArray *array, const Vector<GPURenderPassColorAttachmentDescriptor>& descriptors, const char* const functionName) >+{ >+#if LOG_DISABLED >+ UNUSED_PARAM(functionName); >+#endif >+ >+ for (unsigned i = 0; i < descriptors.size(); ++i) { >+ const auto& descriptor = descriptors[i]; >+ if (!descriptor.attachment->platformTexture()) { >+ LOG(WebGPU, "%s: Invalid MTLTexture for color attachment %u!", functionName, i); >+ return false; >+ } >+ const auto& color = descriptor.clearColor; >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ auto mtlAttachment = retainPtr([array objectAtIndexedSubscript:i]); >+ [mtlAttachment setTexture:descriptor.attachment->platformTexture()]; >+ [mtlAttachment setClearColor:MTLClearColorMake(color.r, color.g, color.b, color.a)]; >+ [mtlAttachment setLoadAction:loadActionForGPULoadOp(descriptor.loadOp)]; >+ [mtlAttachment setStoreAction:storeActionForGPUStoreOp(descriptor.storeOp)]; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+ } >+ >+ return true; >+} >+ >+static bool populateMtlDepthStencilAttachment(MTLRenderPassDepthAttachmentDescriptor *mtlAttachment, const GPURenderPassDepthStencilAttachmentDescriptor& descriptor, const char* const functionName) >+{ >+#if LOG_DISABLED >+ UNUSED_PARAM(functionName); >+#endif >+ >+ if (!descriptor.attachment->platformTexture()) { >+ LOG(WebGPU, "%s: Invalid MTLTexture for depth attachment!", functionName); >+ return false; >+ } >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ [mtlAttachment setTexture:descriptor.attachment->platformTexture()]; >+ [mtlAttachment setClearDepth:descriptor.clearDepth]; >+ [mtlAttachment setLoadAction:loadActionForGPULoadOp(descriptor.depthLoadOp)]; >+ [mtlAttachment setStoreAction:storeActionForGPUStoreOp(descriptor.depthStoreOp)]; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+ >+ return true; >+} >+ > RefPtr<GPURenderPassEncoder> GPURenderPassEncoder::create(const GPUCommandBuffer& buffer, GPURenderPassDescriptor&& descriptor) > { >- PlatformRenderPassEncoderSmartPtr mtlEncoder; >+ const char* const functionName = "GPURenderPassEncoder::create()"; > >- // FIXME: Default to colorAttachments[0] and this loadOp, storeOp for now. >- const auto& attachmentDescriptor = descriptor.colorAttachments[0]; >- const auto& color = attachmentDescriptor.clearColor; >+ RetainPtr<MTLRenderPassDescriptor> mtlDescriptor; > > BEGIN_BLOCK_OBJC_EXCEPTIONS; > >- auto mtlDescriptor = adoptNS([MTLRenderPassDescriptor new]); >+ mtlDescriptor = adoptNS([MTLRenderPassDescriptor new]); > >- mtlDescriptor.get().colorAttachments[0].texture = attachmentDescriptor.attachment->platformTexture(); >- mtlDescriptor.get().colorAttachments[0].loadAction = MTLLoadActionClear; >- mtlDescriptor.get().colorAttachments[0].storeAction = MTLStoreActionStore; >- mtlDescriptor.get().colorAttachments[0].clearColor = MTLClearColorMake(color.r, color.g, color.b, color.a); >+ END_BLOCK_OBJC_EXCEPTIONS; >+ >+ if (!mtlDescriptor) { >+ LOG(WebGPU, "%s: Unable to create MTLRenderPassDescriptor!", functionName); >+ return nullptr; >+ } >+ >+ if (!populateMtlColorAttachmentsArray(mtlDescriptor.get().colorAttachments, descriptor.colorAttachments, functionName)) >+ return nullptr; >+ >+ if (descriptor.depthStencilAttachment >+ && !populateMtlDepthStencilAttachment(mtlDescriptor.get().depthAttachment, *descriptor.depthStencilAttachment, functionName)) >+ return nullptr; >+ >+ PlatformRenderPassEncoderSmartPtr mtlEncoder; >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; > > mtlEncoder = retainPtr([buffer.platformCommandBuffer() renderCommandEncoderWithDescriptor:mtlDescriptor.get()]); > > END_BLOCK_OBJC_EXCEPTIONS; > > if (!mtlEncoder) { >- LOG(WebGPU, "GPURenderPassEncoder::create(): Unable to create MTLRenderCommandEncoder!"); >+ LOG(WebGPU, "%s: Unable to create MTLRenderCommandEncoder!", functionName); > return nullptr; > } > >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >index 493ff25653548c4fa2286895560d2cb948b90058..84ebea711c5bd0b9b579ade537aee1f882c86183 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >@@ -296,8 +296,11 @@ RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPU > return nullptr; > } > >- // Depth Stencil state is separate from the render pipeline state in Metal. >- auto depthStencil = tryCreateMtlDepthStencilState(functionName, descriptor.depthStencilState, device); >+ // Depth Stencil state is optional and separate from the render pipeline state in Metal. >+ RetainPtr<MTLDepthStencilState> depthStencil; >+ >+ if (descriptor.depthStencilState) >+ depthStencil = tryCreateMtlDepthStencilState(functionName, *descriptor.depthStencilState, device); > > auto pipeline = tryCreateMtlRenderPipelineState(functionName, descriptor, device); > if (!pipeline) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f8008d7691d140207be9611cce90a363761fd97a..0382cc9e9c9d16233bf7dc29559265773a7e7d04 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,27 @@ >+2019-02-08 Justin Fan <justin_fan@apple.com> >+ >+ [Web GPU] DepthStencilAttachment implementation >+ https://bugs.webkit.org/show_bug.cgi?id=194458 >+ <rdar://problem/47932446> >+ >+ Reviewed by Dean Jackson. >+ >+ Add test and update utility functions for depth texture attachments. Update others to specify their >+ loadOp and storeOp for all render pass attachments, as these are no longer provided by default by the implementation. >+ >+ * webgpu/buffer-resource-triangles.html: >+ * webgpu/depth-enabled-triangle-strip-expected.html: Added. >+ * webgpu/depth-enabled-triangle-strip.html: Added. >+ * webgpu/js/basic-webgpu-functions.js: >+ (render): >+ * webgpu/js/webgpu-functions.js: >+ (createBasicDepthStateDescriptor): >+ (createBasicDepthTexture): >+ (beginBasicRenderPass): >+ (createBasicPipeline): Deleted. >+ * webgpu/render-command-encoding.html: >+ * webgpu/render-passes.html: >+ > 2019-02-08 Youenn Fablet <youenn@apple.com> > > Running RTCRtpSender.getCapabilities("video") before initial offer breaks VP8 >diff --git a/LayoutTests/webgpu/buffer-resource-triangles.html b/LayoutTests/webgpu/buffer-resource-triangles.html >index 996579ef16c19b2dfb19ffb7cb41f2955a529ac6..c1964999c0ff7cae834104fc2116898ff64a8f24 100644 >--- a/LayoutTests/webgpu/buffer-resource-triangles.html >+++ b/LayoutTests/webgpu/buffer-resource-triangles.html >@@ -167,7 +167,7 @@ async function test() { > > // WebGPUPipelineLayout and WebGPURenderPipeline > const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [leftTriangleBGLayout, rightTriangleBGLayout] }); >- const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputState, "triangleList"); >+ const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputState, null, "triangleList"); > > // WebGPUBufferBindings > const bindingUL = createBufferBinding(upperLeft); >diff --git a/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html b/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..886f13e8120397a5cc6336c9e2a485e778ba9932 >--- /dev/null >+++ b/LayoutTests/webgpu/depth-enabled-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/depth-enabled-triangle-strip.html b/LayoutTests/webgpu/depth-enabled-triangle-strip.html >new file mode 100644 >index 0000000000000000000000000000000000000000..a68d9d8daa8c44aa99cb192a655da5814c51b9ba >--- /dev/null >+++ b/LayoutTests/webgpu/depth-enabled-triangle-strip.html >@@ -0,0 +1,124 @@ >+<!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 VertexIn >+{ >+ float4 position [[attribute(0)]]; >+}; >+ >+struct VertexOut >+{ >+ float4 position [[position]]; >+ float4 color; >+}; >+ >+vertex VertexOut vertex_main(VertexIn vertexIn [[stage_in]], uint iid [[instance_id]]) >+{ >+ VertexOut vOut; >+ vOut.position = vertexIn.position; >+ >+ if (iid == 0) { >+ vOut.position.z = 0.5; >+ vOut.color = float4(1, 0, 0, 1); >+ } else { >+ vOut.color = float4(0, 1, 0, 1); >+ } >+ >+ return vOut; >+} >+ >+fragment float4 fragment_main(VertexOut v [[stage_in]]) >+{ >+ return v.color; >+} >+` >+ >+function createVertexBuffer(device) { >+ const bufferSize = 4 * 4 * 4; >+ const buffer = device.createBuffer({ size: bufferSize, usage: WebGPUBufferUsage.MAP_WRITE }); >+ >+ let floatArray = new Float32Array(buffer.mapping); >+ >+ const vertices = [ >+ // float4 xyzw >+ -1, 1, 0, 1, >+ -1, -1, 0, 1, >+ 1, 1, 0, 1, >+ 1, -1, 0, 1 >+ ]; >+ >+ floatArray.set(vertices); >+ >+ return buffer; >+} >+ >+function createInputStateDescriptor() { >+ return { >+ indexFormat: WebGPUIndexFormat.UINT32, >+ attributes: [{ >+ shaderLocation: 0, >+ inputSlot: 0, >+ offset: 0, >+ format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32 >+ }], >+ inputs: [{ >+ inputSlot: 0, >+ 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 depthStateDescriptor = createBasicDepthStateDescriptor(); >+ const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor, depthStateDescriptor); >+ const commandBuffer = device.createCommandBuffer(); >+ >+ const basicAttachment = { >+ attachment: context.getNextTexture().createDefaultTextureView(), >+ loadOp: "clear", >+ storeOp: "store", >+ clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 } >+ }; >+ >+ const depthAttachment = { >+ attachment: createBasicDepthTexture(canvas, device).createDefaultTextureView(), >+ depthLoadOp: "clear", >+ depthStoreOp: "store", >+ clearDepth: 1.0 >+ }; >+ >+ const encoder = commandBuffer.beginRenderPass({ >+ colorAttachments: [basicAttachment], >+ depthStencilAttachment: depthAttachment >+ }); >+ >+ encoder.setVertexBuffers(0, [vertexBuffer], [0]); >+ encoder.setPipeline(pipeline); >+ encoder.draw(4, 2, 0, 0); >+ encoder.endPass(); >+ >+ device.getQueue().submit([commandBuffer]); >+ context.present(); >+} >+ >+test(); >+</script> >\ No newline at end of file >diff --git a/LayoutTests/webgpu/js/basic-webgpu-functions.js b/LayoutTests/webgpu/js/basic-webgpu-functions.js >index ce2468514eebff3f59653b8a90e387d12fb9e9fa..395195eaa884d91b45631f26f29f1ea3e46c9a77 100644 >--- a/LayoutTests/webgpu/js/basic-webgpu-functions.js >+++ b/LayoutTests/webgpu/js/basic-webgpu-functions.js >@@ -135,9 +135,10 @@ function render() { > return; > } > >- // FIXME: Default a loadOp, and storeOp in the implementation for now. > const colorAttachmentDescriptor = { > attachment : textureView, >+ loadOp: "clear", >+ storeOp: "store", > clearColor : { r: 0.35, g: 0.65, b: 0.85, a: 1.0 } > } > >diff --git a/LayoutTests/webgpu/js/webgpu-functions.js b/LayoutTests/webgpu/js/webgpu-functions.js >index bf43de6f8ebf48424d3ae1813cec741ad30ae223..278b210511a607dc99f594a2a328c0dbb321da60 100644 >--- a/LayoutTests/webgpu/js/webgpu-functions.js >+++ b/LayoutTests/webgpu/js/webgpu-functions.js >@@ -11,7 +11,32 @@ function createBasicContext(canvas, device) { > return context; > } > >-function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor, primitiveTopology = "triangleStrip") { >+function createBasicDepthStateDescriptor() { >+ return { >+ depthWriteEnabled: true, >+ depthCompare: "less" >+ }; >+} >+ >+function createBasicDepthTexture(canvas, device) { >+ const depthSize = { >+ width: canvas.width, >+ height: canvas.height, >+ depth: 1 >+ }; >+ >+ return device.createTexture({ >+ size: depthSize, >+ arrayLayerCount: 1, >+ mipLevelCount: 1, >+ sampleCount: 1, >+ dimension: "2d", >+ format: "d32-float-s8-uint", >+ usage: GPUTextureUsage.OUTPUT_ATTACHMENT >+ }); >+} >+ >+function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor, depthStateDescriptor, primitiveTopology = "triangleStrip") { > const vertexStageDescriptor = { > module: shaderModule, > entryPoint: "vertex_main" >@@ -34,12 +59,17 @@ function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDes > if (inputStateDescriptor) > pipelineDescriptor.inputState = inputStateDescriptor; > >+ if (depthStateDescriptor) >+ pipelineDescriptor.depthStencilState = depthStateDescriptor; >+ > return device.createRenderPipeline(pipelineDescriptor); > } > > function beginBasicRenderPass(context, commandBuffer) { > const basicAttachment = { > attachment: context.getNextTexture().createDefaultTextureView(), >+ loadOp: "clear", >+ storeOp: "store", > clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 } > } > >diff --git a/LayoutTests/webgpu/render-command-encoding.html b/LayoutTests/webgpu/render-command-encoding.html >index 872fb89ae26a9760dc4280858c6e062341e7bfd2..d2f99b20e02d610bb5497718f1639c56b7d383f4 100644 >--- a/LayoutTests/webgpu/render-command-encoding.html >+++ b/LayoutTests/webgpu/render-command-encoding.html >@@ -12,9 +12,10 @@ > let commandBuffer, renderPassEncoder; > > function beginPass() { >- // Default a loadOp, storeOp in the implementation for now. > const colorAttachmentDescriptor = { > attachment: context.getNextTexture().createDefaultTextureView(), >+ loadOp: "clear", >+ storeOp: "store", > clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 } > } > >diff --git a/LayoutTests/webgpu/render-passes.html b/LayoutTests/webgpu/render-passes.html >index 96c976fd04fa7866526ddec51a673ebc7575c8e1..53e2428bf3ada8c847643bb33616fad6e7ac7c24 100644 >--- a/LayoutTests/webgpu/render-passes.html >+++ b/LayoutTests/webgpu/render-passes.html >@@ -11,9 +11,10 @@ let commandBuffer, renderPassEncoder; > function setUpBasicRenderPassEncoder() { > commandBuffer = defaultDevice.createCommandBuffer(); > >- // Default a loadOp, storeOp in the implementation for now. > const colorAttachmentDescriptor = { > attachment: context.getNextTexture().createDefaultTextureView(), >+ loadOp: "clear", >+ storeOp: "store", > clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 } > } >
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 194458
:
361552
|
361558
|
361746
|
361761
| 361814