aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-11 22:58:00 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-11 22:58:00 +0000
commit51c040ed1e8c50bec4297bbe25242f644b40b0b7 (patch)
tree26db2071a417be87b2395c3c41f9bf0fd3652aa0
parent6f458fc22181622af0ccc7edb583152521bb73b3 (diff)
Alter bench_pictures to "respect" the logPerIter flag.
When --logPerIters is set and --repeat is great then 2 then bench_pictures will run each test "repeat" times (to generate the correct number of timings) by rendering 5 times. This CL also adds a swapBuffers in addition to the pre-existing flush calls. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/194973003 git-svn-id: http://skia.googlecode.com/svn/trunk@13752 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp5
-rw-r--r--tools/PictureBenchmark.cpp117
-rw-r--r--tools/PictureRenderer.cpp1
-rw-r--r--tools/PictureRenderer.h2
4 files changed, 73 insertions, 52 deletions
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index de5edbec17..b777aa1cfa 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -323,7 +323,7 @@ void SkDebuggerGUI::run(SkTimedPicture* pict,
renderer->setup();
renderer->render(NULL);
- renderer->resetState(true);
+ renderer->resetState(true); // flush, swapBuffers and Finish
// We throw this away the first batch of times to remove first time effects (such as paging in this program)
pict->resetTimes();
@@ -331,8 +331,9 @@ void SkDebuggerGUI::run(SkTimedPicture* pict,
for (int i = 0; i < repeats; ++i) {
renderer->setup();
renderer->render(NULL);
- renderer->resetState(true);
+ renderer->resetState(false); // flush & swapBuffers, but don't Finish
}
+ renderer->resetState(true); // flush, swapBuffers and Finish
renderer->end();
}
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index 65f36604c2..f05f80565d 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -78,7 +78,7 @@ void PictureBenchmark::run(SkPicture* pict) {
// We throw this away to remove first time effects (such as paging in this program)
fRenderer->setup();
fRenderer->render(NULL);
- fRenderer->resetState(true);
+ fRenderer->resetState(true); // flush, swapBuffers and Finish
if (fPurgeDecodedTex) {
fRenderer->purgeTextures();
@@ -101,6 +101,17 @@ void PictureBenchmark::run(SkPicture* pict) {
timeFormat = fRenderer->getNormalTimeFormat();
}
+ static const int kNumInnerLoops = 5;
+ int numOuterLoops = 1;
+ int numInnerLoops = fRepeats;
+
+ if (TimerData::kPerIter_Result == fTimerResult && fRepeats > 1) {
+ // interpret this flag combination to mean: generate 'fRepeats'
+ // numbers by averaging each rendering 'kNumInnerLoops' times
+ numOuterLoops = fRepeats;
+ numInnerLoops = kNumInnerLoops;
+ }
+
if (fTimeIndividualTiles) {
TiledPictureRenderer* tiledRenderer = fRenderer->getTiledRenderer();
SkASSERT(tiledRenderer && tiledRenderer->supportsTimingIndividualTiles());
@@ -120,7 +131,7 @@ void PictureBenchmark::run(SkPicture* pict) {
while (tiledRenderer->nextTile(x, y)) {
// There are two timers, which will behave slightly differently:
// 1) longRunningTimer, along with perTileTimerData, will time how long it takes to draw
- // one tile fRepeats times, and take the average. As such, it will not respect thea
+ // one tile fRepeats times, and take the average. As such, it will not respect the
// logPerIter or printMin options, since it does not know the time per iteration. It
// will also be unable to call flush() for each tile.
// The goal of this timer is to make up for a system timer that is not precise enough to
@@ -134,41 +145,46 @@ void PictureBenchmark::run(SkPicture* pict) {
// platforms. To work around this, we disable the gpu timer on the
// long running timer.
SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
- TimerData longRunningTimerData(1);
- SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
- TimerData perTileTimerData(fRepeats);
- longRunningTimer->start();
- for (int i = 0; i < fRepeats; ++i) {
- perTileTimer->start();
- tiledRenderer->drawCurrentTile();
- perTileTimer->truncatedEnd();
- tiledRenderer->resetState(false);
- perTileTimer->end();
- SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get()));
-
- if (fPurgeDecodedTex) {
- fRenderer->purgeTextures();
+ TimerData longRunningTimerData(numOuterLoops);
+
+ for (int outer = 0; outer < numOuterLoops; ++outer) {
+ SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
+ TimerData perTileTimerData(numInnerLoops);
+
+ longRunningTimer->start();
+ for (int inner = 0; inner < numInnerLoops; ++inner) {
+ perTileTimer->start();
+ tiledRenderer->drawCurrentTile();
+ perTileTimer->truncatedEnd();
+ tiledRenderer->resetState(false); // flush & swapBuffers, but don't Finish
+ perTileTimer->end();
+ SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get()));
+
+ if (fPurgeDecodedTex) {
+ fRenderer->purgeTextures();
+ }
}
+ longRunningTimer->truncatedEnd();
+ tiledRenderer->resetState(true); // flush, swapBuffers and Finish
+ longRunningTimer->end();
+ SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
}
- longRunningTimer->truncatedEnd();
- tiledRenderer->resetState(true);
- longRunningTimer->end();
- SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
SkString configName = tiledRenderer->getConfigName();
configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yTiles);
+ // TODO(borenet): Turn off per-iteration tile time reporting for now.
+ // Avoiding logging the time for every iteration for each tile cuts
+ // down on data file size by a significant amount. Re-enable this once
+ // we're loading the bench data directly into a data store and are no
+ // longer generating SVG graphs.
+#if 0
SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTimerResult,
configName.c_str(), timerTypes);
result.append("\n");
-
-// TODO(borenet): Turn off per-iteration tile time reporting for now. Avoiding logging the time
-// for every iteration for each tile cuts down on data file size by a significant amount. Re-enable
-// this once we're loading the bench data directly into a data store and are no longer generating
-// SVG graphs.
-#if 0
this->logProgress(result.c_str());
#endif
+
if (fPurgeDecodedTex) {
configName.append(" <withPurging>");
}
@@ -176,36 +192,39 @@ void PictureBenchmark::run(SkPicture* pict) {
SkString longRunningResult = longRunningTimerData.getResult(
tiledRenderer->getNormalTimeFormat().c_str(),
TimerData::kAvg_Result,
- configName.c_str(), timerTypes, fRepeats);
+ configName.c_str(), timerTypes, numInnerLoops);
longRunningResult.append("\n");
this->logProgress(longRunningResult.c_str());
}
} else {
SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
- TimerData longRunningTimerData(1);
- SkAutoTDelete<BenchTimer> perRunTimer(this->setupTimer(false));
- TimerData perRunTimerData(fRepeats);
+ TimerData longRunningTimerData(numOuterLoops);
+
+ for (int outer = 0; outer < numOuterLoops; ++outer) {
+ SkAutoTDelete<BenchTimer> perRunTimer(this->setupTimer(false));
+ TimerData perRunTimerData(numInnerLoops);
- longRunningTimer->start();
- for (int i = 0; i < fRepeats; ++i) {
- fRenderer->setup();
+ longRunningTimer->start();
+ for (int inner = 0; inner < numInnerLoops; ++inner) {
+ fRenderer->setup();
- perRunTimer->start();
- fRenderer->render(NULL);
- perRunTimer->truncatedEnd();
- fRenderer->resetState(false);
- perRunTimer->end();
+ perRunTimer->start();
+ fRenderer->render(NULL);
+ perRunTimer->truncatedEnd();
+ fRenderer->resetState(false); // flush & swapBuffers, but don't Finish
+ perRunTimer->end();
- SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get()));
+ SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get()));
- if (fPurgeDecodedTex) {
- fRenderer->purgeTextures();
+ if (fPurgeDecodedTex) {
+ fRenderer->purgeTextures();
+ }
}
+ longRunningTimer->truncatedEnd();
+ fRenderer->resetState(true); // flush, swapBuffers and Finish
+ longRunningTimer->end();
+ SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
}
- longRunningTimer->truncatedEnd();
- fRenderer->resetState(true);
- longRunningTimer->end();
- SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
SkString configName = fRenderer->getConfigName();
if (fPurgeDecodedTex) {
@@ -224,10 +243,10 @@ void PictureBenchmark::run(SkPicture* pict) {
this->logProgress(result.c_str());
#else
SkString result = longRunningTimerData.getResult(timeFormat.c_str(),
- fTimerResult,
- configName.c_str(),
- timerTypes,
- fRepeats);
+ fTimerResult,
+ configName.c_str(),
+ timerTypes,
+ numInnerLoops);
result.append("\n");
this->logProgress(result.c_str());
#endif
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 35b1b6166d..ebac9ca46d 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -247,6 +247,7 @@ void PictureRenderer::resetState(bool callFinish) {
}
fGrContext->flush();
+ glContext->swapBuffers();
if (callFinish) {
SK_GL(*glContext, Finish());
}
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index 94912c73ad..c3438c912f 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -149,7 +149,7 @@ public:
/**
* Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls
- * flush, and calls finish if callFinish is true.
+ * flush, swapBuffers and, if callFinish is true, finish.
* @param callFinish Whether to call finish.
*/
void resetState(bool callFinish);