WebKit Bugzilla
Attachment 371723 Details for
Bug 198704
: [WHLSL] Hook up common texture functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
file.txt (text/plain), 71.92 KB, created by
Myles C. Maxfield
on 2019-06-09 23:26:55 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-06-09 23:26:55 PDT
Size:
71.92 KB
patch
obsolete
>commit 571e70cfe2f8e1182cb19eaa51869c291467731b >Author: Myles C. Maxfield <mmaxfield@apple.com> >Date: Sat Jun 8 17:00:13 2019 -0400 > > textures > >diff --git a/LayoutTests/webgpu/whlsl-textures.html b/LayoutTests/webgpu/whlsl-textures.html >new file mode 100644 >index 00000000000..2dffb00d41d >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures.html >@@ -0,0 +1,134 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+const shaderSource = ` >+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position { >+ return position; >+} >+ >+fragment float4 fragmentShader(Texture2D<float4> theTexture : register(t0), sampler theSampler : register(s1)) : SV_Target 0 { >+ return Sample(theTexture, theSampler, float2(0.5, 0.5)); >+} >+`; >+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: 0, format: "float4"}; >+ const input0 = {stride: 16, attributeSet: [attribute0]}; >+ const inputs = [input0]; >+ const vertexInput = {vertexBuffers: inputs}; >+ >+ const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "sampler"}]}; >+ const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); >+ const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; >+ const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor); >+ >+ const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout}; >+ const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor); >+ >+ const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 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; >+ vertexBuffer0Float32Array[4] = -0.5; >+ vertexBuffer0Float32Array[5] = 0.5; >+ vertexBuffer0Float32Array[6] = 1.0; >+ vertexBuffer0Float32Array[7] = 1; >+ vertexBuffer0Float32Array[8] = 0.5; >+ vertexBuffer0Float32Array[9] = -0.5; >+ vertexBuffer0Float32Array[10] = 1.0; >+ vertexBuffer0Float32Array[11] = 1; >+ vertexBuffer0Float32Array[12] = 0.5; >+ vertexBuffer0Float32Array[13] = 0.5; >+ vertexBuffer0Float32Array[14] = 1.0; >+ vertexBuffer0Float32Array[15] = 1; >+ vertexBuffer0.unmap(); >+ >+ const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE}; >+ const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor); >+ const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync(); >+ const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer); >+ textureDataBufferUint8Array[0] = 255; >+ textureDataBufferUint8Array[1] = 255; >+ textureDataBufferUint8Array[2] = 255; >+ textureDataBufferUint8Array[3] = 255; >+ textureDataBufferUint8Array[4] = 255; >+ textureDataBufferUint8Array[5] = 255; >+ textureDataBufferUint8Array[6] = 255; >+ textureDataBufferUint8Array[7] = 255; >+ textureDataBufferUint8Array[8] = 255; >+ textureDataBufferUint8Array[9] = 255; >+ textureDataBufferUint8Array[10] = 255; >+ textureDataBufferUint8Array[11] = 255; >+ textureDataBufferUint8Array[12] = 255; >+ textureDataBufferUint8Array[13] = 255; >+ textureDataBufferUint8Array[14] = 255; >+ textureDataBufferUint8Array[15] = 255; >+ textureDataBuffer.unmap(); >+ >+ const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST}; >+ const texture = device.createTexture(textureDescriptor); >+ const textureView = texture.createDefaultView(); >+ >+ const samplerDescriptor = {magFilter: "linear", minFilter: "linear"}; >+ const sampler = device.createSampler(samplerDescriptor); >+ >+ const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: sampler}]; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings}; >+ 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 bufferCopyView = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2}; >+ const textureCopyView = {texture: texture}; >+ const copySize = {width: 2, height: 2, depth: 1}; >+ commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, copySize); >+ >+ const clearColor = {r: 0, g: 0, b: 1, a: 1}; >+ const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}]; >+ 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> >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >index 8eeceb08b04..7656f62b55b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >@@ -88,14 +88,14 @@ public: > return WTF::get<IntegerLiteral>(m_variant); > } > >- template<typename T> void visit(T&& t) >+ template <typename Visitor> auto visit(const Visitor& visitor) -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) > { >- WTF::visit(WTFMove(t), m_variant); >+ return WTF::visit(visitor, m_variant); > } > >- template<typename T> void visit(T&& t) const >+ template <typename Visitor> auto visit(const Visitor& visitor) const -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) > { >- WTF::visit(WTFMove(t), m_variant); >+ return WTF::visit(visitor, m_variant); > } > > ConstantExpression clone() const >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >index 3ae6ed6475b..217562f08a3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >@@ -63,6 +63,8 @@ public: > bool isVector() const { return m_isVector; } > bool isMatrix() const { return m_isMatrix; } > bool isTexture() const { return m_isTexture; } >+ bool isTextureArray() const { return m_isTextureArray; } >+ bool isDepthTexture() const { return m_isDepthTexture; } > bool isSigned() const { return m_isSigned; } > const std::function<bool(int)>& canRepresentInteger() const { return m_canRepresentInteger; } > const std::function<bool(unsigned)>& canRepresentUnsignedInteger() const { return m_canRepresentUnsignedInteger; } >@@ -79,6 +81,8 @@ public: > void setIsVector() { m_isVector = true; } > void setIsMatrix() { m_isMatrix = true; } > void setIsTexture() { m_isTexture = true; } >+ void setIsTextureArray() { m_isTextureArray = true; } >+ void setIsDepthTexture() { m_isDepthTexture = true; } > void setIsSigned() { m_isSigned = true; } > void setCanRepresentInteger(std::function<bool(int)>&& canRepresent) { m_canRepresentInteger = WTFMove(canRepresent); } > void setCanRepresentUnsignedInteger(std::function<bool(unsigned)>&& canRepresent) { m_canRepresentUnsignedInteger = WTFMove(canRepresent); } >@@ -104,6 +108,8 @@ private: > bool m_isVector { false }; > bool m_isMatrix { false }; > bool m_isTexture { false }; >+ bool m_isTextureArray { false }; >+ bool m_isDepthTexture { false }; > bool m_isSigned { false }; > }; > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >index 3baa37fa54c..f9f7980aebe 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >@@ -147,16 +147,23 @@ String EntryPointScaffolding::resourceHelperTypes() > auto iterator = m_resourceMap.find(&m_layout[i].bindings[j]); > if (iterator == m_resourceMap.end()) > continue; >- auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; >- ASSERT(is<AST::ReferenceType>(unnamedType)); >- auto& referenceType = downcast<AST::ReferenceType>(unnamedType); >- 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; >- stringBuilder.append(makeString(" ", addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];\n")); >- if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) >- stringBuilder.append(makeString(" uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];\n")); >+ 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; >+ stringBuilder.append(makeString(" ", addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];\n")); >+ if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) >+ stringBuilder.append(makeString(" uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];\n")); >+ } 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; >+ stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, " [[id(", index, ")]];\n")); >+ } > } > stringBuilder.append("};\n\n"); > } >@@ -277,9 +284,7 @@ String EntryPointScaffolding::mangledOutputPath(Vector<String>& path) > > AST::StructureDefinition* structureDefinition = nullptr; > auto& unifyNode = m_functionDefinition.type().unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); > auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::StructureDefinition>(namedType)); > structureDefinition = &downcast<AST::StructureDefinition>(namedType); > for (auto& component : path) { > ASSERT(structureDefinition); >@@ -317,7 +322,6 @@ String EntryPointScaffolding::unpackResourcesAndNamedBuiltIns() > auto lengthTemporaryName = m_namedBindGroups[i].namedBindings[j].lengthInformation->temporaryName; > > auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; >- ASSERT(is<AST::ReferenceType>(unnamedType)); > auto& referenceType = downcast<AST::ReferenceType>(unnamedType); > auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >index 44d2b1e46f8..bf914c8a75a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >@@ -397,7 +397,6 @@ void FunctionDefinitionWriter::visit(AST::FloatLiteral& floatLiteral) > void FunctionDefinitionWriter::visit(AST::NullLiteral& nullLiteral) > { > auto& unifyNode = nullLiteral.resolvedType().unifyNode(); >- ASSERT(is<AST::UnnamedType>(unifyNode)); > auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); > bool isArrayReferenceType = is<AST::ArrayReferenceType>(unnamedType); > >@@ -622,23 +621,21 @@ void FunctionDefinitionWriter::visit(AST::VariableReference& variableReference) > > String FunctionDefinitionWriter::constantExpressionString(AST::ConstantExpression& constantExpression) > { >- String result; >- constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- result = makeString("", integerLiteral.value()); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- result = makeString("", unsignedIntegerLiteral.value()); >- }, [&](AST::FloatLiteral& floatLiteral) { >- result = makeString("", floatLiteral.value()); >- }, [&](AST::NullLiteral&) { >- result = "nullptr"_str; >- }, [&](AST::BooleanLiteral& booleanLiteral) { >- result = booleanLiteral.value() ? "true"_str : "false"_str; >- }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >+ return constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> String { >+ return makeString("", integerLiteral.value()); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> String { >+ return makeString("", unsignedIntegerLiteral.value()); >+ }, [&](AST::FloatLiteral& floatLiteral) -> String { >+ return makeString("", floatLiteral.value()); >+ }, [&](AST::NullLiteral&) -> String { >+ return "nullptr"_str; >+ }, [&](AST::BooleanLiteral& booleanLiteral) -> String { >+ return booleanLiteral.value() ? "true"_str : "false"_str; >+ }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> String { > ASSERT(enumerationMemberLiteral.enumerationDefinition()); > ASSERT(enumerationMemberLiteral.enumerationDefinition()); >- result = makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember())); >+ return makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember())); > })); >- return result; > } > > class RenderFunctionDefinitionWriter : public FunctionDefinitionWriter { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >index 69dffdfe5a5..296c491a67b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >@@ -81,6 +81,17 @@ static String atomicName(String input) > return "fetch_xor"_str; > } > >+static int vectorLength(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ int vectorLength = 1; >+ if (!nativeTypeDeclaration.typeArguments().isEmpty()) { >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); >+ ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1])); >+ vectorLength = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]).integerLiteral().value(); >+ } >+ return vectorLength; >+} >+ > String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclaration, String& outputFunctionName, Intrinsics& intrinsics, TypeNamer& typeNamer) > { > StringBuilder stringBuilder; >@@ -133,7 +144,6 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > ASSERT(nativeFunctionDeclaration.parameters().size() == 1); > auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); > auto& parameterType = nativeFunctionDeclaration.parameters()[0]->type()->unifyNode(); >- ASSERT(is<AST::UnnamedType>(parameterType)); > auto& unnamedParameterType = downcast<AST::UnnamedType>(parameterType); > if (is<AST::ArrayType>(unnamedParameterType)) { > auto& arrayParameterType = downcast<AST::ArrayType>(unnamedParameterType); >@@ -350,13 +360,11 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > if (nativeFunctionDeclaration.name().startsWith("Interlocked"_str)) { > if (nativeFunctionDeclaration.name() == "InterlockedCompareExchange") { > ASSERT(nativeFunctionDeclaration.parameters().size() == 4); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type())); > auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); > auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); > auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType()); > auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); > auto thirdArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[2]->type()); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type())); > auto& fourthArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type()); > auto fourthArgumentAddressSpace = fourthArgumentPointer.addressSpace(); > auto fourthArgumentPointee = typeNamer.mangledNameForType(fourthArgumentPointer.elementType()); >@@ -368,12 +376,10 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > } > > ASSERT(nativeFunctionDeclaration.parameters().size() == 3); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type())); > auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); > auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); > auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType()); > auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type())); > auto& thirdArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type()); > auto thirdArgumentAddressSpace = thirdArgumentPointer.addressSpace(); > auto thirdArgumentPointee = typeNamer.mangledNameForType(thirdArgumentPointer.elementType()); >@@ -385,8 +391,39 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > } > > if (nativeFunctionDeclaration.name() == "Sample") { >- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this >- notImplemented(); >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 3 || nativeFunctionDeclaration.parameters().size() == 4); >+ >+ auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); >+ auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode())); >+ auto locationVectorLength = vectorLength(locationType); >+ auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode())); >+ auto returnVectorLength = vectorLength(returnType); >+ >+ auto metalParameter1Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); >+ auto metalParameter2Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); >+ auto metalParameter3Name = typeNamer.mangledNameForType(locationType); >+ String metalParameter4Name; >+ if (nativeFunctionDeclaration.parameters().size() == 4) >+ metalParameter4Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[3]->type()); >+ auto metalReturnName = typeNamer.mangledNameForType(returnType); >+ stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " theSampler, ", metalParameter3Name, " location")); >+ if (!metalParameter4Name.isNull()) >+ stringBuilder.append(makeString(", ", metalParameter4Name, " offset")); >+ stringBuilder.append(") {\n"); >+ stringBuilder.append(" return theTexture.sample(theSampler, "); >+ if (textureType.isTextureArray()) { >+ ASSERT(locationVectorLength > 1); >+ stringBuilder.append(makeString("location.", "xyzw"_str.substring(0, locationVectorLength - 1), ", location.", "xyzw"_str.substring(locationVectorLength - 1, 1))); >+ } else >+ stringBuilder.append("location"); >+ if (!metalParameter4Name.isNull()) >+ stringBuilder.append(", offset"); >+ stringBuilder.append(")"); >+ if (!textureType.isDepthTexture()) >+ stringBuilder.append(makeString(".", "xyzw"_str.substring(0, returnVectorLength))); >+ stringBuilder.append(";\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); > } > > if (nativeFunctionDeclaration.name() == "Load") { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >index 4948d9dd376..f57d5c077cc 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >@@ -71,9 +71,7 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); > auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); > auto& unifyNode = typeReference->unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); > auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); > auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); > auto prefix = ([&]() -> String { > if (parameterType.name() == "bool") >@@ -116,9 +114,7 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); > auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); > auto& unifyNode = typeReference->unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); > auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); > auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); > auto prefix = ([&]() -> String { > if (parameterType.name() == "half") >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >index 41138dda6f8..c3d82725ad0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >@@ -201,7 +201,6 @@ static BaseTypeNameNode& find(AST::UnnamedType& unnamedType, Vector<UniqueRef<Ba > return find(downcast<AST::PointerType>(unnamedType).elementType(), types).children(); > if (is<AST::ArrayReferenceType>(unnamedType)) > return find(downcast<AST::ArrayReferenceType>(unnamedType).elementType(), types).children(); >- ASSERT(is<AST::ArrayType>(unnamedType)); > return find(downcast<AST::ArrayType>(unnamedType).type(), types).children(); > })(); > auto iterator = findInVector(unnamedType, vectorToSearch); >@@ -306,7 +305,6 @@ UniqueRef<BaseTypeNameNode> TypeNamer::createNameNode(AST::UnnamedType& unnamedT > auto& arrayReferenceType = downcast<AST::ArrayReferenceType>(unnamedType); > return makeUniqueRef<ArrayReferenceTypeNameNode>(parent, generateNextTypeName(), arrayReferenceType.addressSpace()); > } >- ASSERT(is<AST::ArrayType>(unnamedType)); > auto& arrayType = downcast<AST::ArrayType>(unnamedType); > return makeUniqueRef<ArrayTypeNameNode>(parent, generateNextTypeName(), arrayType.numElements()); > } >@@ -327,7 +325,6 @@ size_t TypeNamer::insert(AST::UnnamedType& unnamedType, Vector<UniqueRef<BaseTyp > vectorToInsertInto = &item->children(); > parent = &item; > } else { >- ASSERT(is<AST::ArrayType>(unnamedType)); > auto& item = types[insert(downcast<AST::ArrayType>(unnamedType).type(), types)]; > vectorToInsertInto = &item->children(); > parent = &item; >@@ -399,7 +396,6 @@ void TypeNamer::emitUnnamedTypeDefinition(BaseTypeNameNode& baseTypeNameNode, Ha > stringBuilder.append(" uint length;\n"); > stringBuilder.append("};\n"); > } else { >- ASSERT(is<ArrayTypeNameNode>(baseTypeNameNode)); > auto& arrayType = downcast<ArrayTypeNameNode>(baseTypeNameNode); > ASSERT(baseTypeNameNode.parent()); > stringBuilder.append(makeString("typedef Array<", arrayType.parent()->mangledName(), ", ", arrayType.numElements(), "> ", arrayType.mangledName(), ";\n")); >@@ -418,7 +414,6 @@ void TypeNamer::emitNamedTypeDefinition(AST::NamedType& namedType, HashSet<AST:: > if (is<AST::EnumerationDefinition>(namedType)) { > auto& enumerationDefinition = downcast<AST::EnumerationDefinition>(namedType); > auto& baseType = enumerationDefinition.type().unifyNode(); >- ASSERT(is<AST::NamedType>(baseType)); > stringBuilder.append(makeString("enum class ", mangledNameForType(enumerationDefinition), " : ", mangledNameForType(downcast<AST::NamedType>(baseType)), " {\n")); > for (auto& enumerationMember : enumerationDefinition.enumerationMembers()) > stringBuilder.append(makeString(" ", mangledNameForEnumerationMember(enumerationMember), ",\n")); >@@ -432,7 +427,6 @@ void TypeNamer::emitNamedTypeDefinition(AST::NamedType& namedType, HashSet<AST:: > stringBuilder.append(makeString(" ", mangledNameForType(structureElement.type()), ' ', mangledNameForStructureElement(structureElement), ";\n")); > stringBuilder.append("};\n"); > } else { >- ASSERT(is<AST::TypeDefinition>(namedType)); > auto& typeDefinition = downcast<AST::TypeDefinition>(namedType); > stringBuilder.append(makeString("typedef ", mangledNameForType(typeDefinition.type()), ' ', mangledNameForType(typeDefinition), ";\n")); > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >index f14e7d43ba6..8cd0989572c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >@@ -656,14 +656,12 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > auto enumerationMembers = enumerationDefinition.enumerationMembers(); > > auto matchAndCommitMember = [&](AST::EnumerationMember& member) -> bool { >- bool success = false; >- member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) { >+ return member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) -> bool { > auto valueInfo = recurseAndGetInfo(value); > if (!valueInfo) >- return; >- success = static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType)); >+ return false; >+ return static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType)); > })); >- return success; > }; > > for (auto& member : enumerationMembers) { >@@ -679,13 +677,13 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > int64_t nextValue = 0; > for (auto& member : enumerationMembers) { > if (member.get().value()) { >- int64_t value; >- member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.valueForSelectedType(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.valueForSelectedType(); >- }, [&](auto&) { >+ auto value = member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.valueForSelectedType(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.valueForSelectedType(); >+ }, [&](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > nextValue = baseType->successor()(value); > } else { >@@ -706,14 +704,14 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > } > > auto getValue = [&](AST::EnumerationMember& member) -> int64_t { >- int64_t value; > ASSERT(member.value()); >- member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.value(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.value(); >- }, [&](auto&) { >+ auto value = member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.value(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.value(); >+ }, [&](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > return value; > }; >@@ -977,7 +975,6 @@ static Optional<UniqueRef<AST::UnnamedType>> argumentTypeForAndOverload(AST::Unn > return { makeUniqueRef<AST::PointerType>(Lexer::Token(namedType.origin()), addressSpace, AST::TypeReference::wrap(Lexer::Token(namedType.origin()), namedType)) }; > } > >- ASSERT(is<AST::UnnamedType>(unifyNode)); > auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); > > if (is<AST::ArrayReferenceType>(unnamedType)) >@@ -1305,20 +1302,19 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > hasDefault = true; > continue; > } >- bool success; >- switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); >- }, [&](AST::FloatLiteral& floatLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); >- }, [&](AST::NullLiteral& nullLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); >- }, [&](AST::BooleanLiteral&) { >- success = matches(*valueType, m_intrinsics.boolType()); >- }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >+ auto success = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); >+ }, [&](AST::FloatLiteral& floatLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); >+ }, [&](AST::NullLiteral& nullLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); >+ }, [&](AST::BooleanLiteral&) -> bool { >+ return matches(*valueType, m_intrinsics.boolType()); >+ }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> bool { > ASSERT(enumerationMemberLiteral.enumerationDefinition()); >- success = matches(*valueType, *enumerationMemberLiteral.enumerationDefinition()); >+ return matches(*valueType, *enumerationMemberLiteral.enumerationDefinition()); > })); > if (!success) { > setError(); >@@ -1339,31 +1335,37 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > return; > } > >- bool success = true; >- firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) { >- success = firstIntegerLiteral.value() != secondIntegerLiteral.value(); >- }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) { >- success = static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value()); >- }, [](auto&) { >+ auto success = firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { >+ return firstIntegerLiteral.value() != secondIntegerLiteral.value(); >+ }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { >+ return static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value()); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) { >- success = static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); >- }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) { >- success = firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); >- }, [](auto&) { >+ }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { >+ return static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); >+ }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { >+ return firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral&) { >- }, [&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) { >+ }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) -> bool { > ASSERT(firstEnumerationMemberLiteral.enumerationMember()); > ASSERT(secondEnumerationMemberLiteral.enumerationMember()); >- success = firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); >- }, [](auto&) { >+ return firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [](auto&) { >+ }, [](auto&) -> bool { >+ return true; > })); >+ if (!success) { >+ setError(); >+ return; >+ } > } > } > >@@ -1372,13 +1374,13 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > HashSet<int64_t> values; > bool zeroValueExists; > for (auto& switchCase : switchStatement.switchCases()) { >- int64_t value; >- switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.valueForSelectedType(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.valueForSelectedType(); >- }, [](auto&) { >+ auto value = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.valueForSelectedType(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.valueForSelectedType(); >+ }, [](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > if (!value) > zeroValueExists = true; >@@ -1405,7 +1407,6 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > return; > } > } else { >- ASSERT(is<AST::EnumerationDefinition>(*valueType)); > HashSet<AST::EnumerationMember*> values; > for (auto& switchCase : switchStatement.switchCases()) { > switchCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >index 66993626b45..bc89f39ffc8 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >@@ -188,7 +188,6 @@ bool inferTypesForTypeArguments(AST::NamedType& possibleType, AST::TypeArguments > return typeArguments.isEmpty(); > } > >- ASSERT(is<AST::NativeTypeDeclaration>(possibleType)); > auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType); > if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size()) > return false; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >index cb9d8d1fc85..a2aabbe45d8 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >@@ -347,11 +347,7 @@ bool Intrinsics::addMatrix(AST::NativeTypeDeclaration& nativeTypeDeclaration) > > bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) > { >- unsigned textureTypeIndex = WTF_ARRAY_LENGTH(m_textureTypeNames); >- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_textureTypeNames); ++i) { >- if (nativeTypeDeclaration.name() == m_textureTypeNames[i]) >- textureTypeIndex = i; >- } >+ auto textureTypeIndex = std::find(m_textureTypeNames, m_textureTypeNames + WTF_ARRAY_LENGTH(m_textureTypeNames), nativeTypeDeclaration.name()) - m_textureTypeNames; > if (textureTypeIndex == WTF_ARRAY_LENGTH(m_textureTypeNames)) > return false; > >@@ -373,6 +369,8 @@ bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaratio > } > ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_textureInnerTypeNames)); > nativeTypeDeclaration.setIsTexture(); >+ if (textureTypeIndex >= indexOfFirstArrayType) >+ nativeTypeDeclaration.setIsTextureArray(); > m_fullTextures[textureTypeIndex][innerTypeIndex][vectorLength - 1] = &nativeTypeDeclaration; > return true; > } >@@ -392,13 +390,12 @@ bool Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclarati > texture = m_textureDepthCube; > else > ASSERT_NOT_REACHED(); >- unsigned innerTypeIndex = WTF_ARRAY_LENGTH(m_depthTextureInnerTypes); >- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_depthTextureInnerTypes); ++i) { >- if (innerType.name() == m_depthTextureInnerTypes[i]) >- innerTypeIndex = i; >- } >+ auto innerTypeIndex = std::find(m_depthTextureInnerTypes, m_depthTextureInnerTypes + WTF_ARRAY_LENGTH(m_depthTextureInnerTypes), innerType.name()) - m_depthTextureInnerTypes; > ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)); > nativeTypeDeclaration.setIsTexture(); >+ if (texture == m_textureDepth2DArray || texture == m_rwTextureDepth2DArray) >+ nativeTypeDeclaration.setIsTextureArray(); >+ nativeTypeDeclaration.setIsDepthTexture(); > texture[innerTypeIndex] = &nativeTypeDeclaration; > return true; > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >index d23bf9787d8..30eda3f700a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >@@ -263,7 +263,10 @@ private: > AST::NativeTypeDeclaration* m_matrixHalf[3][3] {{ 0 }}; > AST::NativeTypeDeclaration* m_matrixFloat[3][3] {{ 0 }}; > >- static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture1DArray", "RWTexture1DArray", "Texture2D", "RWTexture2D", "Texture2DArray", "RWTexture2DArray", "Texture3D", "RWTexture3D", "TextureCube" }; >+ // Keep the array types partitioned from the non-array types. >+ // This is how we retain what's an array and what isn't. >+ static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture2D", "RWTexture2D", "Texture3D", "RWTexture3D", "TextureCube", "Texture1DArray", "RWTexture1DArray", "Texture2DArray", "RWTexture2DArray" }; >+ static constexpr unsigned indexOfFirstArrayType = 7; > > static constexpr const char* m_textureInnerTypeNames[] = { "uchar", "ushort", "uint", "char", "short", "int", "half", "float" }; > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >index 21ca18dcfa3..44a319559ac 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >@@ -56,6 +56,15 @@ NameResolver::NameResolver(NameContext& nameContext) > { > } > >+void NameResolver::visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) >+{ >+ NameContext newNameContext(&m_nameContext); >+ NameResolver newNameResolver(newNameContext); >+ newNameResolver.Visitor::visit(nativeFunctionDeclaration); >+ if (newNameResolver.error()) >+ setError(); >+} >+ > void NameResolver::visit(AST::TypeReference& typeReference) > { > ScopedSetAdder<AST::TypeReference*> adder(m_typeReferences, &typeReference); >@@ -92,6 +101,8 @@ void NameResolver::visit(AST::FunctionDefinition& functionDefinition) > for (auto& parameter : functionDefinition.parameters()) > newNameResolver.checkErrorAndVisit(parameter); > newNameResolver.checkErrorAndVisit(functionDefinition.block()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::Block& block) >@@ -100,6 +111,8 @@ void NameResolver::visit(AST::Block& block) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.Visitor::visit(block); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::IfStatement& ifStatement) >@@ -109,11 +122,15 @@ void NameResolver::visit(AST::IfStatement& ifStatement) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(ifStatement.body()); >- if (ifStatement.elseBody()) { >+ if (newNameResolver.error()) >+ setError(); >+ else if (ifStatement.elseBody()) { > NameContext nameContext(&m_nameContext); > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(*ifStatement.elseBody()); >+ if (newNameResolver.error()) >+ setError(); > } > } > >@@ -124,6 +141,8 @@ void NameResolver::visit(AST::WhileLoop& whileLoop) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(whileLoop.body()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::DoWhileLoop& whileLoop) >@@ -133,6 +152,8 @@ void NameResolver::visit(AST::DoWhileLoop& whileLoop) > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(whileLoop.body()); > checkErrorAndVisit(whileLoop.conditional()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::ForLoop& forLoop) >@@ -141,6 +162,8 @@ void NameResolver::visit(AST::ForLoop& forLoop) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.Visitor::visit(forLoop); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::VariableDeclaration& variableDeclaration) >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >index 8fb4a34fbd4..b9ae0d7dca7 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >@@ -64,6 +64,7 @@ private: > void visit(AST::DotExpression&) override; > void visit(AST::CallExpression&) override; > void visit(AST::EnumerationMemberLiteral&) override; >+ void visit(AST::NativeFunctionDeclaration&) override; > > NameContext& m_nameContext; > HashSet<AST::TypeReference*> m_typeReferences; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >index f80da99758d..75b4ae3d3cc 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >@@ -306,7 +306,6 @@ static Optional<ModifyResult> modify(AST::PropertyAccessExpression& propertyAcce > if (iterator->base().typeAnnotation().leftAddressSpace()) > break; > ASSERT(!iterator->base().typeAnnotation().isRightValue()); >- ASSERT(is<AST::PropertyAccessExpression>(iterator->base())); > iterator = &downcast<AST::PropertyAccessExpression>(iterator->base()); > } > auto leftExpression = iterator->takeBase(); >@@ -519,7 +518,6 @@ void PropertyResolver::visit(AST::AssignmentExpression& assignmentExpression) > return; > } > ASSERT(!assignmentExpression.left().typeAnnotation().isRightValue()); >- ASSERT(is<AST::PropertyAccessExpression>(assignmentExpression.left())); > > auto type = assignmentExpression.right().resolvedType().clone(); > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >index 0fb48e1de53..94e4ec2fdea 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >@@ -441,7 +441,7 @@ native bool operator<(uint, uint); > native bool operator<(float, float); > native float operator*(float, float); > >-/* native bool operator.x(bool2); >+native bool operator.x(bool2); > native bool operator.y(bool2); > native bool operator.x(bool3); > native bool operator.y(bool3); >@@ -586,16 +586,16 @@ native half4 operator.y=(half4, half); > native half4 operator.z=(half4, half); > native half4 operator.w=(half4, half); > native float operator.x(float2); >-native float operator.y(float2);*/ >+native float operator.y(float2); > native float operator.x(float3); > native float operator.y(float3); > native float operator.z(float3); > native float operator.x(float4); > native float operator.y(float4); > native float operator.z(float4); >-native float operator.w(float4);/* >+native float operator.w(float4); > native float2 operator.x=(float2, float); >-native float2 operator.y=(float2, float);*/ >+native float2 operator.y=(float2, float); > native float3 operator.x=(float3, float); > native float3 operator.y=(float3, float); > native float3 operator.z=(float3, float); >@@ -619,4 +619,234 @@ operator float4(float x, float y, float z, float w) { > return result; > } > >+operator float2(float x, float y) { >+ float2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+ >+native ushort Sample(Texture1D<ushort>, sampler, float location); >+native ushort Sample(Texture1DArray<ushort>, sampler, float2 location); >+native ushort Sample(Texture2D<ushort>, sampler, float2 location); >+native ushort Sample(Texture2D<ushort>, sampler, float2 location, int2 offset); >+native ushort Sample(Texture2DArray<ushort>, sampler, float3 location); >+native ushort Sample(Texture2DArray<ushort>, sampler, float3 location, int2 offset); >+native ushort Sample(Texture3D<ushort>, sampler, float3 location); >+native ushort Sample(Texture3D<ushort>, sampler, float3 location, int3 offset); >+native ushort Sample(TextureCube<ushort>, sampler, float3 location); >+native ushort2 Sample(Texture1D<ushort2>, sampler, float location); >+native ushort2 Sample(Texture1DArray<ushort2>, sampler, float2 location); >+native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location); >+native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location, int2 offset); >+native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location); >+native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location, int2 offset); >+native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location); >+native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location, int3 offset); >+native ushort2 Sample(TextureCube<ushort2>, sampler, float3 location); >+native ushort3 Sample(Texture1D<ushort3>, sampler, float location); >+native ushort3 Sample(Texture1DArray<ushort3>, sampler, float2 location); >+native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location); >+native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location, int2 offset); >+native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location); >+native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location, int2 offset); >+native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location); >+native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location, int3 offset); >+native ushort3 Sample(TextureCube<ushort3>, sampler, float3 location); >+native ushort4 Sample(Texture1D<ushort4>, sampler, float location); >+native ushort4 Sample(Texture1DArray<ushort4>, sampler, float2 location); >+native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location); >+native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location, int2 offset); >+native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location); >+native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location, int2 offset); >+native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location); >+native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location, int3 offset); >+native ushort4 Sample(TextureCube<ushort4>, sampler, float3 location); >+native uint Sample(Texture1D<uint>, sampler, float location); >+native uint Sample(Texture1DArray<uint>, sampler, float2 location); >+native uint Sample(Texture2D<uint>, sampler, float2 location); >+native uint Sample(Texture2D<uint>, sampler, float2 location, int2 offset); >+native uint Sample(Texture2DArray<uint>, sampler, float3 location); >+native uint Sample(Texture2DArray<uint>, sampler, float3 location, int2 offset); >+native uint Sample(Texture3D<uint>, sampler, float3 location); >+native uint Sample(Texture3D<uint>, sampler, float3 location, int3 offset); >+native uint Sample(TextureCube<uint>, sampler, float3 location); >+native uint2 Sample(Texture1D<uint2>, sampler, float location); >+native uint2 Sample(Texture1DArray<uint2>, sampler, float2 location); >+native uint2 Sample(Texture2D<uint2>, sampler, float2 location); >+native uint2 Sample(Texture2D<uint2>, sampler, float2 location, int2 offset); >+native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location); >+native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location, int2 offset); >+native uint2 Sample(Texture3D<uint2>, sampler, float3 location); >+native uint2 Sample(Texture3D<uint2>, sampler, float3 location, int3 offset); >+native uint2 Sample(TextureCube<uint2>, sampler, float3 location); >+native uint3 Sample(Texture1D<uint3>, sampler, float location); >+native uint3 Sample(Texture1DArray<uint3>, sampler, float2 location); >+native uint3 Sample(Texture2D<uint3>, sampler, float2 location); >+native uint3 Sample(Texture2D<uint3>, sampler, float2 location, int2 offset); >+native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location); >+native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location, int2 offset); >+native uint3 Sample(Texture3D<uint3>, sampler, float3 location); >+native uint3 Sample(Texture3D<uint3>, sampler, float3 location, int3 offset); >+native uint3 Sample(TextureCube<uint3>, sampler, float3 location); >+native uint4 Sample(Texture1D<uint4>, sampler, float location); >+native uint4 Sample(Texture1DArray<uint4>, sampler, float2 location); >+native uint4 Sample(Texture2D<uint4>, sampler, float2 location); >+native uint4 Sample(Texture2D<uint4>, sampler, float2 location, int2 offset); >+native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location); >+native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location, int2 offset); >+native uint4 Sample(Texture3D<uint4>, sampler, float3 location); >+native uint4 Sample(Texture3D<uint4>, sampler, float3 location, int3 offset); >+native uint4 Sample(TextureCube<uint4>, sampler, float3 location); >+native short Sample(Texture1D<short>, sampler, float location); >+native short Sample(Texture1DArray<short>, sampler, float2 location); >+native short Sample(Texture2D<short>, sampler, float2 location); >+native short Sample(Texture2D<short>, sampler, float2 location, int2 offset); >+native short Sample(Texture2DArray<short>, sampler, float3 location); >+native short Sample(Texture2DArray<short>, sampler, float3 location, int2 offset); >+native short Sample(Texture3D<short>, sampler, float3 location); >+native short Sample(Texture3D<short>, sampler, float3 location, int3 offset); >+native short Sample(TextureCube<short>, sampler, float3 location); >+native short2 Sample(Texture1D<short2>, sampler, float location); >+native short2 Sample(Texture1DArray<short2>, sampler, float2 location); >+native short2 Sample(Texture2D<short2>, sampler, float2 location); >+native short2 Sample(Texture2D<short2>, sampler, float2 location, int2 offset); >+native short2 Sample(Texture2DArray<short2>, sampler, float3 location); >+native short2 Sample(Texture2DArray<short2>, sampler, float3 location, int2 offset); >+native short2 Sample(Texture3D<short2>, sampler, float3 location); >+native short2 Sample(Texture3D<short2>, sampler, float3 location, int3 offset); >+native short2 Sample(TextureCube<short2>, sampler, float3 location); >+native short3 Sample(Texture1D<short3>, sampler, float location); >+native short3 Sample(Texture1DArray<short3>, sampler, float2 location); >+native short3 Sample(Texture2D<short3>, sampler, float2 location); >+native short3 Sample(Texture2D<short3>, sampler, float2 location, int2 offset); >+native short3 Sample(Texture2DArray<short3>, sampler, float3 location); >+native short3 Sample(Texture2DArray<short3>, sampler, float3 location, int2 offset); >+native short3 Sample(Texture3D<short3>, sampler, float3 location); >+native short3 Sample(Texture3D<short3>, sampler, float3 location, int3 offset); >+native short3 Sample(TextureCube<short3>, sampler, float3 location); >+native short4 Sample(Texture1D<short4>, sampler, float location); >+native short4 Sample(Texture1DArray<short4>, sampler, float2 location); >+native short4 Sample(Texture2D<short4>, sampler, float2 location); >+native short4 Sample(Texture2D<short4>, sampler, float2 location, int2 offset); >+native short4 Sample(Texture2DArray<short4>, sampler, float3 location); >+native short4 Sample(Texture2DArray<short4>, sampler, float3 location, int2 offset); >+native short4 Sample(Texture3D<short4>, sampler, float3 location); >+native short4 Sample(Texture3D<short4>, sampler, float3 location, int3 offset); >+native short4 Sample(TextureCube<short4>, sampler, float3 location); >+native int Sample(Texture1D<int>, sampler, float location); >+native int Sample(Texture1DArray<int>, sampler, float2 location); >+native int Sample(Texture2D<int>, sampler, float2 location); >+native int Sample(Texture2D<int>, sampler, float2 location, int2 offset); >+native int Sample(Texture2DArray<int>, sampler, float3 location); >+native int Sample(Texture2DArray<int>, sampler, float3 location, int2 offset); >+native int Sample(Texture3D<int>, sampler, float3 location); >+native int Sample(Texture3D<int>, sampler, float3 location, int3 offset); >+native int Sample(TextureCube<int>, sampler, float3 location); >+native int2 Sample(Texture1D<int2>, sampler, float location); >+native int2 Sample(Texture1DArray<int2>, sampler, float2 location); >+native int2 Sample(Texture2D<int2>, sampler, float2 location); >+native int2 Sample(Texture2D<int2>, sampler, float2 location, int2 offset); >+native int2 Sample(Texture2DArray<int2>, sampler, float3 location); >+native int2 Sample(Texture2DArray<int2>, sampler, float3 location, int2 offset); >+native int2 Sample(Texture3D<int2>, sampler, float3 location); >+native int2 Sample(Texture3D<int2>, sampler, float3 location, int3 offset); >+native int2 Sample(TextureCube<int2>, sampler, float3 location); >+native int3 Sample(Texture1D<int3>, sampler, float location); >+native int3 Sample(Texture1DArray<int3>, sampler, float2 location); >+native int3 Sample(Texture2D<int3>, sampler, float2 location); >+native int3 Sample(Texture2D<int3>, sampler, float2 location, int2 offset); >+native int3 Sample(Texture2DArray<int3>, sampler, float3 location); >+native int3 Sample(Texture2DArray<int3>, sampler, float3 location, int2 offset); >+native int3 Sample(Texture3D<int3>, sampler, float3 location); >+native int3 Sample(Texture3D<int3>, sampler, float3 location, int3 offset); >+native int3 Sample(TextureCube<int3>, sampler, float3 location); >+native int4 Sample(Texture1D<int4>, sampler, float location); >+native int4 Sample(Texture1DArray<int4>, sampler, float2 location); >+native int4 Sample(Texture2D<int4>, sampler, float2 location); >+native int4 Sample(Texture2D<int4>, sampler, float2 location, int2 offset); >+native int4 Sample(Texture2DArray<int4>, sampler, float3 location); >+native int4 Sample(Texture2DArray<int4>, sampler, float3 location, int2 offset); >+native int4 Sample(Texture3D<int4>, sampler, float3 location); >+native int4 Sample(Texture3D<int4>, sampler, float3 location, int3 offset); >+native int4 Sample(TextureCube<int4>, sampler, float3 location); >+native half Sample(Texture1D<half>, sampler, float location); >+native half Sample(Texture1DArray<half>, sampler, float2 location); >+native half Sample(Texture2D<half>, sampler, float2 location); >+native half Sample(Texture2D<half>, sampler, float2 location, int2 offset); >+native half Sample(Texture2DArray<half>, sampler, float3 location); >+native half Sample(Texture2DArray<half>, sampler, float3 location, int2 offset); >+native half Sample(Texture3D<half>, sampler, float3 location); >+native half Sample(Texture3D<half>, sampler, float3 location, int3 offset); >+native half Sample(TextureCube<half>, sampler, float3 location); >+native half2 Sample(Texture1D<half2>, sampler, float location); >+native half2 Sample(Texture1DArray<half2>, sampler, float2 location); >+native half2 Sample(Texture2D<half2>, sampler, float2 location); >+native half2 Sample(Texture2D<half2>, sampler, float2 location, int2 offset); >+native half2 Sample(Texture2DArray<half2>, sampler, float3 location); >+native half2 Sample(Texture2DArray<half2>, sampler, float3 location, int2 offset); >+native half2 Sample(Texture3D<half2>, sampler, float3 location); >+native half2 Sample(Texture3D<half2>, sampler, float3 location, int3 offset); >+native half2 Sample(TextureCube<half2>, sampler, float3 location); >+native half3 Sample(Texture1D<half3>, sampler, float location); >+native half3 Sample(Texture1DArray<half3>, sampler, float2 location); >+native half3 Sample(Texture2D<half3>, sampler, float2 location); >+native half3 Sample(Texture2D<half3>, sampler, float2 location, int2 offset); >+native half3 Sample(Texture2DArray<half3>, sampler, float3 location); >+native half3 Sample(Texture2DArray<half3>, sampler, float3 location, int2 offset); >+native half3 Sample(Texture3D<half3>, sampler, float3 location); >+native half3 Sample(Texture3D<half3>, sampler, float3 location, int3 offset); >+native half3 Sample(TextureCube<half3>, sampler, float3 location); >+native half4 Sample(Texture1D<half4>, sampler, float location); >+native half4 Sample(Texture1DArray<half4>, sampler, float2 location); >+native half4 Sample(Texture2D<half4>, sampler, float2 location); >+native half4 Sample(Texture2D<half4>, sampler, float2 location, int2 offset); >+native half4 Sample(Texture2DArray<half4>, sampler, float3 location); >+native half4 Sample(Texture2DArray<half4>, sampler, float3 location, int2 offset); >+native half4 Sample(Texture3D<half4>, sampler, float3 location); >+native half4 Sample(Texture3D<half4>, sampler, float3 location, int3 offset); >+native half4 Sample(TextureCube<half4>, sampler, float3 location); >+native float Sample(Texture1D<float>, sampler, float location); >+native float Sample(Texture1DArray<float>, sampler, float2 location); >+native float Sample(Texture2D<float>, sampler, float2 location); >+native float Sample(Texture2D<float>, sampler, float2 location, int2 offset); >+native float Sample(Texture2DArray<float>, sampler, float3 location); >+native float Sample(Texture2DArray<float>, sampler, float3 location, int2 offset); >+native float Sample(Texture3D<float>, sampler, float3 location); >+native float Sample(Texture3D<float>, sampler, float3 location, int3 offset); >+native float Sample(TextureCube<float>, sampler, float3 location); >+native float2 Sample(Texture1D<float2>, sampler, float location); >+native float2 Sample(Texture1DArray<float2>, sampler, float2 location); >+native float2 Sample(Texture2D<float2>, sampler, float2 location); >+native float2 Sample(Texture2D<float2>, sampler, float2 location, int2 offset); >+native float2 Sample(Texture2DArray<float2>, sampler, float3 location); >+native float2 Sample(Texture2DArray<float2>, sampler, float3 location, int2 offset); >+native float2 Sample(Texture3D<float2>, sampler, float3 location); >+native float2 Sample(Texture3D<float2>, sampler, float3 location, int3 offset); >+native float2 Sample(TextureCube<float2>, sampler, float3 location); >+native float3 Sample(Texture1D<float3>, sampler, float location); >+native float3 Sample(Texture1DArray<float3>, sampler, float2 location); >+native float3 Sample(Texture2D<float3>, sampler, float2 location); >+native float3 Sample(Texture2D<float3>, sampler, float2 location, int2 offset); >+native float3 Sample(Texture2DArray<float3>, sampler, float3 location); >+native float3 Sample(Texture2DArray<float3>, sampler, float3 location, int2 offset); >+native float3 Sample(Texture3D<float3>, sampler, float3 location); >+native float3 Sample(Texture3D<float3>, sampler, float3 location, int3 offset); >+native float3 Sample(TextureCube<float3>, sampler, float3 location); >+native float4 Sample(Texture1D<float4>, sampler, float location); >+native float4 Sample(Texture1DArray<float4>, sampler, float2 location); >+native float4 Sample(Texture2D<float4>, sampler, float2 location); >+native float4 Sample(Texture2D<float4>, sampler, float2 location, int2 offset); >+native float4 Sample(Texture2DArray<float4>, sampler, float3 location); >+native float4 Sample(Texture2DArray<float4>, sampler, float3 location, int2 offset); >+native float4 Sample(Texture3D<float4>, sampler, float3 location); >+native float4 Sample(Texture3D<float4>, sampler, float3 location, int3 offset); >+native float4 Sample(TextureCube<float4>, sampler, float3 location); >+native float Sample(TextureDepth2D<float>, sampler, float2 location); >+native float Sample(TextureDepth2D<float>, sampler, float2 location, int2 offset); >+native float Sample(TextureDepth2DArray<float>, sampler, float3 location); >+native float Sample(TextureDepth2DArray<float>, sampler, float3 location, int2 offset); >+native float Sample(TextureDepthCube<float>, sampler, float3 location); >+ >+ > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=192890 Insert the rest of the standard library once the parser is fast enough >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >index 2063d2a46dd..3443d53638a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >@@ -59,10 +59,8 @@ void Visitor::visit(AST::UnnamedType& unnamedType) > checkErrorAndVisit(downcast<AST::PointerType>(unnamedType)); > else if (is<AST::ArrayReferenceType>(unnamedType)) > checkErrorAndVisit(downcast<AST::ArrayReferenceType>(unnamedType)); >- else { >- ASSERT(is<AST::ArrayType>(unnamedType)); >+ else > checkErrorAndVisit(downcast<AST::ArrayType>(unnamedType)); >- } > } > > void Visitor::visit(AST::NamedType& namedType) >@@ -73,10 +71,8 @@ void Visitor::visit(AST::NamedType& namedType) > checkErrorAndVisit(downcast<AST::StructureDefinition>(namedType)); > else if (is<AST::EnumerationDefinition>(namedType)) > checkErrorAndVisit(downcast<AST::EnumerationDefinition>(namedType)); >- else { >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); >+ else > checkErrorAndVisit(downcast<AST::NativeTypeDeclaration>(namedType)); >- } > } > > void Visitor::visit(AST::TypeDefinition& typeDefinition) >@@ -336,10 +332,8 @@ void Visitor::visit(AST::Statement& statement) > checkErrorAndVisit(downcast<AST::Trap>(statement)); > else if (is<AST::VariableDeclarationsStatement>(statement)) > checkErrorAndVisit(downcast<AST::VariableDeclarationsStatement>(statement)); >- else { >- ASSERT(is<AST::WhileLoop>(statement)); >+ else > checkErrorAndVisit(downcast<AST::WhileLoop>(statement)); >- } > } > > void Visitor::visit(AST::Break&) >@@ -396,10 +390,8 @@ void Visitor::visit(AST::Expression& expression) > checkErrorAndVisit(downcast<AST::UnsignedIntegerLiteral>(expression)); > else if (is<AST::EnumerationMemberLiteral>(expression)) > checkErrorAndVisit(downcast<AST::EnumerationMemberLiteral>(expression)); >- else { >- ASSERT(is<AST::VariableReference>(expression)); >+ else > checkErrorAndVisit(downcast<AST::VariableReference>(expression)); >- } > } > > void Visitor::visit(AST::DotExpression& dotExpression) >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >index 6262e5f6d41..3e0c7d38ae1 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >@@ -216,22 +216,22 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr > if (!samplerState) > return false; > if (isForVertex) >- setSamplerOnEncoder(vertexEncoder, samplerState, index); >+ setSamplerOnEncoder(vertexEncoder, samplerState, layoutBinding.internalName); > if (isForFragment) >- setSamplerOnEncoder(fragmentEncoder, samplerState, index); >+ setSamplerOnEncoder(fragmentEncoder, samplerState, layoutBinding.internalName); > if (isForCompute) >- setSamplerOnEncoder(computeEncoder, samplerState, index); >+ setSamplerOnEncoder(computeEncoder, samplerState, layoutBinding.internalName); > return true; > }, [&](GPUBindGroupLayout::SampledTexture&) -> bool { > auto textureResource = tryGetResourceAsTexture(resourceBinding.resource, functionName); > if (!textureResource) > return false; > if (isForVertex) >- setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), layoutBinding.internalName); > if (isForFragment) >- setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), layoutBinding.internalName); > if (isForCompute) >- setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), layoutBinding.internalName); > boundTextures.append(textureResource.releaseNonNull()); > return true; > }, [&](GPUBindGroupLayout::StorageBuffer& storageBuffer) -> bool { >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >index 1745df017b6..ef564025ce7 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >@@ -410,6 +410,8 @@ static bool trySetFunctions(const char* const functionName, const GPUPipelineSta > if (!whlslCompileResult) > return false; > >+ WTFLogAlways("MSL Source: %s", whlslCompileResult->metalSource.utf8().data()); >+ > NSError *error = nil; > > BEGIN_BLOCK_OBJC_EXCEPTIONS;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198704
:
371723
|
371725
|
372024
|
372027
|
372105
|
372109
|
372115
|
372195
|
372234
|
372235
|
372238
|
372239
|
372316
|
372378
|
372421
|
372423
|
372470