summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-11-02 09:47:35 -0400
committerGitHub <noreply@github.com>2022-11-02 09:47:35 -0400
commitfb29bd32cc3404455ff92916a91c517823f486dd (patch)
tree8d847489dc2e9a46c73c01c4c4a8fc79930c75a0 /tools
parent487855ecb46ec4360464d2f028cedf8c24a66d29 (diff)
Shader Execution Reordering (via NVAPI) (#2484)
* #include an absolute path didn't work - because paths were taken to always be relative. * Preliminary SER NVAPI support. * Set the DXC compiler version. Fix typo in premake5.lua * Improve DXC version detection. Enable HLSL2021 on late enough version of DXC. * Fix typo. * Fix launch. * Test via DXIL output. * Update dxc-error output.
Diffstat (limited to 'tools')
-rw-r--r--tools/render-test/render-test-main.cpp12
-rw-r--r--tools/slang-test/slang-test-main.cpp58
-rw-r--r--tools/slang-test/test-context.cpp5
-rw-r--r--tools/slang-test/test-context.h1
4 files changed, 62 insertions, 14 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index c361e6b34..16b47a001 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -1074,22 +1074,20 @@ static SlangResult _setSessionPrelude(const Options& options, const char* exePat
// Let's see if we need to set up special prelude for HLSL
if (options.nvapiExtnSlot.getLength())
{
+ // We want to set the path to NVAPI
String rootPath;
SLANG_RETURN_ON_FAIL(TestToolUtil::getRootPath(exePath, rootPath));
-
String includePath;
- if (TestToolUtil::getIncludePath(rootPath, "external/nvapi/nvHLSLExtns.h", includePath) !=
- SLANG_OK)
- {
- return SLANG_FAIL;
- }
+ SLANG_RETURN_ON_FAIL(TestToolUtil::getIncludePath(rootPath, "external/nvapi/nvHLSLExtns.h", includePath))
StringBuilder buf;
// We have to choose a slot that NVAPI will use.
buf << "#define NV_SHADER_EXTN_SLOT " << options.nvapiExtnSlot << "\n";
// Include the NVAPI header
- buf << "#include \"" << includePath << "\"\n\n";
+ buf << "#include ";
+ StringEscapeUtil::appendQuoted(StringEscapeUtil::getHandler(StringEscapeUtil::Style::Cpp), includePath.getUnownedSlice(), buf);
+ buf << "\n\n";
session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, buf.getBuffer());
}
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 59c16c88b..5c6d480d3 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1173,14 +1173,54 @@ String findExpectedPath(const TestInput& input, const char* postFix)
return "";
}
-static void _initSlangCompiler(TestContext* context, CommandLine& ioCmdLine)
+static SlangResult _initSlangCompiler(TestContext* context, CommandLine& ioCmdLine)
{
ioCmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "slangc"));
if (context->options.verbosePaths)
{
- ioCmdLine.addArg("-verbose-paths");
+ ioCmdLine.addArgIfNotFound("-verbose-paths");
}
+
+ // Look for definition of a slot
+
+ {
+ const auto prefix = toSlice("-DNV_SHADER_EXTN_SLOT=");
+
+ bool usesNVAPI = false;
+
+ for (auto& arg : ioCmdLine.m_args)
+ {
+ if (arg.startsWith(prefix))
+ {
+ // Has NVAPI prefix, meaning
+ usesNVAPI = true;
+ break;
+ }
+ }
+
+ // This is necessary because the session can be shared, and the prelude overwritten by the renderer.
+ if (usesNVAPI)
+ {
+ // We want to set the path to NVAPI
+ String rootPath;
+ SLANG_RETURN_ON_FAIL(TestToolUtil::getRootPath(context->exePath.getBuffer(), rootPath));
+ String includePath;
+ SLANG_RETURN_ON_FAIL(TestToolUtil::getIncludePath(rootPath, "external/nvapi/nvHLSLExtns.h", includePath))
+
+ StringBuilder buf;
+
+ // Include the NVAPI header
+ buf << "#include ";
+
+ StringEscapeUtil::appendQuoted(StringEscapeUtil::getHandler(StringEscapeUtil::Style::Cpp), includePath.getUnownedSlice(), buf);
+ buf << "\n\n";
+
+ context->getSession()->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, buf.getBuffer());
+ }
+ }
+
+ return SLANG_OK;
}
TestResult asTestResult(ToolReturnCode code)
@@ -1291,7 +1331,7 @@ TestResult runDocTest(TestContext* context, TestInput& input)
auto outputStem = input.outputStem;
CommandLine cmdLine;
- _initSlangCompiler(context, cmdLine);
+
cmdLine.addArg(input.filePath);
@@ -1300,6 +1340,8 @@ TestResult runDocTest(TestContext* context, TestInput& input)
cmdLine.addArg(arg);
}
+ _initSlangCompiler(context, cmdLine);
+
ExecuteResult exeRes;
TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes));
@@ -1769,8 +1811,7 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
auto outputStem = input.outputStem;
CommandLine cmdLine;
- _initSlangCompiler(context, cmdLine);
-
+
if (input.testOptions->command != "SIMPLE_EX")
{
cmdLine.addArg(input.filePath);
@@ -1781,6 +1822,13 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
cmdLine.addArg(arg);
}
+ // If we can't set up for simple compilation, it's because some external resource isn't available
+ // such as NVAPI headers. In that case we just ignore the test.
+ if (SLANG_FAILED(_initSlangCompiler(context, cmdLine)))
+ {
+ return TestResult::Ignored;
+ }
+
ExecuteResult exeRes;
TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes));
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp
index a5dc2624c..8d8c20adf 100644
--- a/tools/slang-test/test-context.cpp
+++ b/tools/slang-test/test-context.cpp
@@ -59,14 +59,15 @@ TestReporter* TestContext::getTestReporter()
return m_reporters[slangTestThreadIndex];
}
-Result TestContext::init(const char* exePath)
+Result TestContext::init(const char* inExePath)
{
m_session = spCreateSession(nullptr);
if (!m_session)
{
return SLANG_FAIL;
}
- SLANG_RETURN_ON_FAIL(TestToolUtil::getExeDirectoryPath(exePath, exeDirectoryPath));
+ exePath = inExePath;
+ SLANG_RETURN_ON_FAIL(TestToolUtil::getExeDirectoryPath(inExePath, exeDirectoryPath));
return SLANG_OK;
}
diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h
index 5a48dbcd9..fb391fb42 100644
--- a/tools/slang-test/test-context.h
+++ b/tools/slang-test/test-context.h
@@ -145,6 +145,7 @@ class TestContext
Slang::RefPtr<Slang::DownstreamCompilerSet> compilerSet;
Slang::String exeDirectoryPath;
+ Slang::String exePath;
/// Timeout time for communication over connection.
/// NOTE! If the timeout is hit, the connection will be destroyed, and then recreated.