Changeset 246427 in webkit
- Timestamp:
- Jun 13, 2019 10:20:00 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 2 deleted
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246426 r246427 1 2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Hook up compute 4 https://bugs.webkit.org/show_bug.cgi?id=198644 5 6 Reviewed by Saam Barati. 7 8 This doesn't thoroughly test compute, but it's at least enough to unblock the WHLSL testing effort. 9 10 * webgpu/compute-squares-expected.txt: Deleted. Covered by webgpu/whlsl-compute.html. 11 * webgpu/compute-squares.html: Deleted. Ditto. 12 * webgpu/whlsl-compute-expected.txt: Added. 13 * webgpu/whlsl-compute.html: Added. 14 1 15 2019-06-13 Zalan Bujtas <zalan@apple.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r246415 r246427 1 2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Hook up compute 4 https://bugs.webkit.org/show_bug.cgi?id=198644 5 6 Reviewed by Saam Barati. 7 8 This patch hooks up compute shaders in exactly the same way that vertex and fragment shaders 9 are hooked up. I've modified the two patchs (compute and rendering) to be almost exactly the 10 same code. 11 12 This patch also adds support for the WHLSL compiler to determine what the numthreads() 13 attribute in the shader says so that it can be hooked up to Metal's threads-per-threadgroup 14 argument in the dispatch call. There is some logic to make sure that there aren't two 15 numthreads() attributes on the same compute shader. 16 17 It also adds a little bit of type renaming. For built-in variables, sometimes Metal's type 18 doesn't always match WHLSL's (and HLSL's type). For example, in WHLSL and HLSL, SV_DispatchThreadID variables have to be a float3, but in Metal, they are a uint3. 19 Therefore, I've added a little bit of code during each entry point's pack and unpack stages 20 to handle this type conversion. 21 22 Test: webgpu/whlsl-compute.html 23 24 * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: 25 (WebCore::WHLSL::Metal::internalTypeForSemantic): Determine which Metal type corresponds to 26 each built-in variable. 27 (WebCore::WHLSL::Metal::EntryPointScaffolding::builtInsSignature): Perform the type 28 conversion. 29 (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns): Ditto. 30 (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding): Ditto. 31 (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::helperTypes): Ditto. 32 (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::pack): Ditto. 33 (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::FragmentEntryPointScaffolding): Ditto. 34 (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::helperTypes): Ditto. 35 (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::pack): Ditto. 36 (WebCore::WHLSL::Metal::ComputeEntryPointScaffolding::signature): Ditto. 37 * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h: 38 * Modules/webgpu/WHLSL/WHLSLComputeDimensions.cpp: Added. Add a pass to determine whether 39 or not any entry point has duplicate numthreads() attribute, and to determine what the 40 appropriate numthreads() values should be for the current entry point. 41 (WebCore::WHLSL::ComputeDimensionsVisitor::ComputeDimensionsVisitor): 42 (WebCore::WHLSL::ComputeDimensionsVisitor::computeDimensions const): 43 (WebCore::WHLSL::computeDimensions): 44 * Modules/webgpu/WHLSL/WHLSLComputeDimensions.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h. 45 * Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp: 46 (WebCore::WHLSL::gatherEntryPointItems): Compute shaders don't need to have a semantic for their return type. 47 * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: 48 (WebCore::WHLSL::prepare): Run the computeDimensions() pass. 49 * Modules/webgpu/WHLSL/WHLSLPrepare.h: 50 * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: In a left-value propertyAccessExpression, 51 the index expression can be a right-value. Treat it as such. 52 (WebCore::WHLSL::LeftValueSimplifier::finishVisiting): 53 (WebCore::WHLSL::LeftValueSimplifier::visit): 54 * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt: We need support for multiplication (for a 55 test) and float3 for SV_DispatchThreadID. 56 * Sources.txt: 57 * SourcesCocoa.txt: 58 * WebCore.xcodeproj/project.pbxproj: 59 * platform/graphics/gpu/GPUComputePipeline.h: Associate a compute dimensions with a particular 60 compute pipeline. This is how Metal knows what values to use for a dispatch. 61 (WebCore::GPUComputePipeline::computeDimensions const): 62 * platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm: Use the saved compute dimensions. 63 (WebCore::GPUComputePassEncoder::dispatch): 64 * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm: Make the code match GPURenderPipelineMetal. 65 (WebCore::trySetMetalFunctions): 66 (WebCore::trySetFunctions): 67 (WebCore::convertComputePipelineDescriptor): 68 (WebCore::tryCreateMTLComputePipelineState): 69 (WebCore::GPUComputePipeline::tryCreate): 70 (WebCore::GPUComputePipeline::GPUComputePipeline): 71 (WebCore::tryCreateMtlComputeFunction): Deleted. 72 * platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.cpp: Added. Moved shared helper 73 functions to a file where they can be accessed by multiple places. 74 (WebCore::convertShaderStageFlags): 75 (WebCore::convertBindingType): 76 (WebCore::convertLayout): 77 * platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h. 78 * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: Delete the functions that were moved to GPUPipelineMetalConvertLayout. 79 (WebCore::trySetFunctions): 80 (WebCore::tryCreateMtlRenderPipelineState): 81 (WebCore::convertShaderStageFlags): Deleted. 82 (WebCore::convertBindingType): Deleted. 83 (WebCore::convertLayout): Deleted. 84 1 85 2019-06-13 Jer Noble <jer.noble@apple.com> 2 86 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp
r246409 r246427 179 179 } 180 180 181 static String internalTypeForSemantic(const AST::BuiltInSemantic& builtInSemantic) 182 { 183 switch (builtInSemantic.variable()) { 184 case AST::BuiltInSemantic::Variable::SVInstanceID: 185 return "uint"_str; 186 case AST::BuiltInSemantic::Variable::SVVertexID: 187 return "uint"_str; 188 case AST::BuiltInSemantic::Variable::PSize: 189 return "float"_str; 190 case AST::BuiltInSemantic::Variable::SVPosition: 191 return "float4"_str; 192 case AST::BuiltInSemantic::Variable::SVIsFrontFace: 193 return "bool"_str; 194 case AST::BuiltInSemantic::Variable::SVSampleIndex: 195 return "uint"_str; 196 case AST::BuiltInSemantic::Variable::SVInnerCoverage: 197 return "uint"_str; 198 case AST::BuiltInSemantic::Variable::SVTarget: 199 return String(); 200 case AST::BuiltInSemantic::Variable::SVDepth: 201 return "float"_str; 202 case AST::BuiltInSemantic::Variable::SVCoverage: 203 return "uint"_str; 204 case AST::BuiltInSemantic::Variable::SVDispatchThreadID: 205 return "uint3"_str; 206 case AST::BuiltInSemantic::Variable::SVGroupID: 207 return "uint3"_str; 208 case AST::BuiltInSemantic::Variable::SVGroupIndex: 209 return "uint"_str; 210 default: 211 ASSERT(builtInSemantic.variable() == AST::BuiltInSemantic::Variable::SVGroupThreadID); 212 return "uint3"_str; 213 } 214 } 215 181 216 Optional<String> EntryPointScaffolding::builtInsSignature() 182 217 { … … 191 226 auto& item = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems]; 192 227 auto& builtInSemantic = WTF::get<AST::BuiltInSemantic>(*item.semantic); 193 auto mangledTypeName = m_typeNamer.mangledNameForType(*item.unnamedType); 228 auto internalType = internalTypeForSemantic(builtInSemantic); 229 if (internalType.isNull()) 230 internalType = m_typeNamer.mangledNameForType(*item.unnamedType); 194 231 auto variableName = namedBuiltIn.variableName; 195 stringBuilder.append(makeString( mangledTypeName, ' ', variableName, ' ', attributeForSemantic(builtInSemantic)));232 stringBuilder.append(makeString(internalType, ' ', variableName, ' ', attributeForSemantic(builtInSemantic))); 196 233 } 197 234 return stringBuilder.toString(); … … 300 337 301 338 for (auto& namedBuiltIn : m_namedBuiltIns) { 302 auto& path = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems].path; 339 auto& item = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems]; 340 auto& path = item.path; 303 341 auto& variableName = namedBuiltIn.variableName; 304 stringBuilder.append(makeString(mangledInputPath(path), " = ", variableName, ";\n")); 342 auto mangledTypeName = m_typeNamer.mangledNameForType(*item.unnamedType); 343 stringBuilder.append(makeString(mangledInputPath(path), " = ", mangledTypeName, '(', variableName, ");\n")); 305 344 } 306 345 return stringBuilder.toString(); … … 325 364 m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size()); 326 365 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 366 auto& outputItem = m_entryPointItems.outputs[i]; 327 367 NamedOutput namedOutput; 328 368 namedOutput.elementName = m_typeNamer.generateNextStructureElementName(); 369 if (WTF::holds_alternative<AST::BuiltInSemantic>(*outputItem.semantic)) 370 namedOutput.internalTypeName = internalTypeForSemantic(WTF::get<AST::BuiltInSemantic>(*outputItem.semantic)); 371 if (namedOutput.internalTypeName.isNull()) 372 namedOutput.internalTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType); 329 373 m_namedOutputs.uncheckedAppend(WTFMove(namedOutput)); 330 374 } … … 347 391 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 348 392 auto& outputItem = m_entryPointItems.outputs[i]; 349 auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType);393 auto& internalTypeName = m_namedOutputs[i].internalTypeName; 350 394 auto elementName = m_namedOutputs[i].elementName; 351 395 auto attribute = attributeForSemantic(*outputItem.semantic); 352 stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n"));396 stringBuilder.append(makeString(" ", internalTypeName, ' ', elementName, ' ', attribute, ";\n")); 353 397 } 354 398 stringBuilder.append("};\n\n"); … … 399 443 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 400 444 auto& elementName = m_namedOutputs[i].elementName; 445 auto& internalTypeName = m_namedOutputs[i].internalTypeName; 401 446 auto& path = m_entryPointItems.outputs[i].path; 402 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", in putVariableName, mangledOutputPath(path), ";\n"));447 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", internalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n")); 403 448 } 404 449 return stringBuilder.toString(); … … 425 470 m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size()); 426 471 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 472 auto& outputItem = m_entryPointItems.outputs[i]; 427 473 NamedOutput namedOutput; 428 474 namedOutput.elementName = m_typeNamer.generateNextStructureElementName(); 475 if (WTF::holds_alternative<AST::BuiltInSemantic>(*outputItem.semantic)) 476 namedOutput.internalTypeName = internalTypeForSemantic(WTF::get<AST::BuiltInSemantic>(*outputItem.semantic)); 477 if (namedOutput.internalTypeName.isNull()) 478 namedOutput.internalTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType); 429 479 m_namedOutputs.uncheckedAppend(WTFMove(namedOutput)); 430 480 } … … 447 497 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 448 498 auto& outputItem = m_entryPointItems.outputs[i]; 449 auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType);499 auto& internalTypeName = m_namedOutputs[i].internalTypeName; 450 500 auto elementName = m_namedOutputs[i].elementName; 451 501 auto attribute = attributeForSemantic(*outputItem.semantic); 452 stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n"));502 stringBuilder.append(makeString(" ", internalTypeName, ' ', elementName, ' ', attribute, ";\n")); 453 503 } 454 504 stringBuilder.append("};\n\n"); … … 499 549 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 500 550 auto& elementName = m_namedOutputs[i].elementName; 551 auto& internalTypeName = m_namedOutputs[i].internalTypeName; 501 552 auto& path = m_entryPointItems.outputs[i].path; 502 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", in putVariableName, mangledOutputPath(path), ";\n"));553 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", internalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n")); 503 554 } 504 555 return stringBuilder.toString(); … … 519 570 StringBuilder stringBuilder; 520 571 521 stringBuilder.append(makeString(" computevoid ", functionName, '('));572 stringBuilder.append(makeString("kernel void ", functionName, '(')); 522 573 bool empty = true; 523 574 if (auto resourceSignature = this->resourceSignature()) { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h
r246409 r246427 130 130 struct NamedOutput { 131 131 String elementName; 132 String internalTypeName; 132 133 }; 133 134 Vector<NamedOutput> m_namedOutputs; … … 158 159 struct NamedOutput { 159 160 String elementName; 161 String internalTypeName; 160 162 }; 161 163 Vector<NamedOutput> m_namedOutputs; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLComputeDimensions.h
r246426 r246427 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLP ipelineDescriptor.h"31 #include <wtf/ text/WTFString.h>30 #include "WHLSLPrepare.h" 31 #include <wtf/Optional.h> 32 32 33 33 namespace WebCore { … … 35 35 namespace WHLSL { 36 36 37 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195682 Generate descriptive error messages and return them here. 38 struct RenderPrepareResult { 39 String metalSource; 40 String mangledVertexEntryPointName; 41 String mangledFragmentEntryPointName; 42 }; 43 Optional<RenderPrepareResult> prepare(String& whlslSource, RenderPipelineDescriptor&); 37 namespace AST { 44 38 45 struct ComputePrepareResult { 46 String metalSource; 47 String mangledEntryPointName; 48 }; 49 Optional<ComputePrepareResult> prepare(String& whlslSource, ComputePipelineDescriptor&); 39 class FunctionDefinition; 50 40 51 } // namespace WHLSL41 } 52 42 53 } // namespace WebCore 43 class Program; 54 44 55 #endif // ENABLE(WEBGPU) 45 Optional<ComputeDimensions> computeDimensions(Program&, AST::FunctionDefinition&); 46 47 } 48 49 } 50 51 #endif -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp
r246409 r246427 176 176 } 177 177 Gatherer outputGatherer(intrinsics, functionDefinition.semantic() ? &*functionDefinition.semantic() : nullptr); 178 outputGatherer.checkErrorAndVisit(functionDefinition.type()); 178 if (*functionDefinition.entryPointType() != AST::EntryPointType::Compute) 179 outputGatherer.checkErrorAndVisit(functionDefinition.type()); 179 180 if (outputGatherer.error()) 180 181 return WTF::nullopt; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
r246409 r246427 33 33 #include "WHLSLCheckDuplicateFunctions.h" 34 34 #include "WHLSLChecker.h" 35 #include "WHLSLComputeDimensions.h" 35 36 #include "WHLSLFunctionStageChecker.h" 36 37 #include "WHLSLHighZombieFinder.h" … … 171 172 if (!matchedSemantics) 172 173 return WTF::nullopt; 174 auto computeDimensions = WHLSL::computeDimensions(*program, *matchedSemantics->shader); 175 if (!computeDimensions) 176 return WTF::nullopt; 173 177 174 178 auto generatedCode = Metal::generateMetalCode(*program, WTFMove(*matchedSemantics), computePipelineDescriptor.layout); … … 177 181 result.metalSource = WTFMove(generatedCode.metalSource); 178 182 result.mangledEntryPointName = WTFMove(generatedCode.mangledEntryPointName); 183 result.computeDimensions = WTFMove(*computeDimensions); 179 184 return result; 180 185 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h
r246409 r246427 43 43 Optional<RenderPrepareResult> prepare(String& whlslSource, RenderPipelineDescriptor&); 44 44 45 struct ComputeDimensions { 46 unsigned width; 47 unsigned height; 48 unsigned depth; 49 }; 50 45 51 struct ComputePrepareResult { 46 52 String metalSource; 47 53 String mangledEntryPointName; 54 ComputeDimensions computeDimensions; 48 55 }; 49 56 Optional<ComputePrepareResult> prepare(String& whlslSource, ComputePipelineDescriptor&); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
r246409 r246427 775 775 ASSERT(propertyAccessExpression.anderFunction()); 776 776 777 Visitor::visit(propertyAccessExpression.base()); 778 777 779 Lexer::Token origin = propertyAccessExpression.origin(); 778 780 auto* anderFunction = propertyAccessExpression.anderFunction(); … … 805 807 void LeftValueSimplifier::visit(AST::IndexExpression& indexExpression) 806 808 { 807 Visitor::visit(indexExpression);808 809 PropertyResolver().Visitor::visit(indexExpression.indexExpression()); 809 810 finishVisiting(indexExpression); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt
r246409 r246427 433 433 native operator float(half); 434 434 435 native float operator.x(float4);436 native float operator.y(float4);437 native float operator.z(float4);438 native float operator.w(float4);439 native float4 operator.x=(float4, float);440 native float4 operator.y=(float4, float);441 native float4 operator.z=(float4, float);442 native float4 operator.w=(float4, float);443 444 435 native float operator+(float, float); 445 436 native float operator-(float, float); … … 449 440 native bool operator<(uint, uint); 450 441 native bool operator<(float, float); 442 native float operator*(float, float); 443 444 native bool operator.x(bool2); 445 native bool operator.y(bool2); 446 native bool operator.x(bool3); 447 native bool operator.y(bool3); 448 native bool operator.z(bool3); 449 native bool operator.x(bool4); 450 native bool operator.y(bool4); 451 native bool operator.z(bool4); 452 native bool operator.w(bool4); 453 native bool2 operator.x=(bool2, bool); 454 native bool2 operator.y=(bool2, bool); 455 native bool3 operator.x=(bool3, bool); 456 native bool3 operator.y=(bool3, bool); 457 native bool3 operator.z=(bool3, bool); 458 native bool4 operator.x=(bool4, bool); 459 native bool4 operator.y=(bool4, bool); 460 native bool4 operator.z=(bool4, bool); 461 native bool4 operator.w=(bool4, bool); 462 native uchar operator.x(uchar2); 463 native uchar operator.y(uchar2); 464 native uchar operator.x(uchar3); 465 native uchar operator.y(uchar3); 466 native uchar operator.z(uchar3); 467 native uchar operator.x(uchar4); 468 native uchar operator.y(uchar4); 469 native uchar operator.z(uchar4); 470 native uchar operator.w(uchar4); 471 native uchar2 operator.x=(uchar2, uchar); 472 native uchar2 operator.y=(uchar2, uchar); 473 native uchar3 operator.x=(uchar3, uchar); 474 native uchar3 operator.y=(uchar3, uchar); 475 native uchar3 operator.z=(uchar3, uchar); 476 native uchar4 operator.x=(uchar4, uchar); 477 native uchar4 operator.y=(uchar4, uchar); 478 native uchar4 operator.z=(uchar4, uchar); 479 native uchar4 operator.w=(uchar4, uchar); 480 native ushort operator.x(ushort2); 481 native ushort operator.y(ushort2); 482 native ushort operator.x(ushort3); 483 native ushort operator.y(ushort3); 484 native ushort operator.z(ushort3); 485 native ushort operator.x(ushort4); 486 native ushort operator.y(ushort4); 487 native ushort operator.z(ushort4); 488 native ushort operator.w(ushort4); 489 native ushort2 operator.x=(ushort2, ushort); 490 native ushort2 operator.y=(ushort2, ushort); 491 native ushort3 operator.x=(ushort3, ushort); 492 native ushort3 operator.y=(ushort3, ushort); 493 native ushort3 operator.z=(ushort3, ushort); 494 native ushort4 operator.x=(ushort4, ushort); 495 native ushort4 operator.y=(ushort4, ushort); 496 native ushort4 operator.z=(ushort4, ushort); 497 native ushort4 operator.w=(ushort4, ushort); 498 native uint operator.x(uint2); 499 native uint operator.y(uint2); 500 native uint operator.x(uint3); 501 native uint operator.y(uint3); 502 native uint operator.z(uint3); 503 native uint operator.x(uint4); 504 native uint operator.y(uint4); 505 native uint operator.z(uint4); 506 native uint operator.w(uint4); 507 native uint2 operator.x=(uint2, uint); 508 native uint2 operator.y=(uint2, uint); 509 native uint3 operator.x=(uint3, uint); 510 native uint3 operator.y=(uint3, uint); 511 native uint3 operator.z=(uint3, uint); 512 native uint4 operator.x=(uint4, uint); 513 native uint4 operator.y=(uint4, uint); 514 native uint4 operator.z=(uint4, uint); 515 native uint4 operator.w=(uint4, uint); 516 native char operator.x(char2); 517 native char operator.y(char2); 518 native char operator.x(char3); 519 native char operator.y(char3); 520 native char operator.z(char3); 521 native char operator.x(char4); 522 native char operator.y(char4); 523 native char operator.z(char4); 524 native char operator.w(char4); 525 native char2 operator.x=(char2, char); 526 native char2 operator.y=(char2, char); 527 native char3 operator.x=(char3, char); 528 native char3 operator.y=(char3, char); 529 native char3 operator.z=(char3, char); 530 native char4 operator.x=(char4, char); 531 native char4 operator.y=(char4, char); 532 native char4 operator.z=(char4, char); 533 native char4 operator.w=(char4, char); 534 native short operator.x(short2); 535 native short operator.y(short2); 536 native short operator.x(short3); 537 native short operator.y(short3); 538 native short operator.z(short3); 539 native short operator.x(short4); 540 native short operator.y(short4); 541 native short operator.z(short4); 542 native short operator.w(short4); 543 native short2 operator.x=(short2, short); 544 native short2 operator.y=(short2, short); 545 native short3 operator.x=(short3, short); 546 native short3 operator.y=(short3, short); 547 native short3 operator.z=(short3, short); 548 native short4 operator.x=(short4, short); 549 native short4 operator.y=(short4, short); 550 native short4 operator.z=(short4, short); 551 native short4 operator.w=(short4, short); 552 native int operator.x(int2); 553 native int operator.y(int2); 554 native int operator.x(int3); 555 native int operator.y(int3); 556 native int operator.z(int3); 557 native int operator.x(int4); 558 native int operator.y(int4); 559 native int operator.z(int4); 560 native int operator.w(int4); 561 native int2 operator.x=(int2, int); 562 native int2 operator.y=(int2, int); 563 native int3 operator.x=(int3, int); 564 native int3 operator.y=(int3, int); 565 native int3 operator.z=(int3, int); 566 native int4 operator.x=(int4, int); 567 native int4 operator.y=(int4, int); 568 native int4 operator.z=(int4, int); 569 native int4 operator.w=(int4, int); 570 native half operator.x(half2); 571 native half operator.y(half2); 572 native half operator.x(half3); 573 native half operator.y(half3); 574 native half operator.z(half3); 575 native half operator.x(half4); 576 native half operator.y(half4); 577 native half operator.z(half4); 578 native half operator.w(half4); 579 native half2 operator.x=(half2, half); 580 native half2 operator.y=(half2, half); 581 native half3 operator.x=(half3, half); 582 native half3 operator.y=(half3, half); 583 native half3 operator.z=(half3, half); 584 native half4 operator.x=(half4, half); 585 native half4 operator.y=(half4, half); 586 native half4 operator.z=(half4, half); 587 native half4 operator.w=(half4, half); 588 native float operator.x(float2); 589 native float operator.y(float2); 590 native float operator.x(float3); 591 native float operator.y(float3); 592 native float operator.z(float3); 593 native float operator.x(float4); 594 native float operator.y(float4); 595 native float operator.z(float4); 596 native float operator.w(float4); 597 native float2 operator.x=(float2, float); 598 native float2 operator.y=(float2, float); 599 native float3 operator.x=(float3, float); 600 native float3 operator.y=(float3, float); 601 native float3 operator.z=(float3, float); 602 native float4 operator.x=(float4, float); 603 native float4 operator.y=(float4, float); 604 native float4 operator.z=(float4, float); 605 native float4 operator.w=(float4, float); 451 606 452 607 native float ddx(float); -
trunk/Source/WebCore/Sources.txt
r246409 r246427 307 307 Modules/webgpu/GPUCanvasContext.cpp 308 308 Modules/webgpu/NavigatorGPU.cpp 309 Modules/webgpu/WHLSL/WHLSLComputeDimensions.cpp 309 310 Modules/webgpu/WHLSL/WHLSLASTDumper.cpp 310 311 Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp -
trunk/Source/WebCore/SourcesCocoa.txt
r246409 r246427 327 327 platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm 328 328 platform/graphics/gpu/cocoa/GPUDeviceMetal.mm 329 platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.cpp 329 330 platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm 330 331 platform/graphics/gpu/cocoa/GPUQueueMetal.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r246409 r246427 6395 6395 1C840B9A21EC400900D0500D /* WHLSLGatherEntryPointItems.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLGatherEntryPointItems.h; sourceTree = "<group>"; }; 6396 6396 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLChecker.cpp; sourceTree = "<group>"; }; 6397 1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLComputeDimensions.cpp; sourceTree = "<group>"; }; 6398 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLComputeDimensions.h; sourceTree = "<group>"; }; 6399 1C86CA4E22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipelineMetalConvertLayout.cpp; sourceTree = "<group>"; }; 6400 1C86CA4F22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineMetalConvertLayout.h; sourceTree = "<group>"; }; 6397 6401 1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; }; 6398 6402 1C9AE5CA21ED9DF50069D5F2 /* WHLSLHighZombieFinder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLHighZombieFinder.cpp; sourceTree = "<group>"; }; … … 25449 25453 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */, 25450 25454 1C840B9721EC400700D0500D /* WHLSLChecker.h */, 25455 1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */, 25456 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */, 25451 25457 1CA0C2E421EED12A00A11860 /* WHLSLFunctionStageChecker.cpp */, 25452 25458 1CA0C2E521EED12A00A11860 /* WHLSLFunctionStageChecker.h */, … … 25988 25994 D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */, 25989 25995 D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */, 25996 1C86CA4E22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.cpp */, 25997 1C86CA4F22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.h */, 25990 25998 D087CE3B21ACA94200BDE174 /* GPUProgrammablePassEncoderMetal.mm */, 25991 25999 D087CE3921ACA94200BDE174 /* GPUQueueMetal.mm */, -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h
r246409 r246427 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLPrepare.h" 30 31 #include <wtf/RefCounted.h> 31 32 #include <wtf/RefPtr.h> … … 49 50 const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); } 50 51 52 WHLSL::ComputeDimensions computeDimensions() const { return m_computeDimensions; } 53 51 54 private: 52 GPUComputePipeline(PlatformComputePipelineSmartPtr&& );55 GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions); 53 56 54 57 PlatformComputePipelineSmartPtr m_platformComputePipeline; 58 WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 }; 55 59 }; 56 60 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm
r246409 r246427 93 93 } 94 94 95 auto pipelineState = m_pipeline->platformComputePipeline(); 96 ASSERT(pipelineState); 95 ASSERT(m_pipeline->platformComputePipeline()); 97 96 98 97 BEGIN_BLOCK_OBJC_EXCEPTIONS; 99 98 100 auto w = pipelineState.threadExecutionWidth; 101 auto h = pipelineState.maxTotalThreadsPerThreadgroup / w; 102 103 // FIXME: This should be gleaned from the shader if not using MSL. For now, use the docs' example calculation. 104 auto threadsPerThreadgroup = MTLSizeMake(w, h, 1); 99 auto threadsPerThreadgroup = MTLSizeMake(m_pipeline->computeDimensions().width, m_pipeline->computeDimensions().height, m_pipeline->computeDimensions().depth); 105 100 106 101 auto threadgroupsPerGrid = MTLSizeMake(x, y, z); -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
r246409 r246427 31 31 #import "GPUComputePipelineDescriptor.h" 32 32 #import "GPUDevice.h" 33 #import "GPUPipelineMetalConvertLayout.h" 33 34 #import "Logging.h" 35 #import "WHLSLPrepare.h" 34 36 #import <Metal/Metal.h> 35 37 #import <wtf/BlockObjCExceptions.h> 36 38 37 OBJC_PROTOCOL(MTLFunction);38 39 39 namespace WebCore { 40 40 41 static RetainPtr<MTLFunction> tryCreateMtlComputeFunction(const GPUPipelineStageDescriptor& stage) 42 { 43 if (!stage.module->platformShaderModule() || stage.entryPoint.isNull()) { 44 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUShaderModule!"); 45 return nullptr; 46 } 47 48 RetainPtr<MTLFunction> function; 41 static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *computeMetalLibrary, MTLComputePipelineDescriptor *mtlDescriptor, const String& computeEntryPointName) 42 { 43 #if LOG_DISABLED 44 UNUSED_PARAM(functionName); 45 #endif 49 46 50 47 BEGIN_BLOCK_OBJC_EXCEPTIONS; 51 function = adoptNS([stage.module->platformShaderModule() newFunctionWithName:stage.entryPoint]); 48 49 if (!computeMetalLibrary) { 50 LOG(WebGPU, "%s: MTLLibrary for compute stage does not exist!", functionName); 51 return false; 52 } 53 54 auto function = adoptNS([computeMetalLibrary newFunctionWithName:computeEntryPointName]); 55 if (!function) { 56 LOG(WebGPU, "%s: Cannot create compute MTLFunction \"%s\"!", functionName, computeEntryPointName.utf8().data()); 57 return false; 58 } 59 60 [mtlDescriptor setComputeFunction:function.get()]; 61 return true; 62 52 63 END_BLOCK_OBJC_EXCEPTIONS; 53 64 54 if (!function) 55 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Cannot create compute MTLFunction \"%s\"!", stage.entryPoint.utf8().data()); 56 57 return function; 58 } 59 60 static RetainPtr<MTLComputePipelineState> tryCreateMTLComputePipelineState(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 65 return false; 66 } 67 68 static Optional<WHLSL::ComputeDimensions> trySetFunctions(const char* const functionName, const GPUPipelineStageDescriptor& computeStage, const GPUDevice& device, MTLComputePipelineDescriptor* mtlDescriptor, Optional<WHLSL::ComputePipelineDescriptor>& whlslDescriptor) 69 { 70 #if LOG_DISABLED 71 UNUSED_PARAM(functionName); 72 #endif 73 RetainPtr<MTLLibrary> computeLibrary; 74 String computeEntryPoint; 75 76 WHLSL::ComputeDimensions computeDimensions { 1, 1, 1 }; 77 78 if (whlslDescriptor) { 79 // WHLSL functions are compiled to MSL first. 80 String whlslSource = computeStage.module->whlslSource(); 81 ASSERT(!whlslSource.isNull()); 82 83 whlslDescriptor->entryPointName = computeStage.entryPoint; 84 85 auto whlslCompileResult = WHLSL::prepare(whlslSource, *whlslDescriptor); 86 if (!whlslCompileResult) 87 return WTF::nullopt; 88 computeDimensions = whlslCompileResult->computeDimensions; 89 90 NSError *error = nil; 91 92 BEGIN_BLOCK_OBJC_EXCEPTIONS; 93 computeLibrary = adoptNS([device.platformDevice() newLibraryWithSource:whlslCompileResult->metalSource options:nil error:&error]); 94 END_BLOCK_OBJC_EXCEPTIONS; 95 96 ASSERT(computeLibrary); 97 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195771 Once we zero-fill variables, there should be no warnings, so we should be able to ASSERT(!error) here. 98 99 computeEntryPoint = whlslCompileResult->mangledEntryPointName; 100 } else { 101 computeLibrary = computeStage.module->platformShaderModule(); 102 computeEntryPoint = computeStage.entryPoint; 103 } 104 105 if (trySetMetalFunctions(functionName, computeLibrary.get(), mtlDescriptor, computeEntryPoint)) 106 return computeDimensions; 107 return WTF::nullopt; 108 } 109 110 struct ConvertResult { 111 RetainPtr<MTLComputePipelineDescriptor> pipelineDescriptor; 112 WHLSL::ComputeDimensions computeDimensions; 113 }; 114 static Optional<ConvertResult> convertComputePipelineDescriptor(const char* const functionName, const GPUComputePipelineDescriptor& descriptor, const GPUDevice& device) 115 { 116 RetainPtr<MTLComputePipelineDescriptor> mtlDescriptor; 117 118 BEGIN_BLOCK_OBJC_EXCEPTIONS; 119 120 mtlDescriptor = adoptNS([MTLComputePipelineDescriptor new]); 121 122 END_BLOCK_OBJC_EXCEPTIONS; 123 124 if (!mtlDescriptor) { 125 LOG(WebGPU, "%s: Error creating MTLDescriptor!", functionName); 126 return WTF::nullopt; 127 } 128 129 const auto& computeStage = descriptor.computeStage; 130 131 bool isWhlsl = !computeStage.module->whlslSource().isNull(); 132 133 Optional<WHLSL::ComputePipelineDescriptor> whlslDescriptor; 134 if (isWhlsl) 135 whlslDescriptor = WHLSL::ComputePipelineDescriptor(); 136 137 if (descriptor.layout && whlslDescriptor) { 138 if (auto layout = convertLayout(*descriptor.layout)) 139 whlslDescriptor->layout = WTFMove(*layout); 140 else { 141 LOG(WebGPU, "%s: Error converting GPUPipelineLayout!", functionName); 142 return WTF::nullopt; 143 } 144 } 145 146 if (auto computeDimensions = trySetFunctions(functionName, computeStage, device, mtlDescriptor.get(), whlslDescriptor)) 147 return {{ mtlDescriptor, *computeDimensions }}; 148 149 return WTF::nullopt; 150 } 151 152 struct CreateResult { 153 RetainPtr<MTLComputePipelineState> pipelineState; 154 WHLSL::ComputeDimensions computeDimensions; 155 }; 156 static Optional<CreateResult> tryCreateMTLComputePipelineState(const char* const functionName, const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 61 157 { 62 158 if (!device.platformDevice()) { 63 159 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!"); 160 return WTF::nullopt; 161 } 162 163 auto convertResult = convertComputePipelineDescriptor(functionName, descriptor, device); 164 if (!convertResult) 165 return WTF::nullopt; 166 ASSERT(convertResult->pipelineDescriptor); 167 auto mtlDescriptor = convertResult->pipelineDescriptor; 168 169 RetainPtr<MTLComputePipelineState> pipeline; 170 171 BEGIN_BLOCK_OBJC_EXCEPTIONS; 172 173 NSError *error = nil; 174 pipeline = adoptNS([device.platformDevice() newComputePipelineStateWithDescriptor:mtlDescriptor.get() options:MTLPipelineOptionNone reflection:nil error:&error]); 175 if (!pipeline) { 176 LOG(WebGPU, "GPUComputePipeline::tryCreate(): %s!", error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!"); 177 return WTF::nullopt; 178 } 179 180 END_BLOCK_OBJC_EXCEPTIONS; 181 182 return {{ pipeline, convertResult->computeDimensions }}; 183 } 184 185 RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 186 { 187 const char* const functionName = "GPURenderPipeline::create()"; 188 189 auto createResult = tryCreateMTLComputePipelineState(functionName, device, descriptor); 190 if (!createResult) 64 191 return nullptr; 65 } 66 67 auto computeFunction = tryCreateMtlComputeFunction(descriptor.computeStage); 68 if (!computeFunction) 69 return nullptr; 70 71 RetainPtr<MTLComputePipelineState> pipelineState; 72 NSError *error = nil; 73 74 BEGIN_BLOCK_OBJC_EXCEPTIONS; 75 pipelineState = adoptNS([device.platformDevice() newComputePipelineStateWithFunction:computeFunction.get() error:&error]); 76 END_BLOCK_OBJC_EXCEPTIONS; 77 78 if (!pipelineState) 79 LOG(WebGPU, "GPUComputePipeline::tryCreate(): %s!", error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!"); 80 81 return pipelineState; 82 } 83 84 RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 85 { 86 auto mtlPipeline = tryCreateMTLComputePipelineState(device, descriptor); 87 if (!mtlPipeline) 88 return nullptr; 89 90 return adoptRef(new GPUComputePipeline(WTFMove(mtlPipeline))); 91 } 92 93 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline) 192 193 return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions)); 194 } 195 196 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions) 94 197 : m_platformComputePipeline(WTFMove(pipeline)) 198 , m_computeDimensions(computeDimensions) 95 199 { 96 200 } -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.h
r246426 r246427 29 29 30 30 #include "WHLSLPipelineDescriptor.h" 31 #include <wtf/ text/WTFString.h>31 #include <wtf/Optional.h> 32 32 33 33 namespace WebCore { 34 34 35 namespace WHLSL { 35 class GPUPipelineLayout; 36 36 37 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195682 Generate descriptive error messages and return them here. 38 struct RenderPrepareResult { 39 String metalSource; 40 String mangledVertexEntryPointName; 41 String mangledFragmentEntryPointName; 42 }; 43 Optional<RenderPrepareResult> prepare(String& whlslSource, RenderPipelineDescriptor&); 37 Optional<WHLSL::Layout> convertLayout(const GPUPipelineLayout&); 44 38 45 struct ComputePrepareResult { 46 String metalSource; 47 String mangledEntryPointName; 48 }; 49 Optional<ComputePrepareResult> prepare(String& whlslSource, ComputePipelineDescriptor&); 39 } 50 40 51 } // namespace WHLSL 52 53 } // namespace WebCore 54 55 #endif // ENABLE(WEBGPU) 41 #endif -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r246409 r246427 31 31 #import "GPUDevice.h" 32 32 #import "GPULimits.h" 33 #import "GPUPipelineMetalConvertLayout.h" 33 34 #import "GPUUtils.h" 34 35 #import "Logging.h" … … 97 98 return WHLSL::VertexFormat::FloatR32; 98 99 } 99 }100 101 static OptionSet<WHLSL::ShaderStage> convertShaderStageFlags(GPUShaderStageFlags flags)102 {103 OptionSet<WHLSL::ShaderStage> result;104 if (flags & GPUShaderStageBit::Flags::Vertex)105 result.add(WHLSL::ShaderStage::Vertex);106 if (flags & GPUShaderStageBit::Flags::Fragment)107 result.add(WHLSL::ShaderStage::Fragment);108 if (flags & GPUShaderStageBit::Flags::Compute)109 result.add(WHLSL::ShaderStage::Compute);110 return result;111 }112 113 static Optional<WHLSL::Binding::BindingDetails> convertBindingType(GPUBindGroupLayout::InternalBindingDetails internalBindingDetails)114 {115 return WTF::visit(WTF::makeVisitor([&](GPUBindGroupLayout::UniformBuffer uniformBuffer) -> Optional<WHLSL::Binding::BindingDetails> {116 return { WHLSL::UniformBufferBinding { uniformBuffer.internalLengthName } };117 }, [&](GPUBindGroupLayout::DynamicUniformBuffer) -> Optional<WHLSL::Binding::BindingDetails> {118 return WTF::nullopt;119 }, [&](GPUBindGroupLayout::Sampler) -> Optional<WHLSL::Binding::BindingDetails> {120 return { WHLSL::SamplerBinding { } };121 }, [&](GPUBindGroupLayout::SampledTexture) -> Optional<WHLSL::Binding::BindingDetails> {122 return { WHLSL::TextureBinding { } };123 }, [&](GPUBindGroupLayout::StorageBuffer storageBuffer) -> Optional<WHLSL::Binding::BindingDetails> {124 return { WHLSL::StorageBufferBinding { storageBuffer.internalLengthName } };125 }, [&](GPUBindGroupLayout::DynamicStorageBuffer) -> Optional<WHLSL::Binding::BindingDetails> {126 return WTF::nullopt;127 }), internalBindingDetails);128 100 } 129 101 … … 369 341 } 370 342 371 static Optional<WHLSL::Layout> convertLayout(const GPUPipelineLayout& layout)372 {373 WHLSL::Layout result;374 if (layout.bindGroupLayouts().size() > std::numeric_limits<unsigned>::max())375 return WTF::nullopt;376 for (size_t i = 0; i < layout.bindGroupLayouts().size(); ++i) {377 const auto& bindGroupLayout = layout.bindGroupLayouts()[i];378 WHLSL::BindGroup bindGroup;379 bindGroup.name = static_cast<unsigned>(i);380 for (const auto& keyValuePair : bindGroupLayout->bindingsMap()) {381 const auto& bindingDetails = keyValuePair.value;382 WHLSL::Binding binding;383 binding.visibility = convertShaderStageFlags(bindingDetails.externalBinding.visibility);384 if (auto bindingType = convertBindingType(bindingDetails.internalBindingDetails))385 binding.binding = *bindingType;386 else387 return WTF::nullopt;388 if (bindingDetails.externalBinding.binding > std::numeric_limits<unsigned>::max())389 return WTF::nullopt;390 binding.externalName = bindingDetails.externalBinding.binding;391 binding.internalName = bindingDetails.internalName;392 bindGroup.bindings.append(WTFMove(binding));393 }394 result.append(WTFMove(bindGroup));395 }396 return result;397 }398 399 343 static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *vertexMetalLibrary, MTLLibrary *fragmentMetalLibrary, MTLRenderPipelineDescriptor *mtlDescriptor, const String& vertexEntryPointName, const String& fragmentEntryPointName) 400 344 { … … 466 410 if (!whlslCompileResult) 467 411 return false; 468 469 WTFLogAlways("Metal Source: %s", whlslCompileResult->metalSource.utf8().data());470 412 471 413 NSError *error = nil; … … 543 485 static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const char* const functionName, const GPURenderPipelineDescriptor& descriptor, const GPUDevice& device) 544 486 { 487 if (!device.platformDevice()) { 488 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!"); 489 return nullptr; 490 } 491 545 492 auto mtlDescriptor = convertRenderPipelineDescriptor(functionName, descriptor, device); 546 493 if (!mtlDescriptor) … … 551 498 BEGIN_BLOCK_OBJC_EXCEPTIONS; 552 499 553 NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil];500 NSError *error = nil; 554 501 pipeline = adoptNS([device.platformDevice() newRenderPipelineStateWithDescriptor:mtlDescriptor.get() error:&error]); 555 502 if (!pipeline)
Note: See TracChangeset
for help on using the changeset viewer.