diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-11-21 13:41:34 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-21 13:41:34 -0500 |
| commit | e21d5ad650130631e17662ce8f22d15315ab597a (patch) | |
| tree | a1f5053efebc6184d21b0151e38ba1a52e74b07c /tools/slang-test/main.cpp | |
| parent | 9bb11b69a08c66e2857f439837e2253658aed9a4 (diff) | |
Feature/early depth stencil (#727)
* First pass support for early depth stencil.
* Add a simple test to check if output has attributes.
* Use cross compilation to test [earlydepthstencil] on glsl.
* If target is dxil, use dxc to test against.
Add hlsl to test earlydepthstencil against.
* * Added spSessionHasCompileTargetSupport
* Made slang-test use spSessionHasCompileTargetSupport to ignore tests that cannot run
Diffstat (limited to 'tools/slang-test/main.cpp')
| -rw-r--r-- | tools/slang-test/main.cpp | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index 30fa709d7..9ce92f5bb 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -1,4 +1,4 @@ -// main.cpp +// main.cpp #include "../../source/core/slang-io.h" #include "../../source/core/token-reader.h" @@ -900,6 +900,25 @@ TestResult runEvalTest(TestContext* context, TestInput& input) return result; } +static SlangCompileTarget _getCompileTarget(const UnownedStringSlice& name) +{ +#define CASE(NAME, TARGET) if(name == NAME) return SLANG_##TARGET; + + CASE("hlsl", HLSL) + CASE("glsl", GLSL) + CASE("dxbc", DXBC) + CASE("dxbc-assembly", DXBC_ASM) + CASE("dxbc-asm", DXBC_ASM) + CASE("spirv", SPIRV) + CASE("spirv-assembly", SPIRV_ASM) + CASE("spirv-asm", SPIRV_ASM) + CASE("dxil", DXIL) + CASE("dxil-assembly", DXIL_ASM) + CASE("dxil-asm", DXIL_ASM) +#undef CASE + + return SLANG_TARGET_UNKNOWN; +} TestResult runCrossCompilerTest(TestContext* context, TestInput& input) { @@ -916,10 +935,39 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input) expectedSpawner.pushExecutablePath(String(g_options.binDir) + "slangc" + osGetExecutableSuffix()); actualSpawner.pushArgument(filePath); - expectedSpawner.pushArgument(filePath + ".glsl"); - expectedSpawner.pushArgument("-pass-through"); - expectedSpawner.pushArgument("glslang"); + const auto& args = input.testOptions->args; + + const UInt targetIndex = args.IndexOf("-target"); + if (targetIndex != UInt(-1) && targetIndex + 1 < args.Count()) + { + SlangCompileTarget target = _getCompileTarget(args[targetIndex + 1].getUnownedSlice()); + + // Check the session supports it. If not we ignore it + if (SLANG_FAILED(spSessionHasCompileTargetSupport(context->getSession(), target))) + { + return TestResult::Ignored; + } + + switch (target) + { + case SLANG_DXIL_ASM: + { + expectedSpawner.pushArgument(filePath + ".hlsl"); + expectedSpawner.pushArgument("-pass-through"); + expectedSpawner.pushArgument("dxc"); + break; + } + default: + { + expectedSpawner.pushArgument(filePath + ".glsl"); + expectedSpawner.pushArgument("-pass-through"); + expectedSpawner.pushArgument("glslang"); + break; + } + } + } + for( auto arg : input.testOptions->args ) { actualSpawner.pushArgument(arg); @@ -1960,7 +2008,13 @@ int main( } // Setup the context - TestContext context(g_options.outputMode); + TestContext context; + if (SLANG_FAILED(context.init(g_options.outputMode))) + { + // Unable to initialize context + return 1; + } + context.m_dumpOutputOnFailure = g_options.dumpOutputOnFailure; context.m_isVerbose = g_options.shouldBeVerbose; |
