Added parameters -t --Test and -s -TestSparseBinding to the test app, to execute tests and exit.

This commit is contained in:
Adam Sawicki 2021-12-03 12:13:44 +01:00
parent d74155933e
commit 4e4e1c085d

View File

@ -216,6 +216,8 @@ struct CommandLineParameters
{ {
bool m_Help = false; bool m_Help = false;
bool m_List = false; bool m_List = false;
bool m_Test = false;
bool m_TestSparseBinding = false;
GPUSelection m_GPUSelection; GPUSelection m_GPUSelection;
bool Parse(int argc, wchar_t** argv) bool Parse(int argc, wchar_t** argv)
@ -240,6 +242,14 @@ struct CommandLineParameters
m_GPUSelection.Index = _wtoi(argv[i + 1]); m_GPUSelection.Index = _wtoi(argv[i + 1]);
++i; ++i;
} }
else if (_wcsicmp(argv[i], L"-t") == 0 || _wcsicmp(argv[i], L"--Test") == 0)
{
m_Test = true;
}
else if (_wcsicmp(argv[i], L"-s") == 0 || _wcsicmp(argv[i], L"--TestSparseBinding") == 0)
{
m_TestSparseBinding = true;
}
else else
return false; return false;
} }
@ -2422,17 +2432,6 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
switch(msg) switch(msg)
{ {
case WM_CREATE:
// This is intentionally assigned here because we are now inside CreateWindow, before it returns.
g_hWnd = hWnd;
try
{
InitializeApplication();
}
CATCH_PRINT_ERROR(return -1;)
//PrintAllocatorStats();
return 0;
case WM_DESTROY: case WM_DESTROY:
try try
{ {
@ -2481,8 +2480,6 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
CATCH_PRINT_ERROR(;) CATCH_PRINT_ERROR(;)
break; break;
case 'S': case 'S':
try
{
if (g_SparseBindingEnabled) if (g_SparseBindingEnabled)
{ {
try try
@ -2495,11 +2492,6 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
printf("Sparse binding not supported.\n"); printf("Sparse binding not supported.\n");
} }
}
catch(const std::exception& ex)
{
printf("ERROR: %s\n", ex.what());
}
break; break;
} }
return 0; return 0;
@ -2524,6 +2516,8 @@ static void PrintHelp()
L"-l, --List Print list of GPUs\n" L"-l, --List Print list of GPUs\n"
L"-g S, --GPU S Select GPU with name containing S\n" L"-g S, --GPU S Select GPU with name containing S\n"
L"-i N, --GPUIndex N Select GPU index N\n" L"-i N, --GPUIndex N Select GPU index N\n"
L"-t, --Test Run tests and exit\n"
L"-s, --TestSparseBinding Run sparese binding tests and exit\n"
); );
} }
@ -2547,10 +2541,27 @@ int MainWindow()
RECT rect = { 0, 0, g_SizeX, g_SizeY }; RECT rect = { 0, 0, g_SizeX, g_SizeY };
AdjustWindowRectEx(&rect, style, FALSE, exStyle); AdjustWindowRectEx(&rect, style, FALSE, exStyle);
CreateWindowEx( g_hWnd = CreateWindowEx(
exStyle, WINDOW_CLASS_NAME, APP_TITLE_W, style, exStyle, WINDOW_CLASS_NAME, APP_TITLE_W, style,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, g_hAppInstance, NULL); NULL, NULL, g_hAppInstance, NULL);
assert(g_hWnd);
InitializeApplication();
//PrintAllocatorStats();
// Run tests and close program
if(g_CommandLineParameters.m_Test)
Test();
if(g_CommandLineParameters.m_TestSparseBinding)
{
if(g_SparseBindingEnabled)
TestSparseBinding();
else
printf("Sparse binding not supported.\n");
}
if(g_CommandLineParameters.m_Test || g_CommandLineParameters.m_TestSparseBinding)
PostMessage(g_hWnd, WM_CLOSE, 0, 0);
MSG msg; MSG msg;
for(;;) for(;;)
@ -2562,9 +2573,11 @@ int MainWindow()
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
if(g_hDevice != VK_NULL_HANDLE) else
{
DrawFrame(); DrawFrame();
} }
}
return (int)msg.wParam;; return (int)msg.wParam;;
} }