Prechádzať zdrojové kódy

[spirv] Error out if SV_InnerCoverage is not uint. (#3102)

Ehsan 5 rokov pred
rodič
commit
d2ecfeb065

+ 4 - 0
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

@@ -2041,6 +2041,10 @@ bool DeclResultIdMapper::createStageVars(
                                                  clang::ArrayType::Normal, 0);
       break;
     case hlsl::Semantic::Kind::InnerCoverage:
+      if (!type->isSpecificBuiltinType(BuiltinType::UInt)) {
+        emitError("SV_InnerCoverage must be of uint type.", loc);
+        return false;
+      }
       evalType = astContext.BoolTy;
       break;
     case hlsl::Semantic::Kind::Barycentrics:

+ 8 - 0
tools/clang/test/CodeGenSPIRV/semantic.inner-coverage.type-error.hlsl

@@ -0,0 +1,8 @@
+// Run: %dxc -T ps_6_0 -E main
+
+// CHECK: 5:19: error: SV_InnerCoverage must be of uint type.
+
+float4 main(float inCov : SV_InnerCoverage) : SV_Target {
+  return inCov;
+}
+

+ 4 - 0
tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

@@ -806,6 +806,10 @@ TEST_F(FileTest, SemanticCoverageTypeMismatchPS) {
 TEST_F(FileTest, SemanticInnerCoveragePS) {
   runFileTest("semantic.inner-coverage.ps.hlsl");
 }
+TEST_F(FileTest, SemanticInnerCoverageTypeError) {
+  runFileTest("semantic.inner-coverage.type-error.hlsl", Expect::Failure);
+}
+
 TEST_F(FileTest, SemanticViewIDVS) { runFileTest("semantic.view-id.vs.hlsl"); }
 TEST_F(FileTest, SemanticViewIDHS) { runFileTest("semantic.view-id.hs.hlsl"); }
 TEST_F(FileTest, SemanticViewIDDS) { runFileTest("semantic.view-id.ds.hlsl"); }