Source/WebCore:
authorjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 22:42:36 +0000 (22:42 +0000)
committerjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 22:42:36 +0000 (22:42 +0000)
[Web GPU] Implement API default values
https://bugs.webkit.org/show_bug.cgi?id=197032

Reviewed by Myles C. Maxfield.

Add default values and 'required' qualifiers recently merged to the WebGPU API.

WebGPU tests specifying these default values have been updated to rely on them for functionality.

* Modules/webgpu/GPUBindGroupLayoutBinding.idl:
* Modules/webgpu/GPUBindGroupLayoutDescriptor.idl:
* Modules/webgpu/GPUBlendDescriptor.idl:
* Modules/webgpu/GPUBufferDescriptor.idl:
* Modules/webgpu/GPUColor.idl:
* Modules/webgpu/GPUColorStateDescriptor.idl:
* Modules/webgpu/GPUDepthStencilStateDescriptor.idl:
* Modules/webgpu/GPUExtent3D.idl:
* Modules/webgpu/GPUInputStateDescriptor.idl:
* Modules/webgpu/GPUOrigin3D.h:
* Modules/webgpu/GPUOrigin3D.idl:
* Modules/webgpu/GPURequestAdapterOptions.idl:
* Modules/webgpu/GPUTextureDescriptor.idl:
* Modules/webgpu/GPUVertexAttributeDescriptor.idl:
* Modules/webgpu/GPUVertexInputDescriptor.idl:
* Modules/webgpu/WebGPUBindGroupBinding.idl:
* Modules/webgpu/WebGPUBindGroupDescriptor.idl:
* Modules/webgpu/WebGPUBufferBinding.h:
* Modules/webgpu/WebGPUBufferBinding.idl:
* Modules/webgpu/WebGPUCommandEncoder.idl:
* Modules/webgpu/WebGPUPipelineDescriptorBase.idl:
* Modules/webgpu/WebGPUPipelineLayoutDescriptor.idl:
* Modules/webgpu/WebGPUPipelineStageDescriptor.idl:
* Modules/webgpu/WebGPURenderPassDescriptor.idl:
* Modules/webgpu/WebGPURenderPipelineDescriptor.cpp:
(WebCore::WebGPURenderPipelineDescriptor::tryCreateGPURenderPipelineDescriptor const):
* Modules/webgpu/WebGPURenderPipelineDescriptor.h:
* Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
* Modules/webgpu/WebGPUShaderModuleDescriptor.idl:
* platform/graphics/gpu/GPUBlendDescriptor.h:
* platform/graphics/gpu/GPUColorStateDescriptor.h:
* platform/graphics/gpu/GPUCommandBuffer.h:
* platform/graphics/gpu/GPUDepthStencilStateDescriptor.h:
* platform/graphics/gpu/GPURenderPassDescriptor.h:
* platform/graphics/gpu/GPURenderPipelineDescriptor.h:
(WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor):
* platform/graphics/gpu/GPURequestAdapterOptions.h:
* platform/graphics/gpu/GPUTextureDescriptor.h:
* platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
* platform/graphics/gpu/GPUVertexInputDescriptor.h:
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::convertRenderPipelineDescriptor):
(WebCore::trySetFunctionsForPipelineDescriptor):

LayoutTests:
[WebGPU] Implement API default values
https://bugs.webkit.org/show_bug.cgi?id=197032

Reviewed by Myles C. Maxfield.

Update WebGPU tests to use default values wherever applicable.

* webgpu/bind-groups.html:
* webgpu/blend-triangle-strip.html:
* webgpu/blit-commands.html:
* webgpu/buffer-command-buffer-races.html:
* webgpu/buffer-resource-triangles.html:
* webgpu/color-write-mask-triangle-strip.html:
* webgpu/compute-squares.html:
* webgpu/depth-enabled-triangle-strip.html:
* webgpu/draw-indexed-triangles.html:
* webgpu/js/webgpu-functions.js:
(createBasicDepthTexture):
* webgpu/texture-triangle-strip.html:
* webgpu/textures-textureviews.html:
* webgpu/vertex-buffer-triangle-strip.html:
* webgpu/whlsl.html:

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

48 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/bind-groups.html
LayoutTests/webgpu/blend-triangle-strip.html
LayoutTests/webgpu/blit-commands.html
LayoutTests/webgpu/buffer-command-buffer-races.html
LayoutTests/webgpu/buffer-resource-triangles.html
LayoutTests/webgpu/color-write-mask-triangle-strip.html
LayoutTests/webgpu/compute-squares.html
LayoutTests/webgpu/depth-enabled-triangle-strip.html
LayoutTests/webgpu/draw-indexed-triangles.html
LayoutTests/webgpu/js/webgpu-functions.js
LayoutTests/webgpu/texture-triangle-strip.html
LayoutTests/webgpu/textures-textureviews.html
LayoutTests/webgpu/vertex-buffer-triangle-strip.html
LayoutTests/webgpu/whlsl.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/GPUBindGroupLayoutBinding.idl
Source/WebCore/Modules/webgpu/GPUBindGroupLayoutDescriptor.idl
Source/WebCore/Modules/webgpu/GPUBlendDescriptor.idl
Source/WebCore/Modules/webgpu/GPUBufferDescriptor.idl
Source/WebCore/Modules/webgpu/GPUColor.idl
Source/WebCore/Modules/webgpu/GPUColorStateDescriptor.idl
Source/WebCore/Modules/webgpu/GPUDepthStencilStateDescriptor.idl
Source/WebCore/Modules/webgpu/GPUExtent3D.idl
Source/WebCore/Modules/webgpu/GPUInputStateDescriptor.idl
Source/WebCore/Modules/webgpu/GPUOrigin3D.h
Source/WebCore/Modules/webgpu/GPUOrigin3D.idl
Source/WebCore/Modules/webgpu/GPURequestAdapterOptions.idl
Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl
Source/WebCore/Modules/webgpu/GPUVertexAttributeDescriptor.idl
Source/WebCore/Modules/webgpu/GPUVertexInputDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPUBindGroupBinding.idl
Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPUBufferBinding.idl
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl
Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl
Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.cpp
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl
Source/WebCore/Modules/webgpu/WebGPUShaderModuleDescriptor.idl
Source/WebCore/platform/graphics/gpu/GPUColorStateDescriptor.h
Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h
Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h
Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

index 4cb76d5..a256ff6 100644 (file)
@@ -1,3 +1,28 @@
+2019-04-18  Justin Fan  <justin_fan@apple.com>
+
+        [WebGPU] Implement API default values
+        https://bugs.webkit.org/show_bug.cgi?id=197032
+
+        Reviewed by Myles C. Maxfield.
+
+        Update WebGPU tests to use default values wherever applicable.
+
+        * webgpu/bind-groups.html:
+        * webgpu/blend-triangle-strip.html:
+        * webgpu/blit-commands.html:
+        * webgpu/buffer-command-buffer-races.html:
+        * webgpu/buffer-resource-triangles.html:
+        * webgpu/color-write-mask-triangle-strip.html:
+        * webgpu/compute-squares.html:
+        * webgpu/depth-enabled-triangle-strip.html:
+        * webgpu/draw-indexed-triangles.html:
+        * webgpu/js/webgpu-functions.js:
+        (createBasicDepthTexture):
+        * webgpu/texture-triangle-strip.html:
+        * webgpu/textures-textureviews.html:
+        * webgpu/vertex-buffer-triangle-strip.html:
+        * webgpu/whlsl.html:
+
 2019-04-18  Sihui Liu  <sihui_liu@apple.com>
 
         Blob type cannot be stored correctly in IDB when IDBObjectStore has autoIncrement and keyPath options
index f8f90dd..970c1fd 100644 (file)
@@ -20,7 +20,7 @@ promise_test(async () => {
     const bindGroupLayout = device.createBindGroupLayout({ bindings: [bufferLayoutBinding] });
 
     const buffer = device.createBuffer({ size: 16, usage: GPUBufferUsage.STORAGE });
-    const bufferBinding = { buffer: buffer, offset: 0, size: 16 };
+    const bufferBinding = { buffer: buffer, size: 16 };
     const bindGroupBinding = { binding: 1, resource: bufferBinding };
 
     const bindGroup = device.createBindGroup({ layout: bindGroupLayout, bindings: [bindGroupBinding]});
index 4c67c2e..798135f 100644 (file)
@@ -52,17 +52,8 @@ async function test() {
 
     const colorStates = [{
         format: "bgra8unorm",
-        alphaBlend: {
-            srcFactor: "one",
-            dstFactor: "one",
-            operation: "add"
-        },
-        colorBlend: {
-            srcFactor: "one",
-            dstFactor: "one",
-            operation: "add"
-        },
-        writeMask: GPUColorWriteBits.ALL
+        alphaBlend: { dstFactor: "one" },
+        colorBlend: { dstFactor: "one" }
     }];
 
     const inputStateDescriptor = {
@@ -70,13 +61,11 @@ async function test() {
         attributes: [{
             shaderLocation: positionAttributeNum,
             inputSlot: 0,
-            offset: 0,
             format: "float4"
         }],
         inputs: [{
             inputSlot: 0,
-            stride: 4 * 4,
-            stepMode: "vertex"
+            stride: 4 * 4
         }]
     };
 
index d71947e..d7ea225 100644 (file)
@@ -38,7 +38,6 @@ async function test(image) {
     const bufferB = device.createBuffer(bufferDescriptor);
     const bufferViewB = {
         buffer: bufferB,
-        offset: 0,
         rowPitch: image.width * 4,
         imageHeight: 0
     };
@@ -50,28 +49,14 @@ async function test(image) {
     };
     const textureDescriptor = {
         size: textureSize,
-        arrayLayerCount: 1,
-        mipLevelCount: 1,
-        sampleCount: 1,
-        dimension: "2d",
         format: "rgba8unorm",
         usage: GPUTextureUsage.TRANSFER_SRC | GPUTextureUsage.TRANSFER_DST
     };
     const textureA = device.createTexture(textureDescriptor);
-    const textureViewA = {
-        texture: textureA,
-        mipLevel: 0,
-        arrayLayer: 0,
-        origin: { x: 0, y: 0, z: 0 }
-    };
+    const textureViewA = { texture: textureA };
 
     const textureB = device.createTexture(textureDescriptor);
-    const textureViewB = {
-        texture: textureB,
-        mipLevel: 0,
-        arrayLayer: 0,
-        origin: { x: 0, y: 0, z: 0 }
-    };
+    const textureViewB = { texture: textureB };
 
     const readBufferDescriptor = {
         size: imageData.data.byteLength,
@@ -80,7 +65,6 @@ async function test(image) {
     const readBuffer = device.createBuffer(readBufferDescriptor);
     const readBufferView = {
         buffer: readBuffer,
-        offset: 0,
         rowPitch: image.width * 4,
         imageHeight: 0
     };
index a3c1e13..3f04aec 100644 (file)
@@ -48,18 +48,15 @@ function createInputStateDescriptor() {
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
-            offset: 0,
             format: "float2"
         }, {
             shaderLocation: 1,
             inputSlot: 1,
-            offset: 0,
             format: "float3"
         }],
         inputs: [{
             inputSlot: 0,
-            stride: 4 * 2,
-            stepMode: "vertex"
+            stride: 4 * 2
         }, {
             inputSlot: 1,
             stride: 4 * 3,
index 135ad75..08f9ca1 100644 (file)
@@ -108,11 +108,7 @@ function createFloat4Buffer(device, a, b, promises) {
 }
 
 function createBufferBinding(buffer) {
-    return {
-        buffer: buffer,
-        offset: 0,
-        size: vertexSize
-    };
+    return { buffer: buffer, size: vertexSize };
 }
 
 async function test() {
@@ -141,13 +137,11 @@ async function test() {
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
-            offset: 0,
             format: "float4"
         }],
         inputs: [{
             inputSlot: 0,
-            stride: vertexSize,
-            stepMode: "vertex"
+            stride: vertexSize
         }]
     };
 
index f17f00f..856e46c 100644 (file)
@@ -52,16 +52,8 @@ async function test() {
     const shaderModule = device.createShaderModule({ code: shaderCode });
     const colorStates = [{
         format: "bgra8unorm",
-        alphaBlend: {
-            srcFactor: "one",
-            dstFactor: "zero",
-            operation: "add"
-        },
-        colorBlend: {
-            srcFactor: "one",
-            dstFactor: "zero",
-            operation: "add"
-        },
+        alphaBlend: {},
+        colorBlend: {},
         writeMask: GPUColorWriteBits.GREEN | GPUColorWriteBits.ALPHA
     }];
     const pipeline = createBasicPipeline(shaderModule, device, colorStates);
index 40d60ab..fcacf92 100644 (file)
@@ -45,7 +45,7 @@ promise_test(async () => {
     const bgLayoutBinding = { binding: dataBinding, visibility: GPUShaderStageBit.COMPUTE, type: "storage-buffer" };
     const bgLayout = device.createBindGroupLayout({ bindings: [bgLayoutBinding] });
     
-    const bufferBinding = { buffer: dataBuffer, offset: 0, size: data.byteLength };
+    const bufferBinding = { buffer: dataBuffer, size: data.byteLength };
     const bgBinding = { binding: dataBinding, resource: bufferBinding };
     
     const bindGroupDescriptor = { layout: bgLayout, bindings: [bgBinding] };
index 118960a..e017e9b 100644 (file)
@@ -68,13 +68,11 @@ function createInputStateDescriptor() {
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
-            offset: 0,
             format: "float4"
         }],
         inputs: [{
             inputSlot: 0,
-            stride: 4 * 4,
-            stepMode: "vertex"
+            stride: 4 * 4
         }]
     }
 }
index 4db5dfc..0d644cf 100644 (file)
@@ -77,7 +77,6 @@ function createInputStateDescriptor() {
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
-            offset: 0,
             format: "float4"
         }, {
             shaderLocation: 1,
@@ -87,8 +86,7 @@ function createInputStateDescriptor() {
         }],
         inputs: [{
             inputSlot: 0,
-            stride: 4 * 5,
-            stepMode: "vertex"
+            stride: 4 * 5
         }]
     };
 }
index 9776b4f..13be6f8 100644 (file)
@@ -25,10 +25,6 @@ function createBasicDepthTexture(canvas, device) {
 
     return device.createTexture({
         size: depthSize,
-        arrayLayerCount: 1,
-        mipLevelCount: 1,
-        sampleCount: 1,
-        dimension: "2d",
         format: "depth32float-stencil8",
         usage: GPUTextureUsage.OUTPUT_ATTACHMENT
     });
@@ -48,33 +44,25 @@ function createBasicPipeline(shaderModule, device, colorStates, pipelineLayout,
     if (!colorStates) {
         colorStates = [{ 
             format: "bgra8unorm",
-            alphaBlend: {
-                srcFactor: "one",
-                dstFactor: "zero",
-                operation: "add"
-            },
-            colorBlend: {
-                srcFactor: "one",
-                dstFactor: "zero",
-                operation: "add"
-            },
-            writeMask: GPUColorWriteBits.ALL
+            alphaBlend: {},
+            colorBlend: {}
         }];
     }
 
+    if (!inputStateDescriptor)
+        inputStateDescriptor = { attributes: [], inputs: [] };
+
     const pipelineDescriptor = {
         vertexStage: vertexStageDescriptor,
         fragmentStage: fragmentStageDescriptor,
         primitiveTopology: primitiveTopology,
-        colorStates: colorStates
+        colorStates: colorStates,
+        inputState: inputStateDescriptor
     };
 
     if (pipelineLayout)
         pipelineDescriptor.layout = pipelineLayout;
 
-    if (inputStateDescriptor)
-        pipelineDescriptor.inputState = inputStateDescriptor;
-
     if (depthStateDescriptor)
         pipelineDescriptor.depthStencilState = depthStateDescriptor;
 
index 854038f..d34f3c1 100644 (file)
@@ -61,22 +61,18 @@ function createInputStateDescriptor() {
         attributes: [{
             shaderLocation: positionAttributeNum,
             inputSlot: positionBufferIndex,
-            offset: 0,
             format: "float4"
         }, {
             shaderLocation: texCoordsAttributeNum,
             inputSlot: texCoordsBufferIndex,
-            offset: 0,
             format: "float2"
         }],
         inputs: [{
             inputSlot: positionBufferIndex,
-            stride: 4 * 4,
-            stepMode: "vertex"
+            stride: 4 * 4
         }, {
             inputSlot: texCoordsBufferIndex,
-            stride: 4 * 2,
-            stepMode: "vertex"
+            stride: 4 * 2
         }]
     }
 }
@@ -142,10 +138,6 @@ async function test() {
 
     const textureDescriptor = {
         size: { width: image.width, height: image.height, depth: 1 },
-        arrayLayerCount: 1,
-        mipLevelCount: 1,
-        sampleCount: 1,
-        dimension: "2d",
         format: "rgba8unorm",
         usage: GPUTextureUsage.TRANSFER_DST | GPUTextureUsage.SAMPLED
     };
@@ -190,16 +182,10 @@ async function test() {
 
     const bufferCopyView = {
         buffer: textureBuffer,
-        offset: 0,
         rowPitch: image.width * 4,
         imageHeight: 0
     };
-    const textureCopyView = {
-        texture: texture,
-        mipLevel: 0,
-        arrayLayer: 0,
-        origin: { x: 0, y: 0, z: 0 }
-    };
+    const textureCopyView = { texture: texture };
     commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, textureSize);
     const passEncoder = beginBasicRenderPass(swapChain, commandEncoder);
     passEncoder.setPipeline(pipeline);
index b3f665b..43000ff 100644 (file)
@@ -18,10 +18,6 @@ let texSize = {
 
 let texDescriptor = {
     size: texSize,
-    arrayLayerCount: 1,
-    mipLevelCount: 1,
-    sampleCount: 1,
-    dimension: "2d",
     format: "depth32float-stencil8",
     usage: GPUTextureUsage.OUTPUT_ATTACHMENT
 };
index 5c4d0eb..bd7843c 100644 (file)
@@ -66,7 +66,6 @@ function createInputStateDescriptor() {
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
-            offset: 0,
             format: "float4"
         }, {
             shaderLocation: 1,
@@ -76,8 +75,7 @@ function createInputStateDescriptor() {
         }],
         inputs: [{
             inputSlot: 0,
-            stride: 4 * 5,
-            stepMode: "vertex"
+            stride: 4 * 5
         }]
     }
 }
index 14629de..ce6e200 100644 (file)
@@ -23,16 +23,16 @@ async function start() {
     const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
     const primitiveTopology = "triangle-strip";
     const rasterizationState = {frontFace: "cw", cullMode: "none"};
-    const alphaBlend = {srcFactor: "one", dstFactor: "zero", operation: "add"};
-    const colorBlend = {srcFactor: "one", dstFactor: "zero", operation: "add"};
+    const alphaBlend = {};
+    const colorBlend = {};
     const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
     const depthStencilState = null;
     
-    const attribute0 = {shaderLocation: 0, inputSlot: 0, offset: 0, format: "float4"};
-    const attribute1 = {shaderLocation: 1, inputSlot: 1, offset: 0, format: "float"};
+    const attribute0 = {shaderLocation: 0, inputSlot: 0, format: "float4"};
+    const attribute1 = {shaderLocation: 1, inputSlot: 1, format: "float"};
     const attributes = [attribute0, attribute1];
-    const input0 = {inputSlot: 0, stride: 16, stepMode: "vertex"};
-    const input1 = {inputSlot: 1, stride: 4, stepMode: "vertex"};
+    const input0 = {inputSlot: 0, stride: 16 };
+    const input1 = {inputSlot: 1, stride: 4 };
     const inputs = [input0, input1];
     const inputState = {indexFormat: "uint32", attributes, inputs};
 
@@ -83,7 +83,7 @@ async function start() {
     resourceBufferFloat32Array[0] = 1;
     resourceBuffer.unmap();
 
-    const bufferBinding = {buffer: resourceBuffer, offset: 0, size: 4};
+    const bufferBinding = {buffer: resourceBuffer, size: 4};
     const bindGroupBinding = {binding: 0, resource: bufferBinding};
     const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     const bindGroup = device.createBindGroup(bindGroupDescriptor);
index 2e048fc..634ba6b 100644 (file)
@@ -1,3 +1,58 @@
+2019-04-18  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] Implement API default values
+        https://bugs.webkit.org/show_bug.cgi?id=197032
+
+        Reviewed by Myles C. Maxfield.
+
+        Add default values and 'required' qualifiers recently merged to the WebGPU API.
+
+        WebGPU tests specifying these default values have been updated to rely on them for functionality.
+
+        * Modules/webgpu/GPUBindGroupLayoutBinding.idl:
+        * Modules/webgpu/GPUBindGroupLayoutDescriptor.idl:
+        * Modules/webgpu/GPUBlendDescriptor.idl:
+        * Modules/webgpu/GPUBufferDescriptor.idl:
+        * Modules/webgpu/GPUColor.idl:
+        * Modules/webgpu/GPUColorStateDescriptor.idl:
+        * Modules/webgpu/GPUDepthStencilStateDescriptor.idl:
+        * Modules/webgpu/GPUExtent3D.idl:
+        * Modules/webgpu/GPUInputStateDescriptor.idl:
+        * Modules/webgpu/GPUOrigin3D.h:
+        * Modules/webgpu/GPUOrigin3D.idl:
+        * Modules/webgpu/GPURequestAdapterOptions.idl:
+        * Modules/webgpu/GPUTextureDescriptor.idl:
+        * Modules/webgpu/GPUVertexAttributeDescriptor.idl:
+        * Modules/webgpu/GPUVertexInputDescriptor.idl:
+        * Modules/webgpu/WebGPUBindGroupBinding.idl:
+        * Modules/webgpu/WebGPUBindGroupDescriptor.idl:
+        * Modules/webgpu/WebGPUBufferBinding.h:
+        * Modules/webgpu/WebGPUBufferBinding.idl:
+        * Modules/webgpu/WebGPUCommandEncoder.idl:
+        * Modules/webgpu/WebGPUPipelineDescriptorBase.idl:
+        * Modules/webgpu/WebGPUPipelineLayoutDescriptor.idl:
+        * Modules/webgpu/WebGPUPipelineStageDescriptor.idl:
+        * Modules/webgpu/WebGPURenderPassDescriptor.idl:
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.cpp:
+        (WebCore::WebGPURenderPipelineDescriptor::tryCreateGPURenderPipelineDescriptor const):
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.h:
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
+        * Modules/webgpu/WebGPUShaderModuleDescriptor.idl:
+        * platform/graphics/gpu/GPUBlendDescriptor.h:
+        * platform/graphics/gpu/GPUColorStateDescriptor.h:
+        * platform/graphics/gpu/GPUCommandBuffer.h:
+        * platform/graphics/gpu/GPUDepthStencilStateDescriptor.h:
+        * platform/graphics/gpu/GPURenderPassDescriptor.h:
+        * platform/graphics/gpu/GPURenderPipelineDescriptor.h:
+        (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor):
+        * platform/graphics/gpu/GPURequestAdapterOptions.h:
+        * platform/graphics/gpu/GPUTextureDescriptor.h:
+        * platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
+        * platform/graphics/gpu/GPUVertexInputDescriptor.h:
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::convertRenderPipelineDescriptor):
+        (WebCore::trySetFunctionsForPipelineDescriptor):
+
 2019-04-18  Jer Noble  <jer.noble@apple.com>
 
         Refactoring: Pull all fullscreen code out of Document and into its own helper class
index a6638dd..9655b9f 100644 (file)
@@ -43,7 +43,7 @@ typedef u32 GPUShaderStageFlags;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUBindGroupLayoutBinding {
-    u32 binding;
-    GPUShaderStageFlags visibility;
-    GPUBindingType type;
+    required u32 binding;
+    required GPUShaderStageFlags visibility;
+    required GPUBindingType type;
 };
index 54cb27e..e5d0bbb 100644 (file)
@@ -28,5 +28,5 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUBindGroupLayoutDescriptor {
-    sequence<GPUBindGroupLayoutBinding> bindings;
+    required sequence<GPUBindGroupLayoutBinding> bindings;
 };
index 4167780..fc8f90e 100644 (file)
@@ -56,7 +56,7 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUBlendDescriptor {
-    GPUBlendFactor srcFactor;
-    GPUBlendFactor dstFactor;
-    GPUBlendOperation operation;
+    GPUBlendFactor srcFactor = "one";
+    GPUBlendFactor dstFactor = "zero";
+    GPUBlendOperation operation = "add";
 };
index 273377d..3f3981b 100644 (file)
@@ -31,6 +31,6 @@ typedef unsigned long GPUBufferUsageFlags;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUBufferDescriptor {
-    u64 size;
-    GPUBufferUsageFlags usage;
+    required u64 size;
+    required GPUBufferUsageFlags usage;
 };
index 962cc43..a17d237 100644 (file)
@@ -28,8 +28,8 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUColor {
-    float r;
-    float g;
-    float b;
-    float a;
+    required float r;
+    required float g;
+    required float b;
+    required float a;
 };
index 8c966db..677df2b 100644 (file)
@@ -30,9 +30,9 @@ typedef unsigned long GPUColorWriteFlags;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUColorStateDescriptor {
-    GPUTextureFormat format;
+    required GPUTextureFormat format;
 
-    GPUBlendDescriptor alphaBlend;
-    GPUBlendDescriptor colorBlend;
-    GPUColorWriteFlags writeMask;
+    required GPUBlendDescriptor alphaBlend;
+    required GPUBlendDescriptor colorBlend;
+    GPUColorWriteFlags writeMask; // GPUColorWriteBits.ALL
 };
index 94745b2..bfb1687 100644 (file)
@@ -28,8 +28,8 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUDepthStencilStateDescriptor {
-    boolean depthWriteEnabled;
-    GPUCompareFunction depthCompare;
+    boolean depthWriteEnabled = false;
+    GPUCompareFunction depthCompare = "always";
 
 /* Not Yet Implemented
     GPUStencilStateFaceDescriptor stencilFront;
index e040de8..f354c11 100644 (file)
@@ -30,7 +30,7 @@ typedef unsigned long u32;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUExtent3D {
-    u32 width;
-    u32 height;
-    u32 depth;
+    required u32 width;
+    required u32 height;
+    required u32 depth;
 };
index 8c122f7..c0985f7 100644 (file)
@@ -37,8 +37,8 @@ typedef unsigned long u32;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUInputStateDescriptor {
-    GPUIndexFormat indexFormat;
+    GPUIndexFormat? indexFormat;
 
-    sequence<GPUVertexAttributeDescriptor> attributes;
-    sequence<GPUVertexInputDescriptor> inputs;
+    required sequence<GPUVertexAttributeDescriptor> attributes;
+    required sequence<GPUVertexInputDescriptor> inputs;
 };
index f59540e..ff2b7b3 100644 (file)
@@ -30,9 +30,9 @@
 namespace WebCore {
 
 struct GPUOrigin3D {
-    unsigned x;
-    unsigned y;
-    unsigned z;
+    unsigned x { 0 };
+    unsigned y { 0 };
+    unsigned z { 0 };
 };
 
 } // namespace WebCore
index 813a231..745b3e0 100644 (file)
@@ -30,7 +30,7 @@ typedef unsigned long u32;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUOrigin3D {
-    u32 x;
-    u32 y;
-    u32 z;
+    u32 x = 0;
+    u32 y = 0;
+    u32 z = 0;
 };
index 7ed0767..c53349a 100644 (file)
@@ -35,5 +35,5 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPURequestAdapterOptions {
-    GPUPowerPreference powerPreference;
+    GPUPowerPreference? powerPreference;
 };
index 9472e4e..c151aec 100644 (file)
@@ -39,11 +39,11 @@ typedef unsigned long GPUTextureUsageFlags;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUTextureDescriptor {
-    GPUExtent3D size;
-    u32 arrayLayerCount;
-    u32 mipLevelCount;
-    u32 sampleCount;
-    GPUTextureDimension dimension;
-    GPUTextureFormat format;
-    GPUTextureUsageFlags usage;
+    required GPUExtent3D size;
+    u32 arrayLayerCount = 1;
+    u32 mipLevelCount = 1;
+    u32 sampleCount = 1;
+    GPUTextureDimension dimension = "2d";
+    required GPUTextureFormat format;
+    required GPUTextureUsageFlags usage;
 };
index dc34384..a83e964 100644 (file)
@@ -40,8 +40,8 @@ typedef unsigned long long u64;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUVertexAttributeDescriptor {
-    u32 shaderLocation;
-    u32 inputSlot;
-    u64 offset;
-    GPUVertexFormat format;
+    required u32 shaderLocation;
+    required u32 inputSlot;
+    u64 offset = 0;
+    required GPUVertexFormat format;
 };
index 0eaa8ab..22a0c9e 100644 (file)
@@ -38,7 +38,7 @@ typedef unsigned long long u64;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary GPUVertexInputDescriptor {
-    u32 inputSlot;
-    u64 stride;
-    GPUInputStepMode stepMode;
+    required u32 inputSlot;
+    required u64 stride;
+    GPUInputStepMode stepMode = "vertex";
 };
index 71d458d..ab730ff 100644 (file)
@@ -31,6 +31,6 @@ typedef (WebGPUSampler or WebGPUTextureView or WebGPUBufferBinding) WebGPUBindin
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUBindGroupBinding {
-    u32 binding;
-    WebGPUBindingResource resource;
+    required u32 binding;
+    required WebGPUBindingResource resource;
 };
index 3905610..5a0605a 100644 (file)
@@ -28,6 +28,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUBindGroupDescriptor {
-    WebGPUBindGroupLayout layout;
-    sequence<WebGPUBindGroupBinding> bindings;
+    required WebGPUBindGroupLayout layout;
+    required sequence<WebGPUBindGroupBinding> bindings;
 };
index c9a2efe..3a6834d 100644 (file)
@@ -30,7 +30,7 @@ typedef unsigned long long u64;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUBufferBinding {
-    WebGPUBuffer buffer;
-    u64 offset;
-    u64 size;
+    required WebGPUBuffer buffer;
+    u64 offset = 0;
+    required u64 size;
 };
index fce1a13..6e5db47 100644 (file)
@@ -32,10 +32,10 @@ typedef unsigned long long u64;
     EnabledAtRuntime=WebGPU,
     ImplementedAs=WebGPUBufferCopyView
 ] dictionary GPUBufferCopyView {
-    WebGPUBuffer buffer;
-    u64 offset;
-    u32 rowPitch;
-    u32 imageHeight;
+    required WebGPUBuffer buffer;
+    u64 offset = 0;
+    required u32 rowPitch;
+    required u32 imageHeight;
 };
 
 [
@@ -43,10 +43,10 @@ typedef unsigned long long u64;
     EnabledAtRuntime=WebGPU,
     ImplementedAs=WebGPUTextureCopyView
 ] dictionary GPUTextureCopyView {
-    WebGPUTexture texture;
-    u32 mipLevel;
-    u32 arrayLayer;
-    GPUOrigin3D origin;
+    required WebGPUTexture texture;
+    u32 mipLevel = 0;
+    u32 arrayLayer = 0;
+    GPUOrigin3D origin; // {x: 0, y: 0, z: 0}
 };
 
 [
index fddb093..e13391d 100644 (file)
@@ -28,5 +28,5 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUPipelineDescriptorBase {
-    WebGPUPipelineLayout layout;
+    WebGPUPipelineLayout? layout = null;
 };
index e31f880..7a1233c 100644 (file)
@@ -28,5 +28,5 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUPipelineLayoutDescriptor {
-    sequence<WebGPUBindGroupLayout> bindGroupLayouts;
+    required sequence<WebGPUBindGroupLayout> bindGroupLayouts;
 };
index eedaf08..3746a14 100644 (file)
@@ -30,6 +30,6 @@ typedef unsigned long WebGPUShaderStageEnum;
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUPipelineStageDescriptor {
-    WebGPUShaderModule module;
-    DOMString entryPoint;
+    required WebGPUShaderModule module;
+    required DOMString entryPoint;
 };
index f38f2e3..d418fba 100644 (file)
     EnabledAtRuntime=WebGPU,
     ImplementedAs=WebGPURenderPassColorAttachmentDescriptor
 ] dictionary GPURenderPassColorAttachmentDescriptor {
-    WebGPUTextureView attachment;
+    required WebGPUTextureView attachment;
     // GPUTextureView? resolveTarget;
 
-    GPULoadOp loadOp;
-    GPUStoreOp storeOp;
-    GPUColor clearColor;
+    required GPULoadOp loadOp;
+    required GPUStoreOp storeOp;
+    GPUColor clearColor; // {r: 0.0, g: 0.0, b: 0.0, a: 1.0}
 };
 
 [
     EnabledAtRuntime=WebGPU,
     ImplementedAs=WebGPURenderPassDepthStencilAttachmentDescriptor
 ] dictionary GPURenderPassDepthStencilAttachmentDescriptor {
-    WebGPUTextureView attachment;
+    required WebGPUTextureView attachment;
 
-    GPULoadOp depthLoadOp;
-    GPUStoreOp depthStoreOp;
-    float clearDepth;
+    required GPULoadOp depthLoadOp;
+    required GPUStoreOp depthStoreOp;
+    required float clearDepth;
 
 /* Not yet implemented
     GPULoadOp stencilLoadOp;
@@ -59,6 +59,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPURenderPassDescriptor {
-    sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
-    GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment;
+    required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
+    GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment = null;
 };
index ee41fbb..bd5c5d6 100644 (file)
@@ -37,16 +37,19 @@ Optional<GPURenderPipelineDescriptor> WebGPURenderPipelineDescriptor::tryCreateG
     auto pipelineLayout = layout ? makeRefPtr(layout->pipelineLayout()) : nullptr;
 
     auto vertex = vertexStage.tryCreateGPUPipelineStageDescriptor();
-    auto fragment = fragmentStage.tryCreateGPUPipelineStageDescriptor();
 
-    if (!vertex || !fragment) {
+    Optional<GPUPipelineStageDescriptor> fragment;
+    if (fragmentStage)
+        fragment = fragmentStage->tryCreateGPUPipelineStageDescriptor();
+
+    if (!vertex || (fragmentStage && !fragment)) {
         LOG(WebGPU, "WebGPUDevice::createRenderPipeline(): Invalid GPUPipelineStageDescriptor!");
         return WTF::nullopt;
     }
 
     // FIXME: Web GPU validation, e.g. fail if colorStates is larger than (max number of supported color states).
 
-    return GPURenderPipelineDescriptor { WTFMove(pipelineLayout), WTFMove(*vertex), WTFMove(*fragment), *this };
+    return GPURenderPipelineDescriptor { WTFMove(pipelineLayout), WTFMove(*vertex), WTFMove(fragment), *this };
 }
 
 } // namespace WebCore
index 5d8b43c..0bda5d7 100644 (file)
@@ -38,7 +38,7 @@ struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase, GPURenderP
     Optional<GPURenderPipelineDescriptor> tryCreateGPURenderPipelineDescriptor() const;
 
     WebGPUPipelineStageDescriptor vertexStage;
-    WebGPUPipelineStageDescriptor fragmentStage;
+    Optional<WebGPUPipelineStageDescriptor> fragmentStage;
 };
 
 } // namespace WebCore
index ab3af4e..8748db8 100644 (file)
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase {
-    WebGPUPipelineStageDescriptor vertexStage;
-    WebGPUPipelineStageDescriptor fragmentStage;
+    required WebGPUPipelineStageDescriptor vertexStage;
+    WebGPUPipelineStageDescriptor? fragmentStage = null;
 
-    GPUPrimitiveTopology primitiveTopology;
-    sequence<GPUColorStateDescriptor> colorStates;
-    GPUDepthStencilStateDescriptor? depthStencilState;
-    GPUInputStateDescriptor inputState;
+    required GPUPrimitiveTopology primitiveTopology;
+    required sequence<GPUColorStateDescriptor> colorStates;
+    GPUDepthStencilStateDescriptor? depthStencilState = null;
+    required GPUInputStateDescriptor inputState;
 };
index 971352a..471af6b 100644 (file)
@@ -28,6 +28,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUShaderModuleDescriptor {
-    /*ArrayBuffer*/ DOMString code; // FIXME: DOMString for MTL prototyping only.
+    required /*ArrayBuffer*/ DOMString code; // FIXME: DOMString for MTL prototyping only.
     boolean isWHLSL = false;
 };
index e001705..85c7124 100644 (file)
@@ -38,7 +38,7 @@ struct GPUColorStateDescriptor {
 
     GPUBlendDescriptor alphaBlend;
     GPUBlendDescriptor colorBlend;
-    GPUColorWriteFlags writeMask;
+    GPUColorWriteFlags writeMask { static_cast<GPUColorWriteFlags>(GPUColorWriteBits::Flags::All) };
 };
 
 } // namespace WebCore
index d64cf5f..a680eb7 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 struct GPURenderPassColorAttachmentDescriptorBase {
     GPULoadOp loadOp;
     GPUStoreOp storeOp;
-    GPUColor clearColor;
+    GPUColor clearColor { 0, 0, 0, 1 };
 };
 
 struct GPURenderPassColorAttachmentDescriptor final : GPURenderPassColorAttachmentDescriptorBase {
index 628a813..03fa0e0 100644 (file)
@@ -53,7 +53,7 @@ struct GPURenderPipelineDescriptorBase {
 };
 
 struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase, GPURenderPipelineDescriptorBase {
-    GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, const GPURenderPipelineDescriptorBase& base)
+    GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, Optional<GPUPipelineStageDescriptor>&& fragment, const GPURenderPipelineDescriptorBase& base)
         : GPUPipelineDescriptorBase { WTFMove(layout) }
         , GPURenderPipelineDescriptorBase(base)
         , vertexStage(WTFMove(vertex))
@@ -62,7 +62,7 @@ struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase, GPURenderPipelin
     }
 
     GPUPipelineStageDescriptor vertexStage;
-    GPUPipelineStageDescriptor fragmentStage;
+    Optional<GPUPipelineStageDescriptor> fragmentStage;
 };
 
 } // namespace WebCore
index 7e34557..1f5e88d 100644 (file)
@@ -27,6 +27,8 @@
 
 #if ENABLE(WEBGPU)
 
+#include <wtf/Optional.h>
+
 namespace WebCore {
 
 enum class GPUPowerPreference {
@@ -35,7 +37,7 @@ enum class GPUPowerPreference {
 };
 
 struct GPURequestAdapterOptions {
-    GPUPowerPreference powerPreference;
+    Optional<GPUPowerPreference> powerPreference;
 };
     
 } // namespace WebCore
index 7a725c7..8fb4a26 100644 (file)
@@ -199,7 +199,8 @@ static Optional<WHLSL::RenderPipelineDescriptor> convertRenderPipelineDescriptor
             return WTF::nullopt;
     }
     whlslDescriptor.vertexEntryPointName = descriptor.vertexStage.entryPoint;
-    whlslDescriptor.fragmentEntryPointName = descriptor.fragmentStage.entryPoint;
+    if (descriptor.fragmentStage)
+        whlslDescriptor.fragmentEntryPointName = descriptor.fragmentStage->entryPoint;
     return whlslDescriptor;
 }
 
@@ -275,19 +276,23 @@ static bool trySetFunctionsForPipelineDescriptor(const char* const functionName,
     const auto& vertexStage = descriptor.vertexStage;
     const auto& fragmentStage = descriptor.fragmentStage;
 
-    if (vertexStage.module.ptr() == fragmentStage.module.ptr()) {
-        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195446 Allow WHLSL shaders to come from different programs.
-        const auto& whlslSource = vertexStage.module->whlslSource();
-        if (!whlslSource.isNull())
+    const auto& whlslSource = vertexStage.module->whlslSource();
+    if (!whlslSource.isNull()) {
+        if (!fragmentStage || vertexStage.module.ptr() == fragmentStage->module.ptr()) {
+            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195446 Allow WHLSL shaders to come from different programs.
             return trySetWHLSLFunctionsForPipelineDescriptor(functionName, mtlDescriptor, descriptor, whlslSource, device);
+        }
     }
 
     auto vertexLibrary = vertexStage.module->platformShaderModule();
     MTLLibrary *fragmentLibrary = nil;
-    if (!fragmentStage.entryPoint.isNull())
-        fragmentLibrary = fragmentStage.module->platformShaderModule();
+    String fragmentEntryPoint;
+    if (fragmentStage) {
+        fragmentLibrary = fragmentStage->module->platformShaderModule();
+        fragmentEntryPoint = fragmentStage->entryPoint;
+    }
 
-    return trySetMetalFunctionsForPipelineDescriptor(functionName, vertexLibrary, fragmentLibrary, mtlDescriptor, vertexStage.entryPoint, fragmentStage.entryPoint);
+    return trySetMetalFunctionsForPipelineDescriptor(functionName, vertexLibrary, fragmentLibrary, mtlDescriptor, vertexStage.entryPoint, fragmentEntryPoint);
 }
 
 static MTLVertexFormat mtlVertexFormatForGPUVertexFormat(GPUVertexFormat format)