Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/perf_tests/ANGLEPerfTestArgs.cpp
1693 views
1
//
2
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// ANGLEPerfTestArgs.cpp:
7
// Parse command line arguments for angle_perftests.
8
//
9
10
#include "ANGLEPerfTestArgs.h"
11
#include <string.h>
12
#include <sstream>
13
14
namespace angle
15
{
16
bool gCalibration = false;
17
int gStepsPerTrial = 0;
18
int gMaxStepsPerformed = 0;
19
bool gEnableTrace = false;
20
const char *gTraceFile = "ANGLETrace.json";
21
const char *gScreenShotDir = nullptr;
22
int gScreenShotFrame = 1;
23
bool gVerboseLogging = false;
24
double gCalibrationTimeSeconds = 1.0;
25
double gMaxTrialTimeSeconds = 10.0;
26
int gTestTrials = 3;
27
bool gNoFinish = false;
28
bool gEnableAllTraceTests = false;
29
bool gRetraceMode = false;
30
bool gMinimizeGPUWork = false;
31
bool gTraceTestValidation = false;
32
33
// Default to three warmup loops. There's no science to this. More than two loops was experimentally
34
// helpful on a Windows NVIDIA setup when testing with Vulkan and native trace tests.
35
int gWarmupLoops = 3;
36
} // namespace angle
37
38
namespace
39
{
40
int ReadIntArgument(const char *arg)
41
{
42
std::stringstream strstr;
43
strstr << arg;
44
45
int value;
46
strstr >> value;
47
return value;
48
}
49
50
// The same as --screenshot-dir, but used by Chrome tests.
51
constexpr char kRenderTestDirArg[] = "--render-test-output-dir=";
52
} // namespace
53
54
using namespace angle;
55
56
void ANGLEProcessPerfTestArgs(int *argc, char **argv)
57
{
58
for (int argIndex = 0; argIndex < *argc; argIndex++)
59
{
60
if (strcmp("--one-frame-only", argv[argIndex]) == 0)
61
{
62
gStepsPerTrial = 1;
63
gWarmupLoops = 0;
64
}
65
else if (strcmp("--enable-trace", argv[argIndex]) == 0)
66
{
67
gEnableTrace = true;
68
}
69
else if (strcmp("--trace-file", argv[argIndex]) == 0 && argIndex < *argc - 1)
70
{
71
gTraceFile = argv[argIndex + 1];
72
// Skip an additional argument.
73
argIndex++;
74
}
75
else if (strcmp("--calibration", argv[argIndex]) == 0)
76
{
77
gCalibration = true;
78
gTestTrials = 0;
79
}
80
else if (strcmp("--steps-per-trial", argv[argIndex]) == 0 && argIndex < *argc - 1)
81
{
82
gStepsPerTrial = ReadIntArgument(argv[argIndex + 1]);
83
// Skip an additional argument.
84
argIndex++;
85
}
86
else if (strcmp("--max-steps-performed", argv[argIndex]) == 0 && argIndex < *argc - 1)
87
{
88
gMaxStepsPerformed = ReadIntArgument(argv[argIndex + 1]);
89
gWarmupLoops = 0;
90
gTestTrials = 1;
91
gMaxTrialTimeSeconds = 36000;
92
// Skip an additional argument.
93
argIndex++;
94
}
95
else if (strcmp("--fixed-test-time", argv[argIndex]) == 0 && argIndex < *argc - 1)
96
{
97
gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
98
gStepsPerTrial = std::numeric_limits<int>::max();
99
gTestTrials = 1;
100
gWarmupLoops = 0;
101
// Skip an additional argument.
102
argIndex++;
103
}
104
else if (strcmp("--screenshot-dir", argv[argIndex]) == 0 && argIndex < *argc - 1)
105
{
106
gScreenShotDir = argv[argIndex + 1];
107
argIndex++;
108
}
109
else if (strcmp("--screenshot-frame", argv[argIndex]) == 0 && argIndex < *argc - 1)
110
{
111
gScreenShotFrame = ReadIntArgument(argv[argIndex + 1]);
112
argIndex++;
113
}
114
else if (strcmp("--verbose-logging", argv[argIndex]) == 0 ||
115
strcmp("--verbose", argv[argIndex]) == 0 || strcmp("-v", argv[argIndex]) == 0)
116
{
117
gVerboseLogging = true;
118
}
119
else if (strcmp("--warmup-loops", argv[argIndex]) == 0)
120
{
121
gWarmupLoops = ReadIntArgument(argv[argIndex + 1]);
122
// Skip an additional argument.
123
argIndex++;
124
}
125
else if (strcmp("--no-warmup", argv[argIndex]) == 0)
126
{
127
gWarmupLoops = 0;
128
}
129
else if (strncmp(kRenderTestDirArg, argv[argIndex], strlen(kRenderTestDirArg)) == 0)
130
{
131
gScreenShotDir = argv[argIndex] + strlen(kRenderTestDirArg);
132
}
133
else if (strcmp("--calibration-time", argv[argIndex]) == 0)
134
{
135
gCalibrationTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
136
// Skip an additional argument.
137
argIndex++;
138
}
139
else if (strcmp("--max-trial-time", argv[argIndex]) == 0)
140
{
141
gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
142
// Skip an additional argument.
143
argIndex++;
144
}
145
else if (strcmp("--trials", argv[argIndex]) == 0)
146
{
147
gTestTrials = ReadIntArgument(argv[argIndex + 1]);
148
// Skip an additional argument.
149
argIndex++;
150
}
151
else if (strcmp("--no-finish", argv[argIndex]) == 0)
152
{
153
gNoFinish = true;
154
}
155
else if (strcmp("--enable-all-trace-tests", argv[argIndex]) == 0)
156
{
157
gEnableAllTraceTests = true;
158
}
159
else if (strcmp("--retrace-mode", argv[argIndex]) == 0)
160
{
161
gRetraceMode = true;
162
}
163
else if (strcmp("--minimize-gpu-work", argv[argIndex]) == 0)
164
{
165
gMinimizeGPUWork = true;
166
}
167
else if (strcmp("--validation", argv[argIndex]) == 0)
168
{
169
gTraceTestValidation = true;
170
gWarmupLoops = 0;
171
gTestTrials = 1;
172
gMaxTrialTimeSeconds = 600.0;
173
}
174
}
175
}
176
177