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

Update shader model 6.2 (#435)

1. Update shader model 6.2
2. update DXIL version to 1.2 and its tests
3. Allow noalias and alias_scope metadata per instruction for validator 1.2
Young Kim 8 жил өмнө
parent
commit
4d325c78b4

+ 1 - 1
include/dxc/HLSL/DxilConstants.h

@@ -27,7 +27,7 @@ import hctdb_instrhelp
 namespace DXIL {
   // DXIL version.
   const unsigned kDxilMajor = 1;
-  const unsigned kDxilMinor = 1;
+  const unsigned kDxilMinor = 2;
 
   inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) {
     return 0 | (DxilMajor << 8) | (DxilMinor);

+ 1 - 1
include/dxc/HLSL/DxilShaderModel.h

@@ -86,7 +86,7 @@ private:
               unsigned m_NumInputRegs, unsigned m_NumOutputRegs,
               bool m_bUAVs, bool m_bTypedUavs, unsigned m_UAVRegsLim);
 
-  static const unsigned kNumShaderModels = 34;
+  static const unsigned kNumShaderModels = 41;
   static const ShaderModel ms_ShaderModels[kNumShaderModels];
 
   static const ShaderModel *GetInvalid();

+ 2 - 2
lib/HLSL/DxilGenerationPass.cpp

@@ -1441,7 +1441,7 @@ public:
 
   const char *getPassName() const override { return "HLSL DXIL Metadata Emit"; }
 
-  void patchValidation_1_0(Module &M) {
+  void patchValidation_1_1(Module &M) {
     for (iplist<Function>::iterator F : M.getFunctionList()) {
       for (Function::iterator BBI = F->begin(), BBE = F->end(); BBI != BBE;
            ++BBI) {
@@ -1477,7 +1477,7 @@ public:
       unsigned ValMinor = 0;
       M.GetDxilModule().GetValidatorVersion(ValMajor, ValMinor);
       if (ValMajor == 1 && ValMinor <= 1) {
-        patchValidation_1_0(M);
+        patchValidation_1_1(M);
       }
       for (iplist<Function>::iterator F : M.getFunctionList()) {
         if (!hlslOP->IsDxilOpFunc(F))

+ 23 - 3
lib/HLSL/DxilShaderModel.cpp

@@ -54,6 +54,7 @@ bool ShaderModel::IsValidForDxil() const {
       switch (m_Minor) {
       case 0:
       case 1:
+      case 2:
         return true;
       }
     }
@@ -116,9 +117,15 @@ const ShaderModel *ShaderModel::GetByName(const char *pszName) {
 
   unsigned Minor;
   switch (pszName[Idx++]) {
-  case '0': Minor = 0;  break;
-  case '1': Minor = 1;  break;
-  default:  return GetInvalid();
+    case '0': Minor = 0;  break;
+    case '1': Minor = 1;  break;
+    case '2':
+      if (Major == 6) {
+        Minor = 2;
+        break;
+      }
+      else return GetInvalid();
+    default:  return GetInvalid();
   }
   if (pszName[Idx++] != 0)
     return GetInvalid();
@@ -136,6 +143,9 @@ void ShaderModel::GetDxilVersion(unsigned &DxilMajor, unsigned &DxilMinor) const
   case 1:
     DxilMinor = 1;
     break;
+  case 2:
+    DxilMinor = 2;
+    break;
   default:
     DXASSERT(0, "IsValidForDxil() should have caught this.");
     break;
@@ -152,6 +162,9 @@ void ShaderModel::GetMinValidatorVersion(unsigned &ValMajor, unsigned &ValMinor)
   case 1:
     ValMinor = 1;
     break;
+  case 2:
+    ValMinor = 2;
+    break;
   default:
     DXASSERT(0, "IsValidForDxil() should have caught this.");
     break;
@@ -184,11 +197,13 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
   SM(Kind::Compute,  5, 1, "cs_5_1",  0,  0,   true,  true,  UINT_MAX),
   SM(Kind::Compute,  6, 0, "cs_6_0",  0,  0,   true,  true,  UINT_MAX),
   SM(Kind::Compute,  6, 1, "cs_6_1",  0,  0,   true,  true,  UINT_MAX),
+  SM(Kind::Compute,  6, 2, "cs_6_2",  0,  0,   true,  true,  UINT_MAX),
 
   SM(Kind::Domain,   5, 0, "ds_5_0",  32, 32,  true,  true,  64),
   SM(Kind::Domain,   5, 1, "ds_5_1",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Domain,   6, 0, "ds_6_0",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Domain,   6, 1, "ds_6_1",  32, 32,  true,  true,  UINT_MAX),
+  SM(Kind::Domain,   6, 2, "ds_6_2",  32, 32,  true,  true,  UINT_MAX),
 
   SM(Kind::Geometry, 4, 0, "gs_4_0",  16, 32,  false, false, 0),
   SM(Kind::Geometry, 4, 1, "gs_4_1",  32, 32,  false, false, 0),
@@ -196,11 +211,13 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
   SM(Kind::Geometry, 5, 1, "gs_5_1",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Geometry, 6, 0, "gs_6_0",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Geometry, 6, 1, "gs_6_1",  32, 32,  true,  true,  UINT_MAX),
+  SM(Kind::Geometry, 6, 2, "gs_6_2",  32, 32,  true,  true,  UINT_MAX),
 
   SM(Kind::Hull,     5, 0, "hs_5_0",  32, 32,  true,  true,  64),
   SM(Kind::Hull,     5, 1, "hs_5_1",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Hull,     6, 0, "hs_6_0",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Hull,     6, 1, "hs_6_1",  32, 32,  true,  true,  UINT_MAX),
+  SM(Kind::Hull,     6, 2, "hs_6_2",  32, 32,  true,  true,  UINT_MAX),
 
   SM(Kind::Pixel,    4, 0, "ps_4_0",  32, 8,   false, false, 0),
   SM(Kind::Pixel,    4, 1, "ps_4_1",  32, 8,   false, false, 0),
@@ -208,6 +225,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
   SM(Kind::Pixel,    5, 1, "ps_5_1",  32, 8,   true,  true,  UINT_MAX),
   SM(Kind::Pixel,    6, 0, "ps_6_0",  32, 8,   true,  true,  UINT_MAX),
   SM(Kind::Pixel,    6, 1, "ps_6_1",  32, 8,   true,  true,  UINT_MAX),
+  SM(Kind::Pixel,    6, 2, "ps_6_2",  32, 8,   true,  true,  UINT_MAX),
 
   SM(Kind::Vertex,   4, 0, "vs_4_0",  16, 16,  false, false, 0),
   SM(Kind::Vertex,   4, 1, "vs_4_1",  32, 32,  false, false, 0),
@@ -215,8 +233,10 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
   SM(Kind::Vertex,   5, 1, "vs_5_1",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Vertex,   6, 0, "vs_6_0",  32, 32,  true,  true,  UINT_MAX),
   SM(Kind::Vertex,   6, 1, "vs_6_1",  32, 32,  true,  true,  UINT_MAX),
+  SM(Kind::Vertex,   6, 2, "vs_6_2",  32, 32,  true,  true,  UINT_MAX),
 
   SM(Kind::Library,  6, 1, "lib_6_1",  32, 32,  true,  true,  UINT_MAX),
+  SM(Kind::Library,  6, 2, "lib_6_2",  32, 32,  true,  true,  UINT_MAX),
 
   SM(Kind::Invalid,  0, 0, "invalid", 0,  0,   false, false, 0),
 };

+ 8 - 2
lib/HLSL/DxilValidation.cpp

@@ -2299,6 +2299,9 @@ static void ValidateInstructionMetadata(Instruction *I,
       ValidateTBAAMetadata(MD.second, ValCtx);
     } else if (MD.first == LLVMContext::MD_range) {
       // Validated in Verifier.cpp.
+    } else if (MD.first == LLVMContext::MD_noalias ||
+               MD.first == LLVMContext::MD_alias_scope) {
+      // noalias for DXIL validator >= 1.2
     } else {
       ValCtx.EmitMetaError(MD.second, ValidationRule::MetaUsed);
     }
@@ -2323,6 +2326,7 @@ static void ValidateFunctionBody(Function *F, ValidationContext &ValCtx) {
       llvm::Instruction &I = *i;
 
       if (I.hasMetadata()) {
+
         ValidateInstructionMetadata(&I, ValCtx);
       }
 
@@ -2756,7 +2760,7 @@ static void ValidateDxilVersion(ValidationContext &ValCtx) {
           GetNodeOperandAsInt(ValCtx, pVerValues, 1, &minorVer)) {
         // This will need to be updated as dxil major/minor versions evolve,
         // depending on the degree of compat across versions.
-        if ((majorVer == 1 && minorVer < 2) &&
+        if ((majorVer == 1 && minorVer < 3) &&
             (majorVer == ValCtx.m_DxilMajor && minorVer == ValCtx.m_DxilMinor)) {
           return;
         }
@@ -4101,8 +4105,10 @@ void GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor) {
   // 1.0 is the first validator.
   // 1.1 adds:
   // - ILDN container part support
+  // 1.2 adds:
+  // - Metadata for floating point denorm mode
   *pMajor = 1;
-  *pMinor = 1;
+  *pMinor = 2;
 }
 
 _Use_decl_annotations_ HRESULT

+ 19 - 16
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -143,9 +143,12 @@ bool VersionSupportInfo::SkipIRSensitiveTest() {
   }
   return false;
 }
-bool VersionSupportInfo::SkipDxil_1_1_Test() {
-  if (m_DxilMajor < 1 || m_DxilMinor < 1 || m_ValMajor < 1 || m_ValMinor < 1) {
-    WEX::Logging::Log::Comment(L"Test skipped because it requires Dxil 1.1 and Validator 1.1.");
+bool VersionSupportInfo::SkipDxilVersion(unsigned major, unsigned minor) {
+  if (m_DxilMajor < major || (m_DxilMajor == major && m_DxilMinor < minor) ||
+      m_ValMajor < major || (m_ValMajor == major && m_ValMinor < minor)) {
+    WEX::Logging::Log::Comment(WEX::Common::String().Format(
+        L"Test skipped because it requires Dxil %u.%u and Validator %u.%u.",
+        major, minor, major, minor));
     return true;
   }
   return false;
@@ -2674,22 +2677,22 @@ TEST_F(CompilerTest, CodeGenAtomic2) {
 }
 
 TEST_F(CompilerTest, CodeGenAttributeAtVertex) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\attributeAtVertex.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenBarycentrics) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentrics.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenBarycentrics1) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentrics1.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenBarycentricsThreeSV) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentricsThreeSV.hlsl");
 }
 
@@ -2910,7 +2913,7 @@ TEST_F(CompilerTest, CodeGenEnum2) {
 }
 
 TEST_F(CompilerTest, CodeGenEnum3) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
     CodeGenTestCheck(L"..\\CodeGenHLSL\\enum3.hlsl");
 }
 
@@ -3407,7 +3410,7 @@ TEST_F(CompilerTest, CodeGenMultiUAVLoad1) {
 }
 
 TEST_F(CompilerTest, CodeGenMultiUAVLoad2) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad2.hlsl");
 }
 
@@ -3416,23 +3419,23 @@ TEST_F(CompilerTest, CodeGenMultiUAVLoad3) {
 }
 
 TEST_F(CompilerTest, CodeGenMultiUAVLoad4) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad4.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenMultiUAVLoad5) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad5.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenMultiUAVLoad6) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad6.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenMultiUAVLoad7) {
-    if (m_ver.SkipDxil_1_1_Test()) return;
-    CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad7.hlsl");
+  if (m_ver.SkipDxilVersion(1,1)) return;
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad7.hlsl");
 }
 
 TEST_F(CompilerTest, CodeGenMultiStream) {
@@ -3954,7 +3957,7 @@ TEST_F(CompilerTest, CodeGenUint64_1) {
 }
 
 TEST_F(CompilerTest, CodeGenUint64_2) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\uint64_2.hlsl");
 }
 
@@ -5235,7 +5238,7 @@ TEST_F(CompilerTest, WhenSigMismatchPCFunctionThenFail) {
 }
 
 TEST_F(CompilerTest, ViewID) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid01.hlsl");
   CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid02.hlsl");
   CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid03.hlsl");

+ 2 - 2
tools/clang/unittests/HLSL/DxcTestUtils.h

@@ -125,8 +125,8 @@ public:
   void Initialize(dxc::DxcDllSupport &dllSupport);
   // Return true if IR sensitive test should be skipped, and log comment
   bool SkipIRSensitiveTest();
-  // Return true if DXIL 1.1 test should be skipped, and log comment
-  bool SkipDxil_1_1_Test();
+  // Return true if test requiring DXIL of given version should be skipped, and log comment
+  bool SkipDxilVersion(unsigned major, unsigned minor);
   // Return true if out-of-memory test should be skipped, and log comment
   bool SkipOutOfMemoryTest();
 };

+ 24 - 4
tools/clang/unittests/HLSL/DxilModuleTest.cpp

@@ -46,7 +46,8 @@ public:
   // Basic loading tests.
   TEST_METHOD(LoadDxilModule_1_0);
   TEST_METHOD(LoadDxilModule_1_1);
-  
+  TEST_METHOD(LoadDxilModule_1_2);
+
   // Precise query tests.
   TEST_METHOD(Precise1);
   TEST_METHOD(Precise2);
@@ -73,8 +74,8 @@ public:
     VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
   }
 
-  bool SkipDxil_1_1_Test() {
-    return m_ver.SkipDxil_1_1_Test();
+  bool SkipDxil_Test(unsigned major, unsigned minor) {
+    return m_ver.SkipDxilVersion(major, minor);
   }
   
   IDxcOperationResult *Compile(const char *program, LPCWSTR shaderModel = L"ps_6_0") {
@@ -179,7 +180,7 @@ TEST_F(DxilModuleTest, LoadDxilModule_1_0) {
 
 TEST_F(DxilModuleTest, LoadDxilModule_1_1) {
   Compiler c(m_dllSupport);
-  if (c.SkipDxil_1_1_Test()) return;
+  if (c.SkipDxil_Test(1,1)) return;
   c.Compile(
     "float4 main() : SV_Target {\n"
     "  return 0;\n"
@@ -196,6 +197,25 @@ TEST_F(DxilModuleTest, LoadDxilModule_1_1) {
   VERIFY_IS_TRUE(vMinor == 1);
 }
 
+TEST_F(DxilModuleTest, LoadDxilModule_1_2) {
+  Compiler c(m_dllSupport);
+  if (c.SkipDxil_Test(1,2)) return;
+  c.Compile(
+    "float4 main() : SV_Target {\n"
+    "  return 0;\n"
+    "}\n"
+    ,
+    L"ps_6_2"
+  );
+
+  // Basic sanity check on dxil version in dxil module.
+  DxilModule &DM = c.GetDxilModule();
+  unsigned vMajor, vMinor;
+  DM.GetDxilVersion(vMajor, vMinor);
+  VERIFY_IS_TRUE(vMajor == 1);
+  VERIFY_IS_TRUE(vMinor == 2);
+}
+
 TEST_F(DxilModuleTest, Precise1) {
   Compiler c(m_dllSupport);
   c.Compile(

+ 10 - 10
tools/clang/unittests/HLSL/ValidationTest.cpp

@@ -2939,7 +2939,7 @@ TEST_F(ValidationTest, WhenFeatureInfoMismatchThenFail) {
 }
 
 TEST_F(ValidationTest, ViewIDInCSFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(" \
 RWStructuredBuffer<uint> Buf; \
 [numthreads(1,1,1)] \
@@ -2956,7 +2956,7 @@ void main(uint id : SV_GroupIndex) \
 }
 
 TEST_F(ValidationTest, ViewIDIn60Fail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(" \
 [domain(\"tri\")] \
 float4 main(float3 pos : Position, uint id : SV_PrimitiveID) : SV_Position \
@@ -2972,7 +2972,7 @@ float4 main(float3 pos : Position, uint id : SV_PrimitiveID) : SV_Position \
 }
 
 TEST_F(ValidationTest, ViewIDNoSpaceFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(" \
 float4 main(uint vid : SV_ViewID, float3 In[31] : INPUT) : SV_Target \
 { return float4(In[vid], 1); } \
@@ -2989,7 +2989,7 @@ float4 main(uint vid : SV_ViewID, float3 In[31] : INPUT) : SV_Target \
 }
 
 TEST_F(ValidationTest, GetAttributeAtVertexInVSFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
     "float4 main(float4 pos: POSITION) : SV_POSITION { return pos.x; }",
     "vs_6_1",
@@ -3002,7 +3002,7 @@ TEST_F(ValidationTest, GetAttributeAtVertexInVSFail) {
 }
 
 TEST_F(ValidationTest, GetAttributeAtVertexIn60Fail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
     "float4 main(float4 col : COLOR) : "
     "SV_Target { return EvaluateAttributeCentroid(col).x; }",
@@ -3016,7 +3016,7 @@ TEST_F(ValidationTest, GetAttributeAtVertexIn60Fail) {
 }
 
 TEST_F(ValidationTest, GetAttributeAtVertexInterpFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg("float4 main(nointerpolation float4 col : COLOR) : "
                           "SV_Target { return GetAttributeAtVertex(col, 0); }",
                           "ps_6_1", {"!\"COLOR\", i8 9, i8 0, (![0-9]+), i8 1"},
@@ -3027,7 +3027,7 @@ TEST_F(ValidationTest, GetAttributeAtVertexInterpFail) {
 }
 
 TEST_F(ValidationTest, BarycentricMaxIndexFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
       "float4 main(float3 bary : SV_Barycentrics, noperspective float3 bary1 : "
       "SV_Barycentrics1) : SV_Target { return 1; }",
@@ -3042,7 +3042,7 @@ TEST_F(ValidationTest, BarycentricMaxIndexFail) {
 }
 
 TEST_F(ValidationTest, BarycentricNoInterpolationFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
       "float4 main(float3 bary : SV_Barycentrics) : "
       "SV_Target { return bary.x * float4(1,0,0,0) + bary.y * float4(0,1,0,0) "
@@ -3054,7 +3054,7 @@ TEST_F(ValidationTest, BarycentricNoInterpolationFail) {
 }
 
 TEST_F(ValidationTest, BarycentricFloat4Fail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
       "float4 main(float4 col : COLOR) : SV_Target { return col; }", "ps_6_1",
       {"!\"COLOR\", i8 9, i8 0"}, {"!\"SV_Barycentrics\", i8 9, i8 28"},
@@ -3062,7 +3062,7 @@ TEST_F(ValidationTest, BarycentricFloat4Fail) {
 }
 
 TEST_F(ValidationTest, BarycentricSamePerspectiveFail) {
-  if (m_ver.SkipDxil_1_1_Test()) return;
+  if (m_ver.SkipDxilVersion(1,1)) return;
   RewriteAssemblyCheckMsg(
       "float4 main(float3 bary : SV_Barycentrics, noperspective float3 bary1 : "
       "SV_Barycentrics1) : SV_Target { return 1; }",