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 | |
| 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')
| -rw-r--r-- | tools/slang-test/main.cpp | 64 | ||||
| -rw-r--r-- | tools/slang-test/slang-test.vcxproj | 3 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 29 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 12 |
4 files changed, 99 insertions, 9 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; diff --git a/tools/slang-test/slang-test.vcxproj b/tools/slang-test/slang-test.vcxproj index acaa07d3e..13bf42141 100644 --- a/tools/slang-test/slang-test.vcxproj +++ b/tools/slang-test/slang-test.vcxproj @@ -180,6 +180,9 @@ <ProjectReference Include="..\..\source\core\core.vcxproj"> <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> </ProjectReference> + <ProjectReference Include="..\..\source\slang\slang.vcxproj"> + <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project> + </ProjectReference> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 158258873..b94435a8e 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -69,8 +69,8 @@ static void appendXmlEncode(const String& in, StringBuilder& out) } } -TestContext::TestContext(TestOutputMode outputMode) : - m_outputMode(outputMode) +TestContext::TestContext() : + m_outputMode(TestOutputMode::Default) { m_totalTestCount = 0; m_passedTestCount = 0; @@ -82,6 +82,29 @@ TestContext::TestContext(TestOutputMode outputMode) : m_inTest = false; m_dumpOutputOnFailure = false; m_isVerbose = false; + + m_session = nullptr; +} + +Result TestContext::init(TestOutputMode outputMode) +{ + m_outputMode = outputMode; + + m_session = spCreateSession(nullptr); + if (!m_session) + { + return SLANG_FAIL; + } + + return SLANG_OK; +} + +TestContext::~TestContext() +{ + if (m_session) + { + spDestroySession(m_session); + } } bool TestContext::canWriteStdError() const @@ -601,4 +624,4 @@ void TestContext::endSuite() } m_suiteStack.RemoveLast(); -}
\ No newline at end of file +} diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index 94f8c689f..a81473efa 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -124,8 +124,16 @@ class TestContext /// Returns true if all run tests succeeded bool didAllSucceed() const; + /// Get the slang session + SlangSession* getSession() const { return m_session; } + + SlangResult init(TestOutputMode outputMode); + /// Ctor - TestContext(TestOutputMode outputMode); + TestContext(); + /// Dtor + ~TestContext(); + static TestResult combine(TestResult a, TestResult b) { return (a > b) ? a : b; } @@ -158,6 +166,8 @@ protected: int m_numFailResults; bool m_inTest; + + SlangSession* m_session; static TestContext* s_context; }; |
