Title: [241310] trunk
Revision
241310
Author
[email protected]
Date
2019-02-12 12:11:49 -0800 (Tue, 12 Feb 2019)

Log Message

[Web GPU] DepthStencilAttachment implementation
https://bugs.webkit.org/show_bug.cgi?id=194458
<rdar://problem/47932446>

Reviewed by Dean Jackson.

Source/WebCore:

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):

LayoutTests:

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:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241309 => 241310)


--- trunk/LayoutTests/ChangeLog	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/ChangeLog	2019-02-12 20:11:49 UTC (rev 241310)
@@ -1,3 +1,27 @@
+2019-02-12  Justin Fan  <[email protected]>
+
+        [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-12  Chris Fleizach  <[email protected]>
 
         AX: Fix flaky accessibility/loading-iframe-sends-notification.html

Modified: trunk/LayoutTests/webgpu/buffer-resource-triangles.html (241309 => 241310)


--- trunk/LayoutTests/webgpu/buffer-resource-triangles.html	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/webgpu/buffer-resource-triangles.html	2019-02-12 20:11:49 UTC (rev 241310)
@@ -167,7 +167,7 @@
 
     // 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);

Added: trunk/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html (0 => 241310)


--- trunk/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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

Added: trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html (0 => 241310)


--- trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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=""
+<p>Pass if square canvas below is completely green.</p>
+<canvas width="400" height="400"></canvas>
+<script src=""
+<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

Modified: trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js (241309 => 241310)


--- trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2019-02-12 20:11:49 UTC (rev 241310)
@@ -135,9 +135,10 @@
         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 }
     }
 

Modified: trunk/LayoutTests/webgpu/js/webgpu-functions.js (241309 => 241310)


--- trunk/LayoutTests/webgpu/js/webgpu-functions.js	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/webgpu/js/webgpu-functions.js	2019-02-12 20:11:49 UTC (rev 241310)
@@ -11,7 +11,32 @@
     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,6 +59,9 @@
     if (inputStateDescriptor)
         pipelineDescriptor.inputState = inputStateDescriptor;
 
+    if (depthStateDescriptor)
+        pipelineDescriptor.depthStencilState = depthStateDescriptor;
+
     return device.createRenderPipeline(pipelineDescriptor);
 }
 
@@ -40,6 +68,8 @@
 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 }
     }
 

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


--- trunk/LayoutTests/webgpu/render-command-encoding.html	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/webgpu/render-command-encoding.html	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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 }
     }
 

Modified: trunk/LayoutTests/webgpu/render-passes.html (241309 => 241310)


--- trunk/LayoutTests/webgpu/render-passes.html	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/LayoutTests/webgpu/render-passes.html	2019-02-12 20:11:49 UTC (rev 241310)
@@ -11,9 +11,10 @@
 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 }
     }
 

Modified: trunk/Source/WebCore/CMakeLists.txt (241309 => 241310)


--- trunk/Source/WebCore/CMakeLists.txt	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/CMakeLists.txt	2019-02-12 20:11:49 UTC (rev 241310)
@@ -462,10 +462,13 @@
     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 @@
     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 @@
     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 (241309 => 241310)


--- trunk/Source/WebCore/ChangeLog	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/ChangeLog	2019-02-12 20:11:49 UTC (rev 241310)
@@ -1,3 +1,54 @@
+2019-02-12  Justin Fan  <[email protected]>
+
+        [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-12  David Kilzer  <[email protected]>
 
         REGRESSION (r238955, r240494): Soft-linking optional Lookup.framework triggers release assertion when missing

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (241309 => 241310)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2019-02-12 20:11:49 UTC (rev 241310)
@@ -321,10 +321,13 @@
 $(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

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (241309 => 241310)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2019-02-12 20:11:49 UTC (rev 241310)
@@ -578,6 +578,8 @@
 $(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
@@ -584,8 +586,12 @@
 $(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

Modified: trunk/Source/WebCore/DerivedSources.make (241309 => 241310)


--- trunk/Source/WebCore/DerivedSources.make	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/DerivedSources.make	2019-02-12 20:11:49 UTC (rev 241310)
@@ -372,10 +372,13 @@
     $(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 @@
 	$(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 @@
     $(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 \

Copied: trunk/Source/WebCore/Modules/webgpu/GPUColor.idl (from rev 241309, trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl) (0 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/GPUColor.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPUColor.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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;
+};

Copied: trunk/Source/WebCore/Modules/webgpu/GPULoadOp.idl (from rev 241309, trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl) (0 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/GPULoadOp.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPULoadOp.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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"
+};

Copied: trunk/Source/WebCore/Modules/webgpu/GPUStoreOp.idl (from rev 241309, trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl) (0 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/GPUStoreOp.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPUStoreOp.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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"
+};

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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;
-};

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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 @@
 
 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;
 }

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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;
-};

Added: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp (0 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -26,8 +26,39 @@
 
 [
     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;
 };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -32,6 +32,7 @@
 #include "WebGPUInputStateDescriptor.h"
 #include "WebGPUPipelineDescriptorBase.h"
 #include "WebGPUPipelineStageDescriptor.h"
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -41,7 +42,7 @@
     WebGPUPipelineStageDescriptor vertexStage;
     WebGPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    Optional<GPUDepthStencilStateDescriptor> depthStencilState;
     WebGPUInputStateDescriptor inputState;
 };
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl	2019-02-12 20:11:49 UTC (rev 241310)
@@ -40,7 +40,7 @@
     WebGPUPipelineStageDescriptor fragmentStage;
 
     WebGPUPrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    GPUDepthStencilStateDescriptor? depthStencilState;
     WebGPUInputStateDescriptor inputState;
 /* To Be Implemented:
     sequence<WebGPUBlendStateDescriptor> blendStates;

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h (241309 => 241310)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -28,7 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUTexture.h"
-
+#include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/Sources.txt (241309 => 241310)


--- trunk/Source/WebCore/Sources.txt	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/Sources.txt	2019-02-12 20:11:49 UTC (rev 241310)
@@ -357,6 +357,7 @@
 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
@@ -2765,10 +2766,13 @@
 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
@@ -3313,7 +3317,6 @@
 JSWebGPUBufferBinding.cpp
 JSWebGPUBufferDescriptor.cpp
 JSWebGPUBufferUsage.cpp
-JSWebGPUColor.cpp
 JSWebGPUCommandBuffer.cpp
 JSWebGPUDevice.cpp
 JSWebGPUIndexFormat.cpp
@@ -3326,7 +3329,6 @@
 JSWebGPUPipelineStageDescriptor.cpp
 JSWebGPUProgrammablePassEncoder.cpp
 JSWebGPURenderingContext.cpp
-JSWebGPURenderPassColorAttachmentDescriptor.cpp
 JSWebGPURenderPassDescriptor.cpp
 JSWebGPURenderPassEncoder.cpp
 JSWebGPURenderPipeline.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (241309 => 241310)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-02-12 20:11:49 UTC (rev 241310)
@@ -13935,12 +13935,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>"; };
@@ -13961,6 +13956,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>"; };
@@ -14088,6 +14084,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>"; };
@@ -14163,7 +14165,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>"; };
@@ -18487,6 +18488,7 @@
 				D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */,
 				D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */,
 				D0F7559F2203BA1400118058 /* GPULimits.h */,
+				D08AA02F220D0BD50058C502 /* GPULoadOp.h */,
 				312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */,
 				D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */,
 				D003288621C9A4E500622AA6 /* GPUPipelineLayout.h */,
@@ -18494,7 +18496,6 @@
 				312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */,
 				D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */,
 				312FF8C121A4C2F200EB199D /* GPUQueue.h */,
-				D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */,
 				D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */,
 				D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */,
 				312FF8B921A4C2EF00EB199D /* GPURenderPipeline.h */,
@@ -18502,6 +18503,7 @@
 				D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */,
 				312FF8BB21A4C2F000EB199D /* GPUShaderModule.h */,
 				312FF8C021A4C2F200EB199D /* GPUShaderModuleDescriptor.h */,
+				D08AA032220D0D0B0058C502 /* GPUStoreOp.h */,
 				312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */,
 				312FF8C521A4C2F400EB199D /* GPUTexture.h */,
 				D026F48C220A5BAD00AC5F49 /* GPUTextureDescriptor.h */,
@@ -26074,10 +26076,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 */,
@@ -26111,8 +26116,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 */,
@@ -26143,10 +26146,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 */,

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPULoadOp.h (from rev 241309, trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h) (0 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/GPULoadOp.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPULoadOp.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

Deleted: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h (241309 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h (241309 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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 @@
         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 @@
     GPUPipelineStageDescriptor vertexStage;
     GPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    Optional<GPUDepthStencilStateDescriptor> depthStencilState;
     GPUInputStateDescriptor inputState;
 };
 

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h (from rev 241309, trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h) (0 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUStoreOp.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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)

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h (241309 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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);

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


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2019-02-12 20:11:49 UTC (rev 241310)
@@ -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;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (241309 => 241310)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-02-12 19:58:19 UTC (rev 241309)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-02-12 20:11:49 UTC (rev 241310)
@@ -296,9 +296,12 @@
         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)
         return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to