summaryrefslogtreecommitdiffstats
path: root/tools/render-test/options.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-09-23 15:38:25 -0400
committerGitHub <noreply@github.com>2019-09-23 15:38:25 -0400
commit05af41d21d74d24871507e6f8f50574ea08c48a2 (patch)
tree3197b021ed71c40f6035fdfa7d450b4b3b945422 /tools/render-test/options.cpp
parentede0792fd9b4c7bc5c2653092ba1d492e67ca190 (diff)
Simple test profiling (#1062)
* First pass support for performance profiling * Test across all elements * Fix bug - sourceContents is not used, should use rawSource. * * Add ability to get prelude from API. * Allow specifying source language for render-test * Made it possible to compile a test input file as C++ * Special handling for reflection * Added C++ impl to performance-profile.slang * Remove some clang warnings. * Output profile timings on appveyor and other TC. * Remove passing around of StdWriters (can use global). Small comment improvements.
Diffstat (limited to 'tools/render-test/options.cpp')
-rw-r--r--tools/render-test/options.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index e13a2b88f..3d5df6f62 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -44,6 +44,32 @@ static SlangResult _setRendererType(RendererType type, const char* arg, Slang::W
return SLANG_OK;
}
+static SlangSourceLanguage _findSourceLanguage(const UnownedStringSlice& text)
+{
+ if (text == "c" || text == "C")
+ {
+ return SLANG_SOURCE_LANGUAGE_C;
+ }
+ else if (text == "cpp" || text == "c++" || text == "C++" || text == "cxx")
+ {
+ return SLANG_SOURCE_LANGUAGE_CPP;
+ }
+ else if (text == "slang")
+ {
+ return SLANG_SOURCE_LANGUAGE_SLANG;
+ }
+ else if (text == "glsl")
+ {
+ return SLANG_SOURCE_LANGUAGE_GLSL;
+ }
+ else if (text == "hlsl")
+ {
+ return SLANG_SOURCE_LANGUAGE_HLSL;
+ }
+ return SLANG_SOURCE_LANGUAGE_UNKNOWN;
+}
+
+
SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError)
{
using namespace Slang;
@@ -169,6 +195,10 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
arg.value = *argCursor++;
gOptions.compileArgs.add(arg);
}
+ else if (strcmp(arg, "-performance-profile") == 0)
+ {
+ gOptions.performanceProfile = true;
+ }
else if (strcmp(arg, "-adapter") == 0)
{
if (argCursor == argEnd)
@@ -207,6 +237,24 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
gOptions.computeDispatchSize[i] = v;
}
}
+ else if (strcmp(arg, "-source-language") == 0)
+ {
+ if (argCursor == argEnd)
+ {
+ stdError.print("error: expecting a source language name for '%s'\n", arg);
+ return SLANG_FAIL;
+ }
+ UnownedStringSlice sourceLanguageText(*argCursor++);
+
+ SlangSourceLanguage sourceLanguage = _findSourceLanguage(sourceLanguageText);
+ if (sourceLanguage == SLANG_SOURCE_LANGUAGE_UNKNOWN)
+ {
+ stdError.print("error: expecting unknown source language name '%s' for '%s'\n", String(sourceLanguageText).getBuffer(), arg);
+ return SLANG_FAIL;
+ }
+
+ gOptions.sourceLanguage = sourceLanguage;
+ }
else
{
// Lookup
@@ -228,7 +276,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
if (languageRenderType != RendererType::Unknown)
{
gOptions.targetLanguageRendererType = languageRenderType;
- gOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl") ? InputLanguageID::Native : InputLanguageID::Slang;
+ gOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl" || argName == "cpp" || argName == "cxx" || argName == "c") ? InputLanguageID::Native : InputLanguageID::Slang;
continue;
}
}