Add visualbench option to not reset between samples
Adds a --reset flag that controls whether we teardown the graphics context between samples. Also modifies the timing algorithm to always/ only pre-warm after resetting the context. BUG=skia: Review URL: https://codereview.chromium.org/1442643007
This commit is contained in:
parent
0b47d4b520
commit
266e2024ec
@ -15,7 +15,7 @@
|
||||
__SK_FORCE_IMAGE_DECODER_LINKING;
|
||||
|
||||
VisualInteractiveModule::VisualInteractiveModule(VisualBench* owner)
|
||||
: INHERITED(owner, false)
|
||||
: INHERITED(owner)
|
||||
, fCurrentMeasurement(0)
|
||||
, fAdvance(false) {
|
||||
memset(fMeasurements, 0, sizeof(fMeasurements));
|
||||
|
@ -42,7 +42,7 @@ static SkString humanize(double ms) {
|
||||
#define HUMANIZE(time) humanize(time).c_str()
|
||||
|
||||
VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner)
|
||||
: INHERITED(owner, true)
|
||||
: INHERITED(owner)
|
||||
, fCurrentSample(0)
|
||||
, fResults(new ResultsWriter) {
|
||||
// Print header
|
||||
|
@ -9,9 +9,10 @@
|
||||
|
||||
#include "SkCanvas.h"
|
||||
|
||||
VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preWarmBeforeSample)
|
||||
DEFINE_bool(reset, true, "Reset the GL context between samples.");
|
||||
|
||||
VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner)
|
||||
: fInitState(kReset_InitState)
|
||||
, fPreWarmBeforeSample(preWarmBeforeSample)
|
||||
, fOwner(owner) {
|
||||
fBenchmarkStream.reset(new VisualBenchmarkStream(owner->getSurfaceProps()));
|
||||
}
|
||||
@ -36,18 +37,13 @@ inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) {
|
||||
inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas,
|
||||
TimingStateMachine::ParentEvents event) {
|
||||
switch (event) {
|
||||
case TimingStateMachine::kReset_ParentEvents:
|
||||
fBenchmarkStream->current()->postTimingHooks(canvas);
|
||||
fOwner->reset();
|
||||
fInitState = kReset_InitState;
|
||||
break;
|
||||
case TimingStateMachine::kTiming_ParentEvents:
|
||||
break;
|
||||
case TimingStateMachine::kTimingFinished_ParentEvents:
|
||||
fBenchmarkStream->current()->postTimingHooks(canvas);
|
||||
fOwner->reset();
|
||||
if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(),
|
||||
fTSM.lastMeasurement())) {
|
||||
fBenchmarkStream->current()->postTimingHooks(canvas);
|
||||
fOwner->reset();
|
||||
fTSM.nextBenchmark();
|
||||
if (!fBenchmarkStream->next()) {
|
||||
SkDebugf("Exiting VisualBench successfully\n");
|
||||
@ -55,7 +51,13 @@ inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas,
|
||||
} else {
|
||||
fInitState = kNewBenchmark_InitState;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
case TimingStateMachine::kReset_ParentEvents:
|
||||
if (FLAGS_reset) {
|
||||
fBenchmarkStream->current()->postTimingHooks(canvas);
|
||||
fOwner->reset();
|
||||
fInitState = kReset_InitState;
|
||||
}
|
||||
break;
|
||||
@ -72,6 +74,6 @@ void VisualStreamTimingModule::draw(SkCanvas* canvas) {
|
||||
this->handleInitState(canvas);
|
||||
this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops());
|
||||
fOwner->present();
|
||||
TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample);
|
||||
TimingStateMachine::ParentEvents event = fTSM.nextFrame(FLAGS_reset);
|
||||
this->handleTimingEvent(canvas, event);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class SkCanvas;
|
||||
*/
|
||||
class VisualStreamTimingModule : public VisualModule {
|
||||
public:
|
||||
VisualStreamTimingModule(VisualBench* owner, bool preWarmBeforeSample);
|
||||
VisualStreamTimingModule(VisualBench* owner);
|
||||
void draw(SkCanvas* canvas) override;
|
||||
|
||||
private:
|
||||
@ -44,7 +44,6 @@ private:
|
||||
kNewBenchmark_InitState,
|
||||
};
|
||||
InitState fInitState;
|
||||
bool fPreWarmBeforeSample;
|
||||
|
||||
// support framework
|
||||
VisualBench* fOwner;
|
||||
|
Loading…
Reference in New Issue
Block a user