Title: [239139] trunk
Revision
239139
Author
justin_...@apple.com
Date
2018-12-12 17:26:32 -0800 (Wed, 12 Dec 2018)

Log Message

[WebGPU] Vertex buffers and WebGPUInputState
https://bugs.webkit.org/show_bug.cgi?id=192611

Reviewed by Dean Jackson.

Source/WebCore:

Test: webgpu/vertex-buffer-triangle-strip.html

Basic implementation of vertex buffers with Metal shading language in WebGPU. In
WebGPURenderPipelineDescriptor, refactor to match updated shader stage structure and add
WebGPUInputStateDescriptor. Also implement WebGPURenderPassEncoder::setVertexBuffers.

Add symbols and files for WebGPUIndexFormat, WebGPUInputStateDescriptor, WebGPUInputStepMode,
WebGPUVertexAttributeDescriptor, WebGPUVertexFormat, WebGPUVertexInputDescriptor:
* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:

Add and implement interfaces and dictionaries for WebGPUInputState:
* Modules/webgpu/WebGPUBuffer.cpp:
(WebCore::WebGPUBuffer::WebGPUBuffer):
* Modules/webgpu/WebGPUBuffer.h:
(WebCore::WebGPUBuffer::buffer const): Added getter for backing GPUBuffer.
* Modules/webgpu/WebGPUBufferDescriptor.h:
* Modules/webgpu/WebGPUBufferDescriptor.idl: Moving WebGPUBufferUsage out into its own IDL.
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUIndexFormat.h: Added.
* Modules/webgpu/WebGPUIndexFormat.idl: Added.
* Modules/webgpu/WebGPUInputStateDescriptor.h: Added.
* Modules/webgpu/WebGPUInputStateDescriptor.idl: Added.
* Modules/webgpu/WebGPUInputStepMode.h: Added.
* Modules/webgpu/WebGPUInputStepMode.idl: Added.
* Modules/webgpu/WebGPUVertexAttributeDescriptor.h: Added.
* Modules/webgpu/WebGPUVertexAttributeDescriptor.idl: Added.
* Modules/webgpu/WebGPUVertexFormat.h: Added.
* Modules/webgpu/WebGPUVertexFormat.idl: Added.
* Modules/webgpu/WebGPUVertexInputDescriptor.h: Added.
* Modules/webgpu/WebGPUVertexInputDescriptor.idl: Added.
* platform/graphics/gpu/GPUInputStateDescriptor.h: Added.
* platform/graphics/gpu/GPURenderPassEncoder.h: Added.
* platform/graphics/gpu/GPURenderPipelineDescriptor.h: Added.
* platform/graphics/gpu/GPUVertexAttributeDescriptor.h: Added.
* platform/graphics/gpu/GPUVertexInputDescriptor.h: Added.

Refactor to support updated structure of pipeline descriptor in sketch IDL:
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::validateAndConvertPipelineStage):
(WebCore::WebGPUDevice::createRenderPipeline const):
* Modules/webgpu/WebGPUPipelineDescriptorBase.h:
* Modules/webgpu/WebGPUPipelineDescriptorBase.idl:
* Modules/webgpu/WebGPUPipelineStageDescriptor.h:
* Modules/webgpu/WebGPUPipelineStageDescriptor.idl:
* Modules/webgpu/WebGPURenderPipelineDescriptor.h:
* Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
* Modules/webgpu/WebGPUShaderStage.*: Removed.

Add and implement setVertexBuffers:
* Modules/webgpu/WebGPURenderPassEncoder.cpp:
(WebCore::WebGPURenderPassEncoder::setVertexBuffers): Added.
* Modules/webgpu/WebGPURenderPassEncoder.h:
* Modules/webgpu/WebGPURenderPassEncoder.idl:
* platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
(WebCore::GPURenderPassEncoder::setVertexBuffers):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::setInputStateForPipelineDescriptor):
(WebCore::GPURenderPipeline::create):

LayoutTests:

Added variation of simple-triangle-strip to use a vertex buffer. Refactored aforementioned
test to share code with new test.

* webgpu/js/basic-webgpu-functions.js:
(setUpPipelineDescriptor):
* webgpu/js/webgpu-functions.js: Added.
(async.getBasicDevice):
(createBasicContext):
(createBasicPipeline):
(beginBasicRenderPass):
* webgpu/render-pipelines-expected.txt:
* webgpu/render-pipelines.html:
* webgpu/simple-triangle-strip.html:
* webgpu/vertex-buffer-triangle-strip-expected.html: Added.
* webgpu/vertex-buffer-triangle-strip.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239138 => 239139)


--- trunk/LayoutTests/ChangeLog	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/LayoutTests/ChangeLog	2018-12-13 01:26:32 UTC (rev 239139)
@@ -1,3 +1,26 @@
+2018-12-12  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] Vertex buffers and WebGPUInputState
+        https://bugs.webkit.org/show_bug.cgi?id=192611
+
+        Reviewed by Dean Jackson.
+
+        Added variation of simple-triangle-strip to use a vertex buffer. Refactored aforementioned
+        test to share code with new test.
+
+        * webgpu/js/basic-webgpu-functions.js:
+        (setUpPipelineDescriptor):
+        * webgpu/js/webgpu-functions.js: Added.
+        (async.getBasicDevice):
+        (createBasicContext):
+        (createBasicPipeline):
+        (beginBasicRenderPass):
+        * webgpu/render-pipelines-expected.txt:
+        * webgpu/render-pipelines.html:
+        * webgpu/simple-triangle-strip.html:
+        * webgpu/vertex-buffer-triangle-strip-expected.html: Added.
+        * webgpu/vertex-buffer-triangle-strip.html: Added.
+
 2018-12-12  Joseph Pecoraro  <pecor...@apple.com>
 
         REGRESSION: [ MacOS iOS ] Layout Test http/wpt/resource-timing/rt-revalidate-requests.html is flaky timeout

Modified: trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js (239138 => 239139)


--- trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js	2018-12-13 01:26:32 UTC (rev 239139)
@@ -90,19 +90,18 @@
 
 function setUpPipelineDescriptor() {
     vertexStageDescriptor = { 
-        module: shaderModule, 
-        stage: WebGPUShaderStage.VERTEX, 
+        module: shaderModule,
         entryPoint: "vertex_main" 
     };
 
     fragmentStageDescriptor = {
         module: shaderModule,
-        stage: WebGPUShaderStage.FRAGMENT,
         entryPoint: "fragment_main"
     };
 
     pipelineDescriptor = {
-        stages: [vertexStageDescriptor, fragmentStageDescriptor],
+        vertexStage: vertexStageDescriptor, 
+        fragmentStage: fragmentStageDescriptor,
         primitiveTopology: "triangleList"
     };
 }

Added: trunk/LayoutTests/webgpu/js/webgpu-functions.js (0 => 239139)


--- trunk/LayoutTests/webgpu/js/webgpu-functions.js	                        (rev 0)
+++ trunk/LayoutTests/webgpu/js/webgpu-functions.js	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,52 @@
+async function getBasicDevice() {
+    // FIXME: requestAdapter should take a WebGPUAdapterDescriptor.
+    const adapter = await window.webgpu.requestAdapter({});
+    const device = adapter.createDevice();
+    return device;
+}
+
+function createBasicContext(canvas, device) {
+    const context = canvas.getContext("webgpu");
+    // FIXME: Implement and specify a WebGPUTextureUsageEnum.
+    context.configure({ device: device, format:"B8G8R8A8Unorm", width: canvas.width, height: canvas.height });
+    return context;
+}
+
+function createBasicPipeline(shaderModule, device, inputStateDescriptor) {
+    vertexStageDescriptor = {
+        module: shaderModule,
+        entryPoint: "vertex_main" 
+    };
+
+    fragmentStageDescriptor = {
+        module: shaderModule,
+        entryPoint: "fragment_main"
+    };
+
+    pipelineDescriptor = {
+        vertexStage: vertexStageDescriptor,
+        fragmentStage: fragmentStageDescriptor,
+        primitiveTopology: "triangleStrip",
+        inputState: inputStateDescriptor
+    };
+
+    return device.createRenderPipeline(pipelineDescriptor);
+}
+
+function beginBasicRenderPass(context, commandBuffer) {
+    const basicAttachment = {
+        attachment: context.getNextTexture().createDefaultTextureView(),
+        clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
+    }
+
+    // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
+    return commandBuffer.beginRenderPass({ colorAttachments : [basicAttachment] });
+}
+
+function encodeBasicCommands(renderPassEncoder, renderPipeline, vertexBuffer) {
+    if (vertexBuffer)
+        renderPassEncoder.setVertexBuffers(0, [vertexBuffer], [0]);
+    renderPassEncoder.setPipeline(renderPipeline);
+    renderPassEncoder.draw(4, 1, 0, 0);
+    return renderPassEncoder.endPass();
+}
\ No newline at end of file

Modified: trunk/LayoutTests/webgpu/render-pipelines-expected.txt (239138 => 239139)


--- trunk/LayoutTests/webgpu/render-pipelines-expected.txt	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/LayoutTests/webgpu/render-pipelines-expected.txt	2018-12-13 01:26:32 UTC (rev 239139)
@@ -3,7 +3,6 @@
 PASS WebGPURenderPipeline with invalid shader module was not created.
 PASS WebGPURenderPipeline with invalid vertex shader stage was not created.
 PASS WebGPURenderPipeline with invalid vertex shader entry point was not created.
-PASS WebGPURenderPipeline with invalid WebGPUShaderStageEnum was not created.
 All tests complete.
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/webgpu/render-pipelines.html (239138 => 239139)


--- trunk/LayoutTests/webgpu/render-pipelines.html	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/LayoutTests/webgpu/render-pipelines.html	2018-12-13 01:26:32 UTC (rev 239139)
@@ -19,11 +19,11 @@
     checkBadRenderPipeline({}, "WebGPURenderPipelineDescriptor");
 
     let noModuleVertexDescriptor = {
-        stage: WebGPUShaderStage.VERTEX,
         entryPoint: "vertex_main"
     }
     let noModulePipelineDescriptor = {
-        stages: [noModuleVertexDescriptor, fragmentStageDescriptor],
+        vertexStage: noModuleVertexDescriptor, 
+        fragmentStage: fragmentStageDescriptor,
         primitiveTopology: "triangleList"
     }
     checkBadRenderPipeline(noModulePipelineDescriptor, "shader module");
@@ -30,32 +30,21 @@
 
     // A (Metal) renderpipeline must have a vertex function.
     let noVertexPipelineDescriptor = {
-        stages: [fragmentStageDescriptor],
+        fragmentStage: fragmentStageDescriptor,
         primitiveTopology: "triangleList"
     }
     checkBadRenderPipeline(noVertexPipelineDescriptor, "vertex shader stage")
 
     let badEntryPointDescriptor = { 
-        module: shaderModule, 
-        stage: WebGPUShaderStage.VERTEX, 
+        module: shaderModule,
         entryPoint: "Vertex_Main" 
     };
     let badEntryPointPipelineDescsriptor = {
-        stages: [badEntryPointDescriptor, fragmentStageDescriptor],
+        vertexStage: badEntryPointDescriptor, 
+        fragmentStage: fragmentStageDescriptor,
         primitiveTopology: "triangleList"
     }
     checkBadRenderPipeline(badEntryPointPipelineDescsriptor, "vertex shader entry point");
-
-    let badStageEnumDescriptor = { 
-        module: shaderModule, 
-        stage: WebGPUShaderStage.COMPUTE, 
-        entryPoint: "vertex_main" 
-    };
-    let badStageEnumPipelineDescriptor = {
-        stages: [badStageEnumDescriptor, fragmentStageDescriptor],
-        primitiveTopology: "triangleList"
-    }
-    checkBadRenderPipeline(badStageEnumPipelineDescriptor, "WebGPUShaderStageEnum");
 }
 
 runWebGPUTests([setUpPipeline, setUpBadPipelines]);

Modified: trunk/LayoutTests/webgpu/simple-triangle-strip.html (239138 => 239139)


--- trunk/LayoutTests/webgpu/simple-triangle-strip.html	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/LayoutTests/webgpu/simple-triangle-strip.html	2018-12-13 01:26:32 UTC (rev 239139)
@@ -5,6 +5,7 @@
 <link rel="match" href=""
 <p>Pass if square canvas below is completely green.</p>
 <canvas width="400" height="400"></canvas>
+<script src=""
 <script>
 const shaderCode = `
 #include <metal_stdlib>
@@ -41,57 +42,6 @@
 }
 `
 
-async function getBasicDevice() {
-    // FIXME: requestAdapter should take a WebGPUAdapterDescriptor.
-    const adapter = await window.webgpu.requestAdapter({});
-    const device = adapter.createDevice();
-    return device;
-}
-
-function createBasicContext(canvas, device) {
-    const context = canvas.getContext("webgpu");
-    // FIXME: Implement and specify a WebGPUTextureUsageEnum.
-    context.configure({ device: device, format:"B8G8R8A8Unorm", width: canvas.width, height: canvas.height });
-    return context;
-}
-
-function createBasicPipeline(shaderModule, device) {
-    vertexStageDescriptor = {
-        module: shaderModule, 
-        stage: WebGPUShaderStage.VERTEX, 
-        entryPoint: "vertex_main" 
-    };
-
-    fragmentStageDescriptor = {
-        module: shaderModule,
-        stage: WebGPUShaderStage.FRAGMENT,
-        entryPoint: "fragment_main"
-    };
-
-    pipelineDescriptor = {
-        stages: [vertexStageDescriptor, fragmentStageDescriptor],
-        primitiveTopology: "triangleStrip"
-    };
-
-    return device.createRenderPipeline(pipelineDescriptor);
-}
-
-function beginBasicRenderPass(context, commandBuffer) {
-    const basicAttachment = {
-        attachment: context.getNextTexture().createDefaultTextureView(),
-        clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
-    }
-
-    // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
-    return commandBuffer.beginRenderPass({ colorAttachments : [basicAttachment] });
-}
-
-function encodeBasicCommands(renderPassEncoder, renderPipeline) {
-    renderPassEncoder.setPipeline(renderPipeline);
-    renderPassEncoder.draw(4, 1, 0, 0);
-    return renderPassEncoder.endPass();
-}
-
 async function test() {
     const device = await getBasicDevice();
     const canvas = document.querySelector("canvas");

Added: trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html (0 => 239139)


--- trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip-expected.html	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Reference File</title>
+<p>Pass if square canvas below is completely green.</p>
+<canvas width="400" height="400"></canvas>
+<script>
+const canvas = document.querySelector("canvas");
+const context = canvas.getContext('2d');
+
+context.fillStyle = 'rgb(0, 255, 0)';
+context.fillRect(0, 0, canvas.width, canvas.height);
+</script>
\ No newline at end of file

Added: trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html (0 => 239139)


--- trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebGPU Hello Triangles</title>
+<meta name="assert" content="WebGPU correctly renders a green canvas.">
+<link rel="match" href=""
+<p>Pass if square canvas below is completely green.</p>
+<canvas width="400" height="400"></canvas>
+<script src=""
+<script>
+const shaderCode = `
+#include <metal_stdlib>
+    
+using namespace metal;
+
+struct Vertex
+{
+    float4 position [[position]];
+};
+
+vertex Vertex vertex_main(const device Vertex* vertex_array [[buffer(0)]], uint vid [[vertex_id]])
+{
+    return vertex_array[vid];
+}
+
+fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
+{
+    return float4(0.0, 1.0, 0.0, 1.0);
+}
+`
+
+function createVertexBuffer(device) {
+    const bufferSize = 4 * 4 * 4;
+    const buffer = device.createBuffer({ size: bufferSize, usage: WebGPUBufferUsage.MAP_WRITE });
+    
+    let arrayBuffer = buffer.mapping;
+    let floatArray = new Float32Array(arrayBuffer);
+
+    floatArray[0] = -1;
+    floatArray[1] = 1;
+    floatArray[2] = 0;
+    floatArray[3] = 1;
+
+    floatArray[4] = -1;
+    floatArray[5] = -1;
+    floatArray[6] = 0;
+    floatArray[7] = 1;
+
+    floatArray[8] = 1;
+    floatArray[9] = 1;
+    floatArray[10] = 0;
+    floatArray[11] = 1;
+
+    floatArray[12] = 1;
+    floatArray[13] = -1;
+    floatArray[14] = 0;
+    floatArray[15] = 1;
+
+    return buffer;
+}
+
+function createInputStateDescriptor() {
+    return {
+        indexFormat: WebGPUIndexFormat.UINT32,
+        attributes: [{
+            shaderLocation: 0,
+            inputSlot: 0,
+            offset: 0,
+            format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32
+        }],
+        inputs: [{
+            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 pipeline = createBasicPipeline(shaderModule, device, inputStateDescriptor);
+    const commandBuffer = device.createCommandBuffer();
+    const passEncoder = beginBasicRenderPass(context, commandBuffer);
+    const endCommandBuffer = encodeBasicCommands(passEncoder, pipeline, vertexBuffer);
+    const queue = device.getQueue();
+
+    queue.submit([endCommandBuffer]);
+    context.present();
+}
+
+test();
+</script>
\ No newline at end of file

Modified: trunk/Source/WebCore/CMakeLists.txt (239138 => 239139)


--- trunk/Source/WebCore/CMakeLists.txt	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-12-13 01:26:32 UTC (rev 239139)
@@ -464,6 +464,9 @@
     Modules/webgpu/WebGPUColor.idl
     Modules/webgpu/WebGPUCommandBuffer.idl
     Modules/webgpu/WebGPUDevice.idl
+    Modules/webgpu/WebGPUIndexFormat.idl
+    Modules/webgpu/WebGPUInputStateDescriptor.idl
+    Modules/webgpu/WebGPUInputStepMode.idl
     Modules/webgpu/WebGPUPipelineDescriptorBase.idl
     Modules/webgpu/WebGPUPipelineStageDescriptor.idl
     Modules/webgpu/WebGPUProgrammablePassEncoder.idl
@@ -476,11 +479,13 @@
     Modules/webgpu/WebGPURenderingContext.idl
     Modules/webgpu/WebGPUShaderModule.idl
     Modules/webgpu/WebGPUShaderModuleDescriptor.idl
-    Modules/webgpu/WebGPUShaderStage.idl
     Modules/webgpu/WebGPUSwapChain.idl
     Modules/webgpu/WebGPUTexture.idl
     Modules/webgpu/WebGPUTextureFormatEnum.idl
     Modules/webgpu/WebGPUTextureView.idl
+    Modules/webgpu/WebGPUVertexAttributeDescriptor.idl
+    Modules/webgpu/WebGPUVertexFormat.idl
+    Modules/webgpu/WebGPUVertexInputDescriptor.idl
 
     Modules/websockets/CloseEvent.idl
     Modules/websockets/WebSocket.idl

Modified: trunk/Source/WebCore/ChangeLog (239138 => 239139)


--- trunk/Source/WebCore/ChangeLog	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/ChangeLog	2018-12-13 01:26:32 UTC (rev 239139)
@@ -1,3 +1,73 @@
+2018-12-12  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] Vertex buffers and WebGPUInputState
+        https://bugs.webkit.org/show_bug.cgi?id=192611
+
+        Reviewed by Dean Jackson.
+
+        Test: webgpu/vertex-buffer-triangle-strip.html
+
+        Basic implementation of vertex buffers with Metal shading language in WebGPU. In 
+        WebGPURenderPipelineDescriptor, refactor to match updated shader stage structure and add 
+        WebGPUInputStateDescriptor. Also implement WebGPURenderPassEncoder::setVertexBuffers.
+
+        Add symbols and files for WebGPUIndexFormat, WebGPUInputStateDescriptor, WebGPUInputStepMode, 
+        WebGPUVertexAttributeDescriptor, WebGPUVertexFormat, WebGPUVertexInputDescriptor:
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+
+        Add and implement interfaces and dictionaries for WebGPUInputState:
+        * Modules/webgpu/WebGPUBuffer.cpp:
+        (WebCore::WebGPUBuffer::WebGPUBuffer):
+        * Modules/webgpu/WebGPUBuffer.h:
+        (WebCore::WebGPUBuffer::buffer const): Added getter for backing GPUBuffer.
+        * Modules/webgpu/WebGPUBufferDescriptor.h:
+        * Modules/webgpu/WebGPUBufferDescriptor.idl: Moving WebGPUBufferUsage out into its own IDL.
+        * Modules/webgpu/WebGPUDevice.h:
+        * Modules/webgpu/WebGPUIndexFormat.h: Added.
+        * Modules/webgpu/WebGPUIndexFormat.idl: Added. 
+        * Modules/webgpu/WebGPUInputStateDescriptor.h: Added.
+        * Modules/webgpu/WebGPUInputStateDescriptor.idl: Added.
+        * Modules/webgpu/WebGPUInputStepMode.h: Added.
+        * Modules/webgpu/WebGPUInputStepMode.idl: Added.
+        * Modules/webgpu/WebGPUVertexAttributeDescriptor.h: Added.
+        * Modules/webgpu/WebGPUVertexAttributeDescriptor.idl: Added.
+        * Modules/webgpu/WebGPUVertexFormat.h: Added.
+        * Modules/webgpu/WebGPUVertexFormat.idl: Added.
+        * Modules/webgpu/WebGPUVertexInputDescriptor.h: Added.
+        * Modules/webgpu/WebGPUVertexInputDescriptor.idl: Added.
+        * platform/graphics/gpu/GPUInputStateDescriptor.h: Added.
+        * platform/graphics/gpu/GPURenderPassEncoder.h: Added.
+        * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Added.
+        * platform/graphics/gpu/GPUVertexAttributeDescriptor.h: Added.
+        * platform/graphics/gpu/GPUVertexInputDescriptor.h: Added.
+
+        Refactor to support updated structure of pipeline descriptor in sketch IDL:
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::validateAndConvertPipelineStage):
+        (WebCore::WebGPUDevice::createRenderPipeline const):
+        * Modules/webgpu/WebGPUPipelineDescriptorBase.h:
+        * Modules/webgpu/WebGPUPipelineDescriptorBase.idl:
+        * Modules/webgpu/WebGPUPipelineStageDescriptor.h:
+        * Modules/webgpu/WebGPUPipelineStageDescriptor.idl:
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.h:
+        * Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
+        * Modules/webgpu/WebGPUShaderStage.*: Removed.
+
+        Add and implement setVertexBuffers:
+        * Modules/webgpu/WebGPURenderPassEncoder.cpp:
+        (WebCore::WebGPURenderPassEncoder::setVertexBuffers): Added. 
+        * Modules/webgpu/WebGPURenderPassEncoder.h:
+        * Modules/webgpu/WebGPURenderPassEncoder.idl: 
+        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
+        (WebCore::GPURenderPassEncoder::setVertexBuffers):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::setInputStateForPipelineDescriptor):
+        (WebCore::GPURenderPipeline::create):
+
 2018-12-12  Tim Horton  <timothy_hor...@apple.com>
 
         REGRESSION (r237565): >20 Find in Page highlights in one tile results in a single giant highlight

Modified: trunk/Source/WebCore/DerivedSources.make (239138 => 239139)


--- trunk/Source/WebCore/DerivedSources.make	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/DerivedSources.make	2018-12-13 01:26:32 UTC (rev 239139)
@@ -381,6 +381,9 @@
     $(WebCore)/Modules/webgpu/WebGPUColor.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
     $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
+    $(WebCore)/Modules/webgpu/WebGPUIndexFormat.idl \
+    $(WebCore)/Modules/webgpu/WebGPUInputStateDescriptor.idl \
+    $(WebCore)/Modules/webgpu/WebGPUInputStepMode.idl \
     $(WebCore)/Modules/webgpu/WebGPUQueue.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \
@@ -393,11 +396,13 @@
     $(WebCore)/Modules/webgpu/WebGPURenderingContext.idl \
     $(WebCore)/Modules/webgpu/WebGPUShaderModule.idl \
     $(WebCore)/Modules/webgpu/WebGPUShaderModuleDescriptor.idl \
-    $(WebCore)/Modules/webgpu/WebGPUShaderStage.idl \
     $(WebCore)/Modules/webgpu/WebGPUSwapChain.idl \
     $(WebCore)/Modules/webgpu/WebGPUTexture.idl \
     $(WebCore)/Modules/webgpu/WebGPUTextureFormatEnum.idl \
     $(WebCore)/Modules/webgpu/WebGPUTextureView.idl \
+	$(WebCore)/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl \
+    $(WebCore)/Modules/webgpu/WebGPUVertexFormat.idl \
+	$(WebCore)/Modules/webgpu/WebGPUVertexInputDescriptor.idl \
     $(WebCore)/Modules/websockets/CloseEvent.idl \
     $(WebCore)/Modules/websockets/WebSocket.idl \
     $(WebCore)/Modules/webvr/DOMWindowWebVR.idl \

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp	2018-12-13 01:26:32 UTC (rev 239139)
@@ -38,7 +38,6 @@
 WebGPUBuffer::WebGPUBuffer(Ref<GPUBuffer>&& buffer)
     : m_buffer(WTFMove(buffer))
 {
-    UNUSED_PARAM(m_buffer);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -38,6 +38,8 @@
 public:
     static RefPtr<WebGPUBuffer> create(Ref<GPUBuffer>&&);
 
+    const GPUBuffer& buffer() const { return m_buffer.get(); }
+
     JSC::ArrayBuffer* mapping() const { return m_buffer->mapping(); }
     void unmap() { /* FIXME: Unimplemented stub. */ }
     void destroy() { /* FIXME: Unimplemented stub. */ }

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -33,7 +33,6 @@
 
 using WebGPUBufferDescriptor = GPUBufferDescriptor;
 using WebGPUBufferUsageFlags = GPUBufferUsageFlags;
-using WebGPUBufferUsage = GPUBufferUsage;
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2018-12-13 01:26:32 UTC (rev 239139)
@@ -41,7 +41,6 @@
 #include "WebGPURenderPipelineDescriptor.h"
 #include "WebGPUShaderModule.h"
 #include "WebGPUShaderModuleDescriptor.h"
-#include "WebGPUShaderStage.h"
 
 namespace WebCore {
 
@@ -72,59 +71,25 @@
     return module ? WebGPUShaderModule::create(module.releaseNonNull()) : nullptr;
 }
 
-RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const
+static std::optional<GPUPipelineStageDescriptor> validateAndConvertPipelineStage(const WebGPUPipelineStageDescriptor& descriptor)
 {
-    const char* const functionName = "WebGPUDevice::createRenderPipeline()";
-#if LOG_DISABLED
-    UNUSED_PARAM(functionName);
-#endif
+    if (!descriptor.module || !descriptor.module->module() || descriptor.entryPoint.isEmpty())
+        return std::nullopt;
 
-    if (descriptor.stages.isEmpty()) {
-        LOG(WebGPU, "%s: No stages in WebGPURenderPipelineDescriptor!", functionName);
-        return nullptr;
-    }
+    return GPUPipelineStageDescriptor { descriptor.module->module(), descriptor.entryPoint };
+}
 
-    GPUPipelineStageDescriptor vertexStage;
-    GPUPipelineStageDescriptor fragmentStage;
+RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const
+{
+    auto vertexStage = validateAndConvertPipelineStage(descriptor.vertexStage);
+    auto fragmentStage = validateAndConvertPipelineStage(descriptor.fragmentStage);
 
-    for (const auto& stageDescriptor : descriptor.stages) {
-        if (!stageDescriptor.module || !stageDescriptor.module->module() || stageDescriptor.entryPoint.isEmpty()) {
-            LOG(WebGPU, "%s: Invalid WebGPUPipelineStageDescriptor!", functionName);
-            return nullptr;
-        }
-
-        switch (stageDescriptor.stage) {
-        case WebGPUShaderStage::VERTEX:
-            if (vertexStage.module) {
-                LOG(WebGPU, "%s: Multiple vertex stages in WebGPURenderPipelineDescriptor!", functionName);
-                return nullptr;
-            }
-
-            vertexStage.module = stageDescriptor.module->module();
-            vertexStage.entryPoint = stageDescriptor.entryPoint;
-            break;
-        case WebGPUShaderStage::FRAGMENT:
-            if (fragmentStage.module) {
-                LOG(WebGPU, "%s: Multiple fragment stages in WebGPURenderPipelineDescriptor!", functionName);
-                return nullptr;
-            }
-
-            fragmentStage.module = stageDescriptor.module->module();
-            fragmentStage.entryPoint = stageDescriptor.entryPoint;
-            break;
-        default:
-            LOG(WebGPU, "%s: Invalid shader stage in WebGPURenderPipelineDescriptor!", functionName);
-            return nullptr;
-        }
-    }
-
-    // Metal (if not other APIs) requires at least the vertex shader.
-    if (!vertexStage.module || vertexStage.entryPoint.isEmpty()) {
-        LOG(WebGPU, "%s: Invalid vertex stage in WebGPURenderPipelineDescriptor!", functionName);
+    if (!vertexStage || !fragmentStage) {
+        LOG(WebGPU, "WebGPUDevice::createRenderPipeline(): Invalid WebGPUPipelineStageDescriptor!");
         return nullptr;
     }
 
-    auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(vertexStage), WTFMove(fragmentStage), descriptor.primitiveTopology });
+    auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(*vertexStage), WTFMove(*fragmentStage), descriptor.primitiveTopology, descriptor.inputState });
     return pipeline ? WebGPURenderPipeline::create(pipeline.releaseNonNull()) : nullptr;
 }
 

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include "GPUInputStateDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUIndexFormat = GPUIndexFormat;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUIndexFormat.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl) (0 => 239139)


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

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include "GPUInputStateDescriptor.h"
+#include "WebGPUVertexAttributeDescriptor.h"
+#include "WebGPUVertexInputDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUIndexFormatEnum = GPUIndexFormatEnum;
+using WebGPUInputStateDescriptor = GPUInputStateDescriptor;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUInputStateDescriptor.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl) (0 => 239139)


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

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include "GPUVertexInputDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUInputStepMode = GPUInputStepMode;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUInputStepMode.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl) (0 => 239139)


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

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -27,13 +27,10 @@
 
 #if ENABLE(WEBGPU)
 
-#include "WebGPUPipelineStageDescriptor.h"
-#include <wtf/Vector.h>
-
 namespace WebCore {
 
 struct WebGPUPipelineDescriptorBase {
-    Vector<WebGPUPipelineStageDescriptor> stages;
+    // WebGPUPipelineLayout layout;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl	2018-12-13 01:26:32 UTC (rev 239139)
@@ -29,5 +29,4 @@
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUPipelineDescriptorBase {
     // WebGPUPipelineLayout layout;
-    sequence<WebGPUPipelineStageDescriptor> stages;
 };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -33,11 +33,8 @@
 
 namespace WebCore {
 
-using WebGPUShaderStageEnum = unsigned long;
-
 struct WebGPUPipelineStageDescriptor {
     const WebGPUShaderModule* module = nullptr;
-    WebGPUShaderStageEnum stage;
     String entryPoint;
 };
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl	2018-12-13 01:26:32 UTC (rev 239139)
@@ -31,6 +31,5 @@
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPUPipelineStageDescriptor {
     WebGPUShaderModule module;
-    WebGPUShaderStageEnum stage;
     DOMString entryPoint;
 };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp	2018-12-13 01:26:32 UTC (rev 239139)
@@ -30,6 +30,8 @@
 
 #include "GPUProgrammablePassEncoder.h"
 #include "GPURenderPassEncoder.h"
+#include "Logging.h"
+#include "WebGPUBuffer.h"
 
 namespace WebCore {
 
@@ -44,6 +46,21 @@
 {
 }
 
+void WebGPURenderPassEncoder::setVertexBuffers(unsigned long startSlot, Vector<RefPtr<WebGPUBuffer>>&& buffers, Vector<unsigned>&& offsets)
+{
+    if (buffers.isEmpty() || buffers.size() != offsets.size()) {
+        LOG(WebGPU, "WebGPURenderPassEncoder::setVertexBuffers: Invalid number of buffers or offsets!");
+        return;
+    }
+
+    auto gpuBuffers = buffers.map([] (const auto& buffer) -> Ref<const GPUBuffer> {
+        return buffer->buffer();
+    });
+
+    // FIXME: Use startSlot properly.
+    m_passEncoder->setVertexBuffers(startSlot, WTFMove(gpuBuffers), WTFMove(offsets));
+}
+
 void WebGPURenderPassEncoder::draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance)
 {
     // FIXME: What kind of validation do we need to handle here?

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -30,16 +30,20 @@
 #include "WebGPUProgrammablePassEncoder.h"
 
 #include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
 class GPUProgrammablePassEncoder;
 class GPURenderPassEncoder;
+class WebGPUBuffer;
 
 class WebGPURenderPassEncoder final : public WebGPUProgrammablePassEncoder {
 public:
     static RefPtr<WebGPURenderPassEncoder> create(Ref<WebGPUCommandBuffer>&&, Ref<GPURenderPassEncoder>&&);
 
+    // FIXME: Last argument should be Vector<unsigned long>. Why is the generated code incorrectly assuming the IDL wants a sequence<unsigned int>?
+    void setVertexBuffers(unsigned long, Vector<RefPtr<WebGPUBuffer>>&&, Vector<unsigned>&&);
     void draw(unsigned long, unsigned long, unsigned long, unsigned long);
 
 private:

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.idl	2018-12-13 01:26:32 UTC (rev 239139)
@@ -31,12 +31,13 @@
     EnabledAtRuntime=WebGPU,
     JSGenerateToJSObject
 ] interface WebGPURenderPassEncoder : WebGPUProgrammablePassEncoder {
+    void setVertexBuffers(u32 startSlot, sequence<WebGPUBuffer> buffers, sequence<u32> offsets);
+
     void draw(u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance);
 
 /* Not Yet Implemented
     void setBlendColor(float r, float g, float b, float a);
     void setIndexBuffer(WebGPUBuffer buffer, u32 offset);
-    void setVertexBuffers(u32 startSlot, sequence<WebGPUBuffer> buffers, sequence<u32> offsets);
 
     void drawIndexed(u32 indexCount, u32 instanceCount, u32 firstIndex, i32 baseVertex, u32 firstInstance);
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -28,7 +28,9 @@
 #if ENABLE(WEBGPU)
 
 #include "GPURenderPipelineDescriptor.h"
+#include "WebGPUInputStateDescriptor.h"
 #include "WebGPUPipelineDescriptorBase.h"
+#include "WebGPUPipelineStageDescriptor.h"
 
 namespace WebCore {
 
@@ -35,7 +37,10 @@
 struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase {
     using PrimitiveTopology = GPURenderPipelineDescriptor::PrimitiveTopology;
 
+    WebGPUPipelineStageDescriptor vertexStage;
+    WebGPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
+    WebGPUInputStateDescriptor inputState;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl	2018-12-13 01:26:32 UTC (rev 239139)
@@ -36,11 +36,15 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] dictionary WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase {
+    WebGPUPipelineStageDescriptor vertexStage;
+    WebGPUPipelineStageDescriptor fragmentStage;
+
     WebGPUPrimitiveTopology primitiveTopology;
-    /* To Be Implemented:
-    sequence<WebGPUBlendState> blendStates;
-    WebGPUDepthStencilState depthStencilState;
-    WebGPUInputState inputState;
-    WebGPUAttachmentsState attachmentsState; */
+    WebGPUInputStateDescriptor inputState;
+/* To Be Implemented:
+    sequence<WebGPUBlendStateDescriptor> blendStates;
+    WebGPUDepthStencilStateDescriptor depthStencilState;
+    WebGPUAttachmentsStateDescriptor attachmentsState;
     // TODO other properties
+*/
 };

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h (239138 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -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 <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGPUShaderStage : public RefCounted<WebGPUShaderStage> {
-public:
-    static const unsigned long VERTEX = 0;
-    static const unsigned long FRAGMENT = 1;
-    static const unsigned long COMPUTE = 2;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)

Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl (239138 => 239139)


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

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,39 @@
+/*
+ * 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 "GPUVertexAttributeDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUVertexAttributeDescriptor = GPUVertexAttributeDescriptor;
+using WebGPUVertexFormatEnum = GPUVertexFormatEnum;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexAttributeDescriptor.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.idl) (0 => 239139)


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

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include "GPUVertexAttributeDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUVertexFormat = GPUVertexFormat;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.idl) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUVertexFormat.idl	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+typedef unsigned long u32;
+
+[
+    Conditional=WEBGPU,
+    DoNotCheckConstants,
+    EnabledAtRuntime=WebGPU,
+    ImplementationLacksVTable
+] interface WebGPUVertexFormat {
+    const u32 FLOAT_R32_G32_B32_A32 = 0;
+    const u32 FLOAT_R32_G32_B32 = 1;
+    const u32 FLOAT_R32_G32 = 2;
+    const u32 FLOAT_R32 = 3;
+    // TODO other vertex formats
+};

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUBufferDescriptor.h) (0 => 239139)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,39 @@
+/*
+ * 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 "GPUVertexInputDescriptor.h"
+
+namespace WebCore {
+
+using WebGPUInputStepModeEnum = GPUInputStepModeEnum;
+using WebGPUVertexInputDescriptor = GPUVertexInputDescriptor;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUVertexInputDescriptor.idl (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl) (0 => 239139)


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

Modified: trunk/Source/WebCore/Sources.txt (239138 => 239139)


--- trunk/Source/WebCore/Sources.txt	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/Sources.txt	2018-12-13 01:26:32 UTC (rev 239139)
@@ -3228,6 +3228,9 @@
 JSWebGPUCommandBuffer.cpp
 JSWebGPUColor.cpp
 JSWebGPUDevice.cpp
+JSWebGPUIndexFormat.cpp
+JSWebGPUInputStateDescriptor.cpp
+JSWebGPUInputStepMode.cpp
 JSWebGPUQueue.cpp
 JSWebGPUPipelineDescriptorBase.cpp
 JSWebGPUPipelineStageDescriptor.cpp
@@ -3240,11 +3243,13 @@
 JSWebGPURenderPipelineDescriptor.cpp
 JSWebGPUShaderModule.cpp
 JSWebGPUShaderModuleDescriptor.cpp
-JSWebGPUShaderStage.cpp
 JSWebGPUSwapChain.cpp
 JSWebGPUTexture.cpp
 JSWebGPUTextureFormatEnum.cpp
 JSWebGPUTextureView.cpp
+JSWebGPUVertexAttributeDescriptor.cpp
+JSWebGPUVertexFormat.cpp
+JSWebGPUVertexInputDescriptor.cpp
 JSWebMetalBuffer.cpp
 JSWebMetalCommandBuffer.cpp
 JSWebMetalCommandQueue.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239138 => 239139)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-13 01:26:32 UTC (rev 239139)
@@ -13798,8 +13798,14 @@
 		D0615FCC217FE5C6008A48A8 /* WebGPUShaderModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUShaderModule.h; sourceTree = "<group>"; };
 		D0615FCD217FE5C6008A48A8 /* WebGPUShaderModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUShaderModule.cpp; sourceTree = "<group>"; };
 		D0615FCE217FE5C6008A48A8 /* WebGPUShaderModule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUShaderModule.idl; sourceTree = "<group>"; };
-		D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBufferUsage.idl; sourceTree = "<group>"; };
-		D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBufferUsage.h; sourceTree = "<group>"; };
+		D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBufferUsage.h; sourceTree = "<group>"; };
+		D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBufferUsage.idl; sourceTree = "<group>"; };
+		D063AE4421C0617D000E6A35 /* WebGPUVertexFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexFormat.h; sourceTree = "<group>"; };
+		D063AE4521C0617D000E6A35 /* WebGPUVertexFormat.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexFormat.idl; sourceTree = "<group>"; };
+		D063AE4621C06626000E6A35 /* WebGPUInputStepMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUInputStepMode.h; sourceTree = "<group>"; };
+		D063AE4721C06626000E6A35 /* WebGPUInputStepMode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUInputStepMode.idl; sourceTree = "<group>"; };
+		D063AE4821C066DB000E6A35 /* WebGPUIndexFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUIndexFormat.h; sourceTree = "<group>"; };
+		D063AE4921C066DB000E6A35 /* WebGPUIndexFormat.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUIndexFormat.idl; sourceTree = "<group>"; };
 		D06C0D8D0CFD11460065F43F /* RemoveFormatCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoveFormatCommand.h; sourceTree = "<group>"; };
 		D06C0D8E0CFD11460065F43F /* RemoveFormatCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveFormatCommand.cpp; sourceTree = "<group>"; };
 		D07DEAB70A36554A00CA30F8 /* InsertListCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InsertListCommand.cpp; sourceTree = "<group>"; };
@@ -13830,8 +13836,6 @@
 		D0BD4F5B1408850F006839B6 /* DictationCommandIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictationCommandIOS.h; sourceTree = "<group>"; };
 		D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUPipelineStageDescriptor.h; sourceTree = "<group>"; };
 		D0C419EC2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUPipelineStageDescriptor.idl; sourceTree = "<group>"; };
-		D0C419EE2183D9C8009EC1DE /* WebGPUShaderStage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUShaderStage.h; sourceTree = "<group>"; };
-		D0C419EF2183D9C8009EC1DE /* WebGPUShaderStage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUShaderStage.idl; sourceTree = "<group>"; };
 		D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUPipelineDescriptorBase.h; sourceTree = "<group>"; };
 		D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUPipelineDescriptorBase.idl; sourceTree = "<group>"; };
 		D0C419F22183EFEC009EC1DE /* WebGPURenderPipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPipelineDescriptor.h; sourceTree = "<group>"; };
@@ -13853,6 +13857,15 @@
 		D0D8648E21B70676003C983C /* WebGPUBuffer.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBuffer.idl; sourceTree = "<group>"; };
 		D0D8649121B760C4003C983C /* GPUBufferMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBufferMetal.mm; sourceTree = "<group>"; };
 		D0D8649221B760F2003C983C /* GPUBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; };
+		D0D8649321BA173D003C983C /* WebGPUInputStateDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUInputStateDescriptor.h; sourceTree = "<group>"; };
+		D0D8649421BA173D003C983C /* WebGPUInputStateDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUInputStateDescriptor.idl; sourceTree = "<group>"; };
+		D0D8649521BA18F4003C983C /* WebGPUVertexAttributeDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexAttributeDescriptor.h; sourceTree = "<group>"; };
+		D0D8649621BA18F4003C983C /* WebGPUVertexAttributeDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexAttributeDescriptor.idl; sourceTree = "<group>"; };
+		D0D8649721BA19A7003C983C /* WebGPUVertexInputDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUVertexInputDescriptor.h; sourceTree = "<group>"; };
+		D0D8649821BA19A7003C983C /* WebGPUVertexInputDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUVertexInputDescriptor.idl; sourceTree = "<group>"; };
+		D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUInputStateDescriptor.h; sourceTree = "<group>"; };
+		D0D8649B21BA1C2D003C983C /* GPUVertexAttributeDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUVertexAttributeDescriptor.h; sourceTree = "<group>"; };
+		D0D8649C21BA1CE8003C983C /* GPUVertexInputDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUVertexInputDescriptor.h; sourceTree = "<group>"; };
 		D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSwapChain.h; sourceTree = "<group>"; };
 		D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUSwapChain.cpp; sourceTree = "<group>"; };
 		D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSwapChain.idl; sourceTree = "<group>"; };
@@ -18024,6 +18037,7 @@
 				312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */,
 				312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */,
 				312FF8BE21A4C2F100EB199D /* GPUDevice.h */,
+				D0D8649921BA1B1F003C983C /* GPUInputStateDescriptor.h */,
 				312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */,
 				312FF8C221A4C2F300EB199D /* GPUPipelineStageDescriptor.h */,
 				D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */,
@@ -18038,6 +18052,8 @@
 				312FF8BA21A4C2EF00EB199D /* GPUSwapChain.h */,
 				312FF8C521A4C2F400EB199D /* GPUTexture.h */,
 				312FF8C321A4C2F300EB199D /* GPUTextureFormatEnum.h */,
+				D0D8649B21BA1C2D003C983C /* GPUVertexAttributeDescriptor.h */,
+				D0D8649C21BA1CE8003C983C /* GPUVertexInputDescriptor.h */,
 				498770D71242C535002226BA /* Texture.cpp */,
 				498770D81242C535002226BA /* Texture.h */,
 				498770D91242C535002226BA /* TilingData.cpp */,
@@ -25515,6 +25531,10 @@
 				D0D8648E21B70676003C983C /* WebGPUBuffer.idl */,
 				D0D8648221B61727003C983C /* WebGPUBufferDescriptor.h */,
 				D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */,
+				D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */,
+				D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */,
+				D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */,
+				D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */,
 				D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */,
 				D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */,
 				D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */,
@@ -25523,6 +25543,12 @@
 				D00F595321701D8C000D71DB /* WebGPUDevice.cpp */,
 				D00F595221701D8C000D71DB /* WebGPUDevice.h */,
 				D00F595421701D8C000D71DB /* WebGPUDevice.idl */,
+				D063AE4821C066DB000E6A35 /* WebGPUIndexFormat.h */,
+				D063AE4921C066DB000E6A35 /* WebGPUIndexFormat.idl */,
+				D0D8649321BA173D003C983C /* WebGPUInputStateDescriptor.h */,
+				D0D8649421BA173D003C983C /* WebGPUInputStateDescriptor.idl */,
+				D063AE4621C06626000E6A35 /* WebGPUInputStepMode.h */,
+				D063AE4721C06626000E6A35 /* WebGPUInputStepMode.idl */,
 				D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */,
 				D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */,
 				D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */,
@@ -25553,8 +25579,6 @@
 				D0615FCE217FE5C6008A48A8 /* WebGPUShaderModule.idl */,
 				D060D8872182697000339318 /* WebGPUShaderModuleDescriptor.h */,
 				D060D88421825D5F00339318 /* WebGPUShaderModuleDescriptor.idl */,
-				D0C419EE2183D9C8009EC1DE /* WebGPUShaderStage.h */,
-				D0C419EF2183D9C8009EC1DE /* WebGPUShaderStage.idl */,
 				D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */,
 				D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */,
 				D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */,
@@ -25566,8 +25590,12 @@
 				D0EACF882193EE4E000FA75C /* WebGPUTextureView.cpp */,
 				D0EACF872193EE4E000FA75C /* WebGPUTextureView.h */,
 				D0EACF892193EE4E000FA75C /* WebGPUTextureView.idl */,
-				D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */,
-				D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */,
+				D0D8649521BA18F4003C983C /* WebGPUVertexAttributeDescriptor.h */,
+				D0D8649621BA18F4003C983C /* WebGPUVertexAttributeDescriptor.idl */,
+				D063AE4421C0617D000E6A35 /* WebGPUVertexFormat.h */,
+				D063AE4521C0617D000E6A35 /* WebGPUVertexFormat.idl */,
+				D0D8649721BA19A7003C983C /* WebGPUVertexInputDescriptor.h */,
+				D0D8649821BA19A7003C983C /* WebGPUVertexInputDescriptor.idl */,
 			);
 			path = webgpu;
 			sourceTree = "<group>";

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (239138 => 239139)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -193,16 +193,18 @@
     macro(WebGPUBufferUsage) \
     macro(WebGPUCommandBuffer) \
     macro(WebGPUDevice) \
+    macro(WebGPUIndexFormat) \
+    macro(WebGPUInputStepMode) \
     macro(WebGPUQueue) \
     macro(WebGPUProgrammablePassEncoder) \
     macro(WebGPURenderingContext) \
     macro(WebGPURenderPassEncoder) \
     macro(WebGPURenderPipeline) \
-    macro(WebGPUShaderStage) \
     macro(WebGPUShaderModule) \
     macro(WebGPUSwapChain) \
     macro(WebGPUTexture) \
     macro(WebGPUTextureView) \
+    macro(WebGPUVertexFormat) \
     macro(WebMetalBuffer) \
     macro(WebMetalCommandBuffer) \
     macro(WebMetalCommandQueue) \

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h) (0 => 239139)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,57 @@
+/*
+ * 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 "GPUVertexAttributeDescriptor.h"
+#include "GPUVertexInputDescriptor.h"
+
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+using GPUIndexFormatEnum = unsigned long;
+
+class GPUIndexFormat : public RefCounted<GPUIndexFormat> {
+public:
+    enum Enum : GPUIndexFormatEnum {
+        Uint16 = 0,
+        Uint32 = 1
+    };
+};
+
+struct GPUInputStateDescriptor {
+    GPUIndexFormatEnum indexFormat;
+
+    Vector<GPUVertexAttributeDescriptor> attributes;
+    Vector<GPUVertexInputDescriptor> inputs;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h (239138 => 239139)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -32,11 +32,13 @@
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
 
 OBJC_PROTOCOL(MTLRenderCommandEncoder);
 
 namespace WebCore {
 
+class GPUBuffer;
 class GPUCommandBuffer;
 class GPURenderPipeline;
 
@@ -51,6 +53,7 @@
 
     void setPipeline(Ref<GPURenderPipeline>&&) final;
 
+    void setVertexBuffers(unsigned long, Vector<Ref<const GPUBuffer>>&&, Vector<unsigned>&&);
     void draw(unsigned long, unsigned long, unsigned long, unsigned long);
 
 private:

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -27,6 +27,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "GPUInputStateDescriptor.h"
 #include "GPUPipelineDescriptorBase.h"
 #include "GPUPipelineStageDescriptor.h"
 
@@ -46,6 +47,7 @@
     GPUPipelineStageDescriptor vertexStage;
     GPUPipelineStageDescriptor fragmentStage;
     PrimitiveTopology primitiveTopology;
+    GPUInputStateDescriptor inputState;
 };
 
 } // namespace WebCore

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h) (0 => 239139)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,55 @@
+/*
+ * 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 <wtf/RefCounted.h>
+
+namespace WebCore {
+
+using GPUVertexFormatEnum = unsigned long;
+
+class GPUVertexFormat : public RefCounted<GPUVertexFormat> {
+public:
+    enum Enum : GPUVertexFormatEnum {
+        FloatR32G32B32A32 = 0,
+        FloatR32G32B32 = 1,
+        FloatR32G32 = 2,
+        FloatR32 = 3
+    };
+};
+
+struct GPUVertexAttributeDescriptor {
+    unsigned long shaderLocation;
+    unsigned long inputSlot;
+    unsigned long offset;
+    GPUVertexFormatEnum format;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h (from rev 239138, trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h) (0 => 239139)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h	2018-12-13 01:26:32 UTC (rev 239139)
@@ -0,0 +1,51 @@
+/*
+ * 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 <wtf/RefCounted.h>
+
+namespace WebCore {
+
+using GPUInputStepModeEnum = unsigned long;
+
+class GPUInputStepMode : public RefCounted<GPUInputStepMode> {
+public:
+    enum Enum : GPUInputStepModeEnum {
+        Vertex = 0,
+        Instance = 1
+    };
+};
+
+struct GPUVertexInputDescriptor {
+    unsigned long stride;
+    GPUInputStepModeEnum stepMode;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

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


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm	2018-12-13 01:26:32 UTC (rev 239139)
@@ -28,6 +28,7 @@
 
 #if ENABLE(WEBGPU)
 
+#import "GPUBuffer.h"
 #import "GPUCommandBuffer.h"
 #import "GPURenderPassDescriptor.h"
 #import "GPURenderPipeline.h"
@@ -83,6 +84,13 @@
     m_pipeline = WTFMove(pipeline);
 }
 
+void GPURenderPassEncoder::setVertexBuffers(unsigned long index, Vector<Ref<const GPUBuffer>>&& buffers, Vector<unsigned>&& offsets) 
+{
+    ASSERT(buffers.size() && offsets.size() == buffers.size());
+    // FIXME: Only worry about the first buffer for now, and treat startSlot as the index.
+    [m_platformRenderPassEncoder setVertexBuffer:buffers[0]->platformBuffer() offset:offsets[0] atIndex:index];
+}
+
 static MTLPrimitiveType primitiveTypeForGPUPrimitiveTopology(PrimitiveTopology type)
 {
     switch (type) {

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


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2018-12-13 01:23:04 UTC (rev 239138)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2018-12-13 01:26:32 UTC (rev 239139)
@@ -32,6 +32,7 @@
 
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
+#import <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -82,6 +83,84 @@
     return true;
 }
 
+static std::optional<MTLVertexFormat> validateAndConvertVertexFormatToMTLVertexFormat(GPUVertexFormatEnum format)
+{
+    switch (format) {
+    case GPUVertexFormat::FloatR32G32B32A32:
+        return MTLVertexFormatFloat4;
+    case GPUVertexFormat::FloatR32G32B32:
+        return MTLVertexFormatFloat3;
+    case GPUVertexFormat::FloatR32G32:
+        return MTLVertexFormatFloat2;
+    case GPUVertexFormat::FloatR32:
+        return MTLVertexFormatFloat;
+    default:
+        return std::nullopt;
+    }
+}
+
+static std::optional<MTLVertexStepFunction> validateAndConvertStepModeToMTLStepFunction(GPUInputStepModeEnum mode)
+{
+    switch (mode) {
+    case GPUInputStepMode::Vertex:
+        return MTLVertexStepFunctionPerVertex;
+    case GPUInputStepMode::Instance:
+        return MTLVertexStepFunctionPerInstance;
+    default:
+        return std::nullopt;
+    }
+}
+
+static bool setInputStateForPipelineDescriptor(const char* const functionName, MTLRenderPipelineDescriptor *mtlDescriptor, const GPURenderPipelineDescriptor& descriptor)
+{
+#if LOG_DISABLED
+    UNUSED_PARAM(functionName);
+#endif
+    auto mtlVertexDescriptor = adoptNS([MTLVertexDescriptor new]);
+
+    // Populate vertex attributes, if any.
+    const auto& attributes = descriptor.inputState.attributes;
+
+    // FIXME: What kind of validation is needed here?
+    MTLVertexAttributeDescriptorArray *attributeArray = mtlVertexDescriptor.get().attributes;
+
+    for (size_t i = 0; i < attributes.size(); ++i) {
+        auto mtlFormat = validateAndConvertVertexFormatToMTLVertexFormat(attributes[i].format);
+        if (!mtlFormat) {
+            LOG(WebGPU, "%s: Invalid WebGPUVertexFormatEnum for vertex attribute!", functionName);
+            return false;
+        }
+
+        MTLVertexAttributeDescriptor *mtlAttributeDesc = [attributeArray objectAtIndexedSubscript:i];
+        mtlAttributeDesc.format = *mtlFormat;
+        mtlAttributeDesc.offset = attributes[i].offset;
+        mtlAttributeDesc.bufferIndex = attributes[i].shaderLocation;
+        [mtlVertexDescriptor.get().attributes setObject:mtlAttributeDesc atIndexedSubscript:i];
+    }
+
+    // Populate vertex buffer layouts, if any.
+    const auto& inputs = descriptor.inputState.inputs;
+
+    MTLVertexBufferLayoutDescriptorArray *layoutArray = mtlVertexDescriptor.get().layouts;
+
+    for (size_t j = 0; j < inputs.size(); ++j) {
+        auto mtlStepFunction = validateAndConvertStepModeToMTLStepFunction(inputs[j].stepMode);
+        if (!mtlStepFunction) {
+            LOG(WebGPU, "%s: Invalid WebGPUInputStepMode for vertex input!", functionName);
+            return false;
+        }
+
+        MTLVertexBufferLayoutDescriptor *mtlLayoutDesc = [layoutArray objectAtIndexedSubscript:j];
+        mtlLayoutDesc.stepFunction = *mtlStepFunction;
+        mtlLayoutDesc.stride = inputs[j].stride;
+        [mtlVertexDescriptor.get().layouts setObject:mtlLayoutDesc atIndexedSubscript:j];
+    }
+
+    mtlDescriptor.vertexDescriptor = mtlVertexDescriptor.get();
+
+    return true;
+}
+
 RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPURenderPipelineDescriptor&& descriptor)
 {
     const char* const functionName = "GPURenderPipeline::create()";
@@ -104,7 +183,8 @@
         return nullptr;
     }
 
-    if (!setFunctionsForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor))
+    if (!setFunctionsForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor)
+        || !setInputStateForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor))
         return nullptr;
 
     // FIXME: Get the pixelFormat as configured for the context/CAMetalLayer.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to