[Web GPU] DepthStencilAttachment implementation
authorjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 20:11:49 +0000 (20:11 +0000)
committerjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 20:11:49 +0000 (20:11 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241310 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/buffer-resource-triangles.html
LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html [new file with mode: 0644]
LayoutTests/webgpu/depth-enabled-triangle-strip.html [new file with mode: 0644]
LayoutTests/webgpu/js/basic-webgpu-functions.js
LayoutTests/webgpu/js/webgpu-functions.js
LayoutTests/webgpu/render-command-encoding.html
LayoutTests/webgpu/render-passes.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/webgpu/GPUColor.idl [moved from Source/WebCore/Modules/webgpu/WebGPUColor.idl with 94% similarity]
Source/WebCore/Modules/webgpu/GPULoadOp.idl [moved from Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl with 84% similarity]
Source/WebCore/Modules/webgpu/GPUStoreOp.idl [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp
Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h [deleted file]
Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h
Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPUTextureView.h
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/gpu/GPULoadOp.h [moved from Source/WebCore/Modules/webgpu/WebGPUColor.h with 92% similarity]
Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h
Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h
Source/WebCore/platform/graphics/gpu/GPUStoreOp.h [moved from Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h with 87% similarity]
Source/WebCore/platform/graphics/gpu/GPUTexture.h
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

index 172e399..fcc4fba 100644 (file)
@@ -1,3 +1,27 @@
+2019-02-12  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] DepthStencilAttachment implementation
+        https://bugs.webkit.org/show_bug.cgi?id=194458
+        <rdar://problem/47932446>
+
+        Reviewed by Dean Jackson.
+
+        Add test and update utility functions for depth texture attachments. Update others to specify their 
+        loadOp and storeOp for all render pass attachments, as these are no longer provided by default by the implementation.
+
+        * webgpu/buffer-resource-triangles.html:
+        * webgpu/depth-enabled-triangle-strip-expected.html: Added.
+        * webgpu/depth-enabled-triangle-strip.html: Added.
+        * webgpu/js/basic-webgpu-functions.js:
+        (render):
+        * webgpu/js/webgpu-functions.js:
+        (createBasicDepthStateDescriptor):
+        (createBasicDepthTexture):
+        (beginBasicRenderPass):
+        (createBasicPipeline): Deleted.
+        * webgpu/render-command-encoding.html:
+        * webgpu/render-passes.html:
+
 2019-02-12  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Fix flaky accessibility/loading-iframe-sends-notification.html
index 996579e..c196499 100644 (file)
@@ -167,7 +167,7 @@ async function test() {
 
     // WebGPUPipelineLayout and WebGPURenderPipeline
     const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [leftTriangleBGLayout, rightTriangleBGLayout] });
-    const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputState, "triangleList");
+    const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputState, null, "triangleList");
 
     // WebGPUBufferBindings
     const bindingUL = createBufferBinding(upperLeft);
diff --git a/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html b/LayoutTests/webgpu/depth-enabled-triangle-strip-expected.html
new file mode 100644 (file)
index 0000000..886f13e
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Reference File</title>
+<p>Pass if square canvas below is completely green.</p>
+<canvas width="400" height="400"></canvas>
+<script>
+const canvas = document.querySelector("canvas");
+const context = canvas.getContext('2d');
+
+context.fillStyle = 'rgb(0, 255, 0)';
+context.fillRect(0, 0, canvas.width, canvas.height);
+</script>
\ No newline at end of file
diff --git a/LayoutTests/webgpu/depth-enabled-triangle-strip.html b/LayoutTests/webgpu/depth-enabled-triangle-strip.html
new file mode 100644 (file)
index 0000000..a68d9d8
--- /dev/null
@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGPU Hello Triangles</title>
+<meta name="assert" content="WebGPU correctly renders a green canvas.">
+<link rel="match" href="vertex-buffer-triangle-strip-expected.html">
+<p>Pass if square canvas below is completely green.</p>
+<canvas width="400" height="400"></canvas>
+<script src="js/webgpu-functions.js"></script>
+<script>
+const shaderCode = `
+#include <metal_stdlib>
+    
+using namespace metal;
+
+struct VertexIn
+{
+    float4 position [[attribute(0)]];
+};
+
+struct VertexOut
+{
+    float4 position [[position]];
+    float4 color;
+};
+
+vertex VertexOut vertex_main(VertexIn vertexIn [[stage_in]], uint iid [[instance_id]])
+{
+    VertexOut vOut;
+    vOut.position = vertexIn.position;
+
+    if (iid == 0) {
+        vOut.position.z = 0.5;
+        vOut.color = float4(1, 0, 0, 1);
+    } else {
+        vOut.color = float4(0, 1, 0, 1);
+    }
+
+    return vOut;
+}
+
+fragment float4 fragment_main(VertexOut v [[stage_in]])
+{
+    return v.color;
+}
+`
+
+function createVertexBuffer(device) {
+    const bufferSize = 4 * 4 * 4;
+    const buffer = device.createBuffer({ size: bufferSize, usage: WebGPUBufferUsage.MAP_WRITE });
+    
+    let floatArray = new Float32Array(buffer.mapping);
+
+    const vertices = [
+        // float4 xyzw
+        -1, 1, 0, 1,
+        -1, -1, 0, 1,
+        1, 1, 0, 1,
+        1, -1, 0, 1
+    ];
+
+    floatArray.set(vertices);
+
+    return buffer;
+}
+
+function createInputStateDescriptor() {
+    return {
+        indexFormat: WebGPUIndexFormat.UINT32,
+        attributes: [{
+            shaderLocation: 0,
+            inputSlot: 0,
+            offset: 0,
+            format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32
+        }],
+        inputs: [{
+            inputSlot: 0,
+            stride: 4 * 4,
+            stepMode: WebGPUInputStepMode.VERTEX
+        }]
+    }
+}
+
+async function test() {
+    const device = await getBasicDevice();
+    const canvas = document.querySelector("canvas");
+    const context = createBasicContext(canvas, device);
+    // FIXME: Replace with non-MSL shaders.
+    const shaderModule = device.createShaderModule({ code: shaderCode });
+    const vertexBuffer = createVertexBuffer(device);
+    const inputStateDescriptor = createInputStateDescriptor();
+    const depthStateDescriptor = createBasicDepthStateDescriptor();
+    const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor, depthStateDescriptor);
+    const commandBuffer = device.createCommandBuffer();
+
+    const basicAttachment = {
+        attachment: context.getNextTexture().createDefaultTextureView(),
+        loadOp: "clear",
+        storeOp: "store",
+        clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
+    };
+
+    const depthAttachment = {
+        attachment: createBasicDepthTexture(canvas, device).createDefaultTextureView(),
+        depthLoadOp: "clear",
+        depthStoreOp: "store",
+        clearDepth: 1.0
+    };
+
+    const encoder = commandBuffer.beginRenderPass({
+        colorAttachments: [basicAttachment],
+        depthStencilAttachment: depthAttachment
+    });
+
+    encoder.setVertexBuffers(0, [vertexBuffer], [0]);
+    encoder.setPipeline(pipeline);
+    encoder.draw(4, 2, 0, 0);
+    encoder.endPass();
+
+    device.getQueue().submit([commandBuffer]);
+    context.present();
+}
+
+test();
+</script>
\ No newline at end of file
index ce24685..395195e 100644 (file)
@@ -135,9 +135,10 @@ function render() {
         return;
     }
 
-    // FIXME: Default a loadOp, and storeOp in the implementation for now.
     const colorAttachmentDescriptor = {
         attachment : textureView,
+        loadOp: "clear",
+        storeOp: "store",
         clearColor : { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     }
 
index bf43de6..278b210 100644 (file)
@@ -11,7 +11,32 @@ function createBasicContext(canvas, device) {
     return context;
 }
 
-function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor, primitiveTopology = "triangleStrip") {
+function createBasicDepthStateDescriptor() {
+    return {
+        depthWriteEnabled: true,
+        depthCompare: "less"
+    };
+}
+
+function createBasicDepthTexture(canvas, device) {
+    const depthSize = {
+        width: canvas.width,
+        height: canvas.height,
+        depth: 1
+    };
+
+    return device.createTexture({
+        size: depthSize,
+        arrayLayerCount: 1,
+        mipLevelCount: 1,
+        sampleCount: 1,
+        dimension: "2d",
+        format: "d32-float-s8-uint",
+        usage: GPUTextureUsage.OUTPUT_ATTACHMENT
+    });
+}
+
+function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor, depthStateDescriptor, primitiveTopology = "triangleStrip") {
     const vertexStageDescriptor = {
         module: shaderModule,
         entryPoint: "vertex_main" 
@@ -34,12 +59,17 @@ function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDes
     if (inputStateDescriptor)
         pipelineDescriptor.inputState = inputStateDescriptor;
 
+    if (depthStateDescriptor)
+        pipelineDescriptor.depthStencilState = depthStateDescriptor;
+
     return device.createRenderPipeline(pipelineDescriptor);
 }
 
 function beginBasicRenderPass(context, commandBuffer) {
     const basicAttachment = {
         attachment: context.getNextTexture().createDefaultTextureView(),
+        loadOp: "clear",
+        storeOp: "store",
         clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
     }
 
index 872fb89..d2f99b2 100644 (file)
 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 }
     }
 
index 96c976f..53e2428 100644 (file)
@@ -11,9 +11,10 @@ let commandBuffer, renderPassEncoder;
 function setUpBasicRenderPassEncoder() {
     commandBuffer = defaultDevice.createCommandBuffer();
 
-    // Default a loadOp, storeOp in the implementation for now.
     const colorAttachmentDescriptor = {
         attachment: context.getNextTexture().createDefaultTextureView(),
+        loadOp: "clear",
+        storeOp: "store",
         clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     }
 
index 502974b..b2f7d51 100644 (file)
@@ -462,10 +462,13 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/webdriver/NavigatorWebDriver.idl
 
     Modules/webgpu/DOMWindowWebGPU.idl
+    Modules/webgpu/GPUColor.idl
     Modules/webgpu/GPUCompareFunction.idl
     Modules/webgpu/GPUDepthStencilStateDescriptor.idl
     Modules/webgpu/GPUExtent3D.idl
+    Modules/webgpu/GPULoadOp.idl
     Modules/webgpu/GPURequestAdapterOptions.idl
+    Modules/webgpu/GPUStoreOp.idl
     Modules/webgpu/GPUTextureDescriptor.idl
     Modules/webgpu/GPUTextureDimension.idl
     Modules/webgpu/GPUTextureFormat.idl
@@ -482,7 +485,6 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/webgpu/WebGPUBufferBinding.idl
     Modules/webgpu/WebGPUBufferDescriptor.idl
     Modules/webgpu/WebGPUBufferUsage.idl
-    Modules/webgpu/WebGPUColor.idl
     Modules/webgpu/WebGPUCommandBuffer.idl
     Modules/webgpu/WebGPUDevice.idl
     Modules/webgpu/WebGPUIndexFormat.idl
@@ -494,7 +496,6 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/webgpu/WebGPUPipelineStageDescriptor.idl
     Modules/webgpu/WebGPUProgrammablePassEncoder.idl
     Modules/webgpu/WebGPUQueue.idl
-    Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl
     Modules/webgpu/WebGPURenderPassDescriptor.idl
     Modules/webgpu/WebGPURenderPassEncoder.idl
     Modules/webgpu/WebGPURenderPipeline.idl
index ce16291..1befc7c 100644 (file)
@@ -1,3 +1,54 @@
+2019-02-12  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] DepthStencilAttachment implementation
+        https://bugs.webkit.org/show_bug.cgi?id=194458
+        <rdar://problem/47932446>
+
+        Reviewed by Dean Jackson.
+
+        Implement ability to provide a depth attachment to the render pass encoder. Also implement
+        GPULoad/StoreOp and update color attachments' implementation for full functionality.
+
+        Test: webgpu/depth-enabled-triangle-strip.html
+
+        Update project files for new symbols:
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * Modules/webgpu/GPUColor.idl: Renamed from WebGPUColor.idl
+        * Modules/webgpu/GPULoadOp.idl: Added. Interface for attachment operation enum.
+        * Modules/webgpu/GPUStoreOp.idl: Ditto.
+        * Modules/webpug/WebGPUColor.h: Removed.
+        * Modules/webgpu/WebGPUCommandBuffer.cpp: Refactored descriptor validation logic out of this file.
+        (WebCore::WebGPUCommandBuffer::beginRenderPass):
+        * Modules/webgpu/WebGPURenderPassDescriptor.cpp: Added. Now owns code for validating descriptors.
+        (WebCore::WebGPURenderPassDescriptor::validateAndConvertToGPUVersion const):
+        * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h/idl: Removed. Code moved into WebGPURenderPassDescriptor.
+        * Modules/webgpu/WebGPURenderPassDescriptor.h: Move sub-descriptor definitions into this file.
+        * Modules/webgpu/WebGPURenderPassDescriptor.idl: Ditto.
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.h: Make depthStencilState optional to match API update.
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.idl: Ditto.
+        * Modules/webgpu/WebGPUTextureView.h:
+        * platform/graphics/gpu/GPULoadOp.h: Added.
+        * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Removed (moved into GPURenderPassDescriptor).
+        * platform/graphics/gpu/GPURenderPassDescriptor.h: Mirror WebGPU* changes.
+        * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Make depthStencilState optional.
+        (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor):
+        * platform/graphics/gpu/GPUStoreOp.h: Added.
+        * platform/graphics/gpu/GPUTexture.h:
+        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
+        (WebCore::loadActionForGPULoadOp): Added.
+        (WebCore::storeActionForGPUStoreOp): Added.
+        (WebCore::populateMtlColorAttachmentsArray): Added. Create all expected color attachments, rather than just the first.
+        (WebCore::populateMtlDepthStencilAttachment): Added.
+        (WebCore::GPURenderPassEncoder::create):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: Make depthStencilState optional.
+        (WebCore::GPURenderPipeline::create):
+
 2019-02-12  David Kilzer  <ddkilzer@apple.com>
 
         REGRESSION (r238955, r240494): Soft-linking optional Lookup.framework triggers release assertion when missing
index 4c3bc74..d409cb8 100644 (file)
@@ -321,10 +321,13 @@ $(PROJECT_DIR)/Modules/webdatabase/SQLTransactionCallback.idl
 $(PROJECT_DIR)/Modules/webdatabase/SQLTransactionErrorCallback.idl
 $(PROJECT_DIR)/Modules/webdriver/NavigatorWebDriver.idl
 $(PROJECT_DIR)/Modules/webgpu/DOMWindowWebGPU.idl
+$(PROJECT_DIR)/Modules/webgpu/GPUColor.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUCompareFunction.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUExtent3D.idl
+$(PROJECT_DIR)/Modules/webgpu/GPULoadOp.idl
 $(PROJECT_DIR)/Modules/webgpu/GPURequestAdapterOptions.idl
+$(PROJECT_DIR)/Modules/webgpu/GPUStoreOp.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUTextureDescriptor.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUTextureDimension.idl
 $(PROJECT_DIR)/Modules/webgpu/GPUTextureFormat.idl
index 22fcf27..eeea5fe 100644 (file)
@@ -578,14 +578,20 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFaceSet.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFaceSet.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGCObservation.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGCObservation.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPULoadOp.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPULoadOp.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUStoreOp.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUStoreOp.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDescriptor.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDescriptor.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureDimension.cpp
index 0547279..22927ed 100644 (file)
@@ -372,10 +372,13 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/webdatabase/SQLTransactionErrorCallback.idl \
     $(WebCore)/Modules/webdriver/NavigatorWebDriver.idl \
     $(WebCore)/Modules/webgpu/DOMWindowWebGPU.idl \
+    $(WebCore)/Modules/webgpu/GPUColor.idl \
     $(WebCore)/Modules/webgpu/GPUCompareFunction.idl \
     $(WebCore)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl \
     $(WebCore)/Modules/webgpu/GPUExtent3D.idl \
+    $(WebCore)/Modules/webgpu/GPULoadOp.idl \
     $(WebCore)/Modules/webgpu/GPURequestAdapterOptions.idl \
+    $(WebCore)/Modules/webgpu/GPUStoreOp.idl \
     $(WebCore)/Modules/webgpu/GPUTextureDescriptor.idl \
     $(WebCore)/Modules/webgpu/GPUTextureDimension.idl \
     $(WebCore)/Modules/webgpu/GPUTextureFormat.idl \
@@ -392,7 +395,6 @@ JS_BINDING_IDLS = \
        $(WebCore)/Modules/webgpu/WebGPUBufferBinding.idl \
     $(WebCore)/Modules/webgpu/WebGPUBufferDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUBufferUsage.idl \
-    $(WebCore)/Modules/webgpu/WebGPUColor.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
     $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
     $(WebCore)/Modules/webgpu/WebGPUIndexFormat.idl \
@@ -404,7 +406,6 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/webgpu/WebGPUPipelineLayoutDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUProgrammablePassEncoder.idl \
-    $(WebCore)/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPURenderPassDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPURenderPassEncoder.idl \
     $(WebCore)/Modules/webgpu/WebGPURenderPipeline.idl \
similarity index 94%
rename from Source/WebCore/Modules/webgpu/WebGPUColor.idl
rename to Source/WebCore/Modules/webgpu/GPUColor.idl
index e613c2b..962cc43 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * 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
@@ -27,7 +27,7 @@
 [
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
-] dictionary WebGPUColor {
+] dictionary GPUColor {
     float r;
     float g;
     float b;
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * 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
 [
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
-] dictionary WebGPURenderPassColorAttachmentDescriptor {
-    WebGPUTextureView attachment;
-
-    // Not Yet Implemented
-    // WebGPULoadOp loadOp;
-    // WebGPUStoreOp storeOp;
-    WebGPUColor clearColor;
+] enum GPULoadOp {
+    "clear",
+    "load"
 };
diff --git a/Source/WebCore/Modules/webgpu/GPUStoreOp.idl b/Source/WebCore/Modules/webgpu/GPUStoreOp.idl
new file mode 100644 (file)
index 0000000..f7d11c9
--- /dev/null
@@ -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"
+};
index 1a41053..43a86e7 100644 (file)
 
 #if ENABLE(WEBGPU)
 
-#include "GPUCommandBuffer.h"
 #include "GPURenderPassDescriptor.h"
 #include "GPURenderPassEncoder.h"
-#include "GPURenderPipeline.h"
-#include "Logging.h"
 #include "WebGPURenderPassDescriptor.h"
 #include "WebGPURenderPassEncoder.h"
 
@@ -50,23 +47,11 @@ WebGPUCommandBuffer::WebGPUCommandBuffer(Ref<GPUCommandBuffer>&& buffer)
 
 RefPtr<WebGPURenderPassEncoder> WebGPUCommandBuffer::beginRenderPass(WebGPURenderPassDescriptor&& descriptor)
 {
-    // FIXME: Improve error checking as WebGPURenderPassDescriptor is implemented.
-    if (descriptor.colorAttachments.isEmpty()) {
-        LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachments specified for WebGPURenderPassDescriptor!");
+    auto gpuDescriptor = descriptor.validateAndConvertToGPUVersion();
+    if (!gpuDescriptor)
         return nullptr;
-    }
 
-    GPURenderPassDescriptor gpuRenderPassDescriptor;
-
-    for (const auto& colorAttachment : descriptor.colorAttachments) {
-        if (!colorAttachment.attachment) {
-            LOG(WebGPU, "WebGPUCommandBuffer::create(): Invalid attachment in WebGPURenderPassColorAttachmentDescriptor!");
-            return nullptr;
-        }
-        gpuRenderPassDescriptor.colorAttachments.append(GPURenderPassColorAttachmentDescriptor { colorAttachment.attachment->texture(), colorAttachment.clearColor });
-    }
-
-    if (auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(gpuRenderPassDescriptor)))
+    if (auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(*gpuDescriptor)))
         return WebGPURenderPassEncoder::create(*this, encoder.releaseNonNull());
     return nullptr;
 }
diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h
deleted file mode 100644 (file)
index ab72b55..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEBGPU)
-
-#include "WebGPUColor.h"
-#include "WebGPUTextureView.h"
-
-namespace WebCore {
-
-struct WebGPURenderPassColorAttachmentDescriptor {
-    RefPtr<WebGPUTextureView> attachment;
-
-    WebGPUColor clearColor;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp b/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp
new file mode 100644 (file)
index 0000000..f688be7
--- /dev/null
@@ -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)
index c19230c..da9b1f7 100644 (file)
 
 #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
index b7ade3c..f38f2e3 100644 (file)
 
 [
     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;
 };
index 04ea688..f95657b 100644 (file)
@@ -32,6 +32,7 @@
 #include "WebGPUInputStateDescriptor.h"
 #include "WebGPUPipelineDescriptorBase.h"
 #include "WebGPUPipelineStageDescriptor.h"
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -41,7 +42,7 @@ struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase {
     WebGPUPipelineStageDescriptor vertexStage;
     WebGPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    Optional<GPUDepthStencilStateDescriptor> depthStencilState;
     WebGPUInputStateDescriptor inputState;
 };
 
index 12bd71d..0ffe8a1 100644 (file)
@@ -40,7 +40,7 @@ enum WebGPUPrimitiveTopology {
     WebGPUPipelineStageDescriptor fragmentStage;
 
     WebGPUPrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    GPUDepthStencilStateDescriptor? depthStencilState;
     WebGPUInputStateDescriptor inputState;
 /* To Be Implemented:
     sequence<WebGPUBlendStateDescriptor> blendStates;
index fbeb8bc..123f440 100644 (file)
@@ -28,7 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUTexture.h"
-
+#include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
index 81cbc04..fa0706b 100644 (file)
@@ -357,6 +357,7 @@ Modules/webgpu/WebGPUQueue.cpp
 Modules/webgpu/WebGPUPipelineLayout.cpp
 Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
 Modules/webgpu/WebGPURenderingContext.cpp
+Modules/webgpu/WebGPURenderPassDescriptor.cpp
 Modules/webgpu/WebGPURenderPassEncoder.cpp
 Modules/webgpu/WebGPURenderPipeline.cpp
 Modules/webgpu/WebGPUShaderModule.cpp
@@ -2765,10 +2766,13 @@ JSFillMode.cpp
 JSFocusEvent.cpp
 JSFontFace.cpp
 JSFontFaceSet.cpp
+JSGPUColor.cpp
 JSGPUCompareFunction.cpp
 JSGPUDepthStencilStateDescriptor.cpp
 JSGPUExtent3D.cpp
+JSGPULoadOp.cpp
 JSGPURequestAdapterOptions.cpp
+JSGPUStoreOp.cpp
 JSGPUTextureDescriptor.cpp
 JSGPUTextureDimension.cpp
 JSGPUTextureFormat.cpp
@@ -3313,7 +3317,6 @@ JSWebGPUBuffer.cpp
 JSWebGPUBufferBinding.cpp
 JSWebGPUBufferDescriptor.cpp
 JSWebGPUBufferUsage.cpp
-JSWebGPUColor.cpp
 JSWebGPUCommandBuffer.cpp
 JSWebGPUDevice.cpp
 JSWebGPUIndexFormat.cpp
@@ -3326,7 +3329,6 @@ JSWebGPUPipelineLayoutDescriptor.cpp
 JSWebGPUPipelineStageDescriptor.cpp
 JSWebGPUProgrammablePassEncoder.cpp
 JSWebGPURenderingContext.cpp
-JSWebGPURenderPassColorAttachmentDescriptor.cpp
 JSWebGPURenderPassDescriptor.cpp
 JSWebGPURenderPassEncoder.cpp
 JSWebGPURenderPipeline.cpp
index ac2e224..9162abc 100644 (file)
                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>"; };
                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>"; };
                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>"; };
                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>"; };
                                D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */,
                                D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */,
                                D0F7559F2203BA1400118058 /* GPULimits.h */,
+                               D08AA02F220D0BD50058C502 /* GPULoadOp.h */,
                                312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */,
                                D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */,
                                D003288621C9A4E500622AA6 /* GPUPipelineLayout.h */,
                                312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */,
                                D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */,
                                312FF8C121A4C2F200EB199D /* GPUQueue.h */,
-                               D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */,
                                D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */,
                                D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */,
                                312FF8B921A4C2EF00EB199D /* GPURenderPipeline.h */,
                                D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */,
                                312FF8BB21A4C2F000EB199D /* GPUShaderModule.h */,
                                312FF8C021A4C2F200EB199D /* GPUShaderModuleDescriptor.h */,
+                               D08AA032220D0D0B0058C502 /* GPUStoreOp.h */,
                                312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */,
                                312FF8C521A4C2F400EB199D /* GPUTexture.h */,
                                D026F48C220A5BAD00AC5F49 /* GPUTextureDescriptor.h */,
                                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 */,
                                D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */,
                                D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */,
                                D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */,
-                               D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */,
-                               D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */,
                                D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */,
                                D0EACF7621937228000FA75C /* WebGPUCommandBuffer.h */,
                                D0EACF7821937228000FA75C /* WebGPUCommandBuffer.idl */,
                                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 */,
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * 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
 
 #if ENABLE(WEBGPU)
 
-#include "GPUColor.h"
-
 namespace WebCore {
 
-using WebGPUColor = GPUColor;
+enum class GPULoadOp {
+    Clear,
+    Load
+};
 
 } // namespace WebCore
 
index edce9de..f4ac69a 100644 (file)
 
 #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
index 627531b..a8f59ac 100644 (file)
@@ -31,7 +31,7 @@
 #include "GPUInputStateDescriptor.h"
 #include "GPUPipelineDescriptorBase.h"
 #include "GPUPipelineStageDescriptor.h"
-
+#include <wtf/Optional.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -45,7 +45,7 @@ struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
         TriangleStrip
     };
 
-    GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, PrimitiveTopology topology, GPUDepthStencilStateDescriptor&& depth, GPUInputStateDescriptor&& input)
+    GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, PrimitiveTopology topology, Optional<GPUDepthStencilStateDescriptor>&& depth, GPUInputStateDescriptor&& input)
         : GPUPipelineDescriptorBase { WTFMove(layout) }
         , vertexStage(WTFMove(vertex))
         , fragmentStage(WTFMove(fragment))
@@ -58,7 +58,7 @@ struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
     GPUPipelineStageDescriptor vertexStage;
     GPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
-    GPUDepthStencilStateDescriptor depthStencilState;
+    Optional<GPUDepthStencilStateDescriptor> depthStencilState;
     GPUInputStateDescriptor inputState;
 };
 
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * 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
 
 #if ENABLE(WEBGPU)
 
-#include "GPUColor.h"
-#include "GPUTexture.h"
-
 namespace WebCore {
 
-struct GPURenderPassColorAttachmentDescriptor {
-    Ref<GPUTexture> attachment;
-
-    GPUColor clearColor;
+enum class GPUStoreOp {
+    Store
 };
 
 } // namespace WebCore
index 502b12b..55d1e3c 100644 (file)
@@ -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);
index 5a8c8d2..92e2acf 100644 (file)
 
 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;
     }
 
index 493ff25..84ebea7 100644 (file)
@@ -296,8 +296,11 @@ RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPU
         return nullptr;
     }
 
-    // Depth Stencil state is separate from the render pipeline state in Metal.
-    auto depthStencil = tryCreateMtlDepthStencilState(functionName, descriptor.depthStencilState, device);
+    // Depth Stencil state is optional and separate from the render pipeline state in Metal.
+    RetainPtr<MTLDepthStencilState> depthStencil;
+
+    if (descriptor.depthStencilState)
+        depthStencil = tryCreateMtlDepthStencilState(functionName, *descriptor.depthStencilState, device);
 
     auto pipeline = tryCreateMtlRenderPipelineState(functionName, descriptor, device);
     if (!pipeline)