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
This commit is contained in:
mtklein 2014-07-15 08:27:06 -07:00 committed by Commit bot
parent c09e8c2ec9
commit 1e319f7342
3 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,7 @@ DEFINE_bool(cpu, true, "Master switch for CPU-bound work.");
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 @@ static void create_targets(Benchmark* bench, SkTDArray<Target*>* targets) {
}
#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)); \

View File

@ -47,6 +47,7 @@ public:
kNVPR_GLContextType = 0,
kNative_GLContextType = 0,
kNull_GLContextType = 0;
void destroyContexts() {}
};
namespace DM {

View File

@ -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 @@ GpuTask::GpuTask(Reporter* reporter, TaskRunner* taskRunner) : Task(reporter, ta
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();