Fix the build after r239844
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2019 03:54:43 +0000 (03:54 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2019 03:54:43 +0000 (03:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192991

Unreviewed.

* Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp:
(WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp:
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp:
(WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp:
(WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239854 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp

index 487db82..fb8d9c2 100644 (file)
@@ -1,3 +1,23 @@
+2019-01-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Fix the build after r239844
+        https://bugs.webkit.org/show_bug.cgi?id=192991
+
+        Unreviewed.
+
+        * Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp:
+        (WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp:
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp:
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp:
+        (WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):
+
 2019-01-10  Justin Fan  <justin_fan@apple.com>
 
         [WebGPU] WebGPUBindGroup and device::createBindGroup prototype
index ae3c78e..e42ee47 100644 (file)
@@ -37,6 +37,74 @@ namespace WHLSL {
 
 namespace AST {
 
+bool BuiltInSemantic::isAcceptableType(const UnnamedType&, const Intrinsics&) const
+{
+    // FIXME: Implement this
+    return true;
+}
+
+bool BuiltInSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition& functionDefinition) const
+{
+    switch (*functionDefinition.entryPointType()) {
+    case FunctionDeclaration::EntryPointType::Vertex:
+        switch (direction) {
+        case ShaderItemDirection::Input:
+            switch (m_variable) {
+            case Variable::SVInstanceID:
+            case Variable::SVVertexID:
+                return true;
+            default:
+                return false;
+            }
+        case ShaderItemDirection::Output:
+            switch (m_variable) {
+            case Variable::PSize:
+            case Variable::SVPosition:
+                return true;
+            default:
+                return false;
+            }
+        }
+    case FunctionDeclaration::EntryPointType::Fragment:
+        switch (direction) {
+        case ShaderItemDirection::Input:
+            switch (m_variable) {
+            case Variable::SVIsFrontFace:
+            case Variable::SVPosition:
+            case Variable::SVSampleIndex:
+            case Variable::SVInnerCoverage:
+                return true;
+            default:
+                return false;
+            }
+        case ShaderItemDirection::Output:
+            switch (m_variable) {
+            case Variable::SVTarget:
+            case Variable::SVDepth:
+            case Variable::SVCoverage:
+                return true;
+            default:
+                return false;
+            }
+        }
+    case FunctionDeclaration::EntryPointType::Compute:
+        switch (direction) {
+        case ShaderItemDirection::Input:
+            switch (m_variable) {
+            case Variable::SVDispatchThreadID:
+            case Variable::SVGroupID:
+            case Variable::SVGroupIndex:
+            case Variable::SVGroupThreadID:
+                return true;
+            default:
+                return false;
+            }
+        case ShaderItemDirection::Output:
+            return false;
+        }
+    }
+}
+
 } // namespace AST
 
 }
index 6365888..65fbb33 100644 (file)
@@ -38,6 +38,17 @@ namespace WHLSL {
 
 namespace AST {
 
+bool ResourceSemantic::isAcceptableType(const UnnamedType&, const Intrinsics&) const
+{
+    // FIXME: Implement this
+    return true;
+}
+
+bool ResourceSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition&) const
+{
+    return direction == ShaderItemDirection::Input;
+}
+
 } // namespace AST
 
 }
index a57dccc..d7f4de7 100644 (file)
@@ -36,6 +36,22 @@ namespace WHLSL {
 
 namespace AST {
 
+bool SpecializationConstantSemantic::isAcceptableType(const UnnamedType& unnamedType, const Intrinsics&) const
+{
+    if (!is<TypeReference>(unnamedType))
+        return false;
+    auto& typeReference = downcast<TypeReference>(unnamedType);
+    ASSERT(typeReference.resolvedType());
+    if (!is<NativeTypeDeclaration>(*typeReference.resolvedType()))
+        return false;
+    return downcast<NativeTypeDeclaration>(*typeReference.resolvedType()).isNumber();
+}
+
+bool SpecializationConstantSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition&) const
+{
+    return direction == ShaderItemDirection::Input;
+}
+
 } // namespace AST
 
 }
index 5553552..389d35e 100644 (file)
@@ -39,6 +39,37 @@ namespace WHLSL {
 
 namespace AST {
 
+bool StageInOutSemantic::isAcceptableType(const UnnamedType& unnamedType, const Intrinsics&) const
+{
+    if (is<ArrayType>(unnamedType))
+        return true;
+    if (!is<TypeReference>(unnamedType))
+        return false;
+    auto& typeReference = downcast<TypeReference>(unnamedType);
+    ASSERT(typeReference.resolvedType());
+    auto& resolvedType = *typeReference.resolvedType();
+    if (is<EnumerationDefinition>(resolvedType))
+        return true;
+    if (!is<NativeTypeDeclaration>(resolvedType))
+        return false;
+    auto& nativeTypeDeclaration = downcast<NativeTypeDeclaration>(*typeReference.resolvedType());
+    return nativeTypeDeclaration.isNumber()
+        || nativeTypeDeclaration.isVector()
+        || nativeTypeDeclaration.isMatrix();
+}
+
+bool StageInOutSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition& functionDefinition) const
+{
+    switch (*functionDefinition.entryPointType()) {
+    case FunctionDeclaration::EntryPointType::Vertex:
+        return true;
+    case FunctionDeclaration::EntryPointType::Fragment:
+        return direction == ShaderItemDirection::Input;
+    case FunctionDeclaration::EntryPointType::Compute:
+        return false;
+    }
+}
+
 } // namespace AST
 
 }