From 15aba2fe81fea44969e036e181a4cf252ff41963 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 17 Jul 2017 08:58:47 -0700 Subject: Handle `flat` interpolation cases in cross compilation Fixes #104 - Map HLSL `nointerpolation` to GLSL `flat` - When lowering a `struct` type varying input/output, look for interpolation modifiers along the "chain" from the leaf field up to the original shader input variable (and take the first one found) - Not sure if this is strictly needed, but it seems like a reasonable policy - Add `flat` to varying input of integer type, with no other interpolation modifier - Note: I do *not* do anything to ignore a manually imposed interpolation modifier that might be incorrect --- tools/slang-test/main.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'tools/slang-test/main.cpp') diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index 2bca2f78d..6b7da5844 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -671,6 +671,83 @@ TestResult runSimpleTest(TestInput& input) return result; } +TestResult runCrossCompilerTest(TestInput& input) +{ + // need to execute the stand-alone Slang compiler on the file + // then on the same file + `.glsl` and compare output + + auto filePath = input.filePath; + auto outputStem = input.outputStem; + + OSProcessSpawner actualSpawner; + OSProcessSpawner expectedSpawner; + + actualSpawner.pushExecutablePath(String(options.binDir) + "slangc.exe"); + expectedSpawner.pushExecutablePath(String(options.binDir) + "slangc.exe"); + + actualSpawner.pushArgument(filePath); + expectedSpawner.pushArgument(filePath + ".glsl"); + + for( auto arg : input.testOptions->args ) + { + actualSpawner.pushArgument(arg); + expectedSpawner.pushArgument(arg); + } + expectedSpawner.pushArgument("-no-checking"); + + if (spawnAndWait(outputStem, expectedSpawner) != kOSError_None) + { + return kTestResult_Fail; + } + + String expectedOutput = getOutput(expectedSpawner); + String expectedOutputPath = outputStem + ".expected"; + try + { + Slang::File::WriteAllText(expectedOutputPath, expectedOutput); + } + catch (Slang::IOException) + { + return kTestResult_Fail; + } + + if (spawnAndWait(outputStem, actualSpawner) != kOSError_None) + { + return kTestResult_Fail; + } + String actualOutput = getOutput(actualSpawner); + + TestResult result = kTestResult_Pass; + + // Otherwise we compare to the expected output + if (actualOutput != expectedOutput) + { + result = kTestResult_Fail; + } + + // If the test failed, then we write the actual output to a file + // so that we can easily diff it from the command line and + // diagnose the problem. + if (result == kTestResult_Fail) + { + String actualOutputPath = outputStem + ".actual"; + Slang::File::WriteAllText(actualOutputPath, actualOutput); + + if (options.outputMode == kOutputMode_AppVeyor) + { + fprintf(stderr, "ERROR:\n" + "EXPECTED{{{\n%s}}}\n" + "ACTUAL{{{\n%s}}}\n", + expectedOutput.Buffer(), + actualOutput.Buffer()); + fflush(stderr); + } + } + + return result; +} + + #ifdef SLANG_TEST_SUPPORT_HLSL TestResult generateHLSLBaseline(TestInput& input) { @@ -1076,6 +1153,7 @@ TestResult runTest( { "COMPARE_HLSL_CROSS_COMPILE_RENDER", &runHLSLCrossCompileRenderComparisonTest}, { "COMPARE_HLSL_GLSL_RENDER", &runHLSLAndGLSLComparisonTest }, { "COMPARE_GLSL", &runGLSLComparisonTest }, + { "CROSS_COMPILE", &runCrossCompilerTest }, { nullptr, nullptr }, }; -- cgit v1.2.3