Unreviewed, rolling out r249369.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Sep 2019 04:38:38 +0000 (04:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Sep 2019 04:38:38 +0000 (04:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201394

broke WHLSL tests (Requested by litherum on #webkit).

Reverted changeset:

"[WHLSL] Resources don't work when only a subset of a bind
group is referenced by a shader"
https://bugs.webkit.org/show_bug.cgi?id=201383
https://trac.webkit.org/changeset/249369

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl/compute.html
LayoutTests/webgpu/whlsl/sparse-bind-group-2-expected.txt [deleted file]
LayoutTests/webgpu/whlsl/sparse-bind-group-2.html [deleted file]
LayoutTests/webgpu/whlsl/sparse-bind-group-3-expected.txt [deleted file]
LayoutTests/webgpu/whlsl/sparse-bind-group-3.html [deleted file]
LayoutTests/webgpu/whlsl/sparse-bind-group-expected.txt [deleted file]
LayoutTests/webgpu/whlsl/sparse-bind-group.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp
Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp
Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm

index ae743c9..13a489d 100644 (file)
@@ -1,3 +1,17 @@
+2019-09-01  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r249369.
+        https://bugs.webkit.org/show_bug.cgi?id=201394
+
+        broke WHLSL tests (Requested by litherum on #webkit).
+
+        Reverted changeset:
+
+        "[WHLSL] Resources don't work when only a subset of a bind
+        group is referenced by a shader"
+        https://bugs.webkit.org/show_bug.cgi?id=201383
+        https://trac.webkit.org/changeset/249369
+
 2019-09-01  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [WHLSL] Resources don't work when only a subset of a bind group is referenced by a shader
index 1cee6e6..1f632e6 100644 (file)
@@ -74,7 +74,6 @@ async function start(device) {
         testFailed("");
     resultsBuffer.unmap();
 }
-
 window.jsTestIsAsync = true;
 getBasicDevice().then(function(device) {
     start(device).then(function() {
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group-2-expected.txt b/LayoutTests/webgpu/whlsl/sparse-bind-group-2-expected.txt
deleted file mode 100644 (file)
index 4882f90..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-PASS 
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group-2.html b/LayoutTests/webgpu/whlsl/sparse-bind-group-2.html
deleted file mode 100644 (file)
index 443a399..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="../js/webgpu-functions.js"></script>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<script>
-const shaderSource = `
-[numthreads(1, 1, 1)]
-compute void computeShader(device float[] buffer : register(u1)) {
-    buffer[0] = 17;
-}
-`;
-
-async function start(device) {
-    device.pushErrorScope("validation");
-    const shaderModule = device.createShaderModule({code: shaderSource});
-    const computeStage = {module: shaderModule, entryPoint: "computeShader"};
-
-    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}, {binding: 1, visibility: 7, type: "storage-buffer"}]};
-    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
-    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
-    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
-
-    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
-    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
-    device.popErrorScope().then(function(e) {
-        alert(e.message);
-    });
-
-    const size = Float32Array.BYTES_PER_ELEMENT * 1;
-
-    const buffer1 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-    const buffer2 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-
-    const bindGroup = device.createBindGroup({layout: bindGroupLayout, bindings: [{binding: 0, resource: {buffer: buffer1, size}}, {binding: 1, resource: {buffer: buffer2, size}}]});
-
-    const commandEncoder = device.createCommandEncoder(); // {}
-    const computePassEncoder = commandEncoder.beginComputePass();
-    computePassEncoder.setPipeline(computePipeline);
-    computePassEncoder.setBindGroup(0, bindGroup);
-    computePassEncoder.dispatch(1, 1, 1);
-    computePassEncoder.endPass();
-    const commandBuffer = commandEncoder.finish();
-    device.getQueue().submit([commandBuffer]);
-
-    const resultsArrayBuffer = await buffer2.mapReadAsync();
-    const resultsFloat32Array = new Float32Array(resultsArrayBuffer);
-    if (resultsFloat32Array[0] == 17)
-        testPassed("");
-    else
-        testFailed("");
-    buffer2.unmap();
-}
-
-window.jsTestIsAsync = true;
-getBasicDevice().then(function(device) {
-    start(device).then(function() {
-        finishJSTest();
-    }, function() {
-        testFailed("");
-        finishJSTest();
-    });
-}, function() {
-    testPassed("");
-    finishJSTest();
-});
-</script>
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group-3-expected.txt b/LayoutTests/webgpu/whlsl/sparse-bind-group-3-expected.txt
deleted file mode 100644 (file)
index 4882f90..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-PASS 
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group-3.html b/LayoutTests/webgpu/whlsl/sparse-bind-group-3.html
deleted file mode 100644 (file)
index cffd181..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="../js/webgpu-functions.js"></script>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<script>
-const shaderSource = `
-[numthreads(1, 1, 1)]
-compute void computeShader(device float[] buffer : register(u1)) {
-    buffer[0] = 17;
-}
-`;
-
-async function start(device) {
-    device.pushErrorScope("validation");
-    const shaderModule = device.createShaderModule({code: shaderSource});
-    const computeStage = {module: shaderModule, entryPoint: "computeShader"};
-
-    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 0, type: "storage-buffer"}, {binding: 1, visibility: 7, type: "storage-buffer"}]};
-    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
-    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
-    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
-
-    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
-    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
-    device.popErrorScope().then(function(e) {
-        alert(e.message);
-    });
-
-    const size = Float32Array.BYTES_PER_ELEMENT * 1;
-
-    const buffer1 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-    const buffer2 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-
-    const bindGroup = device.createBindGroup({layout: bindGroupLayout, bindings: [{binding: 0, resource: {buffer: buffer1, size}}, {binding: 1, resource: {buffer: buffer2, size}}]});
-
-    const commandEncoder = device.createCommandEncoder(); // {}
-    const computePassEncoder = commandEncoder.beginComputePass();
-    computePassEncoder.setPipeline(computePipeline);
-    computePassEncoder.setBindGroup(0, bindGroup);
-    computePassEncoder.dispatch(1, 1, 1);
-    computePassEncoder.endPass();
-    const commandBuffer = commandEncoder.finish();
-    device.getQueue().submit([commandBuffer]);
-
-    const resultsArrayBuffer = await buffer2.mapReadAsync();
-    const resultsFloat32Array = new Float32Array(resultsArrayBuffer);
-    if (resultsFloat32Array[0] == 17)
-        testPassed("");
-    else
-        testFailed("");
-    buffer2.unmap();
-}
-
-window.jsTestIsAsync = true;
-getBasicDevice().then(function(device) {
-    start(device).then(function() {
-        finishJSTest();
-    }, function() {
-        testFailed("");
-        finishJSTest();
-    });
-}, function() {
-    testPassed("");
-    finishJSTest();
-});
-</script>
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group-expected.txt b/LayoutTests/webgpu/whlsl/sparse-bind-group-expected.txt
deleted file mode 100644 (file)
index 4882f90..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-PASS 
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/webgpu/whlsl/sparse-bind-group.html b/LayoutTests/webgpu/whlsl/sparse-bind-group.html
deleted file mode 100644 (file)
index a938224..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="../js/webgpu-functions.js"></script>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<script>
-const shaderSource = `
-[numthreads(1, 1, 1)]
-compute void computeShader(device float[] buffer : register(u0, space1)) {
-    buffer[0] = 17;
-}
-`;
-
-async function start(device) {
-    const shaderModule = device.createShaderModule({code: shaderSource});
-    const computeStage = {module: shaderModule, entryPoint: "computeShader"};
-
-    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]};
-    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
-    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout, bindGroupLayout]};
-    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
-
-    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
-    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
-
-    const size = Float32Array.BYTES_PER_ELEMENT * 1;
-
-    const buffer1 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-    const buffer2 = device.createBuffer({size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ});
-
-    const bindGroup1 = device.createBindGroup({layout: bindGroupLayout, bindings: [{binding: 0, resource: {buffer: buffer1, size}}]});
-    const bindGroup2 = device.createBindGroup({layout: bindGroupLayout, bindings: [{binding: 0, resource: {buffer: buffer2, size}}]});
-
-    const commandEncoder = device.createCommandEncoder(); // {}
-    const computePassEncoder = commandEncoder.beginComputePass();
-    computePassEncoder.setPipeline(computePipeline);
-    computePassEncoder.setBindGroup(0, bindGroup1);
-    computePassEncoder.setBindGroup(1, bindGroup2);
-    computePassEncoder.dispatch(1, 1, 1);
-    computePassEncoder.endPass();
-    const commandBuffer = commandEncoder.finish();
-    device.getQueue().submit([commandBuffer]);
-
-    const resultsArrayBuffer = await buffer2.mapReadAsync();
-    const resultsFloat32Array = new Float32Array(resultsArrayBuffer);
-    if (resultsFloat32Array[0] == 17)
-        testPassed("");
-    else
-        testFailed("");
-    buffer2.unmap();
-}
-
-window.jsTestIsAsync = true;
-getBasicDevice().then(function(device) {
-    start(device).then(function() {
-        finishJSTest();
-    }, function() {
-        testFailed("");
-        finishJSTest();
-    });
-}, function() {
-    testPassed("");
-    finishJSTest();
-});
-</script>
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
index e689ce5..2bb4896 100644 (file)
@@ -1,3 +1,17 @@
+2019-09-01  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r249369.
+        https://bugs.webkit.org/show_bug.cgi?id=201394
+
+        broke WHLSL tests (Requested by litherum on #webkit).
+
+        Reverted changeset:
+
+        "[WHLSL] Resources don't work when only a subset of a bind
+        group is referenced by a shader"
+        https://bugs.webkit.org/show_bug.cgi?id=201383
+        https://trac.webkit.org/changeset/249369
+
 2019-09-01  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Unreviewed, rolling out r249366.
index 3288618..7e75937 100644 (file)
@@ -139,7 +139,7 @@ EntryPointScaffolding::EntryPointScaffolding(AST::FunctionDefinition& functionDe
         m_parameterVariables.uncheckedAppend(m_generateNextVariableName());
 }
 
-void EntryPointScaffolding::emitResourceHelperTypes(StringBuilder& stringBuilder, Indentation<4> indent, ShaderStage shaderStage)
+void EntryPointScaffolding::emitResourceHelperTypes(StringBuilder& stringBuilder, Indentation<4> indent)
 {
     for (size_t i = 0; i < m_layout.size(); ++i) {
         stringBuilder.append(indent, "struct ", m_namedBindGroups[i].structName, " {\n");
@@ -147,43 +147,25 @@ void EntryPointScaffolding::emitResourceHelperTypes(StringBuilder& stringBuilder
             IndentationScope scope(indent);
             Vector<std::pair<unsigned, String>> structItems;
             for (size_t j = 0; j < m_layout[i].bindings.size(); ++j) {
-                auto& binding = m_layout[i].bindings[j];
-                if (!binding.visibility.contains(shaderStage))
-                    continue;
-
-                auto elementName = m_namedBindGroups[i].namedBindings[j].elementName;
-                auto index = m_namedBindGroups[i].namedBindings[j].index;
-                if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation)
-                    structItems.append(std::make_pair(lengthInformation->index, makeString("uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];")));
-
                 auto iterator = m_resourceMap.find(&m_layout[i].bindings[j]);
-                if (iterator != m_resourceMap.end()) {
-                    auto& type = m_entryPointItems.inputs[iterator->value].unnamedType->unifyNode();
-                    if (is<AST::UnnamedType>(type) && is<AST::ReferenceType>(downcast<AST::UnnamedType>(type))) {
-                        auto& referenceType = downcast<AST::ReferenceType>(downcast<AST::UnnamedType>(type));
-                        auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType());
-                        auto addressSpace = toString(referenceType.addressSpace());
-                        structItems.append(std::make_pair(index, makeString(addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];")));
-                    } else if (is<AST::NamedType>(type) && is<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type))) {
-                        auto& namedType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type));
-                        auto mangledTypeName = m_typeNamer.mangledNameForType(namedType);
-                        structItems.append(std::make_pair(index, makeString(mangledTypeName, ' ', elementName, " [[id(", index, ")]];")));
-                    }
-                } else {
-                    // The binding doesn't appear in the shader source.
-                    // However, we must still emit a placeholder, so successive items in the argument buffer struct have the correct offset.
-                    // Because the binding doesn't appear in the shader source, we don't know which exact type the bind point should have.
-                    // Therefore, we must synthesize a type out of thin air.
-                    WTF::visit(WTF::makeVisitor([&](UniformBufferBinding) {
-                        structItems.append(std::make_pair(index, makeString("constant void* ", elementName, " [[id(", index, ")]];")));
-                    }, [&](SamplerBinding) {
-                        structItems.append(std::make_pair(index, makeString("sampler ", elementName, " [[id(", index, ")]];")));
-                    }, [&](TextureBinding) {
-                        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=201384 We don't know which texture type the binding represents. This is no good very bad.
-                        structItems.append(std::make_pair(index, makeString("texture2d<float4> ", elementName, " [[id(", index, ")]];")));
-                    }, [&](StorageBufferBinding) {
-                        structItems.append(std::make_pair(index, makeString("device void* ", elementName, " [[id(", index, ")]];")));
-                    }), binding.binding);
+                if (iterator == m_resourceMap.end())
+                    continue;
+                auto& type = m_entryPointItems.inputs[iterator->value].unnamedType->unifyNode();
+                if (is<AST::UnnamedType>(type) && is<AST::ReferenceType>(downcast<AST::UnnamedType>(type))) {
+                    auto& referenceType = downcast<AST::ReferenceType>(downcast<AST::UnnamedType>(type));
+                    auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType());
+                    auto addressSpace = toString(referenceType.addressSpace());
+                    auto elementName = m_namedBindGroups[i].namedBindings[j].elementName;
+                    auto index = m_namedBindGroups[i].namedBindings[j].index;
+                    structItems.append(std::make_pair(index, makeString(addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];")));
+                    if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation)
+                        structItems.append(std::make_pair(lengthInformation->index, makeString("uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];")));
+                } else if (is<AST::NamedType>(type) && is<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type))) {
+                    auto& namedType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type));
+                    auto mangledTypeName = m_typeNamer.mangledNameForType(namedType);
+                    auto elementName = m_namedBindGroups[i].namedBindings[j].elementName;
+                    auto index = m_namedBindGroups[i].namedBindings[j].index;
+                    structItems.append(std::make_pair(index, makeString(mangledTypeName, ' ', elementName, " [[id(", index, ")]];")));
                 }
             }
             std::sort(structItems.begin(), structItems.end(), [](const std::pair<unsigned, String>& left, const std::pair<unsigned, String>& right) {
@@ -443,7 +425,7 @@ void VertexEntryPointScaffolding::emitHelperTypes(StringBuilder& stringBuilder,
     }
     stringBuilder.append(indent, "};\n\n");
     
-    emitResourceHelperTypes(stringBuilder, indent, ShaderStage::Vertex);
+    emitResourceHelperTypes(stringBuilder, indent);
 }
 
 void VertexEntryPointScaffolding::emitSignature(StringBuilder& stringBuilder, MangledFunctionName functionName, Indentation<4> indent)
@@ -548,7 +530,7 @@ void FragmentEntryPointScaffolding::emitHelperTypes(StringBuilder& stringBuilder
     }
     stringBuilder.append(indent, "};\n\n");
 
-    emitResourceHelperTypes(stringBuilder, indent, ShaderStage::Fragment);
+    emitResourceHelperTypes(stringBuilder, indent);
 }
 
 void FragmentEntryPointScaffolding::emitSignature(StringBuilder& stringBuilder, MangledFunctionName functionName, Indentation<4> indent)
@@ -598,7 +580,7 @@ ComputeEntryPointScaffolding::ComputeEntryPointScaffolding(AST::FunctionDefiniti
 
 void ComputeEntryPointScaffolding::emitHelperTypes(StringBuilder& stringBuilder, Indentation<4> indent)
 {
-    emitResourceHelperTypes(stringBuilder, indent, ShaderStage::Compute);
+    emitResourceHelperTypes(stringBuilder, indent);
 }
 
 void ComputeEntryPointScaffolding::emitSignature(StringBuilder& stringBuilder, MangledFunctionName functionName, Indentation<4> indent)
index e5b4c6d..48a8c5b 100644 (file)
@@ -64,7 +64,7 @@ public:
 protected:
     EntryPointScaffolding(AST::FunctionDefinition&, Intrinsics&, TypeNamer&, EntryPointItems&, HashMap<Binding*, size_t>& resourceMap, Layout&, std::function<MangledVariableName()>&& generateNextVariableName);
 
-    void emitResourceHelperTypes(StringBuilder&, Indentation<4>, ShaderStage);
+    void emitResourceHelperTypes(StringBuilder&, Indentation<4>);
 
     enum class IncludePrecedingComma {
         Yes,
index 542fa78..2cc7d7d 100644 (file)
@@ -61,7 +61,9 @@ static bool matchMode(Binding::BindingDetails bindingType, AST::ResourceSemantic
 static Optional<HashMap<Binding*, size_t>> matchResources(Vector<EntryPointItem>& entryPointItems, Layout& layout, ShaderStage shaderStage)
 {
     HashMap<Binding*, size_t> result;
-    HashSet<size_t, DefaultHash<size_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<size_t>> itemIndices;
+    HashSet<size_t> itemIndices;
+    if (entryPointItems.size() == std::numeric_limits<size_t>::max())
+        return WTF::nullopt; // Work around the fact that HashSet's keys are restricted.
     for (auto& bindGroup : layout) {
         auto space = bindGroup.name;
         for (auto& binding : bindGroup.bindings) {
@@ -80,7 +82,7 @@ static Optional<HashMap<Binding*, size_t>> matchResources(Vector<EntryPointItem>
                 if (space != resourceSemantic.space())
                     continue;
                 result.add(&binding, i);
-                itemIndices.add(i);
+                itemIndices.add(i + 1); // Work around the fact that HashSet's keys are restricted.
             }
         }
     }
@@ -90,7 +92,7 @@ static Optional<HashMap<Binding*, size_t>> matchResources(Vector<EntryPointItem>
         auto& semantic = *item.semantic;
         if (!WTF::holds_alternative<AST::ResourceSemantic>(semantic))
             continue;
-        if (!itemIndices.contains(i))
+        if (!itemIndices.contains(i + 1))
             return WTF::nullopt;
     }
 
@@ -140,7 +142,9 @@ static bool isAcceptableFormat(VertexFormat vertexFormat, AST::UnnamedType& unna
 static Optional<HashMap<VertexAttribute*, size_t>> matchVertexAttributes(Vector<EntryPointItem>& vertexInputs, VertexAttributes& vertexAttributes, Intrinsics& intrinsics)
 {
     HashMap<VertexAttribute*, size_t> result;
-    HashSet<size_t, DefaultHash<size_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<size_t>> itemIndices;
+    HashSet<size_t> itemIndices;
+    if (vertexInputs.size() == std::numeric_limits<size_t>::max())
+        return WTF::nullopt; // Work around the fact that HashSet's keys are restricted.
     for (auto& vertexAttribute : vertexAttributes) {
         for (size_t i = 0; i < vertexInputs.size(); ++i) {
             auto& item = vertexInputs[i];
@@ -153,7 +157,7 @@ static Optional<HashMap<VertexAttribute*, size_t>> matchVertexAttributes(Vector<
             if (!isAcceptableFormat(vertexAttribute.vertexFormat, *item.unnamedType, intrinsics))
                 return WTF::nullopt;
             result.add(&vertexAttribute, i);
-            itemIndices.add(i);
+            itemIndices.add(i + 1); // Work around the fact that HashSet's keys are restricted.
         }
     }
 
@@ -162,7 +166,7 @@ static Optional<HashMap<VertexAttribute*, size_t>> matchVertexAttributes(Vector<
         auto& semantic = *item.semantic;
         if (!WTF::holds_alternative<AST::StageInOutSemantic>(semantic))
             continue;
-        if (!itemIndices.contains(i))
+        if (!itemIndices.contains(i + 1))
             return WTF::nullopt;
     }
 
@@ -226,7 +230,9 @@ static bool isAcceptableFormat(TextureFormat textureFormat, AST::UnnamedType& un
 static Optional<HashMap<AttachmentDescriptor*, size_t>> matchColorAttachments(Vector<EntryPointItem>& fragmentOutputs, Vector<AttachmentDescriptor>& attachmentDescriptors, Intrinsics& intrinsics)
 {
     HashMap<AttachmentDescriptor*, size_t> result;
-    HashSet<size_t, DefaultHash<size_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<size_t>> itemIndices;
+    HashSet<size_t> itemIndices;
+    if (attachmentDescriptors.size() == std::numeric_limits<size_t>::max())
+        return WTF::nullopt; // Work around the fact that HashSet's keys are restricted.
     for (auto& attachmentDescriptor : attachmentDescriptors) {
         for (size_t i = 0; i < fragmentOutputs.size(); ++i) {
             auto& item = fragmentOutputs[i];
@@ -239,7 +245,7 @@ static Optional<HashMap<AttachmentDescriptor*, size_t>> matchColorAttachments(Ve
             if (!isAcceptableFormat(attachmentDescriptor.textureFormat, *item.unnamedType, intrinsics, true))
                 return WTF::nullopt;
             result.add(&attachmentDescriptor, i);
-            itemIndices.add(i);
+            itemIndices.add(i + 1); // Work around the fact that HashSet's keys are restricted.
         }
     }
 
@@ -248,7 +254,7 @@ static Optional<HashMap<AttachmentDescriptor*, size_t>> matchColorAttachments(Ve
         auto& semantic = *item.semantic;
         if (!WTF::holds_alternative<AST::StageInOutSemantic>(semantic))
             continue;
-        if (!itemIndices.contains(i))
+        if (!itemIndices.contains(i + 1))
             return WTF::nullopt;
     }
 
index a26badf..8020163 100644 (file)
@@ -84,7 +84,6 @@ static RetainPtr<MTLArgumentDescriptor> argumentDescriptor(MTLDataType dataType,
     mtlArgument = adoptNS([MTLArgumentDescriptor new]);
     END_BLOCK_OBJC_EXCEPTIONS;
 
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=201384 This needs to set the "textureType" field
     [mtlArgument setDataType:dataType];
     [mtlArgument setIndex:index];
     return mtlArgument;