From 9604118401f185c0e1a213b8e99dad060c6263bc Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 13 Nov 2019 13:35:56 -0500 Subject: * Added getCStr(Name*) (#1121) * Added the name to the EntryPointLayout so is always available * Made spReflectionEntryPoint_getName use name * Improved checking for entry point name in render-test * Improved COMPILE test type to allow failure and output of failure. --- tools/render-test/slang-support.cpp | 27 +++++++++++++++++++++++---- tools/slang-test/slang-test-main.cpp | 12 ++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 06284e1e3..5b038d208 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -149,20 +149,22 @@ static const char computeEntryPointName[] = "computeMain"; if (request.computeShader.name) { - int computeEntryPoint = 0; + int computeEntryPointIndex = 0; if(!gOptions.dontAddDefaultEntryPoints) { - computeEntryPoint = spAddEntryPointEx(slangRequest, computeTranslationUnit, + computeEntryPointIndex = spAddEntryPointEx(slangRequest, computeTranslationUnit, computeEntryPointName, SLANG_STAGE_COMPUTE, (int)rawEntryPointTypeNames.getCount(), rawEntryPointTypeNames.getBuffer()); - setEntryPointExistentialTypeArgs(computeEntryPoint); + setEntryPointExistentialTypeArgs(computeEntryPointIndex); } spSetLineDirectiveMode(slangRequest, SLANG_LINE_DIRECTIVE_MODE_NONE); + const SlangResult res = spCompile(slangRequest); + if (auto diagnostics = spGetDiagnosticOutput(slangRequest)) { fprintf(stderr, "%s", diagnostics); @@ -170,9 +172,26 @@ static const char computeEntryPointName[] = "computeMain"; SLANG_RETURN_ON_FAIL(res); + // We are going to get the entry point count... lets check what we have + { + auto reflection = spGetReflection(slangRequest); + // Get the amount of entry points in reflection + const int entryPointCount = int(spReflection_getEntryPointCount(reflection)); + + // Above code assumes there is an entry point + SLANG_ASSERT(entryPointCount && computeEntryPointIndex < entryPointCount); + + auto entryPoint = spReflection_getEntryPointByIndex(reflection, computeEntryPointIndex); + + // Get the entry point name + const char* entryPointName = spReflectionEntryPoint_getName(entryPoint); + + SLANG_ASSERT(entryPointName); + } + { size_t codeSize = 0; - char const* code = (char const*) spGetEntryPointCode(slangRequest, computeEntryPoint, &codeSize); + char const* code = (char const*) spGetEntryPointCode(slangRequest, computeEntryPointIndex, &codeSize); ShaderProgram::KernelDesc kernelDesc; kernelDesc.stage = StageType::Compute; diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 2000bf617..e0474ebe6 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1106,6 +1106,18 @@ TestResult runCompile(TestContext* context, TestInput& input) return TestResult::Pass; } + if (exeRes.resultCode != 0) + { + auto reporter = context->reporter; + if (reporter) + { + auto output = getOutput(exeRes); + reporter->message(TestMessageType::TestFailure, output); + } + + return TestResult::Fail; + } + return TestResult::Pass; } -- cgit v1.2.3