summaryrefslogtreecommitdiffstats
path: root/tools/slang-test
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2019-09-04 09:59:52 -0700
committerGitHub <noreply@github.com>2019-09-04 09:59:52 -0700
commit30083e5958f62b995a56fc181f9944aadf9130d9 (patch)
tree4b88a7eb48be8a8bbff5414a8b86265871677ec8 /tools/slang-test
parent146c343f967fdc23f9627a0b9afa58ba2e80449d (diff)
Allow slang-vs-dxc output comparison tets (#1044)
We already have test cases that compare `slangc` and `fxc` output (in DXBC assembly). This change adds an option to do the same basic thing for `slangc` and `dxc` (comparing DXIL output). This isn't being enabled for any of our regression tests right now. It is mostly just a useful feature to have when reproducing customer issues that relate to DXIL output in cases where `dxc` can produce a baseline to compare against to isolate the problem.
Diffstat (limited to 'tools/slang-test')
-rw-r--r--tools/slang-test/slang-test-main.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 42072cc81..af78dbb14 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1730,7 +1730,11 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input)
return result;
}
-TestResult generateHLSLBaseline(TestContext* context, TestInput& input)
+TestResult generateHLSLBaseline(
+ TestContext* context,
+ TestInput& input,
+ char const* targetFormat,
+ char const* passThroughName)
{
auto filePath999 = input.filePath;
auto outputStem = input.outputStem;
@@ -1746,9 +1750,9 @@ TestResult generateHLSLBaseline(TestContext* context, TestInput& input)
}
cmdLine.addArg("-target");
- cmdLine.addArg("dxbc-assembly");
+ cmdLine.addArg(targetFormat);
cmdLine.addArg("-pass-through");
- cmdLine.addArg("fxc");
+ cmdLine.addArg(passThroughName);
ExecuteResult exeRes;
TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes));
@@ -1771,7 +1775,18 @@ TestResult generateHLSLBaseline(TestContext* context, TestInput& input)
return TestResult::Pass;
}
-TestResult runHLSLComparisonTest(TestContext* context, TestInput& input)
+TestResult generateHLSLBaseline(
+ TestContext* context,
+ TestInput& input)
+{
+ return generateHLSLBaseline(context, input, "dxbc-assembly", "fxc");
+}
+
+static TestResult _runHLSLComparisonTest(
+ TestContext* context,
+ TestInput& input,
+ char const* targetFormat,
+ char const* passThroughName)
{
auto filePath999 = input.filePath;
auto outputStem = input.outputStem;
@@ -1780,7 +1795,7 @@ TestResult runHLSLComparisonTest(TestContext* context, TestInput& input)
String expectedOutputPath = outputStem + ".expected";
// Generate the expected output using standard HLSL compiler
- generateHLSLBaseline(context, input);
+ generateHLSLBaseline(context, input, targetFormat, passThroughName);
// need to execute the stand-alone Slang compiler on the file, and compare its output to what we expect
@@ -1799,7 +1814,7 @@ TestResult runHLSLComparisonTest(TestContext* context, TestInput& input)
cmdLine.addArg("__SLANG__");
cmdLine.addArg("-target");
- cmdLine.addArg("dxbc-assembly");
+ cmdLine.addArg(targetFormat);
ExecuteResult exeRes;
TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes));
@@ -1877,6 +1892,20 @@ TestResult runHLSLComparisonTest(TestContext* context, TestInput& input)
return result;
}
+static TestResult runDXBCComparisonTest(
+ TestContext* context,
+ TestInput& input)
+{
+ return _runHLSLComparisonTest(context, input, "dxbc-assembly", "fxc");
+}
+
+static TestResult runDXILComparisonTest(
+ TestContext* context,
+ TestInput& input)
+{
+ return _runHLSLComparisonTest(context, input, "dxil-assembly", "dxc");
+}
+
TestResult doGLSLComparisonTestRun(TestContext* context,
TestInput& input,
char const* langDefine,
@@ -2405,7 +2434,8 @@ static const TestCommandInfo s_testCommandInfos[] =
{ "REFLECTION", &runReflectionTest},
{ "CPU_REFLECTION", &runReflectionTest},
{ "COMMAND_LINE_SIMPLE", &runSimpleCompareCommandLineTest},
- { "COMPARE_HLSL", &runHLSLComparisonTest},
+ { "COMPARE_HLSL", &runDXBCComparisonTest},
+ { "COMPARE_DXIL", &runDXILComparisonTest},
{ "COMPARE_HLSL_RENDER", &runHLSLRenderComparisonTest},
{ "COMPARE_HLSL_CROSS_COMPILE_RENDER", &runHLSLCrossCompileRenderComparisonTest},
{ "COMPARE_HLSL_GLSL_RENDER", &runHLSLAndGLSLRenderComparisonTest},