27 "While auto-tuning the number of benchmark runs per sample, increase the number of runs "
28 "until a single sample takes this many milliseconds. Do this for each benchmark.");
30static DEFINE_bool(gpuStats,
false,
"Print GPU stats after each GPU benchmark.");
34 "Dump GPU stats after each benchmark into the "
35 "results.json output file, which can be ingested by Perf.");
39 "Dump DMSAA stats after each benchmark into the "
40 "results.json output file, which can be ingested by Perf.");
54 if (FLAGS_dmsaaStatsDump) {
88 fSurfaceManager->getGaneshContextInfo()->testContext()->flushAndWaitOnSync(
96 int maxFrameLag = computeMaxFrameLag();
102 if (1 << 30 == loops) {
110 for (
int i = 0;
i < maxFrameLag;
i++) {
111 elapsed =
time(loops);
113 }
while (elapsed < FLAGS_gpuMs);
116 loops = (
int)
ceil(loops * FLAGS_gpuMs / elapsed);
121 return std::make_tuple(loops,
true);
129 int maxFrameLag = computeMaxFrameLag();
130 for (
int i = 0;
i < maxFrameLag;
i++) {
137 if (FLAGS_gpuStatsDump) {
143 dmsaaStats.dumpKeyValuePairs(keys,
values);
150 if (FLAGS_gpuStats) {
151 auto context =
fSurfaceManager->getGaneshContextInfo()->directContext();
153 context->priv().printCacheStats();
154 context->priv().printGpuStats();
155 context->priv().printContextStats();
162 int computeMaxFrameLag()
const {
164 if (!
fSurfaceManager->getGaneshContextInfo()->testContext()->getMaxGpuFrameLag(
179 benchmark->modifyGrContextOptions(grContextOptions);
181 std::unique_ptr<SurfaceManager> surfaceManager =
183 if (surfaceManager ==
nullptr) {
184 SK_ABORT(
"Unknown --surfaceConfig flag value: %s.", surfaceConfig.c_str());
187 if (surfaceManager->getGaneshContextInfo()->testContext()->fenceSyncSupport()) {
189 "WARNING: GL context for config \"%s\" does not support fence sync. "
190 "Timings might not be accurate.",
191 surfaceConfig.c_str());
194 return std::make_unique<GaneshBenchmarkTarget>(std::move(surfaceManager),
benchmark);
static constexpr int ESTIMATED_GPU_FRAME_LAG
GrRecordingContextPriv::DMSAAStats combinedDMSAAStats
static DEFINE_bool(gpuStats, false, "Print GPU stats after each GPU benchmark.")
static DEFINE_double(gpuMs, 5, "While auto-tuning the number of benchmark runs per sample, increase the number of runs " "until a single sample takes this many milliseconds. Do this for each benchmark.")
#define SK_ABORT(message,...)
virtual void setup() const
static std::unique_ptr< BenchmarkTarget > FromConfig(std::string surfaceConfig, Benchmark *benchmark)
std::unique_ptr< SurfaceManager > fSurfaceManager
static void printGlobalStats()
double time(int loops) const
SkCanvas * getCanvas() const
virtual void getGpuStats(SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
virtual bool getDMSAAStats(GrRecordingContext *)
~GaneshBenchmarkTarget() override
void setup() const override
void printStats() const override
Benchmark::Backend getBackend() const override
void warmUp(int loops) const override
void onAfterDraw() const override
void dumpStats(skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values) const override
std::tuple< int, bool > autoTuneLoops() const override
GaneshBenchmarkTarget(std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
GrRecordingContextPriv priv()
virtual GrRecordingContext * recordingContext() const
static std::unique_ptr< SurfaceManager > FromConfig(std::string config, SurfaceOptions surfaceOptions)
void Log(const char *format,...) SK_PRINTF_LIKE(1
SIN Vec< N, float > ceil(const Vec< N, float > &x)