Changeset 246631 in webkit
- Timestamp:
- Jun 20, 2019 2:40:41 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 37 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246629 r246631 1 2019-06-19 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Hook up common texture functions 4 https://bugs.webkit.org/show_bug.cgi?id=198704 5 <rdar://problem/51668841> 6 7 Reviewed by Saam Barati. 8 9 Make the text tests play better with js-test-pre.js. 10 11 * webgpu/whlsl-buffer-length.html: 12 * webgpu/whlsl-compute-expected.txt: 13 * webgpu/whlsl-compute.html: 14 * webgpu/whlsl-duplicate-types-should-not-produce-duplicate-ctors.html: 15 * webgpu/whlsl-null-dereference-expected.txt: 16 * webgpu/whlsl-null-dereference.html: 17 * webgpu/whlsl-oob-access-expected.txt: 18 * webgpu/whlsl-oob-access.html: 19 * webgpu/whlsl-textures-getdimensions-expected.txt: Added. 20 * webgpu/whlsl-textures-getdimensions.html: Copied from LayoutTests/webgpu/whlsl-buffer-length.html. 21 * webgpu/whlsl-textures-load-expected.html: Added. 22 * webgpu/whlsl-textures-load.html: Added. 23 * webgpu/whlsl-textures-sample-expected.html: Added. 24 * webgpu/whlsl-textures-sample.html: Added. 25 1 26 2019-06-19 Rob Buis <rbuis@igalia.com> 2 27 -
trunk/LayoutTests/webgpu/whlsl-buffer-length-expected.txt
r246515 r246631 1 PASS resultUint32Array[0] is 1337 1 2 PASS successfullyParsed is true 2 3 3 4 TEST COMPLETE 4 PASS resultUint32Array[0] is 13375 5 -
trunk/LayoutTests/webgpu/whlsl-buffer-length.html
r246515 r246631 60 60 resultsBuffer.unmap(); 61 61 } 62 if (window.testRunner) 63 testRunner.waitUntilDone(); 62 window.jsTestIsAsync = true; 64 63 window.addEventListener("load", function() { 65 64 start().then(function() { 66 if (window.testRunner) 67 testRunner.notifyDone(); 65 finishJSTest(); 68 66 }, function() { 69 if (window.testRunner) 70 testRunner.notifyDone(); 67 finishJSTest(); 71 68 }); 72 69 }); -
trunk/LayoutTests/webgpu/whlsl-compute-expected.txt
r246427 r246631 1 PASS successfullyParsed is true2 3 TEST COMPLETE4 1 PASS resultsFloat32Array[0] is 2 5 2 PASS resultsFloat32Array[1] is 4 … … 10 7 PASS resultsFloat32Array[6] is 7 11 8 PASS resultsFloat32Array[7] is 8 9 PASS successfullyParsed is true 12 10 11 TEST COMPLETE 12 -
trunk/LayoutTests/webgpu/whlsl-compute.html
r246515 r246631 74 74 resultsBuffer.unmap(); 75 75 } 76 if (window.testRunner) 77 testRunner.waitUntilDone(); 76 window.jsTestIsAsync = true; 78 77 window.addEventListener("load", function() { 79 78 start().then(function() { 80 if (window.testRunner) 81 testRunner.notifyDone(); 79 finishJSTest(); 82 80 }, function() { 83 if (window.testRunner) 84 testRunner.notifyDone(); 81 finishJSTest(); 85 82 }); 86 83 }); -
trunk/LayoutTests/webgpu/whlsl-duplicate-types-should-not-produce-duplicate-ctors-expected.txt
r246550 r246631 1 PASS successfullyParsed is true2 3 TEST COMPLETE4 1 PASS resultsFloat32Array[0] is 2 5 2 PASS resultsFloat32Array[1] is 4 … … 10 7 PASS resultsFloat32Array[6] is 7 11 8 PASS resultsFloat32Array[7] is 8 9 PASS successfullyParsed is true 12 10 11 TEST COMPLETE 12 -
trunk/LayoutTests/webgpu/whlsl-duplicate-types-should-not-produce-duplicate-ctors.html
r246550 r246631 95 95 resultsBuffer.unmap(); 96 96 } 97 if (window.testRunner) 98 testRunner.waitUntilDone(); 97 window.jsTestIsAsync = true; 99 98 window.addEventListener("load", function() { 100 99 start().then(function() { 101 if (window.testRunner) 102 testRunner.notifyDone(); 100 finishJSTest(); 103 101 }, function() { 104 if (window.testRunner) 105 testRunner.notifyDone(); 102 finishJSTest(); 106 103 }); 107 104 }); -
trunk/LayoutTests/webgpu/whlsl-null-dereference-expected.txt
r246438 r246631 1 PASS successfullyParsed is true2 3 TEST COMPLETE4 1 PASS resultsFloat32Array[0] is 2 5 2 PASS resultsFloat32Array[1] is 4 … … 10 7 PASS resultsFloat32Array[6] is 7 11 8 PASS resultsFloat32Array[7] is 8 9 PASS successfullyParsed is true 12 10 11 TEST COMPLETE 12 -
trunk/LayoutTests/webgpu/whlsl-null-dereference.html
r246515 r246631 110 110 resultsBuffer.unmap(); 111 111 } 112 if (window.testRunner) 113 testRunner.waitUntilDone(); 112 window.jsTestIsAsync = true; 114 113 window.addEventListener("load", function() { 115 114 start().then(function() { 116 if (window.testRunner) 117 testRunner.notifyDone(); 115 finishJSTest(); 118 116 }, function() { 119 if (window.testRunner) 120 testRunner.notifyDone(); 117 finishJSTest(); 121 118 }); 122 119 }); -
trunk/LayoutTests/webgpu/whlsl-oob-access-expected.txt
r246438 r246631 1 PASS successfullyParsed is true2 3 TEST COMPLETE4 1 PASS resultsFloat32Array[0] is 2 5 2 PASS resultsFloat32Array[1] is 4 … … 10 7 PASS resultsFloat32Array[6] is 7 11 8 PASS resultsFloat32Array[7] is 8 9 PASS successfullyParsed is true 12 10 11 TEST COMPLETE 12 -
trunk/LayoutTests/webgpu/whlsl-oob-access.html
r246515 r246631 77 77 resultsBuffer.unmap(); 78 78 } 79 if (window.testRunner) 80 testRunner.waitUntilDone(); 79 window.jsTestIsAsync = true; 81 80 window.addEventListener("load", function() { 82 81 start().then(function() { 83 if (window.testRunner) 84 testRunner.notifyDone(); 82 finishJSTest(); 85 83 }, function() { 86 if (window.testRunner) 87 testRunner.notifyDone(); 84 finishJSTest(); 88 85 }); 89 86 }); -
trunk/LayoutTests/webgpu/whlsl-textures-getdimensions.html
r246630 r246631 8 8 const shaderSource = ` 9 9 [numthreads(1, 1, 1)] 10 compute void computeShader(device uint[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) { 11 buffer[0] = buffer.length; 10 compute void computeShader(Texture2D<float4> theTexture : register(t0), device uint[] theBuffer : register(u1)) { 11 uint width; 12 uint height; 13 uint numberOfLevels; 14 GetDimensions(theTexture, 0, &width, &height, &numberOfLevels); 15 theBuffer[0] = width; 16 theBuffer[1] = height; 17 theBuffer[2] = numberOfLevels; 12 18 } 13 19 `; 14 let result Uint32Array;20 let resultsUint32Array; 15 21 async function start() { 16 22 const adapter = await navigator.gpu.requestAdapter(); … … 20 26 const computeStage = {module: shaderModule, entryPoint: "computeShader"}; 21 27 22 const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "s torage-buffer"}]};28 const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "storage-buffer"}]}; 23 29 const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); 24 30 const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; … … 28 34 const computePipeline = device.createComputePipeline(computePipelineDescriptor); 29 35 30 const size = Uint32Array.BYTES_PER_ELEMENT * 1337; 36 const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED}; 37 const texture = device.createTexture(textureDescriptor); 38 const textureView = texture.createDefaultView(); 31 39 32 const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; 33 const buffer = device.createBuffer(bufferDescriptor); 34 const bufferArrayBuffer = await buffer.mapWriteAsync(); 35 const bufferUint32Array = new Uint32Array(bufferArrayBuffer); 36 bufferUint32Array[0] = 0; 37 buffer.unmap(); 38 39 const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; 40 const resultsBufferDescriptor = {size: Uint32Array.BYTES_PER_ELEMENT * 3, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.MAP_READ}; 40 41 const resultsBuffer = device.createBuffer(resultsBufferDescriptor); 41 42 42 const bufferBinding = {buffer: resultsBuffer, size };43 const bindGroupBinding = {binding: 0, resource: bufferBinding};44 const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};43 const bufferBinding = {buffer: resultsBuffer, size: Uint32Array.BYTES_PER_ELEMENT * 3}; 44 const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: bufferBinding}]; 45 const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings}; 45 46 const bindGroup = device.createBindGroup(bindGroupDescriptor); 46 47 47 48 const commandEncoder = device.createCommandEncoder(); // {} 48 commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, 1 * Uint32Array.BYTES_PER_ELEMENT);49 49 const computePassEncoder = commandEncoder.beginComputePass(); 50 50 computePassEncoder.setPipeline(computePipeline); … … 56 56 57 57 const resultsArrayBuffer = await resultsBuffer.mapReadAsync(); 58 resultUint32Array = new Uint32Array(resultsArrayBuffer); 59 shouldBe("resultUint32Array[0]", "1337"); 58 resultsUint32Array = new Uint32Array(resultsArrayBuffer); 59 shouldBe("resultsUint32Array[0]", "2"); 60 shouldBe("resultsUint32Array[1]", "2"); 61 shouldBe("resultsUint32Array[2]", "1"); 60 62 resultsBuffer.unmap(); 61 63 } 62 if (window.testRunner) 63 testRunner.waitUntilDone(); 64 window.jsTestIsAsync = true; 64 65 window.addEventListener("load", function() { 65 66 start().then(function() { 66 if (window.testRunner) 67 testRunner.notifyDone(); 68 }, function() { 69 if (window.testRunner) 70 testRunner.notifyDone(); 67 finishJSTest(); 68 }, function(e) { 69 finishJSTest(); 71 70 }); 72 71 }); -
trunk/Source/WebCore/ChangeLog
r246628 r246631 1 2019-06-19 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Hook up common texture functions 4 https://bugs.webkit.org/show_bug.cgi?id=198704 5 <rdar://problem/51668841> 6 7 Reviewed by Saam Barati. 8 9 This patch adds the Metal implementation of the Sample(), Load(), and GetDimensions() 10 texture functions. The implementation simply performs string concatenation to produce the 11 correct results, and adds many new native functions to the standard library. 12 13 We can't zero-fill texture types or sampler types, so this patch forbids default 14 constructors for those types. It also forbids those types to exist within arrays, array 15 references, or pointers, becuase an out-of-bounds access may cause us to try to zero-fill 16 them. 17 18 Tests: webgpu/whlsl-textures-getdimensions.html 19 webgpu/whlsl-textures-load.html 20 webgpu/whlsl-textures-sample.html 21 22 * Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h: Add some more introspection functions 23 so we can generate the necessary Metal functions for the appropriate texture types. 24 (WebCore::WHLSL::AST::NativeTypeDeclaration::isAtomic const): 25 (WebCore::WHLSL::AST::NativeTypeDeclaration::isTextureArray const): 26 (WebCore::WHLSL::AST::NativeTypeDeclaration::isDepthTexture const): 27 (WebCore::WHLSL::AST::NativeTypeDeclaration::isWritableTexture const): 28 (WebCore::WHLSL::AST::NativeTypeDeclaration::textureDimension const): 29 (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsTextureArray): 30 (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsDepthTexture): 31 (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsWritableTexture): 32 (WebCore::WHLSL::AST::NativeTypeDeclaration::setTextureDimension): 33 (WebCore::WHLSL::AST::NativeTypeDeclaration::isAtom const): Deleted. 34 * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: Native types can be passed into 35 entry points, too. 36 (WebCore::WHLSL::Metal::EntryPointScaffolding::resourceHelperTypes): 37 * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp: Entry points that return void don't need a 38 semantic. 39 (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit): 40 * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: Implement the functions. 41 (WebCore::WHLSL::Metal::vectorLength): 42 (WebCore::WHLSL::Metal::vectorInnerType): 43 (WebCore::WHLSL::Metal::vectorSuffix): 44 (WebCore::WHLSL::Metal::writeNativeFunction): 45 * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp: Textures come in two flavors: sample-able 46 and read/write-able. Make sure we produce the correct Metal types for them. 47 (WebCore::WHLSL::Metal::writeNativeType): 48 * Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp: We can't auto-initialize textures and 49 samplers. Therefore, this function needs to be able to fail. 50 (WebCore::WHLSL::AutoInitialize::visit): 51 (WebCore::WHLSL::autoInitializeVariables): 52 * Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.h: 53 * Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp: We can't auto-initialize textures, so users 54 shouldn't be able to either. 55 (WebCore::WHLSL::checkDuplicateFunctions): 56 * Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp: Added. Make sure textures and samplers can't 57 exist inside arrays, array references, or pointers. This is because out-of-bounds accesses may cause 58 us to attempt to zero-fill the inner type, but we can't zero-fill textures and samplers. 59 (WebCore::WHLSL::TextureReferencesChecker::TextureReferencesChecker): 60 (WebCore::WHLSL::Searcher::Searcher): 61 (WebCore::WHLSL::Searcher::found const): 62 (WebCore::WHLSL::Searcher::visit): 63 (WebCore::WHLSL::TextureReferencesChecker::containsTextureOrSampler): 64 (WebCore::WHLSL::TextureReferencesChecker::visit): 65 (WebCore::WHLSL::checkTextureReferences): 66 * Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.h. 67 * Modules/webgpu/WHLSL/WHLSLChecker.cpp: 68 * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp: Record more detailed information about texture types, 69 so we can emit correct Metal code. 70 (WebCore::WHLSL::Intrinsics::addFullTexture): 71 (WebCore::WHLSL::Intrinsics::addDepthTexture): 72 * Modules/webgpu/WHLSL/WHLSLIntrinsics.h: 73 (WebCore::WHLSL::Intrinsics::WTF_ARRAY_LENGTH): 74 * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp: Nested NameResolvers need to propagate their error. Also, 75 native functions with named arguments shouldn't be adding their arguments to the global scope. 76 (WebCore::WHLSL::NameResolver::visit): 77 * Modules/webgpu/WHLSL/WHLSLNameResolver.h: 78 * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: 79 (WebCore::WHLSL::prepareShared): 80 * Modules/webgpu/WHLSL/WHLSLProgram.h: 81 (WebCore::WHLSL::Program::intrinsics const): 82 * Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp: 83 * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt: Metal doesn't have writable depth textures. 84 * Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp: 85 * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: Don't generate default constructors for textures 86 or samplers. 87 (WebCore::WHLSL::synthesizeConstructors): 88 * Sources.txt: 89 * WebCore.xcodeproj/project.pbxproj: 90 * platform/graphics/gpu/GPUTexture.h: Make texture usages more clear. 91 (WebCore::GPUTexture::isSampled const): 92 (WebCore::GPUTexture::isStorage const): 93 * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm: Ditto. 94 (WebCore::GPUBindGroup::tryCreate): 95 * platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm: Ditto. 96 (WebCore::GPUProgrammablePassEncoder::setBindGroup): 97 * platform/graphics/gpu/cocoa/GPUTextureMetal.mm: Ditto. 98 (WebCore::mtlTextureUsageForGPUTextureUsageFlags): 99 1 100 2019-06-19 Justin Fan <justin_fan@apple.com> 2 101 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h
r246490 r246631 60 60 bool isNumber() const { return m_isNumber; } 61 61 bool isFloating() const { return m_isFloating; } 62 bool isAtom () const { return m_isAtomic; }62 bool isAtomic() const { return m_isAtomic; } 63 63 bool isVector() const { return m_isVector; } 64 64 bool isMatrix() const { return m_isMatrix; } 65 bool isOpaqueType() const { return m_isOpaqueType; } 65 66 bool isTexture() const { return m_isTexture; } 67 bool isTextureArray() const { return m_isTextureArray; } 68 bool isDepthTexture() const { return m_isDepthTexture; } 69 bool isWritableTexture() const { return m_isWritableTexture; } 70 uint textureDimension() const { return m_textureDimension; } 66 71 bool isSigned() const { return m_isSigned; } 67 72 const std::function<bool(int)>& canRepresentInteger() const { return m_canRepresentInteger; } … … 79 84 void setIsVector() { m_isVector = true; } 80 85 void setIsMatrix() { m_isMatrix = true; } 86 void setIsOpaqueType() { m_isOpaqueType = true; } 81 87 void setIsTexture() { m_isTexture = true; } 88 void setIsTextureArray() { m_isTextureArray = true; } 89 void setIsDepthTexture() { m_isDepthTexture = true; } 90 void setIsWritableTexture() { m_isWritableTexture = true; } 91 void setTextureDimension(uint textureDimension) { m_textureDimension = textureDimension; } 82 92 void setIsSigned() { m_isSigned = true; } 83 93 void setCanRepresentInteger(std::function<bool(int)>&& canRepresent) { m_canRepresentInteger = WTFMove(canRepresent); } … … 98 108 std::function<int64_t(unsigned)> m_formatValueFromUnsignedInteger; 99 109 std::function<void(const std::function<bool(int64_t)>&)> m_iterateAllValues; 110 uint m_textureDimension { 0 }; 100 111 bool m_isInt { false }; 101 112 bool m_isNumber { false }; … … 104 115 bool m_isVector { false }; 105 116 bool m_isMatrix { false }; 117 bool m_isOpaqueType { false }; 106 118 bool m_isTexture { false }; 119 bool m_isTextureArray { false }; 120 bool m_isDepthTexture { false }; 121 bool m_isWritableTexture { false }; 107 122 bool m_isSigned { false }; 108 123 }; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp
r246628 r246631 150 150 if (iterator == m_resourceMap.end()) 151 151 continue; 152 auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; 153 auto& referenceType = downcast<AST::ReferenceType>(unnamedType); 154 auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); 155 auto addressSpace = toString(referenceType.addressSpace()); 156 auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; 157 auto index = m_namedBindGroups[i].namedBindings[j].index; 158 structItems.append(std::make_pair(index, makeString(" ", addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];\n"))); 159 if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) 160 structItems.append(std::make_pair(lengthInformation->index, makeString("uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];"))); 152 auto& type = m_entryPointItems.inputs[iterator->value].unnamedType->unifyNode(); 153 if (is<AST::UnnamedType>(type) && is<AST::ReferenceType>(downcast<AST::UnnamedType>(type))) { 154 auto& referenceType = downcast<AST::ReferenceType>(downcast<AST::UnnamedType>(type)); 155 auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); 156 auto addressSpace = toString(referenceType.addressSpace()); 157 auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; 158 auto index = m_namedBindGroups[i].namedBindings[j].index; 159 structItems.append(std::make_pair(index, makeString(addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];"))); 160 if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) 161 structItems.append(std::make_pair(lengthInformation->index, makeString("uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];"))); 162 } else if (is<AST::NamedType>(type) && is<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type))) { 163 auto& namedType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type)); 164 auto mangledTypeName = m_typeNamer.mangledNameForType(namedType); 165 auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; 166 auto index = m_namedBindGroups[i].namedBindings[j].index; 167 structItems.append(std::make_pair(index, makeString(mangledTypeName, ' ', elementName, " [[id(", index, ")]];"))); 168 } 161 169 } 162 170 std::sort(structItems.begin(), structItems.end(), [](const std::pair<unsigned, String>& left, const std::pair<unsigned, String>& right) { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp
r246579 r246631 559 559 ASSERT(iterator != m_functionMapping.end()); 560 560 auto variableName = generateNextVariableName(); 561 m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(callExpression.resolvedType()), ' ', variableName, " = ", iterator->value, '(')); 561 if (!matches(callExpression.resolvedType(), m_intrinsics.voidType())) 562 m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(callExpression.resolvedType()), ' ', variableName, " = ")); 563 m_stringBuilder.append(makeString(iterator->value, '(')); 562 564 for (size_t i = 0; i < argumentNames.size(); ++i) { 563 565 if (i) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp
r246579 r246631 82 82 } 83 83 84 static int vectorLength(AST::NativeTypeDeclaration& nativeTypeDeclaration) 85 { 86 int vectorLength = 1; 87 if (!nativeTypeDeclaration.typeArguments().isEmpty()) { 88 ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); 89 ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1])); 90 vectorLength = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]).integerLiteral().value(); 91 } 92 return vectorLength; 93 } 94 95 static AST::NamedType& vectorInnerType(AST::NativeTypeDeclaration& nativeTypeDeclaration) 96 { 97 if (nativeTypeDeclaration.typeArguments().isEmpty()) 98 return nativeTypeDeclaration; 99 100 ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); 101 ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); 102 return WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])->resolvedType(); 103 } 104 105 static const char* vectorSuffix(int vectorLength) 106 { 107 switch (vectorLength) { 108 case 1: 109 return ""; 110 case 2: 111 return "2"; 112 case 3: 113 return "3"; 114 default: 115 ASSERT(vectorLength == 4); 116 return "4"; 117 } 118 } 119 84 120 String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclaration, String& outputFunctionName, Intrinsics& intrinsics, TypeNamer& typeNamer, const char* memsetZeroFunctionName) 85 121 { … … 103 139 if (is<AST::NativeTypeDeclaration>(parameterNamedType)) { 104 140 auto& parameterNativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(parameterNamedType); 105 if (parameterNativeTypeDeclaration.isAtom ()) {141 if (parameterNativeTypeDeclaration.isAtomic()) { 106 142 stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameterName, " x) {\n")); 107 143 stringBuilder.append(" return atomic_load_explicit(&x, memory_order_relaxed);\n"); … … 390 426 391 427 if (nativeFunctionDeclaration.name() == "Sample") { 392 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this 393 notImplemented(); 428 ASSERT(nativeFunctionDeclaration.parameters().size() == 3 || nativeFunctionDeclaration.parameters().size() == 4); 429 430 auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); 431 auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode())); 432 auto locationVectorLength = vectorLength(locationType); 433 auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode())); 434 auto returnVectorLength = vectorLength(returnType); 435 436 auto metalParameter1Name = typeNamer.mangledNameForType(textureType); 437 auto metalParameter2Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); 438 auto metalParameter3Name = typeNamer.mangledNameForType(locationType); 439 String metalParameter4Name; 440 if (nativeFunctionDeclaration.parameters().size() == 4) 441 metalParameter4Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[3]->type()); 442 auto metalReturnName = typeNamer.mangledNameForType(returnType); 443 stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " theSampler, ", metalParameter3Name, " location")); 444 if (!metalParameter4Name.isNull()) 445 stringBuilder.append(makeString(", ", metalParameter4Name, " offset")); 446 stringBuilder.append(") {\n"); 447 stringBuilder.append(" return theTexture.sample(theSampler, "); 448 if (textureType.isTextureArray()) { 449 ASSERT(locationVectorLength > 1); 450 stringBuilder.append(makeString("location.", "xyzw"_str.substring(0, locationVectorLength - 1), ", location.", "xyzw"_str.substring(locationVectorLength - 1, 1))); 451 } else 452 stringBuilder.append("location"); 453 if (!metalParameter4Name.isNull()) 454 stringBuilder.append(", offset"); 455 stringBuilder.append(")"); 456 if (!textureType.isDepthTexture()) 457 stringBuilder.append(makeString(".", "xyzw"_str.substring(0, returnVectorLength))); 458 stringBuilder.append(";\n"); 459 stringBuilder.append("}\n"); 460 return stringBuilder.toString(); 394 461 } 395 462 396 463 if (nativeFunctionDeclaration.name() == "Load") { 397 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this 398 notImplemented(); 464 ASSERT(nativeFunctionDeclaration.parameters().size() == 2); 465 466 auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); 467 auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[1]->type()->unifyNode())); 468 auto locationVectorLength = vectorLength(locationType); 469 auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode())); 470 auto returnVectorLength = vectorLength(returnType); 471 472 auto metalParameter1Name = typeNamer.mangledNameForType(textureType); 473 auto metalParameter2Name = typeNamer.mangledNameForType(locationType); 474 auto metalReturnName = typeNamer.mangledNameForType(returnType); 475 stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " location) {\n")); 476 if (textureType.isTextureArray()) { 477 ASSERT(locationVectorLength > 1); 478 String dimensions[] = { "width"_str, "height"_str, "depth"_str }; 479 for (int i = 0; i < locationVectorLength - 1; ++i) { 480 auto suffix = "xyzw"_str.substring(i, 1); 481 stringBuilder.append(makeString(" if (location.", suffix, " < 0 || static_cast<uint32_t>(location.", suffix, ") >= theTexture.get_", dimensions[i], "()) return ", metalReturnName, "(0);\n")); 482 } 483 auto suffix = "xyzw"_str.substring(locationVectorLength - 1, 1); 484 stringBuilder.append(makeString(" if (location.", suffix, " < 0 || static_cast<uint32_t>(location.", suffix, ") >= theTexture.get_array_size()) return ", metalReturnName, "(0);\n")); 485 } else { 486 if (locationVectorLength == 1) 487 stringBuilder.append(makeString(" if (location < 0 || static_cast<uint32_t>(location) >= theTexture.get_width()) return ", metalReturnName, "(0);\n")); 488 else { 489 stringBuilder.append(makeString(" if (location.x < 0 || static_cast<uint32_t>(location.x) >= theTexture.get_width()) return ", metalReturnName, "(0);\n")); 490 stringBuilder.append(makeString(" if (location.y < 0 || static_cast<uint32_t>(location.y) >= theTexture.get_height()) return ", metalReturnName, "(0);\n")); 491 if (locationVectorLength >= 3) 492 stringBuilder.append(makeString(" if (location.z < 0 || static_cast<uint32_t>(location.z) >= theTexture.get_depth()) return ", metalReturnName, "(0);\n")); 493 } 494 } 495 stringBuilder.append(" return theTexture.read("); 496 if (textureType.isTextureArray()) { 497 ASSERT(locationVectorLength > 1); 498 stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength - 1), "(location.", "xyzw"_str.substring(0, locationVectorLength - 1), "), uint(location.", "xyzw"_str.substring(locationVectorLength - 1, 1), ")")); 499 } else 500 stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength), "(location)")); 501 stringBuilder.append(")"); 502 if (!textureType.isDepthTexture()) 503 stringBuilder.append(makeString(".", "xyzw"_str.substring(0, returnVectorLength))); 504 stringBuilder.append(";\n"); 505 stringBuilder.append("}\n"); 506 return stringBuilder.toString(); 399 507 } 400 508 401 509 if (nativeFunctionDeclaration.name() == "GetDimensions") { 402 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this 403 notImplemented(); 510 auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); 511 512 size_t index = 1; 513 if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) 514 ++index; 515 auto widthTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); 516 ++index; 517 String heightTypeName; 518 if (textureType.textureDimension() >= 2) { 519 heightTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); 520 ++index; 521 } 522 String depthTypeName; 523 if (textureType.textureDimension() >= 3) { 524 depthTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); 525 ++index; 526 } 527 String elementsTypeName; 528 if (textureType.isTextureArray()) { 529 elementsTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); 530 ++index; 531 } 532 String numberOfLevelsTypeName; 533 if (!textureType.isWritableTexture()) { 534 numberOfLevelsTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); 535 ++index; 536 } 537 ASSERT(index == nativeFunctionDeclaration.parameters().size()); 538 539 auto metalParameter1Name = typeNamer.mangledNameForType(textureType); 540 stringBuilder.append(makeString("void ", outputFunctionName, '(', metalParameter1Name, " theTexture")); 541 if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) 542 stringBuilder.append(", uint mipLevel"); 543 stringBuilder.append(makeString(", ", widthTypeName, " width")); 544 if (!heightTypeName.isNull()) 545 stringBuilder.append(makeString(", ", heightTypeName, " height")); 546 if (!depthTypeName.isNull()) 547 stringBuilder.append(makeString(", ", depthTypeName, " depth")); 548 if (!elementsTypeName.isNull()) 549 stringBuilder.append(makeString(", ", elementsTypeName, " elements")); 550 if (!numberOfLevelsTypeName.isNull()) 551 stringBuilder.append(makeString(", ", numberOfLevelsTypeName, " numberOfLevels")); 552 stringBuilder.append(") {\n"); 553 stringBuilder.append(" if (width)\n"); 554 stringBuilder.append(" *width = theTexture.get_width("); 555 if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) 556 stringBuilder.append("mipLevel"); 557 stringBuilder.append(");\n"); 558 if (!heightTypeName.isNull()) { 559 stringBuilder.append(" if (height)\n"); 560 stringBuilder.append(" *height = theTexture.get_height("); 561 if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) 562 stringBuilder.append("mipLevel"); 563 stringBuilder.append(");\n"); 564 } 565 if (!depthTypeName.isNull()) { 566 stringBuilder.append(" if (depth)\n"); 567 stringBuilder.append(" *depth = theTexture.get_depth("); 568 if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) 569 stringBuilder.append("mipLevel"); 570 stringBuilder.append(");\n"); 571 } 572 if (!elementsTypeName.isNull()) { 573 stringBuilder.append(" if (elements)\n"); 574 stringBuilder.append(" *elements = theTexture.get_array_size();\n"); 575 } 576 if (!numberOfLevelsTypeName.isNull()) { 577 stringBuilder.append(" if (numberOfLevels)\n"); 578 stringBuilder.append(" *numberOfLevels = theTexture.get_num_mip_levels();\n"); 579 } 580 stringBuilder.append("}\n"); 581 return stringBuilder.toString(); 404 582 } 405 583 … … 440 618 441 619 if (nativeFunctionDeclaration.name() == "Store") { 442 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this 443 notImplemented(); 620 ASSERT(nativeFunctionDeclaration.parameters().size() == 3); 621 622 auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); 623 auto& itemType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[1]->type()->unifyNode())); 624 auto& itemVectorInnerType = vectorInnerType(itemType); 625 auto itemVectorLength = vectorLength(itemType); 626 auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode())); 627 auto locationVectorLength = vectorLength(locationType); 628 629 auto metalParameter1Name = typeNamer.mangledNameForType(textureType); 630 auto metalParameter2Name = typeNamer.mangledNameForType(itemType); 631 auto metalParameter3Name = typeNamer.mangledNameForType(locationType); 632 auto metalInnerTypeName = typeNamer.mangledNameForType(itemVectorInnerType); 633 stringBuilder.append(makeString("void ", outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " item, ", metalParameter3Name, " location) {\n")); 634 if (textureType.isTextureArray()) { 635 ASSERT(locationVectorLength > 1); 636 String dimensions[] = { "width"_str, "height"_str, "depth"_str }; 637 for (int i = 0; i < locationVectorLength - 1; ++i) { 638 auto suffix = "xyzw"_str.substring(i, 1); 639 stringBuilder.append(makeString(" if (location.", suffix, " >= theTexture.get_", dimensions[i], "()) return;\n")); 640 } 641 auto suffix = "xyzw"_str.substring(locationVectorLength - 1, 1); 642 stringBuilder.append(makeString(" if (location.", suffix, " >= theTexture.get_array_size()) return;\n")); 643 } else { 644 if (locationVectorLength == 1) 645 stringBuilder.append(makeString(" if (location >= theTexture.get_width()) return;\n")); 646 else { 647 stringBuilder.append(makeString(" if (location.x >= theTexture.get_width()) return;\n")); 648 stringBuilder.append(makeString(" if (location.y >= theTexture.get_height()) return;\n")); 649 if (locationVectorLength >= 3) 650 stringBuilder.append(makeString(" if (location.z >= theTexture.get_depth()) return;\n")); 651 } 652 } 653 stringBuilder.append(makeString(" theTexture.write(vec<", metalInnerTypeName, ", 4>(item")); 654 for (int i = 0; i < 4 - itemVectorLength; ++i) 655 stringBuilder.append(", 0"); 656 stringBuilder.append("), "); 657 if (textureType.isTextureArray()) { 658 ASSERT(locationVectorLength > 1); 659 stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength - 1), "(location.", "xyzw"_str.substring(0, locationVectorLength - 1), "), uint(location.", "xyzw"_str.substring(locationVectorLength - 1, 1), ")")); 660 } else 661 stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength), "(location)")); 662 stringBuilder.append(");\n"); 663 stringBuilder.append("}\n"); 664 return stringBuilder.toString(); 444 665 } 445 666 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp
r246428 r246631 181 181 if (nativeTypeDeclaration.name() == "TextureDepth2D") 182 182 return "depth2d"_str; 183 if (nativeTypeDeclaration.name() == "RWTextureDepth2D")184 return "depth2d"_str;185 183 if (nativeTypeDeclaration.name() == "TextureDepth2DArray") 186 return "depth2d_array"_str;187 if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray")188 184 return "depth2d_array"_str; 189 185 ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); … … 240 236 return "float"_str; 241 237 })(); 242 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Specify the second template argument to Metal texture types. 243 return makeString(prefix, '<', innerType, '>'); 238 auto isReadWrite = nativeTypeDeclaration.name() == "RWTexture1D" 239 || nativeTypeDeclaration.name() == "RWTexture1DArray" 240 || nativeTypeDeclaration.name() == "RWTexture2D" 241 || nativeTypeDeclaration.name() == "RWTexture2DArray" 242 || nativeTypeDeclaration.name() == "RWTexture3D"; 243 return makeString(prefix, '<', innerType, ", ", isReadWrite ? "access::read_write" : "access::sample", '>'); 244 244 } 245 245 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp
r246273 r246631 76 76 Vector<std::reference_wrapper<ResolvingType>> argumentTypes; 77 77 auto* function = resolveFunctionOverload(*callExpression->overloads(), argumentTypes, type); 78 RELEASE_ASSERT(function); 78 if (!function) { 79 setError(); 80 return; 81 } 79 82 callExpression->setFunction(*function); 80 83 … … 86 89 }; 87 90 88 voidautoInitializeVariables(Program& program)91 bool autoInitializeVariables(Program& program) 89 92 { 90 93 AutoInitialize autoInitialize(program.nameContext()); 91 94 autoInitialize.Visitor::visit(program); 95 return !autoInitialize.error(); 92 96 } 93 97 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.h
r246273 r246631 34 34 class Program; 35 35 36 voidautoInitializeVariables(Program&);36 bool autoInitializeVariables(Program&); 37 37 38 38 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp
r246439 r246631 142 142 && matches(*function.parameters()[0]->type(), *function.parameters()[1]->type())) 143 143 return false; 144 else if (function.isCast() && function.parameters().isEmpty()) { 145 auto& unifyNode = function.type().unifyNode(); 146 if (is<AST::NamedType>(unifyNode) && is<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(unifyNode))) { 147 auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(unifyNode)); 148 if (nativeTypeDeclaration.isOpaqueType()) 149 return false; 150 } 151 } 144 152 145 153 return true; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.h
r246630 r246631 34 34 class Program; 35 35 36 void autoInitializeVariables(Program&);36 bool checkTextureReferences(Program&); 37 37 38 38 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
r246625 r246631 453 453 } 454 454 455 ~Checker() = default;455 virtual ~Checker() = default; 456 456 457 457 void visit(Program&) override; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp
r246428 r246631 273 273 nativeTypeDeclaration.setIsAtomic(); 274 274 m_atomicUintType = &nativeTypeDeclaration; 275 } else if (nativeTypeDeclaration.name() == "sampler") 275 } else if (nativeTypeDeclaration.name() == "sampler") { 276 276 m_samplerType = &nativeTypeDeclaration; 277 nativeTypeDeclaration.setIsOpaqueType(); 278 } 277 279 else 278 280 ASSERT_NOT_REACHED(); … … 370 372 ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_textureInnerTypeNames)); 371 373 nativeTypeDeclaration.setIsTexture(); 374 nativeTypeDeclaration.setIsOpaqueType(); 375 if (nativeTypeDeclaration.name() == "Texture1DArray" || nativeTypeDeclaration.name() == "RWTexture1DArray" || nativeTypeDeclaration.name() == "Texture2DArray" || nativeTypeDeclaration.name() == "RWTexture2DArray") 376 nativeTypeDeclaration.setIsTextureArray(); 377 if (nativeTypeDeclaration.name() == "RWTexture1D" || nativeTypeDeclaration.name() == "RWTexture2D" || nativeTypeDeclaration.name() == "RWTexture3D" || nativeTypeDeclaration.name() == "RWTexture1DArray" || nativeTypeDeclaration.name() == "RWTexture2DArray") 378 nativeTypeDeclaration.setIsWritableTexture(); 379 if (nativeTypeDeclaration.name() == "Texture1D" || nativeTypeDeclaration.name() == "RWTexture1D" || nativeTypeDeclaration.name() == "Texture1DArray" || nativeTypeDeclaration.name() == "RWTexture1DArray") 380 nativeTypeDeclaration.setTextureDimension(1); 381 if (nativeTypeDeclaration.name() == "Texture2D" || nativeTypeDeclaration.name() == "RWTexture2D" || nativeTypeDeclaration.name() == "TextureCube" || nativeTypeDeclaration.name() == "Texture2DArray" || nativeTypeDeclaration.name() == "RWTexture2DArray") 382 nativeTypeDeclaration.setTextureDimension(2); 383 if (nativeTypeDeclaration.name() == "Texture3D" || nativeTypeDeclaration.name() == "RWTexture3D") 384 nativeTypeDeclaration.setTextureDimension(3); 372 385 m_fullTextures[textureTypeIndex][innerTypeIndex][vectorLength - 1] = &nativeTypeDeclaration; 373 386 return true; … … 379 392 if (nativeTypeDeclaration.name() == "TextureDepth2D") 380 393 texture = m_textureDepth2D; 381 else if (nativeTypeDeclaration.name() == "RWTextureDepth2D")382 texture = m_rwTextureDepth2D;383 394 else if (nativeTypeDeclaration.name() == "TextureDepth2DArray") 384 395 texture = m_textureDepth2DArray; 385 else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray")386 texture = m_rwTextureDepth2DArray;387 396 else { 388 397 ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); … … 392 401 ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)); 393 402 nativeTypeDeclaration.setIsTexture(); 403 nativeTypeDeclaration.setIsOpaqueType(); 404 if (texture == m_textureDepth2DArray) 405 nativeTypeDeclaration.setIsTextureArray(); 406 nativeTypeDeclaration.setTextureDimension(2); 407 nativeTypeDeclaration.setIsDepthTexture(); 394 408 texture[innerTypeIndex] = &nativeTypeDeclaration; 395 409 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h
r246428 r246631 264 264 AST::NativeTypeDeclaration* m_matrixFloat[3][3] {{ 0 }}; 265 265 266 static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture 1DArray", "RWTexture1DArray", "Texture2D", "RWTexture2D", "Texture2DArray", "RWTexture2DArray", "Texture3D", "RWTexture3D", "TextureCube" };266 static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture2D", "RWTexture2D", "Texture3D", "RWTexture3D", "TextureCube", "Texture1DArray", "RWTexture1DArray", "Texture2DArray", "RWTexture2DArray" }; 267 267 268 268 static constexpr const char* m_textureInnerTypeNames[] = { "uchar", "ushort", "uint", "char", "short", "int", "half", "float" }; … … 273 273 274 274 AST::NativeTypeDeclaration* m_textureDepth2D[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; 275 AST::NativeTypeDeclaration* m_rwTextureDepth2D[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 };276 275 AST::NativeTypeDeclaration* m_textureDepth2DArray[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; 277 AST::NativeTypeDeclaration* m_rwTextureDepth2DArray[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 };278 276 AST::NativeTypeDeclaration* m_textureDepthCube[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; 279 277 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp
r246550 r246631 59 59 NameResolver::NameResolver(NameResolver& parentResolver, NameContext& nameContext) 60 60 : m_nameContext(nameContext) 61 , m_parentNameResolver(&parentResolver) 61 62 { 62 63 m_isResolvingCalls = parentResolver.m_isResolvingCalls; 63 64 setCurrentFunctionDefinition(parentResolver.m_currentFunction); 65 } 66 67 NameResolver::~NameResolver() 68 { 69 if (error() && m_parentNameResolver) 70 m_parentNameResolver->setError(); 64 71 } 65 72 … … 117 124 NameResolver newNameResolver(*this, nameContext); 118 125 newNameResolver.checkErrorAndVisit(ifStatement.body()); 119 if (ifStatement.elseBody()) { 126 if (newNameResolver.error()) 127 setError(); 128 else if (ifStatement.elseBody()) { 120 129 NameContext nameContext(&m_nameContext); 121 130 NameResolver newNameResolver(*this, nameContext); … … 259 268 } 260 269 270 void NameResolver::visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) 271 { 272 NameContext newNameContext(&m_nameContext); 273 NameResolver newNameResolver(newNameContext); 274 newNameResolver.Visitor::visit(nativeFunctionDeclaration); 275 } 276 261 277 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198167 Make sure all the names have been resolved. 262 278 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
r246550 r246631 43 43 NameResolver(NameResolver&, NameContext&); 44 44 45 virtual ~NameResolver() = default;45 virtual ~NameResolver(); 46 46 47 47 void visit(AST::FunctionDefinition&) override; … … 55 55 56 56 private: 57 void visit(AST::NativeFunctionDeclaration&) override; 57 58 void visit(AST::TypeReference&) override; 58 59 void visit(AST::Block&) override; … … 72 73 HashSet<AST::TypeReference*> m_typeReferences; 73 74 AST::FunctionDefinition* m_currentFunction { nullptr }; 75 NameResolver* m_parentNameResolver { nullptr }; 74 76 bool m_isResolvingCalls { false }; 75 77 }; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
r246550 r246631 32 32 #include "WHLSLAutoInitializeVariables.h" 33 33 #include "WHLSLCheckDuplicateFunctions.h" 34 #include "WHLSLCheckTextureReferences.h" 34 35 #include "WHLSLChecker.h" 35 36 #include "WHLSLComputeDimensions.h" … … 134 135 135 136 checkLiteralTypes(program); 136 autoInitializeVariables(program); 137 RUN_PASS(checkTextureReferences, program); 138 RUN_PASS(autoInitializeVariables, program); 137 139 resolveProperties(program); 138 140 findHighZombies(program); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h
r240020 r246631 87 87 NameContext& nameContext() { return m_nameContext; } 88 88 Intrinsics& intrinsics() { return m_intrinsics; } 89 const Intrinsics& intrinsics() const { return m_intrinsics; } 89 90 Vector<UniqueRef<AST::TypeDefinition>>& typeDefinitions() { return m_typeDefinitions; } 90 91 Vector<UniqueRef<AST::StructureDefinition>>& structureDefinitions() { return m_structureDefinitions; } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp
r245680 r246631 42 42 class RecursiveTypeChecker : public Visitor { 43 43 public: 44 ~RecursiveTypeChecker() = default;44 virtual ~RecursiveTypeChecker() = default; 45 45 46 46 void visit(AST::TypeDefinition&) override; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt
r246579 r246631 130 130 native typedef Texture1D<float3>; 131 131 native typedef Texture1D<float4>; 132 native typedef RWTexture1D<ushort>;133 native typedef RWTexture1D<ushort2>;134 native typedef RWTexture1D<ushort3>;135 native typedef RWTexture1D<ushort4>;136 native typedef RWTexture1D<uint>;137 native typedef RWTexture1D<uint2>;138 native typedef RWTexture1D<uint3>;139 native typedef RWTexture1D<uint4>;140 native typedef RWTexture1D<short>;141 native typedef RWTexture1D<short2>;142 native typedef RWTexture1D<short3>;143 native typedef RWTexture1D<short4>;144 native typedef RWTexture1D<int>;145 native typedef RWTexture1D<int2>;146 native typedef RWTexture1D<int3>;147 native typedef RWTexture1D<int4>;148 native typedef RWTexture1D<half>;149 native typedef RWTexture1D<half2>;150 native typedef RWTexture1D<half3>;151 native typedef RWTexture1D<half4>;152 native typedef RWTexture1D<float>;153 native typedef RWTexture1D<float2>;154 native typedef RWTexture1D<float3>;155 native typedef RWTexture1D<float4>;156 132 native typedef Texture1DArray<ushort>; 157 133 native typedef Texture1DArray<ushort2>; … … 178 154 native typedef Texture1DArray<float3>; 179 155 native typedef Texture1DArray<float4>; 180 native typedef RWTexture1DArray<ushort>;181 native typedef RWTexture1DArray<ushort2>;182 native typedef RWTexture1DArray<ushort3>;183 native typedef RWTexture1DArray<ushort4>;184 native typedef RWTexture1DArray<uint>;185 native typedef RWTexture1DArray<uint2>;186 native typedef RWTexture1DArray<uint3>;187 native typedef RWTexture1DArray<uint4>;188 native typedef RWTexture1DArray<short>;189 native typedef RWTexture1DArray<short2>;190 native typedef RWTexture1DArray<short3>;191 native typedef RWTexture1DArray<short4>;192 native typedef RWTexture1DArray<int>;193 native typedef RWTexture1DArray<int2>;194 native typedef RWTexture1DArray<int3>;195 native typedef RWTexture1DArray<int4>;196 native typedef RWTexture1DArray<half>;197 native typedef RWTexture1DArray<half2>;198 native typedef RWTexture1DArray<half3>;199 native typedef RWTexture1DArray<half4>;200 native typedef RWTexture1DArray<float>;201 native typedef RWTexture1DArray<float2>;202 native typedef RWTexture1DArray<float3>;203 native typedef RWTexture1DArray<float4>;204 156 native typedef Texture2D<ushort>; 205 157 native typedef Texture2D<ushort2>; … … 226 178 native typedef Texture2D<float3>; 227 179 native typedef Texture2D<float4>; 228 native typedef RWTexture2D<ushort>;229 native typedef RWTexture2D<ushort2>;230 native typedef RWTexture2D<ushort3>;231 native typedef RWTexture2D<ushort4>;232 native typedef RWTexture2D<uint>;233 native typedef RWTexture2D<uint2>;234 native typedef RWTexture2D<uint3>;235 native typedef RWTexture2D<uint4>;236 native typedef RWTexture2D<short>;237 native typedef RWTexture2D<short2>;238 native typedef RWTexture2D<short3>;239 native typedef RWTexture2D<short4>;240 native typedef RWTexture2D<int>;241 native typedef RWTexture2D<int2>;242 native typedef RWTexture2D<int3>;243 native typedef RWTexture2D<int4>;244 native typedef RWTexture2D<half>;245 native typedef RWTexture2D<half2>;246 native typedef RWTexture2D<half3>;247 native typedef RWTexture2D<half4>;248 native typedef RWTexture2D<float>;249 native typedef RWTexture2D<float2>;250 native typedef RWTexture2D<float3>;251 native typedef RWTexture2D<float4>;252 180 native typedef Texture2DArray<ushort>; 253 181 native typedef Texture2DArray<ushort2>; … … 274 202 native typedef Texture2DArray<float3>; 275 203 native typedef Texture2DArray<float4>; 276 native typedef RWTexture2DArray<ushort>;277 native typedef RWTexture2DArray<ushort2>;278 native typedef RWTexture2DArray<ushort3>;279 native typedef RWTexture2DArray<ushort4>;280 native typedef RWTexture2DArray<uint>;281 native typedef RWTexture2DArray<uint2>;282 native typedef RWTexture2DArray<uint3>;283 native typedef RWTexture2DArray<uint4>;284 native typedef RWTexture2DArray<short>;285 native typedef RWTexture2DArray<short2>;286 native typedef RWTexture2DArray<short3>;287 native typedef RWTexture2DArray<short4>;288 native typedef RWTexture2DArray<int>;289 native typedef RWTexture2DArray<int2>;290 native typedef RWTexture2DArray<int3>;291 native typedef RWTexture2DArray<int4>;292 native typedef RWTexture2DArray<half>;293 native typedef RWTexture2DArray<half2>;294 native typedef RWTexture2DArray<half3>;295 native typedef RWTexture2DArray<half4>;296 native typedef RWTexture2DArray<float>;297 native typedef RWTexture2DArray<float2>;298 native typedef RWTexture2DArray<float3>;299 native typedef RWTexture2DArray<float4>;300 204 native typedef Texture3D<ushort>; 301 205 native typedef Texture3D<ushort2>; … … 322 226 native typedef Texture3D<float3>; 323 227 native typedef Texture3D<float4>; 324 native typedef RWTexture3D<ushort>;325 native typedef RWTexture3D<ushort2>;326 native typedef RWTexture3D<ushort3>;327 native typedef RWTexture3D<ushort4>;328 native typedef RWTexture3D<uint>;329 native typedef RWTexture3D<uint2>;330 native typedef RWTexture3D<uint3>;331 native typedef RWTexture3D<uint4>;332 native typedef RWTexture3D<short>;333 native typedef RWTexture3D<short2>;334 native typedef RWTexture3D<short3>;335 native typedef RWTexture3D<short4>;336 native typedef RWTexture3D<int>;337 native typedef RWTexture3D<int2>;338 native typedef RWTexture3D<int3>;339 native typedef RWTexture3D<int4>;340 native typedef RWTexture3D<half>;341 native typedef RWTexture3D<half2>;342 native typedef RWTexture3D<half3>;343 native typedef RWTexture3D<half4>;344 native typedef RWTexture3D<float>;345 native typedef RWTexture3D<float2>;346 native typedef RWTexture3D<float3>;347 native typedef RWTexture3D<float4>;348 228 native typedef TextureCube<ushort>; 349 229 native typedef TextureCube<ushort2>; … … 371 251 native typedef TextureCube<float4>; 372 252 native typedef TextureDepth2D<float>; 373 native typedef RWTextureDepth2D<float>;374 253 native typedef TextureDepth2DArray<float>; 375 native typedef RWTextureDepth2DArray<float>;376 254 native typedef TextureDepthCube<float>; 377 255 … … 849 727 } 850 728 729 operator float2(float x, float y) { 730 float2 result; 731 result.x = x; 732 result.y = y; 733 return result; 734 } 735 736 operator int3(int x, int y, int z) { 737 int3 result; 738 result.x = x; 739 result.y = y; 740 result.z = z; 741 return result; 742 } 743 744 operator int2(int x, int y) { 745 int2 result; 746 result.x = x; 747 result.y = y; 748 return result; 749 } 750 751 operator uint2(uint x, uint y) { 752 uint2 result; 753 result.x = x; 754 result.y = y; 755 return result; 756 } 757 758 native ushort Sample(Texture1D<ushort>, sampler, float location); 759 native ushort Sample(Texture1DArray<ushort>, sampler, float2 location); 760 native ushort Sample(Texture2D<ushort>, sampler, float2 location); 761 native ushort Sample(Texture2D<ushort>, sampler, float2 location, int2 offset); 762 native ushort Sample(Texture2DArray<ushort>, sampler, float3 location); 763 native ushort Sample(Texture2DArray<ushort>, sampler, float3 location, int2 offset); 764 native ushort Sample(Texture3D<ushort>, sampler, float3 location); 765 native ushort Sample(Texture3D<ushort>, sampler, float3 location, int3 offset); 766 native ushort Sample(TextureCube<ushort>, sampler, float3 location); 767 native ushort2 Sample(Texture1D<ushort2>, sampler, float location); 768 native ushort2 Sample(Texture1DArray<ushort2>, sampler, float2 location); 769 native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location); 770 native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location, int2 offset); 771 native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location); 772 native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location, int2 offset); 773 native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location); 774 native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location, int3 offset); 775 native ushort2 Sample(TextureCube<ushort2>, sampler, float3 location); 776 native ushort3 Sample(Texture1D<ushort3>, sampler, float location); 777 native ushort3 Sample(Texture1DArray<ushort3>, sampler, float2 location); 778 native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location); 779 native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location, int2 offset); 780 native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location); 781 native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location, int2 offset); 782 native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location); 783 native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location, int3 offset); 784 native ushort3 Sample(TextureCube<ushort3>, sampler, float3 location); 785 native ushort4 Sample(Texture1D<ushort4>, sampler, float location); 786 native ushort4 Sample(Texture1DArray<ushort4>, sampler, float2 location); 787 native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location); 788 native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location, int2 offset); 789 native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location); 790 native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location, int2 offset); 791 native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location); 792 native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location, int3 offset); 793 native ushort4 Sample(TextureCube<ushort4>, sampler, float3 location); 794 native uint Sample(Texture1D<uint>, sampler, float location); 795 native uint Sample(Texture1DArray<uint>, sampler, float2 location); 796 native uint Sample(Texture2D<uint>, sampler, float2 location); 797 native uint Sample(Texture2D<uint>, sampler, float2 location, int2 offset); 798 native uint Sample(Texture2DArray<uint>, sampler, float3 location); 799 native uint Sample(Texture2DArray<uint>, sampler, float3 location, int2 offset); 800 native uint Sample(Texture3D<uint>, sampler, float3 location); 801 native uint Sample(Texture3D<uint>, sampler, float3 location, int3 offset); 802 native uint Sample(TextureCube<uint>, sampler, float3 location); 803 native uint2 Sample(Texture1D<uint2>, sampler, float location); 804 native uint2 Sample(Texture1DArray<uint2>, sampler, float2 location); 805 native uint2 Sample(Texture2D<uint2>, sampler, float2 location); 806 native uint2 Sample(Texture2D<uint2>, sampler, float2 location, int2 offset); 807 native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location); 808 native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location, int2 offset); 809 native uint2 Sample(Texture3D<uint2>, sampler, float3 location); 810 native uint2 Sample(Texture3D<uint2>, sampler, float3 location, int3 offset); 811 native uint2 Sample(TextureCube<uint2>, sampler, float3 location); 812 native uint3 Sample(Texture1D<uint3>, sampler, float location); 813 native uint3 Sample(Texture1DArray<uint3>, sampler, float2 location); 814 native uint3 Sample(Texture2D<uint3>, sampler, float2 location); 815 native uint3 Sample(Texture2D<uint3>, sampler, float2 location, int2 offset); 816 native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location); 817 native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location, int2 offset); 818 native uint3 Sample(Texture3D<uint3>, sampler, float3 location); 819 native uint3 Sample(Texture3D<uint3>, sampler, float3 location, int3 offset); 820 native uint3 Sample(TextureCube<uint3>, sampler, float3 location); 821 native uint4 Sample(Texture1D<uint4>, sampler, float location); 822 native uint4 Sample(Texture1DArray<uint4>, sampler, float2 location); 823 native uint4 Sample(Texture2D<uint4>, sampler, float2 location); 824 native uint4 Sample(Texture2D<uint4>, sampler, float2 location, int2 offset); 825 native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location); 826 native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location, int2 offset); 827 native uint4 Sample(Texture3D<uint4>, sampler, float3 location); 828 native uint4 Sample(Texture3D<uint4>, sampler, float3 location, int3 offset); 829 native uint4 Sample(TextureCube<uint4>, sampler, float3 location); 830 native short Sample(Texture1D<short>, sampler, float location); 831 native short Sample(Texture1DArray<short>, sampler, float2 location); 832 native short Sample(Texture2D<short>, sampler, float2 location); 833 native short Sample(Texture2D<short>, sampler, float2 location, int2 offset); 834 native short Sample(Texture2DArray<short>, sampler, float3 location); 835 native short Sample(Texture2DArray<short>, sampler, float3 location, int2 offset); 836 native short Sample(Texture3D<short>, sampler, float3 location); 837 native short Sample(Texture3D<short>, sampler, float3 location, int3 offset); 838 native short Sample(TextureCube<short>, sampler, float3 location); 839 native short2 Sample(Texture1D<short2>, sampler, float location); 840 native short2 Sample(Texture1DArray<short2>, sampler, float2 location); 841 native short2 Sample(Texture2D<short2>, sampler, float2 location); 842 native short2 Sample(Texture2D<short2>, sampler, float2 location, int2 offset); 843 native short2 Sample(Texture2DArray<short2>, sampler, float3 location); 844 native short2 Sample(Texture2DArray<short2>, sampler, float3 location, int2 offset); 845 native short2 Sample(Texture3D<short2>, sampler, float3 location); 846 native short2 Sample(Texture3D<short2>, sampler, float3 location, int3 offset); 847 native short2 Sample(TextureCube<short2>, sampler, float3 location); 848 native short3 Sample(Texture1D<short3>, sampler, float location); 849 native short3 Sample(Texture1DArray<short3>, sampler, float2 location); 850 native short3 Sample(Texture2D<short3>, sampler, float2 location); 851 native short3 Sample(Texture2D<short3>, sampler, float2 location, int2 offset); 852 native short3 Sample(Texture2DArray<short3>, sampler, float3 location); 853 native short3 Sample(Texture2DArray<short3>, sampler, float3 location, int2 offset); 854 native short3 Sample(Texture3D<short3>, sampler, float3 location); 855 native short3 Sample(Texture3D<short3>, sampler, float3 location, int3 offset); 856 native short3 Sample(TextureCube<short3>, sampler, float3 location); 857 native short4 Sample(Texture1D<short4>, sampler, float location); 858 native short4 Sample(Texture1DArray<short4>, sampler, float2 location); 859 native short4 Sample(Texture2D<short4>, sampler, float2 location); 860 native short4 Sample(Texture2D<short4>, sampler, float2 location, int2 offset); 861 native short4 Sample(Texture2DArray<short4>, sampler, float3 location); 862 native short4 Sample(Texture2DArray<short4>, sampler, float3 location, int2 offset); 863 native short4 Sample(Texture3D<short4>, sampler, float3 location); 864 native short4 Sample(Texture3D<short4>, sampler, float3 location, int3 offset); 865 native short4 Sample(TextureCube<short4>, sampler, float3 location); 866 native int Sample(Texture1D<int>, sampler, float location); 867 native int Sample(Texture1DArray<int>, sampler, float2 location); 868 native int Sample(Texture2D<int>, sampler, float2 location); 869 native int Sample(Texture2D<int>, sampler, float2 location, int2 offset); 870 native int Sample(Texture2DArray<int>, sampler, float3 location); 871 native int Sample(Texture2DArray<int>, sampler, float3 location, int2 offset); 872 native int Sample(Texture3D<int>, sampler, float3 location); 873 native int Sample(Texture3D<int>, sampler, float3 location, int3 offset); 874 native int Sample(TextureCube<int>, sampler, float3 location); 875 native int2 Sample(Texture1D<int2>, sampler, float location); 876 native int2 Sample(Texture1DArray<int2>, sampler, float2 location); 877 native int2 Sample(Texture2D<int2>, sampler, float2 location); 878 native int2 Sample(Texture2D<int2>, sampler, float2 location, int2 offset); 879 native int2 Sample(Texture2DArray<int2>, sampler, float3 location); 880 native int2 Sample(Texture2DArray<int2>, sampler, float3 location, int2 offset); 881 native int2 Sample(Texture3D<int2>, sampler, float3 location); 882 native int2 Sample(Texture3D<int2>, sampler, float3 location, int3 offset); 883 native int2 Sample(TextureCube<int2>, sampler, float3 location); 884 native int3 Sample(Texture1D<int3>, sampler, float location); 885 native int3 Sample(Texture1DArray<int3>, sampler, float2 location); 886 native int3 Sample(Texture2D<int3>, sampler, float2 location); 887 native int3 Sample(Texture2D<int3>, sampler, float2 location, int2 offset); 888 native int3 Sample(Texture2DArray<int3>, sampler, float3 location); 889 native int3 Sample(Texture2DArray<int3>, sampler, float3 location, int2 offset); 890 native int3 Sample(Texture3D<int3>, sampler, float3 location); 891 native int3 Sample(Texture3D<int3>, sampler, float3 location, int3 offset); 892 native int3 Sample(TextureCube<int3>, sampler, float3 location); 893 native int4 Sample(Texture1D<int4>, sampler, float location); 894 native int4 Sample(Texture1DArray<int4>, sampler, float2 location); 895 native int4 Sample(Texture2D<int4>, sampler, float2 location); 896 native int4 Sample(Texture2D<int4>, sampler, float2 location, int2 offset); 897 native int4 Sample(Texture2DArray<int4>, sampler, float3 location); 898 native int4 Sample(Texture2DArray<int4>, sampler, float3 location, int2 offset); 899 native int4 Sample(Texture3D<int4>, sampler, float3 location); 900 native int4 Sample(Texture3D<int4>, sampler, float3 location, int3 offset); 901 native int4 Sample(TextureCube<int4>, sampler, float3 location); 902 native half Sample(Texture1D<half>, sampler, float location); 903 native half Sample(Texture1DArray<half>, sampler, float2 location); 904 native half Sample(Texture2D<half>, sampler, float2 location); 905 native half Sample(Texture2D<half>, sampler, float2 location, int2 offset); 906 native half Sample(Texture2DArray<half>, sampler, float3 location); 907 native half Sample(Texture2DArray<half>, sampler, float3 location, int2 offset); 908 native half Sample(Texture3D<half>, sampler, float3 location); 909 native half Sample(Texture3D<half>, sampler, float3 location, int3 offset); 910 native half Sample(TextureCube<half>, sampler, float3 location); 911 native half2 Sample(Texture1D<half2>, sampler, float location); 912 native half2 Sample(Texture1DArray<half2>, sampler, float2 location); 913 native half2 Sample(Texture2D<half2>, sampler, float2 location); 914 native half2 Sample(Texture2D<half2>, sampler, float2 location, int2 offset); 915 native half2 Sample(Texture2DArray<half2>, sampler, float3 location); 916 native half2 Sample(Texture2DArray<half2>, sampler, float3 location, int2 offset); 917 native half2 Sample(Texture3D<half2>, sampler, float3 location); 918 native half2 Sample(Texture3D<half2>, sampler, float3 location, int3 offset); 919 native half2 Sample(TextureCube<half2>, sampler, float3 location); 920 native half3 Sample(Texture1D<half3>, sampler, float location); 921 native half3 Sample(Texture1DArray<half3>, sampler, float2 location); 922 native half3 Sample(Texture2D<half3>, sampler, float2 location); 923 native half3 Sample(Texture2D<half3>, sampler, float2 location, int2 offset); 924 native half3 Sample(Texture2DArray<half3>, sampler, float3 location); 925 native half3 Sample(Texture2DArray<half3>, sampler, float3 location, int2 offset); 926 native half3 Sample(Texture3D<half3>, sampler, float3 location); 927 native half3 Sample(Texture3D<half3>, sampler, float3 location, int3 offset); 928 native half3 Sample(TextureCube<half3>, sampler, float3 location); 929 native half4 Sample(Texture1D<half4>, sampler, float location); 930 native half4 Sample(Texture1DArray<half4>, sampler, float2 location); 931 native half4 Sample(Texture2D<half4>, sampler, float2 location); 932 native half4 Sample(Texture2D<half4>, sampler, float2 location, int2 offset); 933 native half4 Sample(Texture2DArray<half4>, sampler, float3 location); 934 native half4 Sample(Texture2DArray<half4>, sampler, float3 location, int2 offset); 935 native half4 Sample(Texture3D<half4>, sampler, float3 location); 936 native half4 Sample(Texture3D<half4>, sampler, float3 location, int3 offset); 937 native half4 Sample(TextureCube<half4>, sampler, float3 location); 938 native float Sample(Texture1D<float>, sampler, float location); 939 native float Sample(Texture1DArray<float>, sampler, float2 location); 940 native float Sample(Texture2D<float>, sampler, float2 location); 941 native float Sample(Texture2D<float>, sampler, float2 location, int2 offset); 942 native float Sample(Texture2DArray<float>, sampler, float3 location); 943 native float Sample(Texture2DArray<float>, sampler, float3 location, int2 offset); 944 native float Sample(Texture3D<float>, sampler, float3 location); 945 native float Sample(Texture3D<float>, sampler, float3 location, int3 offset); 946 native float Sample(TextureCube<float>, sampler, float3 location); 947 native float2 Sample(Texture1D<float2>, sampler, float location); 948 native float2 Sample(Texture1DArray<float2>, sampler, float2 location); 949 native float2 Sample(Texture2D<float2>, sampler, float2 location); 950 native float2 Sample(Texture2D<float2>, sampler, float2 location, int2 offset); 951 native float2 Sample(Texture2DArray<float2>, sampler, float3 location); 952 native float2 Sample(Texture2DArray<float2>, sampler, float3 location, int2 offset); 953 native float2 Sample(Texture3D<float2>, sampler, float3 location); 954 native float2 Sample(Texture3D<float2>, sampler, float3 location, int3 offset); 955 native float2 Sample(TextureCube<float2>, sampler, float3 location); 956 native float3 Sample(Texture1D<float3>, sampler, float location); 957 native float3 Sample(Texture1DArray<float3>, sampler, float2 location); 958 native float3 Sample(Texture2D<float3>, sampler, float2 location); 959 native float3 Sample(Texture2D<float3>, sampler, float2 location, int2 offset); 960 native float3 Sample(Texture2DArray<float3>, sampler, float3 location); 961 native float3 Sample(Texture2DArray<float3>, sampler, float3 location, int2 offset); 962 native float3 Sample(Texture3D<float3>, sampler, float3 location); 963 native float3 Sample(Texture3D<float3>, sampler, float3 location, int3 offset); 964 native float3 Sample(TextureCube<float3>, sampler, float3 location); 965 native float4 Sample(Texture1D<float4>, sampler, float location); 966 native float4 Sample(Texture1DArray<float4>, sampler, float2 location); 967 native float4 Sample(Texture2D<float4>, sampler, float2 location); 968 native float4 Sample(Texture2D<float4>, sampler, float2 location, int2 offset); 969 native float4 Sample(Texture2DArray<float4>, sampler, float3 location); 970 native float4 Sample(Texture2DArray<float4>, sampler, float3 location, int2 offset); 971 native float4 Sample(Texture3D<float4>, sampler, float3 location); 972 native float4 Sample(Texture3D<float4>, sampler, float3 location, int3 offset); 973 native float4 Sample(TextureCube<float4>, sampler, float3 location); 974 native float Sample(TextureDepth2D<float>, sampler, float2 location); 975 native float Sample(TextureDepth2D<float>, sampler, float2 location, int2 offset); 976 native float Sample(TextureDepth2DArray<float>, sampler, float3 location); 977 native float Sample(TextureDepth2DArray<float>, sampler, float3 location, int2 offset); 978 native float Sample(TextureDepthCube<float>, sampler, float3 location); 979 980 native ushort Load(Texture1D<ushort>, int location); 981 native ushort Load(Texture1DArray<ushort>, int2 location); 982 native ushort Load(Texture2D<ushort>, int2 location); 983 native ushort Load(Texture2DArray<ushort>, int3 location); 984 native ushort Load(Texture3D<ushort>, int3 location); 985 native ushort2 Load(Texture1D<ushort2>, int location); 986 native ushort2 Load(Texture1DArray<ushort2>, int2 location); 987 native ushort2 Load(Texture2D<ushort2>, int2 location); 988 native ushort2 Load(Texture2DArray<ushort2>, int3 location); 989 native ushort2 Load(Texture3D<ushort2>, int3 location); 990 native ushort3 Load(Texture1D<ushort3>, int location); 991 native ushort3 Load(Texture1DArray<ushort3>, int2 location); 992 native ushort3 Load(Texture2D<ushort3>, int2 location); 993 native ushort3 Load(Texture2DArray<ushort3>, int3 location); 994 native ushort3 Load(Texture3D<ushort3>, int3 location); 995 native ushort4 Load(Texture1D<ushort4>, int location); 996 native ushort4 Load(Texture1DArray<ushort4>, int2 location); 997 native ushort4 Load(Texture2D<ushort4>, int2 location); 998 native ushort4 Load(Texture2DArray<ushort4>, int3 location); 999 native ushort4 Load(Texture3D<ushort4>, int3 location); 1000 native uint Load(Texture1D<uint>, int location); 1001 native uint Load(Texture1DArray<uint>, int2 location); 1002 native uint Load(Texture2D<uint>, int2 location); 1003 native uint Load(Texture2DArray<uint>, int3 location); 1004 native uint Load(Texture3D<uint>, int3 location); 1005 native uint2 Load(Texture1D<uint2>, int location); 1006 native uint2 Load(Texture1DArray<uint2>, int2 location); 1007 native uint2 Load(Texture2D<uint2>, int2 location); 1008 native uint2 Load(Texture2DArray<uint2>, int3 location); 1009 native uint2 Load(Texture3D<uint2>, int3 location); 1010 native uint3 Load(Texture1D<uint3>, int location); 1011 native uint3 Load(Texture1DArray<uint3>, int2 location); 1012 native uint3 Load(Texture2D<uint3>, int2 location); 1013 native uint3 Load(Texture2DArray<uint3>, int3 location); 1014 native uint3 Load(Texture3D<uint3>, int3 location); 1015 native uint4 Load(Texture1D<uint4>, int location); 1016 native uint4 Load(Texture1DArray<uint4>, int2 location); 1017 native uint4 Load(Texture2D<uint4>, int2 location); 1018 native uint4 Load(Texture2DArray<uint4>, int3 location); 1019 native uint4 Load(Texture3D<uint4>, int3 location); 1020 native short Load(Texture1D<short>, int location); 1021 native short Load(Texture1DArray<short>, int2 location); 1022 native short Load(Texture2D<short>, int2 location); 1023 native short Load(Texture2DArray<short>, int3 location); 1024 native short Load(Texture3D<short>, int3 location); 1025 native short2 Load(Texture1D<short2>, int location); 1026 native short2 Load(Texture1DArray<short2>, int2 location); 1027 native short2 Load(Texture2D<short2>, int2 location); 1028 native short2 Load(Texture2DArray<short2>, int3 location); 1029 native short2 Load(Texture3D<short2>, int3 location); 1030 native short3 Load(Texture1D<short3>, int location); 1031 native short3 Load(Texture1DArray<short3>, int2 location); 1032 native short3 Load(Texture2D<short3>, int2 location); 1033 native short3 Load(Texture2DArray<short3>, int3 location); 1034 native short3 Load(Texture3D<short3>, int3 location); 1035 native short4 Load(Texture1D<short4>, int location); 1036 native short4 Load(Texture1DArray<short4>, int2 location); 1037 native short4 Load(Texture2D<short4>, int2 location); 1038 native short4 Load(Texture2DArray<short4>, int3 location); 1039 native short4 Load(Texture3D<short4>, int3 location); 1040 native int Load(Texture1D<int>, int location); 1041 native int Load(Texture1DArray<int>, int2 location); 1042 native int Load(Texture2D<int>, int2 location); 1043 native int Load(Texture2DArray<int>, int3 location); 1044 native int Load(Texture3D<int>, int3 location); 1045 native int2 Load(Texture1D<int2>, int location); 1046 native int2 Load(Texture1DArray<int2>, int2 location); 1047 native int2 Load(Texture2D<int2>, int2 location); 1048 native int2 Load(Texture2DArray<int2>, int3 location); 1049 native int2 Load(Texture3D<int2>, int3 location); 1050 native int3 Load(Texture1D<int3>, int location); 1051 native int3 Load(Texture1DArray<int3>, int2 location); 1052 native int3 Load(Texture2D<int3>, int2 location); 1053 native int3 Load(Texture2DArray<int3>, int3 location); 1054 native int3 Load(Texture3D<int3>, int3 location); 1055 native int4 Load(Texture1D<int4>, int location); 1056 native int4 Load(Texture1DArray<int4>, int2 location); 1057 native int4 Load(Texture2D<int4>, int2 location); 1058 native int4 Load(Texture2DArray<int4>, int3 location); 1059 native int4 Load(Texture3D<int4>, int3 location); 1060 native half Load(Texture1D<half>, int location); 1061 native half Load(Texture1DArray<half>, int2 location); 1062 native half Load(Texture2D<half>, int2 location); 1063 native half Load(Texture2DArray<half>, int3 location); 1064 native half Load(Texture3D<half>, int3 location); 1065 native half2 Load(Texture1D<half2>, int location); 1066 native half2 Load(Texture1DArray<half2>, int2 location); 1067 native half2 Load(Texture2D<half2>, int2 location); 1068 native half2 Load(Texture2DArray<half2>, int3 location); 1069 native half2 Load(Texture3D<half2>, int3 location); 1070 native half3 Load(Texture1D<half3>, int location); 1071 native half3 Load(Texture1DArray<half3>, int2 location); 1072 native half3 Load(Texture2D<half3>, int2 location); 1073 native half3 Load(Texture2DArray<half3>, int3 location); 1074 native half3 Load(Texture3D<half3>, int3 location); 1075 native half4 Load(Texture1D<half4>, int location); 1076 native half4 Load(Texture1DArray<half4>, int2 location); 1077 native half4 Load(Texture2D<half4>, int2 location); 1078 native half4 Load(Texture2DArray<half4>, int3 location); 1079 native half4 Load(Texture3D<half4>, int3 location); 1080 native float Load(Texture1D<float>, int location); 1081 native float Load(Texture1DArray<float>, int2 location); 1082 native float Load(Texture2D<float>, int2 location); 1083 native float Load(Texture2DArray<float>, int3 location); 1084 native float Load(Texture3D<float>, int3 location); 1085 native float2 Load(Texture1D<float2>, int location); 1086 native float2 Load(Texture1DArray<float2>, int2 location); 1087 native float2 Load(Texture2D<float2>, int2 location); 1088 native float2 Load(Texture2DArray<float2>, int3 location); 1089 native float2 Load(Texture3D<float2>, int3 location); 1090 native float3 Load(Texture1D<float3>, int location); 1091 native float3 Load(Texture1DArray<float3>, int2 location); 1092 native float3 Load(Texture2D<float3>, int2 location); 1093 native float3 Load(Texture2DArray<float3>, int3 location); 1094 native float3 Load(Texture3D<float3>, int3 location); 1095 native float4 Load(Texture1D<float4>, int location); 1096 native float4 Load(Texture1DArray<float4>, int2 location); 1097 native float4 Load(Texture2D<float4>, int2 location); 1098 native float4 Load(Texture2DArray<float4>, int3 location); 1099 native float4 Load(Texture3D<float4>, int3 location); 1100 native float Load(TextureDepth2D<float>, int2 location); 1101 native float Load(TextureDepth2DArray<float>, int3 location); 1102 1103 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, thread uint* Height, thread uint* NumberOfLevels); 1104 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, thread uint* Height, device uint* NumberOfLevels); 1105 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, thread uint* Height, threadgroup uint* NumberOfLevels); 1106 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, device uint* Height, thread uint* NumberOfLevels); 1107 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, device uint* Height, device uint* NumberOfLevels); 1108 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, device uint* Height, threadgroup uint* NumberOfLevels); 1109 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, threadgroup uint* Height, thread uint* NumberOfLevels); 1110 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, threadgroup uint* Height, device uint* NumberOfLevels); 1111 native void GetDimensions(Texture2D<float4>, uint MipLevel, thread uint* Width, threadgroup uint* Height, threadgroup uint* NumberOfLevels); 1112 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, thread uint* Height, thread uint* NumberOfLevels); 1113 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, thread uint* Height, device uint* NumberOfLevels); 1114 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, thread uint* Height, threadgroup uint* NumberOfLevels); 1115 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, device uint* Height, thread uint* NumberOfLevels); 1116 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, device uint* Height, device uint* NumberOfLevels); 1117 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, device uint* Height, threadgroup uint* NumberOfLevels); 1118 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, threadgroup uint* Height, thread uint* NumberOfLevels); 1119 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, threadgroup uint* Height, device uint* NumberOfLevels); 1120 native void GetDimensions(Texture2D<float4>, uint MipLevel, device uint* Width, threadgroup uint* Height, threadgroup uint* NumberOfLevels); 1121 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, thread uint* Height, thread uint* NumberOfLevels); 1122 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, thread uint* Height, device uint* NumberOfLevels); 1123 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, thread uint* Height, threadgroup uint* NumberOfLevels); 1124 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, device uint* Height, thread uint* NumberOfLevels); 1125 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, device uint* Height, device uint* NumberOfLevels); 1126 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, device uint* Height, threadgroup uint* NumberOfLevels); 1127 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, threadgroup uint* Height, thread uint* NumberOfLevels); 1128 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, threadgroup uint* Height, device uint* NumberOfLevels); 1129 native void GetDimensions(Texture2D<float4>, uint MipLevel, threadgroup uint* Width, threadgroup uint* Height, threadgroup uint* NumberOfLevels); 1130 851 1131 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=192890 Insert the rest of the standard library once the parser is fast enough -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp
r245680 r246631 40 40 class FindArrayTypes : public Visitor { 41 41 public: 42 ~FindArrayTypes() = default;42 virtual ~FindArrayTypes() = default; 43 43 44 44 void visit(AST::ArrayType& arrayType) override -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp
r246550 r246631 83 83 class FindAllTypes : public Visitor { 84 84 public: 85 ~FindAllTypes() = default;85 virtual ~FindAllTypes() = default; 86 86 87 87 void visit(AST::PointerType& pointerType) override … … 172 172 if (matches(namedType, program.intrinsics().voidType())) 173 173 continue; 174 if (is<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType)) && downcast<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType)).isAtom ())174 if (is<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType)) && downcast<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType)).isAtomic()) 175 175 continue; 176 176 … … 181 181 program.append(WTFMove(copyConstructor)); 182 182 183 if (is<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType))) { 184 auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(static_cast<AST::NamedType&>(namedType)); 185 if (nativeTypeDeclaration.isOpaqueType()) 186 continue; 187 } 183 188 AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(Lexer::Token(namedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), "operator cast"_str, AST::VariableDeclarations(), WTF::nullopt, isOperator)); 184 189 if (!program.append(WTFMove(defaultConstructor))) -
trunk/Source/WebCore/Sources.txt
r246540 r246631 313 313 Modules/webgpu/WHLSL/WHLSLLexer.cpp 314 314 Modules/webgpu/WHLSL/WHLSLParser.cpp 315 Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp 315 316 Modules/webgpu/WHLSL/WHLSLChecker.cpp 316 317 Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r246611 r246631 6384 6384 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFaceSet.h; path = DerivedSources/WebCore/JSFontFaceSet.h; sourceTree = BUILT_PRODUCTS_DIR; }; 6385 6385 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; }; 6386 1C281C6D22B87B9800691C00 /* WHLSLCheckTextureReferences.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLCheckTextureReferences.cpp; sourceTree = "<group>"; }; 6387 1C281C6E22B87B9800691C00 /* WHLSLCheckTextureReferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCheckTextureReferences.h; sourceTree = "<group>"; }; 6386 6388 1C3249101C6D6A3B007EDB32 /* FontVariantBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontVariantBuilder.cpp; sourceTree = "<group>"; }; 6387 6389 1C33277121CF0BE1000DC9F2 /* WHLSLNamedType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNamedType.h; sourceTree = "<group>"; }; … … 25482 25484 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */, 25483 25485 1C840B9721EC400700D0500D /* WHLSLChecker.h */, 25486 1C281C6D22B87B9800691C00 /* WHLSLCheckTextureReferences.cpp */, 25487 1C281C6E22B87B9800691C00 /* WHLSLCheckTextureReferences.h */, 25484 25488 1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */, 25485 25489 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */, -
trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h
r242575 r246631 55 55 bool isOutputAttachment() const { return m_usage.contains(GPUTextureUsage::Flags::OutputAttachment); } 56 56 bool isReadOnly() const { return m_usage.containsAny({ GPUTextureUsage::Flags::TransferSource, GPUTextureUsage::Flags::Sampled }); } 57 bool isSampled() const { return m_usage.contains(GPUTextureUsage::Flags::Sampled); } 58 bool isStorage() const { return m_usage.contains(GPUTextureUsage::Flags::Storage); } 57 59 58 60 RefPtr<GPUTexture> tryCreateDefaultTextureView(); -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm
r246394 r246631 217 217 return false; 218 218 if (isForVertex) 219 setSamplerOnEncoder(vertexEncoder, samplerState, index);219 setSamplerOnEncoder(vertexEncoder, samplerState, layoutBinding.internalName); 220 220 if (isForFragment) 221 setSamplerOnEncoder(fragmentEncoder, samplerState, index);221 setSamplerOnEncoder(fragmentEncoder, samplerState, layoutBinding.internalName); 222 222 if (isForCompute) 223 setSamplerOnEncoder(computeEncoder, samplerState, index);223 setSamplerOnEncoder(computeEncoder, samplerState, layoutBinding.internalName); 224 224 return true; 225 225 }, [&](GPUBindGroupLayout::SampledTexture&) -> bool { … … 228 228 return false; 229 229 if (isForVertex) 230 setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), index);230 setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), layoutBinding.internalName); 231 231 if (isForFragment) 232 setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), index);232 setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), layoutBinding.internalName); 233 233 if (isForCompute) 234 setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), index);234 setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), layoutBinding.internalName); 235 235 boundTextures.append(textureResource.releaseNonNull()); 236 236 return true; -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
r243627 r246631 64 64 65 65 for (auto& bufferRef : bindGroup.boundBuffers()) { 66 useResource(bufferRef->platformBuffer(), bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); 66 MTLResourceUsage usage = 0; 67 if (bufferRef->isUniform()) { 68 ASSERT(!bufferRef->isStorage()); 69 usage = MTLResourceUsageRead; 70 } else if (bufferRef->isStorage()) { 71 ASSERT(!bufferRef->isUniform()); 72 usage = MTLResourceUsageRead | MTLResourceUsageWrite; 73 } 74 useResource(bufferRef->platformBuffer(), usage); 67 75 m_commandBuffer->useBuffer(bufferRef.copyRef()); 68 76 } 69 77 for (auto& textureRef : bindGroup.boundTextures()) { 70 useResource(textureRef->platformTexture(), textureRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); 78 MTLResourceUsage usage = 0; 79 if (textureRef->isSampled()) { 80 ASSERT(!textureRef->isStorage()); 81 usage = MTLResourceUsageRead | MTLResourceUsageSample; 82 } else if (textureRef->isStorage()) { 83 ASSERT(!textureRef->isSampled()); 84 usage = MTLResourceUsageRead | MTLResourceUsageWrite; 85 } 86 useResource(textureRef->platformTexture(), usage); 71 87 m_commandBuffer->useTexture(textureRef.copyRef()); 72 88 } -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUTextureMetal.mm
r243636 r246631 60 60 UNUSED_PARAM(functionName); 61 61 #endif 62 62 63 if (flags.containsAny({ GPUTextureUsage::Flags::TransferSource, GPUTextureUsage::Flags::Sampled }) && (flags & GPUTextureUsage::Flags::Storage)) { 63 64 LOG(WebGPU, "%s: Texture cannot have both STORAGE and a read-only usage!", functionName); … … 65 66 } 66 67 67 if (flags & GPUTextureUsage::Flags::OutputAttachment) { 68 if (flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) { 69 LOG(WebGPU, "%s: Texture cannot have OUTPUT_ATTACHMENT usage with STORAGE or SAMPLED usages!", functionName); 70 return WTF::nullopt; 71 } 72 73 return MTLTextureUsageRenderTarget | MTLTextureUsagePixelFormatView; 74 } 75 76 if (flags & GPUTextureUsage::Flags::Storage) 77 return MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead | MTLTextureUsagePixelFormatView; 78 79 if (flags & GPUTextureUsage::Flags::Sampled) 80 return MTLTextureUsageShaderRead | MTLTextureUsagePixelFormatView; 81 82 return MTLTextureUsageUnknown; 68 if (flags & GPUTextureUsage::Flags::OutputAttachment && flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) { 69 LOG(WebGPU, "%s: Texture cannot have OUTPUT_ATTACHMENT usage with STORAGE or SAMPLED usages!", functionName); 70 return WTF::nullopt; 71 } 72 73 MTLTextureUsage result = MTLTextureUsagePixelFormatView; 74 if (flags.contains(GPUTextureUsage::Flags::OutputAttachment)) 75 result |= MTLTextureUsageRenderTarget; 76 if (flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) 77 result |= MTLTextureUsageShaderRead; 78 if (flags.contains(GPUTextureUsage::Flags::Storage)) 79 result |= MTLTextureUsageShaderWrite; 80 81 return result; 83 82 } 84 83
Note: See TracChangeset
for help on using the changeset viewer.