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

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: no gpu support 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') | no next file with comments »
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..c5480904053dbfd98cce060e1860f3bc366f3e61 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -155,3 +155,41 @@ void SKPBench::drawPicture() {
fSurfaces[j]->getCanvas()->flush();
}
}
+
+#if SK_SUPPORT_GPU
+static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPicture* picture,
+ 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);
+ }
+}
+#endif
+
+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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698