Changeset 246409 in webkit


Ignore:
Timestamp:
Jun 13, 2019 12:06:31 PM (5 years ago)
Author:
Shawn Roberts
Message:

Unreviewed, rolling out r246396 and r246397.
https://bugs.webkit.org/show_bug.cgi?id=198837

Breaks internal builds (Requested by ShawnRoberts on #webkit).

Reverted changesets:

"[WHLSL] Hook up compute"
https://bugs.webkit.org/show_bug.cgi?id=198644
https://trac.webkit.org/changeset/246396

"[WHLSL] Hook up compute"
https://bugs.webkit.org/show_bug.cgi?id=198644
https://trac.webkit.org/changeset/246397

Patch by Commit Queue <commit-queue@webkit.org> on 2019-06-13

Location:
trunk
Files:
2 added
6 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246407 r246409  
     12019-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
    1182019-06-13  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r246407 r246409  
     12019-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
    1182019-06-13  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp

    r246396 r246409  
    179179}
    180180
    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 
    216181Optional<String> EntryPointScaffolding::builtInsSignature()
    217182{
     
    226191        auto& item = m_entryPointItems.inputs[namedBuiltIn.indexInEntryPointItems];
    227192        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);
    231194        auto variableName = namedBuiltIn.variableName;
    232         stringBuilder.append(makeString(internalType, ' ', variableName, ' ', attributeForSemantic(builtInSemantic)));
     195        stringBuilder.append(makeString(mangledTypeName, ' ', variableName, ' ', attributeForSemantic(builtInSemantic)));
    233196    }
    234197    return stringBuilder.toString();
     
    337300
    338301    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;
    341303        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"));
    344305    }
    345306    return stringBuilder.toString();
     
    364325    m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size());
    365326    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    366         auto& outputItem = m_entryPointItems.outputs[i];
    367327        NamedOutput namedOutput;
    368328        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);
    373329        m_namedOutputs.uncheckedAppend(WTFMove(namedOutput));
    374330    }
     
    391347    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    392348        auto& outputItem = m_entryPointItems.outputs[i];
    393         auto& internalTypeName = m_namedOutputs[i].internalTypeName;
     349        auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType);
    394350        auto elementName = m_namedOutputs[i].elementName;
    395351        auto attribute = attributeForSemantic(*outputItem.semantic);
    396         stringBuilder.append(makeString("    ", internalTypeName, ' ', elementName, ' ', attribute, ";\n"));
     352        stringBuilder.append(makeString("    ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n"));
    397353    }
    398354    stringBuilder.append("};\n\n");
     
    443399    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    444400        auto& elementName = m_namedOutputs[i].elementName;
    445         auto& internalTypeName = m_namedOutputs[i].internalTypeName;
    446401        auto& path = m_entryPointItems.outputs[i].path;
    447         stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", internalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n"));
     402        stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", inputVariableName, mangledOutputPath(path), ";\n"));
    448403    }
    449404    return stringBuilder.toString();
     
    470425    m_namedOutputs.reserveInitialCapacity(m_entryPointItems.outputs.size());
    471426    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    472         auto& outputItem = m_entryPointItems.outputs[i];
    473427        NamedOutput namedOutput;
    474428        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);
    479429        m_namedOutputs.uncheckedAppend(WTFMove(namedOutput));
    480430    }
     
    497447    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    498448        auto& outputItem = m_entryPointItems.outputs[i];
    499         auto& internalTypeName = m_namedOutputs[i].internalTypeName;
     449        auto mangledTypeName = m_typeNamer.mangledNameForType(*outputItem.unnamedType);
    500450        auto elementName = m_namedOutputs[i].elementName;
    501451        auto attribute = attributeForSemantic(*outputItem.semantic);
    502         stringBuilder.append(makeString("    ", internalTypeName, ' ', elementName, ' ', attribute, ";\n"));
     452        stringBuilder.append(makeString("    ", mangledTypeName, ' ', elementName, ' ', attribute, ";\n"));
    503453    }
    504454    stringBuilder.append("};\n\n");
     
    549499    for (size_t i = 0; i < m_entryPointItems.outputs.size(); ++i) {
    550500        auto& elementName = m_namedOutputs[i].elementName;
    551         auto& internalTypeName = m_namedOutputs[i].internalTypeName;
    552501        auto& path = m_entryPointItems.outputs[i].path;
    553         stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", internalTypeName, '(', inputVariableName, mangledOutputPath(path), ");\n"));
     502        stringBuilder.append(makeString(outputVariableName, '.', elementName, " = ", inputVariableName, mangledOutputPath(path), ";\n"));
    554503    }
    555504    return stringBuilder.toString();
     
    570519    StringBuilder stringBuilder;
    571520
    572     stringBuilder.append(makeString("kernel void ", functionName, '('));
     521    stringBuilder.append(makeString("compute void ", functionName, '('));
    573522    bool empty = true;
    574523    if (auto resourceSignature = this->resourceSignature()) {
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h

    r246396 r246409  
    130130    struct NamedOutput {
    131131        String elementName;
    132         String internalTypeName;
    133132    };
    134133    Vector<NamedOutput> m_namedOutputs;
     
    159158    struct NamedOutput {
    160159        String elementName;
    161         String internalTypeName;
    162160    };
    163161    Vector<NamedOutput> m_namedOutputs;
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp

    r246396 r246409  
    176176    }
    177177    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());
    180179    if (outputGatherer.error())
    181180        return WTF::nullopt;
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp

    r246396 r246409  
    3333#include "WHLSLCheckDuplicateFunctions.h"
    3434#include "WHLSLChecker.h"
    35 #include "WHLSLComputeDimensions.h"
    3635#include "WHLSLFunctionStageChecker.h"
    3736#include "WHLSLHighZombieFinder.h"
     
    172171    if (!matchedSemantics)
    173172        return WTF::nullopt;
    174     auto computeDimensions = WHLSL::computeDimensions(*program, *matchedSemantics->shader);
    175     if (!computeDimensions)
    176         return WTF::nullopt;
    177173
    178174    auto generatedCode = Metal::generateMetalCode(*program, WTFMove(*matchedSemantics), computePipelineDescriptor.layout);
     
    181177    result.metalSource = WTFMove(generatedCode.metalSource);
    182178    result.mangledEntryPointName = WTFMove(generatedCode.mangledEntryPointName);
    183     result.computeDimensions = WTFMove(*computeDimensions);
    184179    return result;
    185180}
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h

    r246396 r246409  
    4343Optional<RenderPrepareResult> prepare(String& whlslSource, RenderPipelineDescriptor&);
    4444
    45 struct ComputeDimensions {
    46     unsigned width;
    47     unsigned height;
    48     unsigned depth;
    49 };
    50 
    5145struct ComputePrepareResult {
    5246    String metalSource;
    5347    String mangledEntryPointName;
    54     ComputeDimensions computeDimensions;
    5548};
    5649Optional<ComputePrepareResult> prepare(String& whlslSource, ComputePipelineDescriptor&);
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp

    r246396 r246409  
    775775    ASSERT(propertyAccessExpression.anderFunction());
    776776
    777     Visitor::visit(propertyAccessExpression.base());
    778 
    779777    Lexer::Token origin = propertyAccessExpression.origin();
    780778    auto* anderFunction = propertyAccessExpression.anderFunction();
     
    807805void LeftValueSimplifier::visit(AST::IndexExpression& indexExpression)
    808806{
     807    Visitor::visit(indexExpression);
    809808    PropertyResolver().Visitor::visit(indexExpression.indexExpression());
    810809    finishVisiting(indexExpression);
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt

    r246396 r246409  
    433433native operator float(half);
    434434
     435native float operator.x(float4);
     436native float operator.y(float4);
     437native float operator.z(float4);
     438native float operator.w(float4);
     439native float4 operator.x=(float4, float);
     440native float4 operator.y=(float4, float);
     441native float4 operator.z=(float4, float);
     442native float4 operator.w=(float4, float);
     443
    435444native float operator+(float, float);
    436445native float operator-(float, float);
     
    440449native bool operator<(uint, uint);
    441450native 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);
    606451
    607452native float ddx(float);
  • trunk/Source/WebCore/Sources.txt

    r246396 r246409  
    307307Modules/webgpu/GPUCanvasContext.cpp
    308308Modules/webgpu/NavigatorGPU.cpp
    309 Modules/webgpu/WHLSL/WHLSLComputeDimensions.cpp
    310309Modules/webgpu/WHLSL/WHLSLASTDumper.cpp
    311310Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp
  • trunk/Source/WebCore/SourcesCocoa.txt

    r246396 r246409  
    327327platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
    328328platform/graphics/gpu/cocoa/GPUDeviceMetal.mm
    329 platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.cpp
    330329platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
    331330platform/graphics/gpu/cocoa/GPUQueueMetal.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r246396 r246409  
    63956395                1C840B9A21EC400900D0500D /* WHLSLGatherEntryPointItems.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLGatherEntryPointItems.h; sourceTree = "<group>"; };
    63966396                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>"; };
    64016397                1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
    64026398                1C9AE5CA21ED9DF50069D5F2 /* WHLSLHighZombieFinder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLHighZombieFinder.cpp; sourceTree = "<group>"; };
     
    2545325449                                1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */,
    2545425450                                1C840B9721EC400700D0500D /* WHLSLChecker.h */,
    25455                                 1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */,
    25456                                 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */,
    2545725451                                1CA0C2E421EED12A00A11860 /* WHLSLFunctionStageChecker.cpp */,
    2545825452                                1CA0C2E521EED12A00A11860 /* WHLSLFunctionStageChecker.h */,
     
    2599425988                                D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */,
    2599525989                                D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */,
    25996                                 1C86CA4E22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.cpp */,
    25997                                 1C86CA4F22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.h */,
    2599825990                                D087CE3B21ACA94200BDE174 /* GPUProgrammablePassEncoderMetal.mm */,
    2599925991                                D087CE3921ACA94200BDE174 /* GPUQueueMetal.mm */,
  • trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h

    r246396 r246409  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "WHLSLPrepare.h"
    3130#include <wtf/RefCounted.h>
    3231#include <wtf/RefPtr.h>
     
    5049    const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); }
    5150
    52     WHLSL::ComputeDimensions computeDimensions() const { return m_computeDimensions; }
    53 
    5451private:
    55     GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions);
     52    GPUComputePipeline(PlatformComputePipelineSmartPtr&&);
    5653
    5754    PlatformComputePipelineSmartPtr m_platformComputePipeline;
    58     WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 };
    5955};
    6056
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm

    r246397 r246409  
    9393    }
    9494
    95     ASSERT(m_pipeline->platformComputePipeline());
     95    auto pipelineState = m_pipeline->platformComputePipeline();
     96    ASSERT(pipelineState);
    9697
    9798    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    9899
    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);
    100105
    101106    auto threadgroupsPerGrid = MTLSizeMake(x, y, z);
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm

    r246396 r246409  
    3131#import "GPUComputePipelineDescriptor.h"
    3232#import "GPUDevice.h"
    33 #import "GPUPipelineMetalConvertLayout.h"
    3433#import "Logging.h"
    35 #import "WHLSLPrepare.h"
    3634#import <Metal/Metal.h>
    3735#import <wtf/BlockObjCExceptions.h>
    3836
     37OBJC_PROTOCOL(MTLFunction);
     38
    3939namespace WebCore {
    4040
    41 static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *computeMetalLibrary, MTLComputePipelineDescriptor *mtlDescriptor, const String& computeEntryPointName)
     41static RetainPtr<MTLFunction> tryCreateMtlComputeFunction(const GPUPipelineStageDescriptor& stage)
    4242{
    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;
    4649
    4750    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]);
    6352    END_BLOCK_OBJC_EXCEPTIONS;
    6453
    65     return false;
     54    if (!function)
     55        LOG(WebGPU, "GPUComputePipeline::tryCreate(): Cannot create compute MTLFunction \"%s\"!", stage.entryPoint.utf8().data());
     56
     57    return function;
    6658}
    6759
    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)
     60static RetainPtr<MTLComputePipelineState> tryCreateMTLComputePipelineState(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor)
    15761{
    15862    if (!device.platformDevice()) {
    15963        LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!");
    160         return WTF::nullopt;
     64        return nullptr;
    16165    }
    16266
    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;
    16870
    169     RetainPtr<MTLComputePipelineState> pipeline;
     71    RetainPtr<MTLComputePipelineState> pipelineState;
     72    NSError *error = nil;
    17073
    17174    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]);
    18076    END_BLOCK_OBJC_EXCEPTIONS;
    18177
    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;
    18382}
    18483
    18584RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor)
    18685{
    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)
    19188        return nullptr;
    19289
    193     return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions));
     90    return adoptRef(new GPUComputePipeline(WTFMove(mtlPipeline)));
    19491}
    19592
    196 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions)
     93GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline)
    19794    : m_platformComputePipeline(WTFMove(pipeline))
    198     , m_computeDimensions(computeDimensions)
    19995{
    20096}
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

    r246396 r246409  
    3131#import "GPUDevice.h"
    3232#import "GPULimits.h"
    33 #import "GPUPipelineMetalConvertLayout.h"
    3433#import "GPUUtils.h"
    3534#import "Logging.h"
     
    9897        return WHLSL::VertexFormat::FloatR32;
    9998    }
     99}
     100
     101static 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
     113static 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);
    100128}
    101129
     
    341369}
    342370
     371static 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
    343399static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *vertexMetalLibrary, MTLLibrary *fragmentMetalLibrary, MTLRenderPipelineDescriptor *mtlDescriptor, const String& vertexEntryPointName, const String& fragmentEntryPointName)
    344400{
     
    410466        if (!whlslCompileResult)
    411467            return false;
     468
     469        WTFLogAlways("Metal Source: %s", whlslCompileResult->metalSource.utf8().data());
    412470
    413471        NSError *error = nil;
     
    485543static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const char* const functionName, const GPURenderPipelineDescriptor& descriptor, const GPUDevice& device)
    486544{
    487     if (!device.platformDevice()) {
    488         LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!");
    489         return nullptr;
    490     }
    491 
    492545    auto mtlDescriptor = convertRenderPipelineDescriptor(functionName, descriptor, device);
    493546    if (!mtlDescriptor)
     
    498551    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    499552
    500     NSError *error = nil;
     553    NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil];
    501554    pipeline = adoptNS([device.platformDevice() newRenderPipelineStateWithDescriptor:mtlDescriptor.get() error:&error]);
    502555    if (!pipeline)
Note: See TracChangeset for help on using the changeset viewer.