Flush GrContext between benchmark draw loops
This change updates a small subset of benchmarks to flush the GrContext between draw loops (specifically SKP benchmarks, SampleApp, and the warmup in visualbench). This helps improve timing accuracy by not allowing the gpu to batch across draw boundaries in the affected benchmarks. BUG=skia: Review URL: https://codereview.chromium.org/1427533002
This commit is contained in:
parent
c70483f5ab
commit
e6d2024c68
@ -10,6 +10,10 @@
|
||||
#include "SkMultiPictureDraw.h"
|
||||
#include "SkSurface.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
// These CPU tile sizes are not good per se, but they are similar to what Chrome uses.
|
||||
DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback.");
|
||||
DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback.");
|
||||
@ -115,6 +119,12 @@ void SKPBench::onDraw(int loops, SkCanvas* canvas) {
|
||||
this->drawPicture();
|
||||
}
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't batch across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SKPBench::drawMPDPicture() {
|
||||
|
@ -2257,6 +2257,12 @@ void SampleView::onDraw(SkCanvas* canvas) {
|
||||
for (int i = 0; i < fRepeatCount; i++) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
this->onDrawContent(canvas);
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't batch across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include "VisualFlags.h"
|
||||
#include "VisualSKPBench.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
DEFINE_bool(cpu, false, "Run in CPU mode?");
|
||||
DEFINE_string2(match, m, nullptr,
|
||||
"[~][^]substring[$] [...] of bench name to run.\n"
|
||||
@ -52,6 +56,12 @@ private:
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawPath(fPath, paint);
|
||||
canvas->drawRect(rect, perlinPaint);
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't batch across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
SkPath fPath;
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
#include "VisualSKPBench.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
VisualSKPBench::VisualSKPBench(const char* name, const SkPicture* pic)
|
||||
: fPic(SkRef(pic))
|
||||
, fName(name) {
|
||||
@ -29,5 +33,11 @@ bool VisualSKPBench::isSuitableFor(Backend backend) {
|
||||
void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) {
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawPicture(fPic);
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't batch across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user