2
0
Эх сурвалжийг харах

[spirv] Remove duplicated HLSL type probing methods (#755)

Lei Zhang 7 жил өмнө
parent
commit
6f9fb6a534

+ 9 - 10
tools/clang/lib/SPIRV/SPIRVEmitter.cpp

@@ -44,7 +44,7 @@ bool hasSemantic(const DeclaratorDecl *decl,
 
 bool patchConstFuncTakesHullOutputPatch(FunctionDecl *pcf) {
   for (const auto *param : pcf->parameters())
-    if (TypeTranslator::isOutputPatch(param->getType()))
+    if (hlsl::IsHLSLOutputPatchType(param->getType()))
       return true;
   return false;
 }
@@ -1520,16 +1520,16 @@ uint32_t SPIRVEmitter::processFlatConversion(const QualType type,
         }
         case BuiltinType::Bool:
           return castToBool(initId, initType, ty);
-          // int, min16int (short), and min12int are all translated to 32-bit
-          // signed integers in SPIR-V.
+        // int, min16int (short), and min12int are all translated to 32-bit
+        // signed integers in SPIR-V.
         case BuiltinType::Int:
         case BuiltinType::Short:
         case BuiltinType::Min12Int:
         case BuiltinType::UShort:
         case BuiltinType::UInt:
           return castToInt(initId, initType, ty);
-          // float, min16float (half), and min10float are all translated to
-          // 32-bit float in SPIR-V.
+        // float, min16float (half), and min10float are all translated to
+        // 32-bit float in SPIR-V.
         case BuiltinType::Float:
         case BuiltinType::Half:
         case BuiltinType::Min10Float:
@@ -5530,8 +5530,7 @@ bool SPIRVEmitter::emitEntryFunctionWrapper(const FunctionDecl *decl,
                             hlsl::IsHLSLStreamOutputType(param->getType());
     if (!param->hasAttr<HLSLOutAttr>() && !isGSOutputStream) {
       uint32_t loadedValue = 0;
-      if (shaderModel.IsHS() &&
-          TypeTranslator::isInputPatch(param->getType())) {
+      if (shaderModel.IsHS() && hlsl::IsHLSLInputPatchType(param->getType())) {
         const uint32_t hullInputPatchId =
             declIdMapper.createStageVarWithoutSemantics(
                 /*isInput*/ true, typeId, "hullEntryPointInput",
@@ -5539,7 +5538,7 @@ bool SPIRVEmitter::emitEntryFunctionWrapper(const FunctionDecl *decl,
         loadedValue = theBuilder.createLoad(typeId, hullInputPatchId);
         hullMainInputPatchParam = tempVar;
       } else if (shaderModel.IsDS() &&
-                 TypeTranslator::isOutputPatch(param->getType())) {
+                 hlsl::IsHLSLOutputPatchType(param->getType())) {
         // OutputPatch is the output of the hull shader and an input to the
         // domain shader.
         const uint32_t hullOutputPatchId =
@@ -5711,9 +5710,9 @@ bool SPIRVEmitter::processHullEntryPointOutputAndPatchConstFunc(
     // ControlPoints as well as the PatchID (PrimitiveID). This does not
     // necessarily mean that they are present. There is also no requirement
     // for the order of parameters passed to PCF.
-    if (TypeTranslator::isInputPatch(param->getType()))
+    if (hlsl::IsHLSLInputPatchType(param->getType()))
       pcfParams.push_back(hullMainInputPatch);
-    if (TypeTranslator::isOutputPatch(param->getType()))
+    if (hlsl::IsHLSLOutputPatchType(param->getType()))
       pcfParams.push_back(hullMainOutputPatch);
     if (hasSemantic(param, hlsl::DXIL::SemanticKind::PrimitiveID)) {
       if (!primitiveId) {

+ 0 - 23
tools/clang/lib/SPIRV/TypeTranslator.cpp

@@ -303,29 +303,6 @@ bool TypeTranslator::isScalarType(QualType type, QualType *scalarType) {
   return isScalar;
 }
 
-bool TypeTranslator::isOutputStream(QualType type) {
-  if (const auto *rt = type->getAs<RecordType>()) {
-    const auto name = rt->getDecl()->getName();
-    return name == "PointStream" || name == "LineStream" ||
-           name == "TriangleStream";
-  }
-  return false;
-}
-
-bool TypeTranslator::isOutputPatch(QualType type) {
-  if (const auto *rt = type->getAs<RecordType>()) {
-    return rt->getDecl()->getName() == "OutputPatch";
-  }
-  return false;
-}
-
-bool TypeTranslator::isInputPatch(QualType type) {
-  if (const auto *rt = type->getAs<RecordType>()) {
-    return rt->getDecl()->getName() == "InputPatch";
-  }
-  return false;
-}
-
 bool TypeTranslator::isRWByteAddressBuffer(QualType type) {
   if (const auto *rt = type->getAs<RecordType>()) {
     return rt->getDecl()->getName() == "RWByteAddressBuffer";

+ 0 - 9
tools/clang/lib/SPIRV/TypeTranslator.h

@@ -85,18 +85,9 @@ public:
   /// \brief Returns true if the given type is an HLSL RWTexture type.
   static bool isRWTexture(QualType);
 
-  /// \brief Returns true if the given type is an HLSL output stream type.
-  static bool isOutputStream(QualType);
-
   /// \brief Returns true if the given type is an HLSL sampler type.
   static bool isSampler(QualType);
 
-  /// \brief Returns true if the given type is an HLSL OutputPatch type.
-  static bool isOutputPatch(QualType);
-
-  /// \brief Returns true if the given type is an HLSL InputPatch type.
-  static bool isInputPatch(QualType);
-
   /// \brief Returns true if the given type will be translated into a SPIR-V
   /// scalar type. This includes normal scalar types, vectors of size 1, and
   /// 1x1 matrices. If scalarType is not nullptr, writes the scalar type to