Add --resetGpuContext to both DM and nanobench.
Defaulting to true to be conservative for now.
BUG=skia:
NOTREECHECKS=true
R=mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/398483005
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index be8cc4a..e2a785e 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -49,6 +49,7 @@
DEFINE_bool(gpu, true, "Master switch for GPU-bound work.");
DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
+DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each bench.");
static SkString humanize(double ms) {
@@ -214,6 +215,10 @@
}
#if SK_SUPPORT_GPU
+ if (FLAGS_resetGpuContext) {
+ gGrFactory.destroyContexts();
+ }
+
#define GPU_TARGET(config, ctxType, info, samples) \
if (Target* t = is_enabled(bench, Benchmark::kGPU_Backend, #config)) { \
t->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(ctxType), info, samples)); \
diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h
index bcc00c2..209f322 100644
--- a/dm/DMGpuSupport.h
+++ b/dm/DMGpuSupport.h
@@ -47,6 +47,7 @@
kNVPR_GLContextType = 0,
kNative_GLContextType = 0,
kNull_GLContextType = 0;
+ void destroyContexts() {}
};
namespace DM {
diff --git a/dm/DMTask.cpp b/dm/DMTask.cpp
index 54e7df3..b763556 100644
--- a/dm/DMTask.cpp
+++ b/dm/DMTask.cpp
@@ -4,6 +4,7 @@
DEFINE_bool(cpu, true, "Master switch for running CPU-bound work.");
DEFINE_bool(gpu, true, "Master switch for running GPU-bound work.");
+DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each task.");
DECLARE_bool(dryRun);
@@ -70,6 +71,9 @@
void GpuTask::run(GrContextFactory& factory) {
if (FLAGS_gpu && !this->shouldSkip()) {
+ if (FLAGS_resetGpuContext) {
+ factory.destroyContexts();
+ }
this->start();
if (!FLAGS_dryRun) this->draw(&factory);
this->finish();