Hash :
d6acced1
Author :
Date :
2022-07-25T18:11:20
Add flag --save-screenshots (implied by --screenshot-dir). --screenshot-dir and --render-test-output-dir behave differently on Android. --screenshot-dir is passed as is and therefore means a device directory, and --render-test-output-dir has special handling in Android wrappers that substitutes this flag with a temporary location on the device then copying files to the local directory set by this flag. Cody pointed out that there are many docs referring to --screenshot-dir so behavior should be preserved. So --save-screenshots is implied when this flag is set. Otherwise, it defaults to false, so --render-test-output-dir just on its own won't save screenshots, only when --save-screenshots is added as well. This also allows to produce other artifacts without necessarily producing screenshots by using --render-test-output-dir without --save-screenshots. Bug: angleproject:7299 Change-Id: Ib1a268ddeb7eba9f120e3f37a429ea0e4bbe2411 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3785296 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Roman Lavrov <romanl@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLEPerfTestArgs.cpp:
// Parse command line arguments for angle_perftests.
//
#include "ANGLEPerfTestArgs.h"
#include <string.h>
#include <sstream>
namespace angle
{
bool gCalibration = false;
int gStepsPerTrial = 0;
int gMaxStepsPerformed = 0;
bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json";
const char *gScreenShotDir = nullptr;
bool gSaveScreenshots = false;
int gScreenShotFrame = 1;
bool gVerboseLogging = false;
double gCalibrationTimeSeconds = 1.0;
double gMaxTrialTimeSeconds = 10.0;
int gTestTrials = 3;
bool gNoFinish = false;
bool gEnableAllTraceTests = false;
bool gRetraceMode = false;
bool gMinimizeGPUWork = false;
bool gTraceTestValidation = false;
const char *gPerfCounters = nullptr;
// Default to three warmup loops. There's no science to this. More than two loops was experimentally
// helpful on a Windows NVIDIA setup when testing with Vulkan and native trace tests.
int gWarmupLoops = 3;
int gWarmupSteps = std::numeric_limits<int>::max();
} // namespace angle
namespace
{
int ReadIntArgument(const char *arg)
{
std::stringstream strstr;
strstr << arg;
int value;
strstr >> value;
return value;
}
constexpr char kRenderTestOutputDir[] = "--render-test-output-dir=";
} // namespace
using namespace angle;
void ANGLEProcessPerfTestArgs(int *argc, char **argv)
{
for (int argIndex = 0; argIndex < *argc; argIndex++)
{
if (strcmp("--one-frame-only", argv[argIndex]) == 0)
{
gStepsPerTrial = 1;
gWarmupLoops = 0;
}
else if (strcmp("--enable-trace", argv[argIndex]) == 0)
{
gEnableTrace = true;
}
else if (strcmp("--trace-file", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gTraceFile = argv[argIndex + 1];
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--calibration", argv[argIndex]) == 0)
{
gCalibration = true;
gTestTrials = 0;
}
else if (strcmp("--steps-per-trial", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gStepsPerTrial = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--max-steps-performed", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gMaxStepsPerformed = ReadIntArgument(argv[argIndex + 1]);
gWarmupLoops = 0;
gTestTrials = 1;
gMaxTrialTimeSeconds = 36000;
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--fixed-test-time", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
gStepsPerTrial = std::numeric_limits<int>::max();
gTestTrials = 1;
gWarmupLoops = 0;
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--screenshot-dir", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gScreenShotDir = argv[argIndex + 1];
gSaveScreenshots = true; // implicitly set here but not when using kRenderTestOutputDir
argIndex++;
}
else if (strncmp(kRenderTestOutputDir, argv[argIndex], strlen(kRenderTestOutputDir)) == 0)
{
gScreenShotDir = argv[argIndex] + strlen(kRenderTestOutputDir);
}
else if (strcmp("--save-screenshots", argv[argIndex]) == 0)
{
gSaveScreenshots = true;
}
else if (strcmp("--screenshot-frame", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gScreenShotFrame = ReadIntArgument(argv[argIndex + 1]);
argIndex++;
}
else if (strcmp("--verbose-logging", argv[argIndex]) == 0 ||
strcmp("--verbose", argv[argIndex]) == 0 || strcmp("-v", argv[argIndex]) == 0)
{
gVerboseLogging = true;
}
else if (strcmp("--warmup-loops", argv[argIndex]) == 0)
{
gWarmupLoops = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--warmup-steps", argv[argIndex]) == 0)
{
gWarmupSteps = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--no-warmup", argv[argIndex]) == 0)
{
gWarmupLoops = 0;
}
else if (strcmp("--calibration-time", argv[argIndex]) == 0)
{
gCalibrationTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--max-trial-time", argv[argIndex]) == 0)
{
gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--trials", argv[argIndex]) == 0)
{
gTestTrials = ReadIntArgument(argv[argIndex + 1]);
// Skip an additional argument.
argIndex++;
}
else if (strcmp("--no-finish", argv[argIndex]) == 0)
{
gNoFinish = true;
}
else if (strcmp("--enable-all-trace-tests", argv[argIndex]) == 0)
{
gEnableAllTraceTests = true;
}
else if (strcmp("--retrace-mode", argv[argIndex]) == 0)
{
gRetraceMode = true;
}
else if (strcmp("--minimize-gpu-work", argv[argIndex]) == 0)
{
gMinimizeGPUWork = true;
}
else if (strcmp("--validation", argv[argIndex]) == 0)
{
gTraceTestValidation = true;
gWarmupLoops = 0;
gTestTrials = 1;
gMaxTrialTimeSeconds = 600.0;
}
else if (strcmp("--perf-counters", argv[argIndex]) == 0 && argIndex < *argc - 1)
{
gPerfCounters = argv[argIndex + 1];
argIndex++;
}
}
}