Kaynağa Gözat

Fix Dxil validator compat and test issues (#3610)

(cherry picked from commit 20396101903c899c98dc3f3fcb35381f0b281f9b)
Tex Riddell 4 yıl önce
ebeveyn
işleme
695cc752fd

+ 2 - 1
lib/DXIL/DxilShaderFlags.cpp

@@ -373,6 +373,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
   M->GetValidatorVersion(valMajor, valMinor);
   M->GetValidatorVersion(valMajor, valMinor);
   bool hasMulticomponentUAVLoadsBackCompat = valMajor == 1 && valMinor == 0;
   bool hasMulticomponentUAVLoadsBackCompat = valMajor == 1 && valMinor == 0;
   bool hasViewportOrRTArrayIndexBackCombat = valMajor == 1 && valMinor < 4;
   bool hasViewportOrRTArrayIndexBackCombat = valMajor == 1 && valMinor < 4;
+  bool hasBarycentricsBackCompat = valMajor == 1 && valMinor < 6;
 
 
   Type *int16Ty = Type::getInt16Ty(F->getContext());
   Type *int16Ty = Type::getInt16Ty(F->getContext());
   Type *int64Ty = Type::getInt64Ty(F->getContext());
   Type *int64Ty = Type::getInt64Ty(F->getContext());
@@ -630,7 +631,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
   flag.SetViewID(hasViewID);
   flag.SetViewID(hasViewID);
   flag.SetViewportAndRTArrayIndex(hasViewportOrRTArrayIndex);
   flag.SetViewportAndRTArrayIndex(hasViewportOrRTArrayIndex);
   flag.SetShadingRate(hasShadingRate);
   flag.SetShadingRate(hasShadingRate);
-  flag.SetBarycentrics(hasBarycentrics);
+  flag.SetBarycentrics(hasBarycentricsBackCompat ? false : hasBarycentrics);
   flag.SetSamplerFeedback(hasSamplerFeedback);
   flag.SetSamplerFeedback(hasSamplerFeedback);
   flag.SetRaytracingTier1_1(hasRaytracingTier1_1);
   flag.SetRaytracingTier1_1(hasRaytracingTier1_1);
   flag.SetAtomicInt64OnTypedResource(hasAtomicInt64OnTypedResource);
   flag.SetAtomicInt64OnTypedResource(hasAtomicInt64OnTypedResource);

+ 2 - 2
tools/clang/test/HLSLFileCheck/hlsl/intrinsics/helper/IsHelperLane.hlsl

@@ -32,7 +32,7 @@
 // RUN: %dxc -E cs -T cs_6_0 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
 // RUN: %dxc -E cs -T cs_6_0 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
 // RUN: %dxc -E as -T as_6_5 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
 // RUN: %dxc -E as -T as_6_5 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
 // RUN: %dxc -E ms -T ms_6_5 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
 // RUN: %dxc -E ms -T ms_6_5 -Od %s | FileCheck %s -check-prefixes=CHECKCONST
-// RUN: %dxc -T lib_6_5 %s | FileCheck %s -check-prefixes=CHECKLIBGV
+// RUN: %dxilver 1.6 | %dxc -T lib_6_5 %s | FileCheck %s -check-prefixes=CHECKLIBGV
 
 
 
 
 // Exactly one call
 // Exactly one call
@@ -277,7 +277,7 @@ RWStructuredBuffer<float4> SB;
 void cs(uint gidx : SV_GroupIndex)
 void cs(uint gidx : SV_GroupIndex)
 {
 {
   float4 result = a + IsHelperLane();
   float4 result = a + IsHelperLane();
-  SB[gidx] = QuadReadAcrossX(result);
+  SB[gidx] = result;
 }
 }
 
 
 /// Amplification Shader
 /// Amplification Shader

+ 4 - 3
tools/clang/test/HLSLFileCheck/hlsl/intrinsics/pixel/attr/attributeAtVertex.hlsl

@@ -1,8 +1,9 @@
-// RUN: %dxilver 1.1 | %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_1 %s | FileCheck %s -check-prefixes=CHECK,CHK16
 
 
 
 
-// CHECK: Note: shader requires additional functionality:
-// CHECK-NEXT: Barycentrics
+// CHK16: Note: shader requires additional functionality:
+// CHK16-NEXT: Barycentrics
 
 
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 0, i32 0, i8 0, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 0, i32 0, i8 0, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 0, i32 0, i8 1, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 0, i32 0, i8 1, i8 0)

+ 4 - 3
tools/clang/test/HLSLFileCheck/hlsl/intrinsics/pixel/attr/attributeAtVertexNoOpt.hlsl

@@ -1,7 +1,8 @@
-// RUN: %dxilver 1.1 | %dxc -E main -T ps_6_1 -O0 %s | FileCheck %s
+// RUN: %dxc -E main -T ps_6_1 -O0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_1 -O0 %s | FileCheck %s -check-prefixes=CHECK,CHK16
 
 
-// CHECK: Note: shader requires additional functionality:
-// CHECK-NEXT: Barycentrics
+// CHK16: Note: shader requires additional functionality:
+// CHK16-NEXT: Barycentrics
 
 
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 1, i32 0, i8 0, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 1, i32 0, i8 0, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 1, i32 0, i8 1, i8 0)
 // CHECK: call float @dx.op.attributeAtVertex.f32(i32 137, i32 1, i32 0, i8 1, i8 0)

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/lifetimes/lifetimes_lib_6_3.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -T lib_6_3 -enable-lifetime-markers %s  | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -T lib_6_3 -enable-lifetime-markers %s  | FileCheck %s
 
 
 // This file is identical to lifetimes.hlsl except that it tests for
 // This file is identical to lifetimes.hlsl except that it tests for
 // undef stores instead of lifetime intrinsics (fallback for earlier
 // undef stores instead of lifetime intrinsics (fallback for earlier

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/objects/CbufferLegacy/cbufferSize1.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_0 %s | FileCheck %s
 
 
 // CHECK: error: CBuffer size is 65552 bytes, exceeding maximum of 65536 bytes.
 // CHECK: error: CBuffer size is 65552 bytes, exceeding maximum of 65536 bytes.
 
 

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/objects/CbufferLegacy/cbufferSize3.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_0 %s | FileCheck %s
 
 
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 
 

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/objects/CbufferLegacy/cbufferSize5.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_0 %s | FileCheck %s
 
 
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 
 

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/objects/CbufferLegacy/cbufferSize6.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_0 %s | FileCheck %s
 
 
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 // CHECK: error: CBuffer size is 65540 bytes, exceeding maximum of 65536 bytes.
 
 

+ 4 - 3
tools/clang/test/HLSLFileCheck/hlsl/semantics/sv_barycentrics/barycentrics.hlsl

@@ -1,7 +1,8 @@
-// RUN: %dxilver 1.1 | %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_1 %s | FileCheck %s -check-prefixes=CHECK,CHK16
 
 
-// CHECK: Note: shader requires additional functionality:
-// CHECK-NEXT: Barycentrics
+// CHK16: Note: shader requires additional functionality:
+// CHK16-NEXT: Barycentrics
 // CHECK: !"SV_Barycentrics"
 // CHECK: !"SV_Barycentrics"
 
 
 float4 main(float3 bary : SV_Barycentrics) : SV_Target
 float4 main(float3 bary : SV_Barycentrics) : SV_Target

+ 4 - 3
tools/clang/test/HLSLFileCheck/hlsl/semantics/sv_barycentrics/barycentrics1.hlsl

@@ -1,7 +1,8 @@
-// RUN: %dxilver 1.1 | %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxc -E main -T ps_6_1 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_1 %s | FileCheck %s -check-prefixes=CHECK,CHK16
 
 
-// CHECK: Note: shader requires additional functionality:
-// CHECK-NEXT: Barycentrics
+// CHK16: Note: shader requires additional functionality:
+// CHK16-NEXT: Barycentrics
 
 
 // CHECK: ; SV_Barycentrics
 // CHECK: ; SV_Barycentrics
 // CHECK: ; SV_Barycentrics
 // CHECK: ; SV_Barycentrics

+ 1 - 1
tools/clang/test/HLSLFileCheck/hlsl/types/conversions/semantics_Mod.hlsl

@@ -1,4 +1,4 @@
-// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E main -T ps_6_0 %s | FileCheck %s
 
 
 // CHECK: @main
 // CHECK: @main
 
 

+ 9 - 9
tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/groupshared/groupshared_shadermodels.hlsl

@@ -1,12 +1,12 @@
-// RUN: %dxc -E PSMain -T ps_6_0 %s | FileCheck %s
-// RUN: %dxc -E VSMain -T vs_6_0 %s | FileCheck %s
-// RUN: %dxc -E GSMain -T gs_6_0 %s | FileCheck %s
-// RUN: %dxc -E HSMain -T hs_6_0 %s | FileCheck %s
-// RUN: %dxc -E DSMain -T ds_6_0 %s | FileCheck %s
-// RUN: %dxc -E CSMain -T lib_6_5 %s | FileCheck %s -check-prefix=LIBCHK
-// RUN: %dxc -E CSMain -T cs_6_0 %s | FileCheck %s -check-prefix=CSCHK
-// RUN: %dxc -E MSMain -T ms_6_5 %s | FileCheck %s -check-prefix=CSCHK
-// RUN: %dxc -E ASMain -T as_6_5 %s | FileCheck %s -check-prefix=CSCHK
+// RUN: %dxilver 1.6 | %dxc -E PSMain -T ps_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E VSMain -T vs_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E GSMain -T gs_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E HSMain -T hs_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E DSMain -T ds_6_0 %s | FileCheck %s
+// RUN: %dxilver 1.6 | %dxc -E CSMain -T lib_6_5 %s | FileCheck %s -check-prefix=LIBCHK
+// RUN: %dxilver 1.6 | %dxc -E CSMain -T cs_6_0 %s | FileCheck %s -check-prefix=CSCHK
+// RUN: %dxilver 1.6 | %dxc -E MSMain -T ms_6_5 %s | FileCheck %s -check-prefix=CSCHK
+// RUN: %dxilver 1.6 | %dxc -E ASMain -T as_6_5 %s | FileCheck %s -check-prefix=CSCHK
 
 
 // Test that the proper error for groupshared is produced when compiling in non-compute contexts
 // Test that the proper error for groupshared is produced when compiling in non-compute contexts
 // and that everything is fine when we are
 // and that everything is fine when we are

+ 2 - 0
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -1419,6 +1419,7 @@ static void VerifyPdbUtil(dxc::DxcDllSupport &dllSupport,
 #ifdef _WIN32
 #ifdef _WIN32
 
 
 TEST_F(CompilerTest, CompileThenTestPdbUtilsStripped) {
 TEST_F(CompilerTest, CompileThenTestPdbUtilsStripped) {
+  if (m_ver.SkipDxilVersion(1, 5)) return;
   CComPtr<TestIncludeHandler> pInclude;
   CComPtr<TestIncludeHandler> pInclude;
   CComPtr<IDxcCompiler> pCompiler;
   CComPtr<IDxcCompiler> pCompiler;
   CComPtr<IDxcBlobEncoding> pSource;
   CComPtr<IDxcBlobEncoding> pSource;
@@ -1610,6 +1611,7 @@ void CompilerTest::TestPdbUtils(bool bSlim, bool bSourceInDebugModule, bool bStr
 }
 }
 
 
 TEST_F(CompilerTest, CompileThenTestPdbUtils) {
 TEST_F(CompilerTest, CompileThenTestPdbUtils) {
+  if (m_ver.SkipDxilVersion(1, 5)) return;
   TestPdbUtils(/*bSlim*/true,  /*bSourceInDebugModule*/false, /*strip*/true);  // Slim PDB, where source info is stored in its own part, and debug module is NOT present
   TestPdbUtils(/*bSlim*/true,  /*bSourceInDebugModule*/false, /*strip*/true);  // Slim PDB, where source info is stored in its own part, and debug module is NOT present
 
 
   TestPdbUtils(/*bSlim*/false, /*bSourceInDebugModule*/true,  /*strip*/false);  // Old PDB format, where source info is embedded in the module
   TestPdbUtils(/*bSlim*/false, /*bSourceInDebugModule*/true,  /*strip*/false);  // Old PDB format, where source info is embedded in the module

+ 3 - 0
tools/clang/unittests/HLSL/DxilModuleTest.cpp

@@ -47,6 +47,7 @@ public:
   TEST_CLASS_SETUP(InitSupport);
   TEST_CLASS_SETUP(InitSupport);
 
 
   dxc::DxcDllSupport m_dllSupport;
   dxc::DxcDllSupport m_dllSupport;
+  VersionSupportInfo m_ver;
 
 
   // Basic loading tests.
   // Basic loading tests.
   TEST_METHOD(LoadDxilModule_1_0)
   TEST_METHOD(LoadDxilModule_1_0)
@@ -81,6 +82,7 @@ public:
 bool DxilModuleTest::InitSupport() {
 bool DxilModuleTest::InitSupport() {
   if (!m_dllSupport.IsEnabled()) {
   if (!m_dllSupport.IsEnabled()) {
     VERIFY_SUCCEEDED(m_dllSupport.Initialize());
     VERIFY_SUCCEEDED(m_dllSupport.Initialize());
+    m_ver.Initialize(m_dllSupport);
   }
   }
   return true;
   return true;
 }
 }
@@ -582,6 +584,7 @@ TEST_F(DxilModuleTest, SetValidatorVersion) {
 }
 }
 
 
 TEST_F(DxilModuleTest, PayloadQualifier) {
 TEST_F(DxilModuleTest, PayloadQualifier) {
+  if (m_ver.SkipDxilVersion(1, 6)) return;
   std::vector<LPCWSTR> arguments = { L"-enable-payload-qualifiers" };
   std::vector<LPCWSTR> arguments = { L"-enable-payload-qualifiers" };
   Compiler c(m_dllSupport);
   Compiler c(m_dllSupport);
 
 

+ 1 - 0
tools/clang/unittests/HLSL/LinkerTest.cpp

@@ -793,6 +793,7 @@ TEST_F(LinkerTest, RunLinkToLibWithGlobalCtor) {
 }
 }
 
 
 TEST_F(LinkerTest, LinkSm63ToSm66) {
 TEST_F(LinkerTest, LinkSm63ToSm66) {
+  if (m_ver.SkipDxilVersion(1, 6)) return;
   CComPtr<IDxcBlob> pLib0;
   CComPtr<IDxcBlob> pLib0;
   CompileLib(L"..\\CodeGenHLSL\\linker\\link_to_sm66.hlsl", &pLib0, {}, L"lib_6_3");
   CompileLib(L"..\\CodeGenHLSL\\linker\\link_to_sm66.hlsl", &pLib0, {}, L"lib_6_3");