|
@@ -104,9 +104,12 @@ class ValidationTest
|
|
|
{
|
|
|
public:
|
|
|
BEGIN_TEST_CLASS(ValidationTest)
|
|
|
+ TEST_CLASS_PROPERTY(L"Parallel", L"true")
|
|
|
TEST_METHOD_PROPERTY(L"Priority", L"0")
|
|
|
END_TEST_CLASS()
|
|
|
|
|
|
+ TEST_CLASS_SETUP(InitSupport);
|
|
|
+
|
|
|
TEST_METHOD(WhenCorrectThenOK);
|
|
|
TEST_METHOD(WhenMisalignedThenFail);
|
|
|
TEST_METHOD(WhenEmptyFileThenFail);
|
|
@@ -288,6 +291,15 @@ public:
|
|
|
TEST_METHOD(WhenFeatureInfoMismatchThenFail);
|
|
|
|
|
|
dxc::DxcDllSupport m_dllSupport;
|
|
|
+ bool m_CompilerPreservesBBNames;
|
|
|
+
|
|
|
+ bool SkipIRSensitiveTest() {
|
|
|
+ if (!m_CompilerPreservesBBNames) {
|
|
|
+ WEX::Logging::Log::Comment(L"Test skipped due to name preservation requirment.");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
void TestCheck(LPCWSTR name) {
|
|
|
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
|
|
@@ -303,10 +315,6 @@ public:
|
|
|
CComPtr<IDxcValidator> pValidator;
|
|
|
CComPtr<IDxcOperationResult> pResult;
|
|
|
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
-
|
|
|
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcValidator, &pValidator));
|
|
|
VERIFY_SUCCEEDED(pValidator->Validate(pBlob, DxcValidatorFlags_Default, &pResult));
|
|
|
|
|
@@ -314,9 +322,6 @@ public:
|
|
|
}
|
|
|
|
|
|
void CheckValidationMsgs(const char *pBlob, size_t blobSize, llvm::ArrayRef<LPCSTR> pErrorMsgs, bool bRegex = false) {
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
CComPtr<IDxcLibrary> pLibrary;
|
|
|
CComPtr<IDxcBlobEncoding> pBlobEncoding; // Encoding doesn't actually matter, it's binary.
|
|
|
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
|
|
@@ -330,10 +335,6 @@ public:
|
|
|
CComPtr<IDxcOperationResult> pResult;
|
|
|
CComPtr<IDxcBlob> pProgram;
|
|
|
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
-
|
|
|
CA2W shWide(pShaderModel, CP_UTF8);
|
|
|
VERIFY_SUCCEEDED(
|
|
|
m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
|
|
@@ -346,9 +347,6 @@ public:
|
|
|
|
|
|
void CompileSource(LPCSTR pSource, LPCSTR pShaderModel,
|
|
|
IDxcBlob **pResultBlob) {
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
CComPtr<IDxcBlobEncoding> pSourceBlob;
|
|
|
Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
|
|
|
CompileSource(pSourceBlob, pShaderModel, pResultBlob);
|
|
@@ -364,10 +362,6 @@ public:
|
|
|
CComPtr<IDxcBlob> pText;
|
|
|
CComPtr<IDxcBlobEncoding> pSourceBlob;
|
|
|
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
-
|
|
|
Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
|
|
|
|
|
|
RewriteAssemblyToText(pSourceBlob, pShaderModel, pLookFors, pReplacements, &pText, bRegex);
|
|
@@ -431,9 +425,6 @@ public:
|
|
|
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
|
|
|
CComPtr<IDxcLibrary> pLibrary;
|
|
|
CComPtr<IDxcBlobEncoding> pSource;
|
|
|
- if (!m_dllSupport.IsEnabled()) {
|
|
|
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
- }
|
|
|
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
|
|
|
VERIFY_SUCCEEDED(
|
|
|
pLibrary->CreateBlobFromFile(fullPath.c_str(), nullptr, &pSource));
|
|
@@ -518,6 +509,22 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+bool ValidationTest::InitSupport() {
|
|
|
+ if (!m_dllSupport.IsEnabled()) {
|
|
|
+ VERIFY_SUCCEEDED(m_dllSupport.Initialize());
|
|
|
+
|
|
|
+ // This is a very indirect way of testing this. Consider improving support.
|
|
|
+ CComPtr<IDxcValidator> pValidator;
|
|
|
+ CComPtr<IDxcVersionInfo> pVersionInfo;
|
|
|
+ UINT32 VersionFlags = 0;
|
|
|
+ VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcValidator, &pValidator));
|
|
|
+ VERIFY_SUCCEEDED(pValidator.QueryInterface(&pVersionInfo));
|
|
|
+ VERIFY_SUCCEEDED(pVersionInfo->GetFlags(&VersionFlags));
|
|
|
+ m_CompilerPreservesBBNames = (VersionFlags & DxcVersionInfoFlags_Debug) ? true : false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
TEST_F(ValidationTest, WhenCorrectThenOK) {
|
|
|
CComPtr<IDxcBlob> pProgram;
|
|
|
CompileSource("float4 main() : SV_Target { return 1; }", "ps_6_0", &pProgram);
|
|
@@ -637,6 +644,7 @@ TEST_F(ValidationTest, WhenDepthNotFloatThenFail) {
|
|
|
}
|
|
|
|
|
|
TEST_F(ValidationTest, BarrierFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\barrier.hlsl", "cs_6_0",
|
|
|
{"dx.op.barrier(i32 80, i32 8)",
|
|
@@ -685,6 +693,7 @@ TEST_F(ValidationTest, CsThreadSizeFail) {
|
|
|
});
|
|
|
}
|
|
|
TEST_F(ValidationTest, DeadLoopFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\loop1.hlsl", "ps_6_0",
|
|
|
{"br i1 %exitcond, label %for.end.loopexit, label %for.body, !llvm.loop !([0-9]+)",
|
|
@@ -780,6 +789,7 @@ TEST_F(ValidationTest, MultiStream2Fail) {
|
|
|
"Multiple GS output streams are used but 'XXX' is not pointlist");
|
|
|
}
|
|
|
TEST_F(ValidationTest, PhiTGSMFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\phiTGSM.hlsl", "cs_6_0",
|
|
|
"ret void",
|
|
@@ -789,6 +799,7 @@ TEST_F(ValidationTest, PhiTGSMFail) {
|
|
|
"TGSM pointers must originate from an unambiguous TGSM global variable");
|
|
|
}
|
|
|
TEST_F(ValidationTest, ReducibleFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\reducible.hlsl", "ps_6_0",
|
|
|
{"%conv\n"
|
|
@@ -934,6 +945,7 @@ TEST_F(ValidationTest, SimpleGs1Fail) {
|
|
|
"Stream index (5) must between 0 and 3"});
|
|
|
}
|
|
|
TEST_F(ValidationTest, UavBarrierFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\uavBarrier.hlsl", "ps_6_0",
|
|
|
{"dx.op.barrier(i32 80, i32 2)",
|
|
@@ -955,6 +967,7 @@ TEST_F(ValidationTest, UndefValueFail) {
|
|
|
TestCheck(L"..\\CodeGenHLSL\\UndefValue.hlsl");
|
|
|
}
|
|
|
TEST_F(ValidationTest, UpdateCounterFail) {
|
|
|
+ if (SkipIRSensitiveTest()) return;
|
|
|
RewriteAssemblyCheckMsg(
|
|
|
L"..\\CodeGenHLSL\\UpdateCounter2.hlsl", "ps_6_0",
|
|
|
{"%2 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %buf2_UAV_structbuf, i8 1)",
|