diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-17 08:58:47 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-17 08:58:47 -0700 |
| commit | 15aba2fe81fea44969e036e181a4cf252ff41963 (patch) | |
| tree | 489534f470b3d2dcbb61660458bf473e0a2c0552 /tools/slang-test/main.cpp | |
| parent | eecb6c56da5792010e88f2a0d6d1503244b081a4 (diff) | |
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
Diffstat (limited to 'tools/slang-test/main.cpp')
| -rw-r--r-- | tools/slang-test/main.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
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 }, }; |
