Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2462)

Unified Diff: bench/SKPBench.cpp

Issue 1489033004: Began logging more gpu stats from nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | src/gpu/GrTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SKPBench.cpp
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 910af6b802337a700557f1ceedc24ab5a1375458..bca179c2c083644d157cafbe3e086692cc89a635 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -155,3 +155,39 @@ void SKPBench::drawPicture() {
fSurfaces[j]->getCanvas()->flush();
}
}
+
+static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPicture* picture,
bsalomon 2015/12/02 15:58:10 might need to protect this by a SK_SUPPORT_GPU
+ SkTArray<SkString>* keys, SkTArray<double>* values,
+ const char* tag) {
+ context->resetGpuStats();
+ canvas->drawPicture(picture);
+ canvas->flush();
+
+ int offset = keys->count();
+ context->dumpGpuStatsKeyValuePairs(keys, values);
+
+ // append tag, but only to new tags
+ for (int i = offset; i < keys->count(); i++, offset++) {
+ (*keys)[i].appendf("_%s", tag);
+ }
+}
+
+void SKPBench::getGpuStats(SkCanvas* canvas, SkTArray<SkString>* keys, SkTArray<double>* values) {
+#if SK_SUPPORT_GPU
+ // we do a special single draw and then dump the key / value pairs
+ GrContext* context = canvas->getGrContext();
+ if (!context) {
+ return;
+ }
+
+ // TODO refactor this out if we want to test other subclasses of skpbench
+ context->flush();
+ context->freeGpuResources();
+ context->resetContext();
+ draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame");
+
+ // draw second frame
+ draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame");
+
+#endif
+}
« no previous file with comments | « bench/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | src/gpu/GrTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698