Changeset 246409 in webkit
- Timestamp:
- Jun 13, 2019 12:06:31 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246407 r246409 1 2019-06-13 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r246396 and r246397. 4 https://bugs.webkit.org/show_bug.cgi?id=198837 5 6 Breaks internal builds (Requested by ShawnRoberts on #webkit). 7 8 Reverted changesets: 9 10 "[WHLSL] Hook up compute" 11 https://bugs.webkit.org/show_bug.cgi?id=198644 12 https://trac.webkit.org/changeset/246396 13 14 "[WHLSL] Hook up compute" 15 https://bugs.webkit.org/show_bug.cgi?id=198644 16 https://trac.webkit.org/changeset/246397 17 1 18 2019-06-13 Antti Koivisto <antti@apple.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r246407 r246409 1 2019-06-13 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r246396 and r246397. 4 https://bugs.webkit.org/show_bug.cgi?id=198837 5 6 Breaks internal builds (Requested by ShawnRoberts on #webkit). 7 8 Reverted changesets: 9 10 "[WHLSL] Hook up compute" 11 https://bugs.webkit.org/show_bug.cgi?id=198644 12 https://trac.webkit.org/changeset/246396 13 14 "[WHLSL] Hook up compute" 15 https://bugs.webkit.org/show_bug.cgi?id=198644 16 https://trac.webkit.org/changeset/246397 17 1 18 2019-06-13 Antti Koivisto <antti@apple.com> 2 19 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp
r246396 r246409 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 216 181 Optional<String> EntryPointScaffolding::builtInsSignature() 217 182 { … … 226 191 auto& item = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems]; 227 192 auto& builtInSemantic = WTF::get<AST::BuiltInSemantic>(*item.semantic); 228 auto internalType = internalTypeForSemantic(builtInSemantic); 229 if (internalType.isNull()) 230 internalType = m_typeNamer.mangledNameForType(*item.unnamedType); 193 auto mangledTypeName = m_typeNamer.mangledNameForType(*item.unnamedType); 231 194 auto variableName = namedBuiltIn.variableName; 232 stringBuilder.append(makeString( internalType, ' ', variableName, ' ', attributeForSemantic(builtInSemantic)));195 stringBuilder.append(makeString(mangledTypeName, ' ', variableName, ' ', attributeForSemantic(builtInSemantic))); 233 196 } 234 197 return stringBuilder.toString(); … … 337 300 338 301 for (auto& namedBuiltIn : m_namedBuiltIns) { 339 auto& item = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems]; 340 auto& path = item.path; 302 auto& path = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems].path; 341 303 auto& variableName = namedBuiltIn.variableName; 342 auto mangledTypeName = m_typeNamer.mangledNameForType(*item.unnamedType); 343 stringBuilder.append(makeString(mangledInputPath(path), " = ", mangledTypeName, '(', variableName, ");\n")); 304 stringBuilder.append(makeString(mangledInputPath(path), " = ", variableName, ";\n")); 344 305 } 345 306 return stringBuilder.toString(); … … 364 325 m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size()); 365 326 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 366 auto& outputItem = m_entryPointItems.outputs[i];367 327 NamedOutput namedOutput; 368 328 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);373 329 m_namedOutputs.uncheckedAppend(WTFMove(namedOutput)); 374 330 } … … 391 347 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 392 348 auto& outputItem = m_entryPointItems.outputs[i]; 393 auto & internalTypeName = m_namedOutputs[i].internalTypeName;349 auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType); 394 350 auto elementName = m_namedOutputs[i].elementName; 395 351 auto attribute = attributeForSemantic(*outputItem.semantic); 396 stringBuilder.append(makeString(" ", internalTypeName, ' ', elementName, ' ', attribute, ";\n"));352 stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n")); 397 353 } 398 354 stringBuilder.append("};\n\n"); … … 443 399 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 444 400 auto& elementName = m_namedOutputs[i].elementName; 445 auto& internalTypeName = m_namedOutputs[i].internalTypeName;446 401 auto& path = m_entryPointItems.outputs[i].path; 447 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", in ternalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n"));402 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", inputVariableName, mangledOutputPath(path), ";\n")); 448 403 } 449 404 return stringBuilder.toString(); … … 470 425 m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size()); 471 426 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 472 auto& outputItem = m_entryPointItems.outputs[i];473 427 NamedOutput namedOutput; 474 428 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);479 429 m_namedOutputs.uncheckedAppend(WTFMove(namedOutput)); 480 430 } … … 497 447 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 498 448 auto& outputItem = m_entryPointItems.outputs[i]; 499 auto & internalTypeName = m_namedOutputs[i].internalTypeName;449 auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType); 500 450 auto elementName = m_namedOutputs[i].elementName; 501 451 auto attribute = attributeForSemantic(*outputItem.semantic); 502 stringBuilder.append(makeString(" ", internalTypeName, ' ', elementName, ' ', attribute, ";\n"));452 stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n")); 503 453 } 504 454 stringBuilder.append("};\n\n"); … … 549 499 for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) { 550 500 auto& elementName = m_namedOutputs[i].elementName; 551 auto& internalTypeName = m_namedOutputs[i].internalTypeName;552 501 auto& path = m_entryPointItems.outputs[i].path; 553 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", in ternalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n"));502 stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", inputVariableName, mangledOutputPath(path), ";\n")); 554 503 } 555 504 return stringBuilder.toString(); … … 570 519 StringBuilder stringBuilder; 571 520 572 stringBuilder.append(makeString(" kernelvoid ", functionName, '('));521 stringBuilder.append(makeString("compute void ", functionName, '(')); 573 522 bool empty = true; 574 523 if (auto resourceSignature = this->resourceSignature()) { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h
r246396 r246409 130 130 struct NamedOutput { 131 131 String elementName; 132 String internalTypeName;133 132 }; 134 133 Vector<NamedOutput> m_namedOutputs; … … 159 158 struct NamedOutput { 160 159 String elementName; 161 String internalTypeName;162 160 }; 163 161 Vector<NamedOutput> m_namedOutputs; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp
r246396 r246409 176 176 } 177 177 Gatherer outputGatherer(intrinsics, functionDefinition.semantic() ? &*functionDefinition.semantic() : nullptr); 178 if (*functionDefinition.entryPointType() != AST::EntryPointType::Compute) 179 outputGatherer.checkErrorAndVisit(functionDefinition.type()); 178 outputGatherer.checkErrorAndVisit(functionDefinition.type()); 180 179 if (outputGatherer.error()) 181 180 return WTF::nullopt; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
r246396 r246409 33 33 #include "WHLSLCheckDuplicateFunctions.h" 34 34 #include "WHLSLChecker.h" 35 #include "WHLSLComputeDimensions.h"36 35 #include "WHLSLFunctionStageChecker.h" 37 36 #include "WHLSLHighZombieFinder.h" … … 172 171 if (!matchedSemantics) 173 172 return WTF::nullopt; 174 auto computeDimensions = WHLSL::computeDimensions(*program, *matchedSemantics->shader);175 if (!computeDimensions)176 return WTF::nullopt;177 173 178 174 auto generatedCode = Metal::generateMetalCode(*program, WTFMove(*matchedSemantics), computePipelineDescriptor.layout); … … 181 177 result.metalSource = WTFMove(generatedCode.metalSource); 182 178 result.mangledEntryPointName = WTFMove(generatedCode.mangledEntryPointName); 183 result.computeDimensions = WTFMove(*computeDimensions);184 179 return result; 185 180 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h
r246396 r246409 43 43 Optional<RenderPrepareResult> prepare(String& whlslSource, RenderPipelineDescriptor&); 44 44 45 struct ComputeDimensions {46 unsigned width;47 unsigned height;48 unsigned depth;49 };50 51 45 struct ComputePrepareResult { 52 46 String metalSource; 53 47 String mangledEntryPointName; 54 ComputeDimensions computeDimensions;55 48 }; 56 49 Optional<ComputePrepareResult> prepare(String& whlslSource, ComputePipelineDescriptor&); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
r246396 r246409 775 775 ASSERT(propertyAccessExpression.anderFunction()); 776 776 777 Visitor::visit(propertyAccessExpression.base());778 779 777 Lexer::Token origin = propertyAccessExpression.origin(); 780 778 auto* anderFunction = propertyAccessExpression.anderFunction(); … … 807 805 void LeftValueSimplifier::visit(AST::IndexExpression& indexExpression) 808 806 { 807 Visitor::visit(indexExpression); 809 808 PropertyResolver().Visitor::visit(indexExpression.indexExpression()); 810 809 finishVisiting(indexExpression); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt
r246396 r246409 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 435 444 native float operator+(float, float); 436 445 native float operator-(float, float); … … 440 449 native bool operator<(uint, uint); 441 450 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);606 451 607 452 native float ddx(float); -
trunk/Source/WebCore/Sources.txt
r246396 r246409 307 307 Modules/webgpu/GPUCanvasContext.cpp 308 308 Modules/webgpu/NavigatorGPU.cpp 309 Modules/webgpu/WHLSL/WHLSLComputeDimensions.cpp310 309 Modules/webgpu/WHLSL/WHLSLASTDumper.cpp 311 310 Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp -
trunk/Source/WebCore/SourcesCocoa.txt
r246396 r246409 327 327 platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm 328 328 platform/graphics/gpu/cocoa/GPUDeviceMetal.mm 329 platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.cpp330 329 platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm 331 330 platform/graphics/gpu/cocoa/GPUQueueMetal.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r246396 r246409 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>"; };6401 6397 1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; }; 6402 6398 1C9AE5CA21ED9DF50069D5F2 /* WHLSLHighZombieFinder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLHighZombieFinder.cpp; sourceTree = "<group>"; }; … … 25453 25449 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */, 25454 25450 1C840B9721EC400700D0500D /* WHLSLChecker.h */, 25455 1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */,25456 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */,25457 25451 1CA0C2E421EED12A00A11860 /* WHLSLFunctionStageChecker.cpp */, 25458 25452 1CA0C2E521EED12A00A11860 /* WHLSLFunctionStageChecker.h */, … … 25994 25988 D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */, 25995 25989 D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */, 25996 1C86CA4E22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.cpp */,25997 1C86CA4F22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.h */,25998 25990 D087CE3B21ACA94200BDE174 /* GPUProgrammablePassEncoderMetal.mm */, 25999 25991 D087CE3921ACA94200BDE174 /* GPUQueueMetal.mm */, -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h
r246396 r246409 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLPrepare.h"31 30 #include <wtf/RefCounted.h> 32 31 #include <wtf/RefPtr.h> … … 50 49 const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); } 51 50 52 WHLSL::ComputeDimensions computeDimensions() const { return m_computeDimensions; }53 54 51 private: 55 GPUComputePipeline(PlatformComputePipelineSmartPtr&& , WHLSL::ComputeDimensions);52 GPUComputePipeline(PlatformComputePipelineSmartPtr&&); 56 53 57 54 PlatformComputePipelineSmartPtr m_platformComputePipeline; 58 WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 };59 55 }; 60 56 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm
r246397 r246409 93 93 } 94 94 95 ASSERT(m_pipeline->platformComputePipeline()); 95 auto pipelineState = m_pipeline->platformComputePipeline(); 96 ASSERT(pipelineState); 96 97 97 98 BEGIN_BLOCK_OBJC_EXCEPTIONS; 98 99 99 auto threadsPerThreadgroup = MTLSizeMake(m_pipeline->computeDimensions().width, m_pipeline->computeDimensions().height, m_pipeline->computeDimensions().depth); 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); 100 105 101 106 auto threadgroupsPerGrid = MTLSizeMake(x, y, z); -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
r246396 r246409 31 31 #import "GPUComputePipelineDescriptor.h" 32 32 #import "GPUDevice.h" 33 #import "GPUPipelineMetalConvertLayout.h"34 33 #import "Logging.h" 35 #import "WHLSLPrepare.h"36 34 #import <Metal/Metal.h> 37 35 #import <wtf/BlockObjCExceptions.h> 38 36 37 OBJC_PROTOCOL(MTLFunction); 38 39 39 namespace WebCore { 40 40 41 static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *computeMetalLibrary, MTLComputePipelineDescriptor *mtlDescriptor, const String& computeEntryPointName)41 static RetainPtr<MTLFunction> tryCreateMtlComputeFunction(const GPUPipelineStageDescriptor& stage) 42 42 { 43 #if LOG_DISABLED 44 UNUSED_PARAM(functionName); 45 #endif 43 if (!stage.module->platformShaderModule() || stage.entryPoint.isNull()) { 44 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUShaderModule!"); 45 return nullptr; 46 } 47 48 RetainPtr<MTLFunction> function; 46 49 47 50 BEGIN_BLOCK_OBJC_EXCEPTIONS; 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 51 function = adoptNS([stage.module->platformShaderModule() newFunctionWithName:stage.entryPoint]); 63 52 END_BLOCK_OBJC_EXCEPTIONS; 64 53 65 return false; 54 if (!function) 55 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Cannot create compute MTLFunction \"%s\"!", stage.entryPoint.utf8().data()); 56 57 return function; 66 58 } 67 59 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) 60 static RetainPtr<MTLComputePipelineState> tryCreateMTLComputePipelineState(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 157 61 { 158 62 if (!device.platformDevice()) { 159 63 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!"); 160 return WTF::nullopt;64 return nullptr; 161 65 } 162 66 163 auto convertResult = convertComputePipelineDescriptor(functionName, descriptor, device); 164 if (!convertResult) 165 return WTF::nullopt; 166 ASSERT(convertResult->pipelineDescriptor); 167 auto mtlDescriptor = convertResult->pipelineDescriptor; 67 auto computeFunction = tryCreateMtlComputeFunction(descriptor.computeStage); 68 if (!computeFunction) 69 return nullptr; 168 70 169 RetainPtr<MTLComputePipelineState> pipeline; 71 RetainPtr<MTLComputePipelineState> pipelineState; 72 NSError *error = nil; 170 73 171 74 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 75 pipelineState = adoptNS([device.platformDevice() newComputePipelineStateWithFunction:computeFunction.get() error:&error]); 180 76 END_BLOCK_OBJC_EXCEPTIONS; 181 77 182 return {{ pipeline, convertResult->computeDimensions }}; 78 if (!pipelineState) 79 LOG(WebGPU, "GPUComputePipeline::tryCreate(): %s!", error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!"); 80 81 return pipelineState; 183 82 } 184 83 185 84 RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor) 186 85 { 187 const char* const functionName = "GPURenderPipeline::create()"; 188 189 auto createResult = tryCreateMTLComputePipelineState(functionName, device, descriptor); 190 if (!createResult) 86 auto mtlPipeline = tryCreateMTLComputePipelineState(device, descriptor); 87 if (!mtlPipeline) 191 88 return nullptr; 192 89 193 return adoptRef(new GPUComputePipeline(WTFMove( createResult->pipelineState), createResult->computeDimensions));90 return adoptRef(new GPUComputePipeline(WTFMove(mtlPipeline))); 194 91 } 195 92 196 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline , WHLSL::ComputeDimensions computeDimensions)93 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline) 197 94 : m_platformComputePipeline(WTFMove(pipeline)) 198 , m_computeDimensions(computeDimensions)199 95 { 200 96 } -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r246396 r246409 31 31 #import "GPUDevice.h" 32 32 #import "GPULimits.h" 33 #import "GPUPipelineMetalConvertLayout.h"34 33 #import "GPUUtils.h" 35 34 #import "Logging.h" … … 98 97 return WHLSL::VertexFormat::FloatR32; 99 98 } 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); 100 128 } 101 129 … … 341 369 } 342 370 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 else 387 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 343 399 static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *vertexMetalLibrary, MTLLibrary *fragmentMetalLibrary, MTLRenderPipelineDescriptor *mtlDescriptor, const String& vertexEntryPointName, const String& fragmentEntryPointName) 344 400 { … … 410 466 if (!whlslCompileResult) 411 467 return false; 468 469 WTFLogAlways("Metal Source: %s", whlslCompileResult->metalSource.utf8().data()); 412 470 413 471 NSError *error = nil; … … 485 543 static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const char* const functionName, const GPURenderPipelineDescriptor& descriptor, const GPUDevice& device) 486 544 { 487 if (!device.platformDevice()) {488 LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!");489 return nullptr;490 }491 492 545 auto mtlDescriptor = convertRenderPipelineDescriptor(functionName, descriptor, device); 493 546 if (!mtlDescriptor) … … 498 551 BEGIN_BLOCK_OBJC_EXCEPTIONS; 499 552 500 NSError *error = nil;553 NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil]; 501 554 pipeline = adoptNS([device.platformDevice() newRenderPipelineStateWithDescriptor:mtlDescriptor.get() error:&error]); 502 555 if (!pipeline)
Note: See TracChangeset
for help on using the changeset viewer.