Set up to let demos project filter list of available tests

* This is primarily for the benefit of GL/VK where we need to feature-detect for
  some extensions or functionality that requires selecting a device, e.g. D3D12
  can be more easily detected with a quick check.
* We'll run this once and cache the results when running tests from python so we
  can do a better job of filtering out tests that the current machine doesn't
  support.
This commit is contained in:
baldurk
2019-05-20 16:23:09 +01:00
parent 419fa93ebf
commit 622291fde9
3 changed files with 39 additions and 16 deletions
+1 -1
View File
@@ -72,7 +72,7 @@
<DisableSpecificWarnings>4100;4054;4055</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>kernel32.lib;user32.lib;msimg32.lib;gdi32.lib;shell32.lib;shlwapi.lib</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
+33 -15
View File
@@ -225,6 +225,14 @@ std::vector<TestMetadata> &test_list()
return list;
}
void check_tests(int argc, char **argv)
{
std::vector<TestMetadata> &tests = test_list();
for(TestMetadata &test : tests)
test.test->Prepare(argc, argv);
}
void RegisterTest(TestMetadata test)
{
test_list().push_back(test);
@@ -244,7 +252,8 @@ int main(int argc, char **argv)
Usage: %s Test_Name [test_options]
--help Print this help message.
--list Lists the available tests.
--list Lists all tests, with name, API, description, availability.
--list-available Lists the available test names only, one per line.
--validate
--debug Run the demo with API validation enabled.
--frames <n>
@@ -263,8 +272,27 @@ Usage: %s Test_Name [test_options]
if(argc >= 2 && !strcmp(argv[1], "--list"))
{
check_tests(argc, argv);
for(const TestMetadata &test : tests)
printf("%s (%s) - %s\n", test.Name, test.APIName(), test.Description);
printf("%s (%s %s) - %s\n", test.Name, test.APIName(),
test.IsAvailable() ? "Available" : test.AvailMessage(), test.Description);
fflush(stdout);
return 1;
}
if(argc >= 2 && !strcmp(argv[1], "--list-raw"))
{
check_tests(argc, argv);
for(const TestMetadata &test : tests)
{
if(!test.IsAvailable())
continue;
printf("%s\n", test.Name);
}
fflush(stdout);
return 1;
@@ -285,6 +313,8 @@ Usage: %s Test_Name [test_options]
}
else
{
check_tests(argc, argv);
const int width = 400, height = 575;
nk_context *ctx = NuklearInit(width, height, "RenderDoc Test Program");
@@ -437,24 +467,12 @@ Usage: %s Test_Name [test_options]
if(testchoice.empty())
return 0;
#if defined(WIN32)
if(AllocConsole())
{
FILE *dummy = NULL;
freopen_s(&dummy, "CONOUT$", "w", stdout);
freopen_s(&dummy, "CONOUT$", "w", stderr);
}
#endif
//////////////////////////////////////////////////////////////
// D3D11 tests
//////////////////////////////////////////////////////////////
for(const TestMetadata &test : tests)
{
if(testchoice == test.Name)
{
TEST_LOG("\n\n======\nRunning %s\n\n", test.Name);
test.test->Prepare(argc, argv);
int ret = test.test->main(argc, argv);
test.test->Shutdown();
return ret;
+5
View File
@@ -154,9 +154,12 @@ struct GraphicsTest
virtual GraphicsWindow *MakeWindow(int width, int height, const char *title) { return NULL; }
virtual int main(int argc, char **argv) { return 9; }
virtual bool IsSupported() { return false; }
virtual void Prepare(int argc, char **argv) {}
virtual bool Init(int argc, char **argv);
virtual void Shutdown();
std::string Avail;
std::string GetDataPath(const std::string &filename);
bool FrameLimit();
@@ -193,6 +196,8 @@ struct TestMetadata
const char *Description;
GraphicsTest *test;
bool IsAvailable() const { return test->Avail.empty(); }
const char *AvailMessage() const { return test->Avail.c_str(); }
std::string QualifiedName() const
{
std::string ret = APIName();