<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[245759] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/245759">245759</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2019-05-24 16:38:18 -0700 (Fri, 24 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WHLSL] Allow vertex attributes to have arbitrary names in the shader
https://bugs.webkit.org/show_bug.cgi?id=198235

Reviewed by Dean Jackson and Justin Fan.

Source/WebCore:

Metal doesn't allow arbitrary vertex attribute IDs. If you try to create a vertex attribute > 16,
the Metal validation layer will assert. So, we need to have a mapping from whatever the WebGPU
API says the vertex attribute IDs should be to the internally-used vertex attribute IDs.

Test: webgpu/whlsl-arbitrary-vertex-attribute-locations.html

* Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:
(WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding):
* Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h:
* Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp:
(WebCore::WHLSL::matchVertexAttributes):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::convertRenderPipelineDescriptor):
(WebCore::trySetInputStateForPipelineDescriptor):

LayoutTests:

* webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html: Added.
* webgpu/whlsl-arbitrary-vertex-attribute-locations.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWHLSLMetalWHLSLEntryPointScaffoldingcpp">trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWHLSLWHLSLPipelineDescriptorh">trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWHLSLWHLSLSemanticMatchercpp">trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPURenderPipelineMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebgpuwhlslarbitraryvertexattributelocationsexpectedhtml">trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html</a></li>
<li><a href="#trunkLayoutTestswebgpuwhlslarbitraryvertexattributelocationshtml">trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/LayoutTests/ChangeLog 2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-05-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Allow vertex attributes to have arbitrary names in the shader
+        https://bugs.webkit.org/show_bug.cgi?id=198235
+
+        Reviewed by Dean Jackson and Justin Fan.
+
+        * webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html: Added.
+        * webgpu/whlsl-arbitrary-vertex-attribute-locations.html: Added.
+
</ins><span class="cx"> 2019-05-24  Shawn Roberts  <sroberts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         scrollingcoordinator/scrolling-tree/fixed-inside-frame.html is no longer flaky
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuwhlslarbitraryvertexattributelocationsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html (0 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html                                (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html   2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+async function start() {
+    const canvas = document.getElementById("canvas");
+    const context = canvas.getContext("2d");
+    context.fillStyle = "blue";
+    context.fillRect(0, 0, 400, 400);
+    context.fillStyle = "white";
+    context.fillRect(100, 100, 200, 200);
+}
+window.addEventListener("load", start);
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestswebgpuwhlslarbitraryvertexattributelocationshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations.html (0 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations.html                         (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-arbitrary-vertex-attribute-locations.html    2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -0,0 +1,124 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const shaderSource = `
+struct VertexOut {
+    float4 position : SV_Position;
+    float shade : attribute(0);
+}
+
+vertex VertexOut vertexShader(float4 position : attribute(173), float shade : attribute(498)) {
+    VertexOut result;
+    result.position = position;
+    result.shade = shade;
+    return result;
+}
+
+fragment float4 fragmentShader(float shade : attribute(0)) : SV_Target 0 {
+    return float4(shade, shade, shade, 1.0);
+}
+`;
+async function start() {
+    const adapter = await navigator.gpu.requestAdapter();
+    const device = await adapter.requestDevice();
+
+    const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true});
+    const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
+    const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
+    const primitiveTopology = "triangle-strip";
+    const rasterizationState = {frontFace: "cw", cullMode: "none"};
+    const alphaBlend = {};
+    const colorBlend = {};
+    const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
+    const depthStencilState = null;
+
+    const attribute0 = {shaderLocation: 173, inputSlot: 0, format: "float4", offset: 0};
+    const attribute1 = {shaderLocation: 498, inputSlot: 0, format: "float", offset: 16};
+    const attributes = [attribute0, attribute1];
+    const input0 = {inputSlot: 0, stride: 20 };
+    const inputs = [input0];
+    const inputState = {indexFormat: "uint32", attributes, inputs};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "uniform-buffer"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, inputState, sampleCount: 1, layout: pipelineLayout};
+    const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
+
+    const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 5 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
+    const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor);
+    const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync();
+    const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer);
+    vertexBuffer0Float32Array[0] = -0.5;
+    vertexBuffer0Float32Array[1] = -0.5;
+    vertexBuffer0Float32Array[2] = 1.0;
+    vertexBuffer0Float32Array[3] = 1.0;
+    vertexBuffer0Float32Array[4] = 1.0;
+
+    vertexBuffer0Float32Array[5] = -0.5;
+    vertexBuffer0Float32Array[6] = 0.5;
+    vertexBuffer0Float32Array[7] = 1.0;
+    vertexBuffer0Float32Array[8] = 1.0;
+    vertexBuffer0Float32Array[9] = 1.0;
+
+    vertexBuffer0Float32Array[10] = 0.5;
+    vertexBuffer0Float32Array[11] = -0.5;
+    vertexBuffer0Float32Array[12] = 1.0;
+    vertexBuffer0Float32Array[13] = 1.0;
+    vertexBuffer0Float32Array[14] = 1.0;
+
+    vertexBuffer0Float32Array[15] = 0.5;
+    vertexBuffer0Float32Array[16] = 0.5;
+    vertexBuffer0Float32Array[17] = 1.0;
+    vertexBuffer0Float32Array[18] = 1.0;
+    vertexBuffer0Float32Array[19] = 1.0;
+    vertexBuffer0.unmap();
+
+    const resourceBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.MAP_WRITE};
+    const resourceBuffer = device.createBuffer(resourceBufferDescriptor);
+    const resourceBufferArrayBuffer = await resourceBuffer.mapWriteAsync();
+    const resourceBufferFloat32Array = new Float32Array(resourceBufferArrayBuffer);
+    resourceBufferFloat32Array[0] = 1;
+    resourceBuffer.unmap();
+
+    const bufferBinding = {buffer: resourceBuffer, size: 4};
+    const bindGroupBinding = {binding: 0, resource: bufferBinding};
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const canvas = document.getElementById("canvas");
+    const context = canvas.getContext("gpu");
+    const swapChainDescriptor = {device, format: "bgra8unorm"};
+    const swapChain = context.configureSwapChain(swapChainDescriptor);
+    const outputTexture = swapChain.getCurrentTexture();
+    const outputTextureView = outputTexture.createDefaultView();
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+    const red = {r: 0, g: 0, b: 1, a: 1};
+    const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor: red}];
+    const depthStencilAttachment = null;
+    const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
+    const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
+    renderPassEncoder.setPipeline(renderPipeline);
+    renderPassEncoder.setBindGroup(0, bindGroup);
+    renderPassEncoder.setVertexBuffers(0, [vertexBuffer0], [0]);
+    renderPassEncoder.draw(4, 1, 0, 0);
+    renderPassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+if (window.testRunner)
+    testRunner.waitUntilDone();
+window.addEventListener("load", start);
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/Source/WebCore/ChangeLog      2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2019-05-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Allow vertex attributes to have arbitrary names in the shader
+        https://bugs.webkit.org/show_bug.cgi?id=198235
+
+        Reviewed by Dean Jackson and Justin Fan.
+
+        Metal doesn't allow arbitrary vertex attribute IDs. If you try to create a vertex attribute > 16,
+        the Metal validation layer will assert. So, we need to have a mapping from whatever the WebGPU
+        API says the vertex attribute IDs should be to the internally-used vertex attribute IDs.
+
+        Test: webgpu/whlsl-arbitrary-vertex-attribute-locations.html
+
+        * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:
+        (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding):
+        * Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h:
+        * Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp:
+        (WebCore::WHLSL::matchVertexAttributes):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::convertRenderPipelineDescriptor):
+        (WebCore::trySetInputStateForPipelineDescriptor):
+
</ins><span class="cx"> 2019-05-24  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Refactor how showLetterpressedGlyphsWithAdvances gets the graphics context.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWHLSLMetalWHLSLEntryPointScaffoldingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp   2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp      2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -283,7 +283,7 @@
</span><span class="cx">         NamedStageIn namedStageIn;
</span><span class="cx">         namedStageIn.indexInEntryPointItems = keyValuePair.value;
</span><span class="cx">         namedStageIn.elementName = m_typeNamer.generateNextStructureElementName();
</span><del>-        namedStageIn.attributeIndex = keyValuePair.key->name;
</del><ins>+        namedStageIn.attributeIndex = keyValuePair.key->metalLocation;
</ins><span class="cx">         m_namedStageIns.uncheckedAppend(WTFMove(namedStageIn));
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWHLSLWHLSLPipelineDescriptorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h      2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h 2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -44,7 +44,8 @@
</span><span class="cx"> 
</span><span class="cx"> struct VertexAttribute {
</span><span class="cx">     VertexFormat vertexFormat;
</span><del>-    unsigned name;
</del><ins>+    unsigned shaderLocation;
+    unsigned metalLocation;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> using VertexAttributes = Vector<VertexAttribute>;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWHLSLWHLSLSemanticMatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp       2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp  2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx">             if (!WTF::holds_alternative<AST::StageInOutSemantic>(semantic))
</span><span class="cx">                 continue;
</span><span class="cx">             auto& stageInOutSemantic = WTF::get<AST::StageInOutSemantic>(semantic);
</span><del>-            if (stageInOutSemantic.index() != vertexAttribute.name)
</del><ins>+            if (stageInOutSemantic.index() != vertexAttribute.shaderLocation)
</ins><span class="cx">                 continue;
</span><span class="cx">             if (!isAcceptableFormat(vertexAttribute.vertexFormat, *item.unnamedType, intrinsics))
</span><span class="cx">                 return WTF::nullopt;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPURenderPipelineMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (245758 => 245759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm       2019-05-24 23:17:22 UTC (rev 245758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm  2019-05-24 23:38:18 UTC (rev 245759)
</span><span class="lines">@@ -181,7 +181,7 @@
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i < descriptor.inputState.attributes.size(); ++i)
</span><del>-        whlslDescriptor.vertexAttributes.append({ convertVertexFormat(descriptor.inputState.attributes[i].format), static_cast<unsigned>(i) });
</del><ins>+        whlslDescriptor.vertexAttributes.append({ convertVertexFormat(descriptor.inputState.attributes[i].format), descriptor.inputState.attributes[i].shaderLocation, static_cast<unsigned>(i) });
</ins><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i < descriptor.colorStates.size(); ++i) {
</span><span class="cx">         if (auto format = convertTextureFormat(descriptor.colorStates[i].format))
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx">     auto attributeArray = retainPtr(mtlVertexDescriptor.get().attributes);
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i < attributes.size(); ++i) {
</span><del>-        auto location = attributes[i].shaderLocation;
</del><ins>+        auto location = static_cast<unsigned>(i);
</ins><span class="cx">         // Maximum number of vertex attributes to be supported by Web GPU.
</span><span class="cx">         if (location >= 16) {
</span><span class="cx">             LOG(WebGPU, "%s: Invalid shaderLocation %u for vertex attribute!", functionName, location);
</span></span></pre>
</div>
</div>

</body>
</html>