diff --git a/libs/filamentapp/src/FilamentApp.cpp b/libs/filamentapp/src/FilamentApp.cpp index 2521bf6a27..98760003d5 100644 --- a/libs/filamentapp/src/FilamentApp.cpp +++ b/libs/filamentapp/src/FilamentApp.cpp @@ -323,13 +323,17 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback, if (mImGuiHelper) { // Inform ImGui of the current window size in case it was resized. - int windowWidth, windowHeight; - int displayWidth, displayHeight; - SDL_GetWindowSize(window->mWindow, &windowWidth, &windowHeight); - SDL_GL_GetDrawableSize(window->mWindow, &displayWidth, &displayHeight); - mImGuiHelper->setDisplaySize(windowWidth, windowHeight, - windowWidth > 0 ? ((float)displayWidth / windowWidth) : 0, - displayHeight > 0 ? ((float)displayHeight / windowHeight) : 0); + if (config.headless) { + mImGuiHelper->setDisplaySize(window->mWidth, window->mHeight); + } else { + int windowWidth, windowHeight; + int displayWidth, displayHeight; + SDL_GetWindowSize(window->mWindow, &windowWidth, &windowHeight); + SDL_GL_GetDrawableSize(window->mWindow, &displayWidth, &displayHeight); + mImGuiHelper->setDisplaySize(windowWidth, windowHeight, + windowWidth > 0 ? ((float)displayWidth / windowWidth) : 0, + displayHeight > 0 ? ((float)displayHeight / windowHeight) : 0); + } // Setup mouse inputs (we already got mouse wheel, keyboard keys & characters // from our event handler) diff --git a/libs/viewer/include/viewer/AutomationEngine.h b/libs/viewer/include/viewer/AutomationEngine.h index 3f578aa02b..a3ed876ad9 100644 --- a/libs/viewer/include/viewer/AutomationEngine.h +++ b/libs/viewer/include/viewer/AutomationEngine.h @@ -88,6 +88,9 @@ public: // Similar to sleepDuration, but expressed as a frame count. Both the minimum sleep time // and the minimum frame count must be elapsed before the engine advances to the next test. int minFrameCount = 2; + + // If true, test progress is dumped to the utils Log (info priority). + bool verbose = true; }; Options getOptions() const { return mOptions; } diff --git a/libs/viewer/src/AutomationEngine.cpp b/libs/viewer/src/AutomationEngine.cpp index 17a0c98bfc..2bc7dcc1c1 100644 --- a/libs/viewer/src/AutomationEngine.cpp +++ b/libs/viewer/src/AutomationEngine.cpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -133,6 +134,9 @@ void AutomationEngine::tick(View* view, MaterialInstance* const* materials, size for (size_t i = 0; i < materialCount; i++) { applySettings(mSettings->material, materials[i]); } + if (mOptions.verbose) { + utils::slog.i << "Running test " << mCurrentTest << utils::io::endl; + } }; if (!mIsRunning) { diff --git a/samples/gltf_viewer.cpp b/samples/gltf_viewer.cpp index d6a87927ef..b1c22042da 100644 --- a/samples/gltf_viewer.cpp +++ b/samples/gltf_viewer.cpp @@ -134,6 +134,8 @@ static void printUsage(char* name) { " Specify the backend API: opengl (default), vulkan, or metal\n\n" " --batch=, -b\n" " Start automation using the given JSON spec, then quit the app\n\n" + " --headless, -e\n" + " Use a headless swapchain; ignored if --batch is not present\n\n" " --ibl=, -i \n" " Override the built-in IBL\n\n" " --actual-size, -s\n" @@ -166,11 +168,12 @@ static std::ifstream::pos_type getFileSize(const char* filename) { } static int handleCommandLineArguments(int argc, char* argv[], App* app) { - static constexpr const char* OPTSTR = "ha:i:usc:rt:b:"; + static constexpr const char* OPTSTR = "ha:i:usc:rt:b:e"; static const struct option OPTIONS[] = { { "help", no_argument, nullptr, 'h' }, { "api", required_argument, nullptr, 'a' }, { "batch", required_argument, nullptr, 'b' }, + { "headless", no_argument, nullptr, 'e' }, { "ibl", required_argument, nullptr, 'i' }, { "ubershader", no_argument, nullptr, 'u' }, { "actual-size", no_argument, nullptr, 's' }, @@ -208,6 +211,9 @@ static int handleCommandLineArguments(int argc, char* argv[], App* app) { std::cerr << "Unrecognized camera mode. Must be 'flight'|'orbit'.\n"; } break; + case 'e': + app->config.headless = true; + break; case 'i': app->config.iblDirectory = arg; break; @@ -229,6 +235,10 @@ static int handleCommandLineArguments(int argc, char* argv[], App* app) { } } } + if (app->config.headless && app->batchFile.empty()) { + std::cerr << "--headless is allowed only when --batch is present." << std::endl; + app->config.headless = false; + } return optind; }