summaryrefslogtreecommitdiff
path: root/tools/slang-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-25 11:48:10 -0400
committerGitHub <noreply@github.com>2019-03-25 11:48:10 -0400
commit2f4029a753f72833c30c4e6bad28c06b20540384 (patch)
treeca771b5e00c6126351079b2df920d014e4ed6a1e /tools/slang-test
parent5bdc3ef07373be62363deb64dedd4163589430b6 (diff)
Adapter selection for Renderer (#923)
* * Make adapter used selectable on the command line * Added 'adapter' to Renderer::Desc with dx11, dx12, vk honoring it * GL will check that the renderer matches, but cannot select a specific device * Share functionality on dx adapter selection in D3DUtil Note - that on tests that use OpenGL and the adapter doesn't match it will ignore the test (and display a message that the appropriate device couldn't be started) * Small function name improvement. * Variable rename to match type. * Fix typo in Dx12 device selection. * * Add checking if an adapter is warp * Improve some comments
Diffstat (limited to 'tools/slang-test')
-rw-r--r--tools/slang-test/options.cpp9
-rw-r--r--tools/slang-test/options.h3
-rw-r--r--tools/slang-test/slang-test-main.cpp22
3 files changed, 34 insertions, 0 deletions
diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp
index 70b7a4533..2b9ec6c06 100644
--- a/tools/slang-test/options.cpp
+++ b/tools/slang-test/options.cpp
@@ -170,6 +170,15 @@ static bool _isSubCommand(const char* arg)
argCursor++;
// Assumed to be handle by .bat file that called us
}
+ else if (strcmp(arg, "-adapter") == 0)
+ {
+ if (argCursor == argEnd)
+ {
+ stdError.print("error: expected operand for '%s'\n", arg);
+ return SLANG_FAIL;
+ }
+ optionsOut->adapter = *argCursor++;
+ }
else if (strcmp(arg, "-appveyor") == 0)
{
optionsOut->outputMode = TestOutputMode::AppVeyor;
diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h
index 58b8e0fb2..72dc66035 100644
--- a/tools/slang-test/options.h
+++ b/tools/slang-test/options.h
@@ -86,6 +86,9 @@ struct Options
// OpenGL is disabled for now
Slang::RenderApiFlags synthesizedTestApis = Slang::RenderApiFlag::AllOf & ~(Slang::RenderApiFlag::Vulkan | Slang::RenderApiFlag::OpenGl);
+ // The adapter to use. If empty will match first found adapter.
+ Slang::String adapter;
+
/// Parse the args, report any errors into stdError, and write the results into optionsOut
static SlangResult parse(int argc, char** argv, TestCategorySet* categorySet, Slang::WriterHelper stdError, Options* optionsOut);
};
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 0b4b83198..9119c3224 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -452,6 +452,8 @@ ToolReturnCode getReturnCode(OSProcessSpawner& spawner)
ToolReturnCode spawnAndWait(TestContext* context, const String& testPath, SpawnType spawnType, OSProcessSpawner& spawner)
{
+ const auto& options = context->options;
+
OSError spawnResult = kOSError_OperationFailed;
switch (spawnType)
{
@@ -1079,6 +1081,14 @@ TestResult runGLSLComparisonTest(TestContext* context, TestInput& input)
return TestResult::Pass;
}
+static void _addRenderTestOptions(const Options& options, OSProcessSpawner& spawner)
+{
+ if (options.adapter.Length())
+ {
+ spawner.pushArgument("-adapter");
+ spawner.pushArgument(options.adapter);
+ }
+}
TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, const char *const* langOpts, size_t numLangOpts)
{
@@ -1097,6 +1107,8 @@ TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, cons
spawner.pushExecutablePath(String(context->options.binDir) + "render-test" + osGetExecutableSuffix());
spawner.pushArgument(filePath999);
+ _addRenderTestOptions(context->options, spawner);
+
for (auto arg : input.testOptions->args)
{
spawner.pushArgument(arg);
@@ -1199,6 +1211,8 @@ TestResult doRenderComparisonTestRun(TestContext* context, TestInput& input, cha
spawner.pushExecutablePath(String(context->options.binDir) + "render-test" + osGetExecutableSuffix());
spawner.pushArgument(filePath);
+ _addRenderTestOptions(context->options, spawner);
+
for( auto arg : input.testOptions->args )
{
spawner.pushArgument(arg);
@@ -1405,7 +1419,15 @@ TestResult runHLSLRenderComparisonTestImpl(
String actualOutput;
TestResult hlslResult = doRenderComparisonTestRun(context, input, expectedArg, ".expected", &expectedOutput);
+ if (hlslResult != TestResult::Pass)
+ {
+ return hlslResult;
+ }
TestResult slangResult = doRenderComparisonTestRun(context, input, actualArg, ".actual", &actualOutput);
+ if (slangResult != TestResult::Pass)
+ {
+ return slangResult;
+ }
Slang::File::WriteAllText(outputStem + ".expected", expectedOutput);
Slang::File::WriteAllText(outputStem + ".actual", actualOutput);