Title: [238741] trunk
Revision
238741
Author
justin_...@apple.com
Date
2018-11-30 10:14:52 -0800 (Fri, 30 Nov 2018)

Log Message

[WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
https://bugs.webkit.org/show_bug.cgi?id=192213

Reviewed by Dean Jackson.

Source/WebCore:

WebGPU prototype now uses WebGPURenderPassColorAttachmentDescriptor in WebGPURenderPassDescriptor to match the WebGPU Sketch.
WebGPU developer can now also set the clearColor in WebGPURenderPassDescriptor.

No new tests. Older WebGPURenderPass* tests updated.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/webgpu/WebGPUColor.h: Added. Typedef'd to GPUColor.h.
* Modules/webgpu/WebGPUColor.idl: Added.
* Modules/webgpu/WebGPUCommandBuffer.cpp:
(WebCore::WebGPUCommandBuffer::beginRenderPass): Updated to error check and support the new structure of WebGPURenderPassDescriptor.
* Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h: Added.
* Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl: Added.
* Modules/webgpu/WebGPURenderPassDescriptor.h:
* Modules/webgpu/WebGPURenderPassDescriptor.idl: Updated to match the sketch IDL.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/gpu/GPUColor.h: Added.
* platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Added. Backing struct for WebGPU__.
* platform/graphics/gpu/GPURenderPassDescriptor.h: Updated to match new WebGPURenderPassDescriptor.
* platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
(WebCore::GPURenderPassEncoder::create): Now also uses clearColor set by developer.

LayoutTests:

Updating some tests to match the updated WebGPURenderPassDescriptor.

* webgpu/js/basic-webgpu-functions.js:
(render):
* webgpu/render-command-encoding.html:
* webgpu/render-passes.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238740 => 238741)


--- trunk/LayoutTests/ChangeLog	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/LayoutTests/ChangeLog	2018-11-30 18:14:52 UTC (rev 238741)
@@ -1,3 +1,17 @@
+2018-11-30  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
+        https://bugs.webkit.org/show_bug.cgi?id=192213
+
+        Reviewed by Dean Jackson.
+
+        Updating some tests to match the updated WebGPURenderPassDescriptor. 
+
+        * webgpu/js/basic-webgpu-functions.js:
+        (render):
+        * webgpu/render-command-encoding.html:
+        * webgpu/render-passes.html:
+
 2018-11-30  Zalan Bujtas  <za...@apple.com>
 
         [LFC][BFC] Compute min/maxHeight margins only when they are needed.

Modified: trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js (238740 => 238741)


--- trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2018-11-30 18:14:52 UTC (rev 238741)
@@ -137,10 +137,14 @@
         return;
     }
 
-    // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
-    // Default a loadOp, storeOp, and clearColor in the implementation for now.
+    // FIXME: Default a loadOp, and storeOp in the implementation for now.
+    const colorAttachmentDescriptor = {
+        attachment : textureView,
+        clearColor : { r:0.35, g:0.65, b:0.85, a:1.0 }
+    }
+
     let renderPassDescriptor = {
-        attachment : textureView
+        colorAttachments : [colorAttachmentDescriptor]
     }
 
     let renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);

Modified: trunk/LayoutTests/webgpu/render-command-encoding.html (238740 => 238741)


--- trunk/LayoutTests/webgpu/render-command-encoding.html	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/LayoutTests/webgpu/render-command-encoding.html	2018-11-30 18:14:52 UTC (rev 238741)
@@ -12,12 +12,16 @@
 let commandBuffer, renderPassEncoder;
 
 function beginPass() {
-    // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
-    // Default a loadOp, storeOp, and clearColor in the implementation for now.
-    const renderPassDescriptor = {
-        attachment : context.getNextTexture().createDefaultTextureView()
+    // Default a loadOp, storeOp in the implementation for now.
+    const colorAttachmentDescriptor = {
+        attachment: context.getNextTexture().createDefaultTextureView(),
+        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     }
 
+    let renderPassDescriptor = {
+        colorAttachments : [colorAttachmentDescriptor]
+    }
+
     renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
     assert_true(renderPassEncoder instanceof WebGPURenderPassEncoder, "beginRenderPass returned a WebGPURenderPassEncoder");
 }

Modified: trunk/LayoutTests/webgpu/render-passes.html (238740 => 238741)


--- trunk/LayoutTests/webgpu/render-passes.html	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/LayoutTests/webgpu/render-passes.html	2018-11-30 18:14:52 UTC (rev 238741)
@@ -10,15 +10,17 @@
 
 function setUpBasicRenderPassEncoder() {
     commandBuffer = defaultDevice.createCommandBuffer();
-    const texture = context.getNextTexture();
-    const textureView = texture.createDefaultTextureView();
 
-    // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
-    // Default a loadOp, storeOp, and clearColor in the implementation for now.
-    const renderPassDescriptor = {
-        attachment : textureView
+    // Default a loadOp, storeOp in the implementation for now.
+    const colorAttachmentDescriptor = {
+        attachment: context.getNextTexture().createDefaultTextureView(),
+        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     }
 
+    let renderPassDescriptor = {
+        colorAttachments: [colorAttachmentDescriptor]
+    }
+
     renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
     if (renderPassEncoder)
         testPassed("Successfully created basic WebGPURenderPassEncoder.");

Modified: trunk/Source/WebCore/CMakeLists.txt (238740 => 238741)


--- trunk/Source/WebCore/CMakeLists.txt	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-11-30 18:14:52 UTC (rev 238741)
@@ -458,6 +458,7 @@
     Modules/webgpu/WebGPU.idl
     Modules/webgpu/WebGPUAdapter.idl
     Modules/webgpu/WebGPUAdapterDescriptor.idl
+    Modules/webgpu/WebGPUColor.idl
     Modules/webgpu/WebGPUCommandBuffer.idl
     Modules/webgpu/WebGPUDevice.idl
     Modules/webgpu/WebGPUPipelineDescriptorBase.idl
@@ -464,6 +465,7 @@
     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

Modified: trunk/Source/WebCore/ChangeLog (238740 => 238741)


--- trunk/Source/WebCore/ChangeLog	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/ChangeLog	2018-11-30 18:14:52 UTC (rev 238741)
@@ -1,3 +1,33 @@
+2018-11-30  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
+        https://bugs.webkit.org/show_bug.cgi?id=192213
+
+        Reviewed by Dean Jackson.
+
+        WebGPU prototype now uses WebGPURenderPassColorAttachmentDescriptor in WebGPURenderPassDescriptor to match the WebGPU Sketch.
+        WebGPU developer can now also set the clearColor in WebGPURenderPassDescriptor.
+
+        No new tests. Older WebGPURenderPass* tests updated. 
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/webgpu/WebGPUColor.h: Added. Typedef'd to GPUColor.h.
+        * Modules/webgpu/WebGPUColor.idl: Added.
+        * Modules/webgpu/WebGPUCommandBuffer.cpp:
+        (WebCore::WebGPUCommandBuffer::beginRenderPass): Updated to error check and support the new structure of WebGPURenderPassDescriptor.
+        * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h: Added.
+        * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl: Added.
+        * Modules/webgpu/WebGPURenderPassDescriptor.h: 
+        * Modules/webgpu/WebGPURenderPassDescriptor.idl: Updated to match the sketch IDL.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/gpu/GPUColor.h: Added.
+        * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Added. Backing struct for WebGPU__.
+        * platform/graphics/gpu/GPURenderPassDescriptor.h: Updated to match new WebGPURenderPassDescriptor.
+        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
+        (WebCore::GPURenderPassEncoder::create): Now also uses clearColor set by developer.
+
 2018-11-30  Andy Estes  <aes...@apple.com>
 
         [Cocoa] Add some WKA extension points

Modified: trunk/Source/WebCore/DerivedSources.make (238740 => 238741)


--- trunk/Source/WebCore/DerivedSources.make	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/DerivedSources.make	2018-11-30 18:14:52 UTC (rev 238741)
@@ -375,6 +375,7 @@
     $(WebCore)/Modules/webgpu/WebGPU.idl \
     $(WebCore)/Modules/webgpu/WebGPUAdapter.idl \
     $(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \
+    $(WebCore)/Modules/webgpu/WebGPUColor.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
     $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
     $(WebCore)/Modules/webgpu/WebGPUQueue.idl \
@@ -381,6 +382,7 @@
     $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.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 \

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h (from rev 238740, trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h) (0 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -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 "GPUColor.h"
+
+namespace WebCore {
+
+using WebGPUColor = GPUColor;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl (from rev 238740, trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h) (0 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl	2018-11-30 18:14:52 UTC (rev 238741)
@@ -0,0 +1,35 @@
+/*
+ * 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;
+};

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp (238740 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp	2018-11-30 18:14:52 UTC (rev 238741)
@@ -53,13 +53,23 @@
 RefPtr<WebGPURenderPassEncoder> WebGPUCommandBuffer::beginRenderPass(WebGPURenderPassDescriptor&& descriptor)
 {
     // FIXME: Improve error checking as WebGPURenderPassDescriptor is implemented.
-    if (!descriptor.attachment) {
-        LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachment specified for WebGPURenderPassDescriptor!");
+    if (descriptor.colorAttachments.isEmpty()) {
+        LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachments specified for WebGPURenderPassDescriptor!");
         return nullptr;
     }
-    
-    auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), GPURenderPassDescriptor { descriptor.attachment->texture() });
 
+    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 });
+    }
+
+    auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(gpuRenderPassDescriptor));
+
     if (!encoder)
         return nullptr;
 

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h (from rev 238740, trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h) (0 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -0,0 +1,43 @@
+/*
+ * 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)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl (from rev 238740, trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl) (0 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl	2018-11-30 18:14:52 UTC (rev 238741)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+[
+    Conditional=WEBGPU,
+    EnabledAtRuntime=WebGPU
+] dictionary WebGPURenderPassColorAttachmentDescriptor {
+    WebGPUTextureView attachment;
+
+    // Not Yet Implemented
+    // WebGPULoadOp loadOp;
+    // WebGPUStoreOp storeOp;
+    WebGPUColor clearColor;
+};

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h (238740 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -27,13 +27,14 @@
 
 #if ENABLE(WEBGPU)
 
-#include "WebGPUTextureView.h"
+#include "WebGPURenderPassColorAttachmentDescriptor.h"
 
+#include <wtf/Vector.h>
+
 namespace WebCore {
 
 struct WebGPURenderPassDescriptor {
-    // FIXME: Temporary shortcut implementation for prototyping.
-    RefPtr<WebGPUTextureView> attachment;
+    Vector<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl (238740 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl	2018-11-30 18:14:52 UTC (rev 238741)
@@ -28,11 +28,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPURenderPassDescriptor {
-    // FIXME: Temporary shortcut implementation for prototyping.
-    WebGPUTextureView attachment;
-
-/* Not Yet Implemented:
     sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
-    WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
-*/
+    // WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
 };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.cpp (238740 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.cpp	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.cpp	2018-11-30 18:14:52 UTC (rev 238741)
@@ -28,7 +28,6 @@
 
 #if ENABLE(WEBGPU)
 
-#include "GPUTexture.h"
 #include "WebGPUTextureView.h"
 
 namespace WebCore {

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h (238740 => 238741)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -27,12 +27,13 @@
 
 #if ENABLE(WEBGPU)
 
+#include "GPUTexture.h"
+
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-class GPUTexture;
 class WebGPUTextureView;
 
 class WebGPUTexture : public RefCounted<WebGPUTexture> {

Modified: trunk/Source/WebCore/Sources.txt (238740 => 238741)


--- trunk/Source/WebCore/Sources.txt	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/Sources.txt	2018-11-30 18:14:52 UTC (rev 238741)
@@ -3221,6 +3221,7 @@
 JSWebGPUAdapter.cpp
 JSWebGPUAdapterDescriptor.cpp
 JSWebGPUCommandBuffer.cpp
+JSWebGPUColor.cpp
 JSWebGPUDevice.cpp
 JSWebGPUQueue.cpp
 JSWebGPUPipelineDescriptorBase.cpp
@@ -3227,6 +3228,7 @@
 JSWebGPUPipelineStageDescriptor.cpp
 JSWebGPUProgrammablePassEncoder.cpp
 JSWebGPURenderingContext.cpp
+JSWebGPURenderPassColorAttachmentDescriptor.cpp
 JSWebGPURenderPassDescriptor.cpp
 JSWebGPURenderPassEncoder.cpp
 JSWebGPURenderPipeline.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238740 => 238741)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-11-30 18:14:52 UTC (rev 238741)
@@ -13703,6 +13703,12 @@
 		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>"; };
 		D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowWebGPU.h; sourceTree = "<group>"; };
 		D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowWebGPU.cpp; sourceTree = "<group>"; };
 		D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowWebGPU.idl; sourceTree = "<group>"; };
@@ -18010,6 +18016,7 @@
 			children = (
 				D087CE3721ACA94200BDE174 /* cocoa */,
 				312FF8CE21A4C33F00EB199D /* legacy */,
+				D001D9AB21B0C7BF0023B9BC /* GPUColor.h */,
 				312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */,
 				312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */,
 				312FF8BE21A4C2F100EB199D /* GPUDevice.h */,
@@ -18017,6 +18024,7 @@
 				312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */,
 				D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */,
 				312FF8C121A4C2F200EB199D /* GPUQueue.h */,
+				D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */,
 				D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */,
 				D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */,
 				312FF8B921A4C2EF00EB199D /* GPURenderPipeline.h */,
@@ -25498,6 +25506,8 @@
 				D00F5951216FFAC2000D71DB /* WebGPUAdapter.idl */,
 				D02C26912181416D00D818E4 /* WebGPUAdapterDescriptor.h */,
 				D02C26922181416D00D818E4 /* WebGPUAdapterDescriptor.idl */,
+				D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */,
+				D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */,
 				D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */,
 				D0EACF7621937228000FA75C /* WebGPUCommandBuffer.h */,
 				D0EACF7821937228000FA75C /* WebGPUCommandBuffer.idl */,
@@ -25517,6 +25527,8 @@
 				D093D2292179541600329217 /* WebGPURenderingContext.cpp */,
 				D093D225217951D400329217 /* WebGPURenderingContext.h */,
 				D093D227217951D400329217 /* WebGPURenderingContext.idl */,
+				D001D9B021B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.h */,
+				D001D9B121B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.idl */,
 				D0EACF8C219403C9000FA75C /* WebGPURenderPassDescriptor.h */,
 				D0EACF8D219403C9000FA75C /* WebGPURenderPassDescriptor.idl */,
 				D0EACF8F21940A22000FA75C /* WebGPURenderPassEncoder.cpp */,

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUColor.h (from rev 238740, trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h) (0 => 238741)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUColor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUColor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -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)
+
+namespace WebCore {
+
+struct GPUColor {
+    float r;
+    float g;
+    float b;
+    float a;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h (from rev 238740, trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h) (0 => 238741)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -0,0 +1,43 @@
+/*
+ * 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)

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h (238740 => 238741)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h	2018-11-30 18:14:52 UTC (rev 238741)
@@ -27,12 +27,14 @@
 
 #if ENABLE(WEBGPU)
 
-#include "GPUTexture.h"
+#include "GPURenderPassColorAttachmentDescriptor.h"
 
+#include <wtf/Vector.h>
+
 namespace WebCore {
 
 struct GPURenderPassDescriptor {
-    Ref<GPUTexture> attachment;
+    Vector<GPURenderPassColorAttachmentDescriptor> colorAttachments;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm (238740 => 238741)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2018-11-30 17:41:39 UTC (rev 238740)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2018-11-30 18:14:52 UTC (rev 238741)
@@ -42,15 +42,18 @@
 {
     PlatformRenderPassEncoderSmartPtr mtlEncoder;
 
+    // FIXME: Default to colorAttachments[0] and this loadOp, storeOp for now.
+    const auto& attachmentDescriptor = descriptor.colorAttachments[0];
+    const auto& color = attachmentDescriptor.clearColor;
+
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     auto mtlDescriptor = adoptNS([MTLRenderPassDescriptor new]);
 
-    // FIXME: Default to colorAttachments[0] and this loadOp, storeOp, clearColor for now.
-    mtlDescriptor.get().colorAttachments[0].texture = descriptor.attachment->platformTexture();
+    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(0.35, 0.65, 0.85, 1.0);
+    mtlDescriptor.get().colorAttachments[0].clearColor = MTLClearColorMake(color.r, color.g, color.b, color.a);
 
     mtlEncoder = retainPtr([buffer.platformCommandBuffer() renderCommandEncoderWithDescriptor:mtlDescriptor.get()]);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to