gltf_viewer: add --headless option.

This should only be used in combination with --batch. Users are
admonished if they try using it on its own.
This commit is contained in:
Philip Rideout
2020-10-03 15:15:30 -07:00
parent 79f1744823
commit 4fe5832333
4 changed files with 29 additions and 8 deletions

View File

@@ -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)

View File

@@ -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; }

View File

@@ -25,6 +25,7 @@
#include <backend/PixelBufferDescriptor.h>
#include <utils/Log.h>
#include <utils/Path.h>
#include <iomanip>
@@ -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) {

View File

@@ -134,6 +134,8 @@ static void printUsage(char* name) {
" Specify the backend API: opengl (default), vulkan, or metal\n\n"
" --batch=<path to JSON file or 'default'>, -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=<path to cmgen IBL>, -i <path>\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;
}