Add offscreen mode to visualbench
Replaces "nvpr mode" with "offscreen mode" and a flag to enable/ disable nvpr. Assigns new config names to the various combinations of flags and begins printing them with the bench results in order to match nanobench. BUG=skia: Review URL: https://codereview.chromium.org/1473253002
This commit is contained in:
parent
0f6cca8a20
commit
baf8fcbb1b
@ -22,6 +22,8 @@
|
||||
#include "VisualInteractiveModule.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
DEFINE_bool2(fullscreen, f, true, "Run fullscreen.");
|
||||
DEFINE_bool2(interactive, n, false, "Run in interactive mode.");
|
||||
DEFINE_bool2(dif, d, false, "Use device-independent fonts.");
|
||||
@ -35,6 +37,11 @@ VisualBench::VisualBench(void* hwnd, int argc, char** argv)
|
||||
|
||||
SkCommandLineFlags::Parse(argc, argv);
|
||||
|
||||
if (FLAGS_nvpr && !FLAGS_msaa) {
|
||||
SkDebugf("Got nvpr without msaa. Exiting.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// these have to happen after commandline parsing
|
||||
if (FLAGS_dif) {
|
||||
const SkSurfaceProps& props(INHERITED::getSurfaceProps());
|
||||
@ -90,7 +97,8 @@ void VisualBench::resetContext() {
|
||||
}
|
||||
|
||||
void VisualBench::setupContext() {
|
||||
if (!this->attach(kNativeGL_BackEndType, FLAGS_msaa, &fAttachmentInfo)) {
|
||||
int screenSamples = FLAGS_offscreen ? 0 : FLAGS_msaa;
|
||||
if (!this->attach(kNativeGL_BackEndType, screenSamples, &fAttachmentInfo)) {
|
||||
SkDebugf("Not possible to create backend.\n");
|
||||
INHERITED::detach();
|
||||
SkFAIL("Could not create backend\n");
|
||||
@ -103,7 +111,7 @@ void VisualBench::setupContext() {
|
||||
fInterface.reset(GrGLCreateNativeInterface());
|
||||
|
||||
// TODO use the GLContext creation factories and also set this all up in configs
|
||||
if (0 == FLAGS_nvpr) {
|
||||
if (!FLAGS_nvpr) {
|
||||
fInterface.reset(GrGLInterfaceRemoveNVPR(fInterface));
|
||||
}
|
||||
SkASSERT(fInterface);
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
DEFINE_bool(cpu, false, "Run in CPU mode?");
|
||||
DEFINE_string2(match, m, nullptr,
|
||||
"[~][^]substring[$] [...] of bench name to run.\n"
|
||||
"Multiple matches may be separated by spaces.\n"
|
||||
@ -137,8 +136,8 @@ Benchmark* VisualBenchmarkStream::next() {
|
||||
// TODO move this all to --config
|
||||
if (bench && FLAGS_cpu) {
|
||||
bench = new CpuWrappedBenchmark(fSurfaceProps, bench);
|
||||
} else if (bench && 0 != FLAGS_nvpr) {
|
||||
bench = new NvprWrappedBenchmark(fSurfaceProps, bench, FLAGS_nvpr);
|
||||
} else if (bench && FLAGS_offscreen) {
|
||||
bench = new GpuWrappedBenchmark(fSurfaceProps, bench, FLAGS_msaa);
|
||||
}
|
||||
|
||||
fBenchmark.reset(bench);
|
||||
|
@ -8,4 +8,6 @@
|
||||
#include "VisualFlags.h"
|
||||
|
||||
DEFINE_int32(msaa, 0, "Number of msaa samples.");
|
||||
DEFINE_int32(nvpr, 0, "Number of stencil samples for nvpr, or zero to disable it.");
|
||||
DEFINE_bool(offscreen, false, "Perform rendering in an offscreen buffer.");
|
||||
DEFINE_bool(nvpr, false, "Use nvpr?");
|
||||
DEFINE_bool(cpu, false, "Run in CPU mode?");
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
DECLARE_string(config);
|
||||
DECLARE_int32(msaa);
|
||||
DECLARE_int32(nvpr);
|
||||
DECLARE_bool(offscreen);
|
||||
DECLARE_bool(nvpr);
|
||||
DECLARE_bool(cpu);
|
||||
|
||||
#endif
|
||||
|
@ -46,8 +46,8 @@ VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner)
|
||||
, fCurrentSample(0)
|
||||
, fResults(new ResultsWriter) {
|
||||
// Print header
|
||||
SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tbench\n", FLAGS_samples,
|
||||
"samples");
|
||||
SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
|
||||
FLAGS_samples, "samples");
|
||||
|
||||
// setup json logging if required
|
||||
if (!FLAGS_outResultsFile.isEmpty()) {
|
||||
@ -86,10 +86,26 @@ void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) {
|
||||
// update log
|
||||
// Note: We currently log only the minimum. It would be interesting to log more information
|
||||
SkString configName;
|
||||
if (FLAGS_msaa > 0) {
|
||||
configName.appendf("msaa_%d", FLAGS_msaa);
|
||||
if (FLAGS_cpu) {
|
||||
configName.append("cpu");
|
||||
} else if (FLAGS_nvpr) {
|
||||
if (FLAGS_offscreen) {
|
||||
configName.appendf("nvpr_%d", FLAGS_msaa);
|
||||
} else {
|
||||
configName.appendf("nvpr_msaa_%d", FLAGS_msaa);
|
||||
}
|
||||
} else if (FLAGS_msaa > 0) {
|
||||
if (FLAGS_offscreen) {
|
||||
configName.appendf("offscreen_msaa_%d", FLAGS_msaa);
|
||||
} else {
|
||||
configName.appendf("msaa_%d", FLAGS_msaa);
|
||||
}
|
||||
} else {
|
||||
configName.appendf("gpu");
|
||||
if (FLAGS_offscreen) {
|
||||
configName.append("offscreen");
|
||||
} else {
|
||||
configName.append("gpu");
|
||||
}
|
||||
}
|
||||
// Log bench name
|
||||
fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY);
|
||||
@ -108,7 +124,7 @@ void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) {
|
||||
SkDebugf("%s\n", shortName);
|
||||
} else {
|
||||
const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean;
|
||||
SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\n",
|
||||
SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n",
|
||||
sk_tools::getCurrResidentSetSizeMB(),
|
||||
sk_tools::getMaxResidentSetSizeMB(),
|
||||
loops,
|
||||
@ -118,6 +134,7 @@ void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) {
|
||||
HUMANIZE(stats.max),
|
||||
stdDevPercent,
|
||||
stats.plot.c_str(),
|
||||
configName.c_str(),
|
||||
shortName);
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ private:
|
||||
};
|
||||
|
||||
// Create an MSAA & NVPR-enabled GPU backend
|
||||
class NvprWrappedBenchmark : public WrappedBenchmark {
|
||||
class GpuWrappedBenchmark : public WrappedBenchmark {
|
||||
public:
|
||||
explicit NvprWrappedBenchmark(const SkSurfaceProps& surfaceProps, Benchmark* bench,
|
||||
int numSamples)
|
||||
explicit GpuWrappedBenchmark(const SkSurfaceProps& surfaceProps, Benchmark* bench,
|
||||
int numSamples)
|
||||
: INHERITED(surfaceProps, bench)
|
||||
, fNumSamples(numSamples) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user