summaryrefslogtreecommitdiffstats
path: root/tools/render-test
diff options
context:
space:
mode:
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/options.cpp73
-rw-r--r--tools/render-test/options.h6
-rw-r--r--tools/render-test/render-test-main.cpp152
-rw-r--r--tools/render-test/slang-support.cpp6
-rw-r--r--tools/render-test/slang-support.h2
5 files changed, 150 insertions, 89 deletions
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index c2afe78ac..fd4b75ed1 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -18,10 +18,6 @@
namespace renderer_test {
using namespace Slang;
-static const Options gDefaultOptions = Options();
-
-Options gOptions;
-
static gfx::RendererType _toRenderType(Slang::RenderApiType apiType)
{
using namespace Slang;
@@ -37,23 +33,22 @@ static gfx::RendererType _toRenderType(Slang::RenderApiType apiType)
}
}
-static SlangResult _setRendererType(RendererType type, const char* arg, Slang::WriterHelper stdError)
+static SlangResult _setRendererType(RendererType type, const char* arg, Slang::WriterHelper stdError, Options& ioOptions)
{
- if (gOptions.rendererType != RendererType::Unknown)
+ if (ioOptions.rendererType != RendererType::Unknown)
{
stdError.print("Already has renderer option set. Found '%s'\n", arg);
return SLANG_FAIL;
}
- gOptions.rendererType = type;
+ ioOptions.rendererType = type;
return SLANG_OK;
}
-SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError)
+/* static */SlangResult Options::parse(int argc, const char*const* argv, Slang::WriterHelper stdError, Options& outOptions)
{
using namespace Slang;
- // Reset the options
- gOptions = gDefaultOptions;
+ outOptions = Options();
List<const char*> positionalArgs;
@@ -68,7 +63,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
// first argument is the application name
if( argCursor != argEnd )
{
- gOptions.appName = *argCursor++;
+ outOptions.appName = *argCursor++;
}
// now iterate over arguments to collect options
@@ -96,7 +91,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
stdError.print("expected argument for '%s' option\n", arg);
return SLANG_FAIL;
}
- gOptions.outputPath = *argCursor++;
+ outOptions.outputPath = *argCursor++;
}
else if (strcmp(arg, "-profile") == 0)
{
@@ -105,7 +100,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
stdError.print("expected argument for '%s' option\n", arg);
return SLANG_FAIL;
}
- gOptions.profileName = *argCursor++;
+ outOptions.profileName = *argCursor++;
}
else if (strcmp(arg, "-render-features") == 0 || strcmp(arg, "-render-feature") == 0)
{
@@ -121,7 +116,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
for (const auto& value : values)
{
- gOptions.renderFeatures.add(value);
+ outOptions.renderFeatures.add(value);
}
}
else if( strcmp(arg, "-xslang") == 0 )
@@ -133,36 +128,36 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
stdError.print("expected argument for '%s' option\n", arg);
return SLANG_FAIL;
}
- if( gOptions.slangArgCount == Options::kMaxSlangArgs )
+ if( outOptions.slangArgCount == Options::kMaxSlangArgs )
{
stdError.print("maximum number of '%s' options exceeded (%d)\n", arg, Options::kMaxSlangArgs);
return SLANG_FAIL;
}
- gOptions.slangArgs[gOptions.slangArgCount++] = *argCursor++;
+ outOptions.slangArgs[outOptions.slangArgCount++] = *argCursor++;
}
else if (strcmp(arg, "-compute") == 0)
{
- gOptions.shaderType = ShaderProgramType::Compute;
+ outOptions.shaderType = ShaderProgramType::Compute;
}
else if (strcmp(arg, "-graphics") == 0)
{
- gOptions.shaderType = ShaderProgramType::Graphics;
+ outOptions.shaderType = ShaderProgramType::Graphics;
}
else if (strcmp(arg, "-gcompute") == 0)
{
- gOptions.shaderType = ShaderProgramType::GraphicsCompute;
+ outOptions.shaderType = ShaderProgramType::GraphicsCompute;
}
else if (strcmp(arg, "-rt") == 0)
{
- gOptions.shaderType = ShaderProgramType::RayTracing;
+ outOptions.shaderType = ShaderProgramType::RayTracing;
}
else if( strcmp(arg, "-use-dxil") == 0 )
{
- gOptions.useDXIL = true;
+ outOptions.useDXIL = true;
}
else if (strcmp(arg, "-only-startup") == 0)
{
- gOptions.onlyStartup = true;
+ outOptions.onlyStartup = true;
}
else if (strcmp(arg, "-compile-arg") == 0)
{
@@ -175,11 +170,11 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
CommandLine::Arg arg;
arg.type = CommandLine::ArgType::Escaped;
arg.value = *argCursor++;
- gOptions.compileArgs.add(arg);
+ outOptions.compileArgs.add(arg);
}
else if (strcmp(arg, "-performance-profile") == 0)
{
- gOptions.performanceProfile = true;
+ outOptions.performanceProfile = true;
}
else if (strcmp(arg, "-adapter") == 0)
{
@@ -189,11 +184,11 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
return SLANG_FAIL;
}
- gOptions.adapter = *argCursor++;
+ outOptions.adapter = *argCursor++;
}
else if (strcmp(arg, "-output-using-type") == 0)
{
- gOptions.outputUsingType = true;
+ outOptions.outputUsingType = true;
}
else if (strcmp(arg, "-compute-dispatch") == 0)
{
@@ -220,7 +215,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
stdError.print("error: expected 3 comma positive integers for compute dispatch size for '%s'\n", arg);
return SLANG_FAIL;
}
- gOptions.computeDispatchSize[i] = v;
+ outOptions.computeDispatchSize[i] = v;
}
}
else if (strcmp(arg, "-source-language") == 0)
@@ -239,11 +234,21 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
return SLANG_FAIL;
}
- gOptions.sourceLanguage = sourceLanguage;
+ outOptions.sourceLanguage = sourceLanguage;
}
else if( strcmp(arg, "-no-default-entry-point") == 0 )
{
- gOptions.dontAddDefaultEntryPoints = true;
+ outOptions.dontAddDefaultEntryPoints = true;
+ }
+ else if (strcmp(arg, "-nvapi-register") == 0)
+ {
+ if (argCursor == argEnd)
+ {
+ stdError.print("error: expecting a register name for '%s'\n", arg);
+ return SLANG_FAIL;
+ }
+
+ outOptions.nvapiRegister = (*argCursor++);
}
else
{
@@ -257,7 +262,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
if (rendererType != RendererType::Unknown)
{
- gOptions.rendererType = rendererType;
+ outOptions.rendererType = rendererType;
continue;
}
@@ -265,8 +270,8 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
RendererType languageRenderType = _toRenderType(RenderApiUtil::findImplicitLanguageRenderApiType(argName));
if (languageRenderType != RendererType::Unknown)
{
- gOptions.targetLanguageRendererType = languageRenderType;
- gOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl" || argName == "cpp" || argName == "cxx" || argName == "c") ? InputLanguageID::Native : InputLanguageID::Slang;
+ outOptions.targetLanguageRendererType = languageRenderType;
+ outOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl" || argName == "cpp" || argName == "cxx" || argName == "c") ? InputLanguageID::Native : InputLanguageID::Slang;
continue;
}
}
@@ -277,12 +282,12 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
}
// If a render option isn't set use defaultRenderType
- gOptions.rendererType = (gOptions.rendererType == RendererType::Unknown) ? gOptions.targetLanguageRendererType : gOptions.rendererType;
+ outOptions.rendererType = (outOptions.rendererType == RendererType::Unknown) ? outOptions.targetLanguageRendererType : outOptions.rendererType;
// first positional argument is source shader path
if(positionalArgs.getCount())
{
- gOptions.sourcePath = positionalArgs[0];
+ outOptions.sourcePath = positionalArgs[0];
positionalArgs.removeAt(0);
}
diff --git a/tools/render-test/options.h b/tools/render-test/options.h
index f2f0a8ab6..d311568d4 100644
--- a/tools/render-test/options.h
+++ b/tools/render-test/options.h
@@ -74,10 +74,10 @@ struct Options
Slang::String adapter; ///< The adapter to use either name or index
uint32_t computeDispatchSize[3] = { 1, 1, 1 };
-};
-extern Options gOptions;
+ Slang::String nvapiRegister; ///< The nvapiRegister to use.
-SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError);
+ static SlangResult parse(int argc, const char*const* argv, Slang::WriterHelper stdError, Options& outOptions);
+};
} // renderer_test
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 7efea40f9..e7356901d 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -212,7 +212,7 @@ SlangResult RenderTestApp::initialize(SlangSession* session, Renderer* renderer,
Result RenderTestApp::_initializeShaders(SlangSession* session, Renderer* renderer, Options::ShaderProgramType shaderType, const ShaderCompilerUtil::Input& input)
{
- SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions, input, m_compilationOutput));
+ SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, m_options, input, m_compilationOutput));
m_shaderInputLayout = m_compilationOutput.layout;
m_shaderProgram = renderer->createProgram(m_compilationOutput.output.desc);
return m_shaderProgram ? SLANG_OK : SLANG_FAIL;
@@ -368,9 +368,9 @@ Result RenderTestApp::update(Window* window)
_outputProfileTime(m_startTicks, endTicks);
}
- if (gOptions.outputPath)
+ if (m_options.outputPath)
{
- if (gOptions.shaderType == Options::ShaderProgramType::Compute || gOptions.shaderType == Options::ShaderProgramType::GraphicsCompute)
+ if (m_options.shaderType == Options::ShaderProgramType::Compute || m_options.shaderType == Options::ShaderProgramType::GraphicsCompute)
{
auto request = m_compilationOutput.output.request;
auto slangReflection = (slang::ShaderReflection*) spGetReflection(request);
@@ -379,13 +379,13 @@ Result RenderTestApp::update(Window* window)
GPULikeBindRoot bindRoot;
bindRoot.init(&bindSet, slangReflection, 0);
- BindRoot* outputBindRoot = gOptions.outputUsingType ? &bindRoot : nullptr;
+ BindRoot* outputBindRoot = m_options.outputUsingType ? &bindRoot : nullptr;
- SLANG_RETURN_ON_FAIL(writeBindingOutput(outputBindRoot, gOptions.outputPath));
+ SLANG_RETURN_ON_FAIL(writeBindingOutput(outputBindRoot, m_options.outputPath));
}
else
{
- SlangResult res = writeScreen(gOptions.outputPath);
+ SlangResult res = writeScreen(m_options.outputPath);
if (SLANG_FAILED(res))
{
fprintf(stderr, "ERROR: failed to write screen capture to file\n");
@@ -403,6 +403,33 @@ Result RenderTestApp::update(Window* window)
}
+static SlangResult _setSessionPrelude(const Options& options, const char* exePath, SlangSession* session)
+{
+ // Let's see if we need to set up special prelude for HLSL
+ if (options.nvapiRegister.getLength())
+ {
+ String rootPath;
+ SLANG_RETURN_ON_FAIL(TestToolUtil::getRootPath(exePath, rootPath));
+
+ String includePath;
+ 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.nvapiRegister << "\n";
+
+ // Include the NVAPI header
+ buf << "#include \"" << includePath << "\"\n\n";
+
+ session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, buf.getBuffer());
+ }
+ else
+ {
+ session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, "");
+ }
+
+ return SLANG_OK;
+}
} // namespace renderer_test
@@ -413,8 +440,10 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
StdWriters::setSingleton(stdWriters);
+ Options options;
+
// Parse command-line options
- SLANG_RETURN_ON_FAIL(parseOptions(argcIn, argvIn, StdWriters::getError()));
+ SLANG_RETURN_ON_FAIL(Options::parse(argcIn, argvIn, StdWriters::getError(), options));
// Declare window pointer before renderer, such that window is released after renderer
RefPtr<renderer_test::Window> window;
@@ -423,13 +452,13 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
input.profile = "";
input.target = SLANG_TARGET_NONE;
- input.args = &gOptions.slangArgs[0];
- input.argCount = gOptions.slangArgCount;
+ input.args = &options.slangArgs[0];
+ input.argCount = options.slangArgCount;
SlangSourceLanguage nativeLanguage = SLANG_SOURCE_LANGUAGE_UNKNOWN;
SlangPassThrough slangPassThrough = SLANG_PASS_THROUGH_NONE;
char const* profileName = "";
- switch (gOptions.rendererType)
+ switch (options.rendererType)
{
case RendererType::DirectX11:
input.target = SLANG_DXBC;
@@ -445,7 +474,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
nativeLanguage = SLANG_SOURCE_LANGUAGE_HLSL;
slangPassThrough = SLANG_PASS_THROUGH_FXC;
- if( gOptions.useDXIL )
+ if( options.useDXIL )
{
input.target = SLANG_DXIL;
input.profile = "sm_6_0";
@@ -484,7 +513,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
return SLANG_FAIL;
}
- switch (gOptions.inputLanguageID)
+ switch (options.inputLanguageID)
{
case Options::InputLanguageID::Slang:
input.sourceLanguage = SLANG_SOURCE_LANGUAGE_SLANG;
@@ -500,7 +529,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
break;
}
- switch( gOptions.shaderType )
+ switch( options.shaderType )
{
case Options::ShaderProgramType::Graphics:
case Options::ShaderProgramType::GraphicsCompute:
@@ -519,9 +548,9 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
break;
}
- if (gOptions.sourceLanguage != SLANG_SOURCE_LANGUAGE_UNKNOWN)
+ if (options.sourceLanguage != SLANG_SOURCE_LANGUAGE_UNKNOWN)
{
- input.sourceLanguage = gOptions.sourceLanguage;
+ input.sourceLanguage = options.sourceLanguage;
if (input.sourceLanguage == SLANG_SOURCE_LANGUAGE_C || input.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP)
{
@@ -530,18 +559,18 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
// Use the profile name set on options if set
- input.profile = gOptions.profileName ? gOptions.profileName : input.profile;
+ input.profile = options.profileName ? options.profileName : input.profile;
StringBuilder rendererName;
- rendererName << "[" << RendererUtil::toText(gOptions.rendererType) << "] ";
- if (gOptions.adapter.getLength())
+ rendererName << "[" << RendererUtil::toText(options.rendererType) << "] ";
+ if (options.adapter.getLength())
{
- rendererName << "'" << gOptions.adapter << "'";
+ rendererName << "'" << options.adapter << "'";
}
- if (gOptions.onlyStartup)
+ if (options.onlyStartup)
{
- switch (gOptions.rendererType)
+ switch (options.rendererType)
{
case RendererType::CUDA:
{
@@ -560,11 +589,27 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
}
+ // Let's see if we need to set up special prelude for HLSL
+ if (options.nvapiRegister.getLength())
+ {
+ // We require nvapi to be available on the device
+ if (options.renderFeatures.indexOf("nvapi") < 0)
+ {
+ options.renderFeatures.add("nvapi");
+ }
+ }
+
+ // If can't set up a necessary prelude make not available (which will lead to the test being ignored)
+ if (SLANG_FAILED(_setSessionPrelude(options, argvIn[0], session)))
+ {
+ return SLANG_E_NOT_AVAILABLE;
+ }
+
// If it's CPU testing we don't need a window or a renderer
- if (gOptions.rendererType == RendererType::CPU)
+ if (options.rendererType == RendererType::CPU)
{
// Check we have all the required features
- for (const auto& renderFeature : gOptions.renderFeatures)
+ for (const auto& renderFeature : options.renderFeatures)
{
if (!CPUComputeUtil::hasFeature(renderFeature.getUnownedSlice()))
{
@@ -573,7 +618,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
ShaderCompilerUtil::OutputAndLayout compilationAndLayout;
- SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions, input, compilationAndLayout));
+ SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, options, input, compilationAndLayout));
{
// Get the shared library -> it contains the executable code, we need to keep around if we recompile
@@ -586,7 +631,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
// of the test implementer to *ensure* that the straight C++ code has the same layout as the slang C++ backend.
//
// If we are running c/c++ we still need binding information, so compile again as slang source
- if (gOptions.sourceLanguage == SLANG_SOURCE_LANGUAGE_C || input.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP)
+ if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_C || input.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP)
{
ShaderCompilerUtil::Input slangInput = input;
slangInput.sourceLanguage = SLANG_SOURCE_LANGUAGE_SLANG;
@@ -594,7 +639,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
// We just want CPP, so we get suitable reflection
slangInput.target = SLANG_CPP_SOURCE;
- SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions, slangInput, compilationAndLayout));
+ SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, options, slangInput, compilationAndLayout));
}
// calculate binding
@@ -603,39 +648,39 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
// Get the execution info from the lib
CPUComputeUtil::ExecuteInfo info;
- SLANG_RETURN_ON_FAIL(CPUComputeUtil::calcExecuteInfo(CPUComputeUtil::ExecuteStyle::GroupRange, sharedLibrary, gOptions.computeDispatchSize, compilationAndLayout, context, info));
+ SLANG_RETURN_ON_FAIL(CPUComputeUtil::calcExecuteInfo(CPUComputeUtil::ExecuteStyle::GroupRange, sharedLibrary, options.computeDispatchSize, compilationAndLayout, context, info));
const uint64_t startTicks = ProcessUtil::getClockTick();
SLANG_RETURN_ON_FAIL(CPUComputeUtil::execute(info));
- if (gOptions.performanceProfile)
+ if (options.performanceProfile)
{
const uint64_t endTicks = ProcessUtil::getClockTick();
_outputProfileTime(startTicks, endTicks);
}
- if (gOptions.outputPath)
+ if (options.outputPath)
{
- BindRoot* outputBindRoot = gOptions.outputUsingType ? &context.m_bindRoot : nullptr;
+ BindRoot* outputBindRoot = options.outputUsingType ? &context.m_bindRoot : nullptr;
// Dump everything out that was written
- SLANG_RETURN_ON_FAIL(ShaderInputLayout::writeBindings(outputBindRoot, compilationAndLayout.layout, context.m_buffers, gOptions.outputPath));
+ SLANG_RETURN_ON_FAIL(ShaderInputLayout::writeBindings(outputBindRoot, compilationAndLayout.layout, context.m_buffers, options.outputPath));
// Check all execution styles produce the same result
- SLANG_RETURN_ON_FAIL(CPUComputeUtil::checkStyleConsistency(sharedLibrary, gOptions.computeDispatchSize, compilationAndLayout));
+ SLANG_RETURN_ON_FAIL(CPUComputeUtil::checkStyleConsistency(sharedLibrary, options.computeDispatchSize, compilationAndLayout));
}
}
return SLANG_OK;
}
- if (gOptions.rendererType == RendererType::CUDA)
+ if (options.rendererType == RendererType::CUDA)
{
#if RENDER_TEST_CUDA
// Check we have all the required features
- for (const auto& renderFeature : gOptions.renderFeatures)
+ for (const auto& renderFeature : options.renderFeatures)
{
if (!CUDAComputeUtil::hasFeature(renderFeature.getUnownedSlice()))
{
@@ -644,25 +689,25 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
ShaderCompilerUtil::OutputAndLayout compilationAndLayout;
- SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions, input, compilationAndLayout));
+ SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, options, input, compilationAndLayout));
const uint64_t startTicks = ProcessUtil::getClockTick();
CUDAComputeUtil::Context context;
- SLANG_RETURN_ON_FAIL(CUDAComputeUtil::execute(compilationAndLayout, gOptions.computeDispatchSize, context));
+ SLANG_RETURN_ON_FAIL(CUDAComputeUtil::execute(compilationAndLayout, options.computeDispatchSize, context));
- if (gOptions.performanceProfile)
+ if (options.performanceProfile)
{
const uint64_t endTicks = ProcessUtil::getClockTick();
_outputProfileTime(startTicks, endTicks);
}
- if (gOptions.outputPath)
+ if (options.outputPath)
{
- BindRoot* outputBindRoot = gOptions.outputUsingType ? &context.m_bindRoot : nullptr;
+ BindRoot* outputBindRoot = options.outputUsingType ? &context.m_bindRoot : nullptr;
// Dump everything out that was written
- SLANG_RETURN_ON_FAIL(ShaderInputLayout::writeBindings(outputBindRoot, compilationAndLayout.layout, context.m_buffers, gOptions.outputPath));
+ SLANG_RETURN_ON_FAIL(ShaderInputLayout::writeBindings(outputBindRoot, compilationAndLayout.layout, context.m_buffers, options.outputPath));
}
return SLANG_OK;
@@ -671,9 +716,19 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
#endif
}
+ if (options.nvapiRegister.getLength())
+ {
+ // We require nvapi to be available on the device
+ if (options.renderFeatures.indexOf("nvapi") < 0)
+ {
+ options.renderFeatures.add("nvapi");
+ }
+ }
+
+
Slang::RefPtr<Renderer> renderer;
{
- RendererUtil::CreateFunc createFunc = RendererUtil::getCreateFunc(gOptions.rendererType);
+ RendererUtil::CreateFunc createFunc = RendererUtil::getCreateFunc(options.rendererType);
if (createFunc)
{
renderer = createFunc();
@@ -681,7 +736,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
if (!renderer)
{
- if (!gOptions.onlyStartup)
+ if (!options.onlyStartup)
{
fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer());
}
@@ -691,7 +746,8 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
Renderer::Desc desc;
desc.width = gWindowWidth;
desc.height = gWindowHeight;
- desc.adapter = gOptions.adapter;
+ desc.adapter = options.adapter;
+ desc.requiredFeatures = options.renderFeatures;
window = renderer_test::Window::create();
SLANG_RETURN_ON_FAIL(window->initialize(gWindowWidth, gWindowHeight));
@@ -699,14 +755,14 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
SlangResult res = renderer->initialize(desc, window->getHandle());
if (SLANG_FAILED(res))
{
- if (!gOptions.onlyStartup)
+ if (!options.onlyStartup)
{
fprintf(stderr, "Unable to initialize renderer %s\n", rendererName.getBuffer());
}
return res;
}
- for (const auto& feature : gOptions.renderFeatures)
+ for (const auto& feature : options.renderFeatures)
{
// If doesn't have required feature... we have to give up
if (!renderer->hasFeature(feature.getUnownedSlice()))
@@ -717,14 +773,14 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
// If the only test is we can startup, then we are done
- if (gOptions.onlyStartup)
+ if (options.onlyStartup)
{
return SLANG_OK;
}
{
RefPtr<RenderTestApp> app(new RenderTestApp);
- SLANG_RETURN_ON_FAIL(app->initialize(session, renderer, gOptions, input));
+ SLANG_RETURN_ON_FAIL(app->initialize(session, renderer, options, input));
window->show();
return window->runLoop(app);
}
@@ -758,7 +814,7 @@ int main(int argc, char** argv)
using namespace Slang;
SlangSession* session = spCreateSession(nullptr);
- TestToolUtil::setSessionDefaultPrelude(argv[0], session);
+ TestToolUtil::setSessionDefaultPreludeFromExePath(argv[0], session);
auto stdWriters = StdWriters::initDefaultSingleton();
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index da6ceb010..78c730cab 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -50,7 +50,7 @@ static gfx::StageType _translateStage(SlangStage slangStage)
}
}
-/* static */ SlangResult ShaderCompilerUtil::compileProgram(SlangSession* session, const Input& input, const ShaderCompileRequest& request, Output& out)
+/* static */ SlangResult ShaderCompilerUtil::compileProgram(SlangSession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out)
{
out.reset();
@@ -137,7 +137,7 @@ static gfx::StageType _translateStage(SlangStage slangStage)
Index explicitEntryPointCount = request.entryPoints.getCount();
for(Index ee = 0; ee < explicitEntryPointCount; ++ee)
{
- if(gOptions.dontAddDefaultEntryPoints)
+ if(options.dontAddDefaultEntryPoints)
{
// If default entry points are not to be added, then
// the `request.entryPoints` array should have been
@@ -359,7 +359,7 @@ static gfx::StageType _translateStage(SlangStage slangStage)
compileRequest.globalSpecializationArgs = layout.globalSpecializationArgs;
compileRequest.entryPointSpecializationArgs = layout.entryPointSpecializationArgs;
- return ShaderCompilerUtil::compileProgram(session, input, compileRequest, output.output);
+ return ShaderCompilerUtil::compileProgram(session, options, input, compileRequest, output.output);
}
} // renderer_test
diff --git a/tools/render-test/slang-support.h b/tools/render-test/slang-support.h
index 99509914e..5e38c8c69 100644
--- a/tools/render-test/slang-support.h
+++ b/tools/render-test/slang-support.h
@@ -87,7 +87,7 @@ struct ShaderCompilerUtil
static SlangResult readSource(const Slang::String& inSourcePath, List<char>& outSourceText);
- static SlangResult compileProgram(SlangSession* session, const Input& input, const ShaderCompileRequest& request, Output& out);
+ static SlangResult compileProgram(SlangSession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out);
};