Remove dashing from gpu veto
With new veto our new veto test results look like the following: TP: true positive (picked to use gpu and gpu was faster) I: inderminate, the raster time is withing 5% of gpu time TP FP TN FN I old 21 9 15 12 3 new 29 12 11 6 3 There are three skps that tend to move from TN -> FP, however the absolute difference in their run times are not huge between them. The largest being desk_booking which is about 7.1 raster and 8.8 gpu. The other two skps are desk_yahooanswers and desk_linkedin BUG=skia: R=bsalomon@google.com, robertphillips@google.com Author: egdaniel@google.com Review URL: https://codereview.chromium.org/334053005
This commit is contained in:
parent
de10fdeee5
commit
12c2198535
@ -14,6 +14,10 @@
|
||||
#include "SkTSort.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
template <typename T> int SafeCount(const T* obj) {
|
||||
return obj ? obj->count() : 0;
|
||||
}
|
||||
@ -1335,27 +1339,51 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
||||
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason) const {
|
||||
bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount) const {
|
||||
// TODO: the heuristic used here needs to be refined
|
||||
static const int kNumPaintWithPathEffectUsesTol = 1;
|
||||
static const int kNumAAConcavePaths = 5;
|
||||
|
||||
SkASSERT(fContentInfo.numAAHairlineConcavePaths() <= fContentInfo.numAAConcavePaths());
|
||||
|
||||
bool ret = fContentInfo.numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol &&
|
||||
int numNonDashedPathEffects = fContentInfo.numPaintWithPathEffectUses() -
|
||||
fContentInfo.numFastPathDashEffects();
|
||||
|
||||
bool suitableForDash = (0 == fContentInfo.numPaintWithPathEffectUses()) ||
|
||||
(numNonDashedPathEffects < kNumPaintWithPathEffectUsesTol
|
||||
&& 0 == sampleCount);
|
||||
|
||||
bool ret = suitableForDash &&
|
||||
(fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths())
|
||||
< kNumAAConcavePaths;
|
||||
if (!ret && NULL != reason) {
|
||||
if (fContentInfo.numPaintWithPathEffectUses() >= kNumPaintWithPathEffectUsesTol)
|
||||
*reason = "Too many path effects.";
|
||||
else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths())
|
||||
>= kNumAAConcavePaths)
|
||||
if (!suitableForDash) {
|
||||
if (0 != sampleCount) {
|
||||
*reason = "Can't use multisample on dash effect.";
|
||||
} else {
|
||||
*reason = "Too many non dashed path effects.";
|
||||
}
|
||||
} else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths())
|
||||
>= kNumAAConcavePaths)
|
||||
*reason = "Too many anti-aliased concave paths.";
|
||||
else
|
||||
*reason = "Unknown reason for GPU unsuitability.";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
GrPixelConfig config, SkScalar dpi) const {
|
||||
|
||||
if (context != NULL) {
|
||||
return this->suitableForGpuRasterization(context, reason,
|
||||
context->getRecommendedSampleCount(config, dpi));
|
||||
} else {
|
||||
return this->suitableForGpuRasterization(NULL, reason);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -70,18 +70,21 @@ public:
|
||||
|
||||
void set(const SkPictureContentInfo& src) {
|
||||
fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
|
||||
fNumFastPathDashEffects = src.fNumFastPathDashEffects;
|
||||
fNumAAConcavePaths = src.fNumAAConcavePaths;
|
||||
fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
fNumPaintWithPathEffectUses = 0;
|
||||
fNumFastPathDashEffects = 0;
|
||||
fNumAAConcavePaths = 0;
|
||||
fNumAAHairlineConcavePaths = 0;
|
||||
}
|
||||
|
||||
void swap(SkPictureContentInfo* other) {
|
||||
SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses);
|
||||
SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects);
|
||||
SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
|
||||
SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
|
||||
}
|
||||
@ -89,6 +92,9 @@ public:
|
||||
void incPaintWithPathEffectUses() { ++fNumPaintWithPathEffectUses; }
|
||||
int numPaintWithPathEffectUses() const { return fNumPaintWithPathEffectUses; }
|
||||
|
||||
void incFastPathDashEffects() { ++fNumFastPathDashEffects; }
|
||||
int numFastPathDashEffects() const { return fNumFastPathDashEffects; }
|
||||
|
||||
void incAAConcavePaths() { ++fNumAAConcavePaths; }
|
||||
int numAAConcavePaths() const { return fNumAAConcavePaths; }
|
||||
|
||||
@ -102,6 +108,9 @@ private:
|
||||
// This field is incremented every time a paint with a path effect is
|
||||
// used (i.e., it is not a de-duplicated count)
|
||||
int fNumPaintWithPathEffectUses;
|
||||
// This field is incremented every time a paint with a path effect that is
|
||||
// dashed, we are drawing a line, and we can use the gpu fast path
|
||||
int fNumFastPathDashEffects;
|
||||
// This field is incremented every time an anti-aliased drawPath call is
|
||||
// issued with a concave path
|
||||
int fNumAAConcavePaths;
|
||||
@ -269,7 +278,19 @@ public:
|
||||
#endif
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason) const;
|
||||
/**
|
||||
* sampleCount is the number of samples-per-pixel or zero if non-MSAA.
|
||||
* It is defaulted to be zero.
|
||||
*/
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount = 0) const;
|
||||
|
||||
/**
|
||||
* Calls getRecommendedSampleCount with GrPixelConfig and dpi to calculate sampleCount
|
||||
* and then calls the above version of suitableForGpuRasterization
|
||||
*/
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
GrPixelConfig config, SkScalar dpi) const;
|
||||
#endif
|
||||
|
||||
private: // these help us with reading/writing
|
||||
|
@ -988,6 +988,14 @@ void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
|
||||
size_t initialOffset = this->addDraw(DRAW_POINTS, &size);
|
||||
SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWritten());
|
||||
this->addPaint(paint);
|
||||
if (paint.getPathEffect() != NULL) {
|
||||
SkPathEffect::DashInfo info;
|
||||
SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info);
|
||||
if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() &&
|
||||
SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) {
|
||||
fContentInfo.incFastPathDashEffects();
|
||||
}
|
||||
}
|
||||
this->addInt(mode);
|
||||
this->addInt(SkToInt(count));
|
||||
fWriter.writeMul4(pts, count * sizeof(SkPoint));
|
||||
|
51
tools/test_gpuveto.py
Normal file → Executable file
51
tools/test_gpuveto.py
Normal file → Executable file
@ -57,9 +57,11 @@ class GpuVeto(object):
|
||||
def __init__(self):
|
||||
self.bench_pictures = find_run_binary.find_path_to_program(
|
||||
'bench_pictures')
|
||||
sys.stdout.write('Running: %s\n' % (self.bench_pictures))
|
||||
self.gpuveto = find_run_binary.find_path_to_program('gpuveto')
|
||||
assert os.path.isfile(self.bench_pictures)
|
||||
assert os.path.isfile(self.gpuveto)
|
||||
self.indeterminate = 0
|
||||
self.truePositives = 0
|
||||
self.falsePositives = 0
|
||||
self.trueNegatives = 0
|
||||
@ -69,14 +71,16 @@ class GpuVeto(object):
|
||||
for skp in enumerate(dir_or_file):
|
||||
self.process_skp(skp[1])
|
||||
|
||||
sys.stdout.write('TP %d FP %d TN %d FN %d\n' % (self.truePositives,
|
||||
self.falsePositives,
|
||||
self.trueNegatives,
|
||||
self.falseNegatives))
|
||||
sys.stdout.write('TP %d FP %d TN %d FN %d IND %d\n' % (self.truePositives,
|
||||
self.falsePositives,
|
||||
self.trueNegatives,
|
||||
self.falseNegatives,
|
||||
self.indeterminate))
|
||||
|
||||
|
||||
def process_skp(self, skp_file):
|
||||
assert os.path.isfile(skp_file)
|
||||
#print skp_file
|
||||
|
||||
# run gpuveto on the skp
|
||||
args = [self.gpuveto, '-r', skp_file]
|
||||
@ -92,46 +96,63 @@ class GpuVeto(object):
|
||||
|
||||
# run raster config
|
||||
args = [self.bench_pictures, '-r', skp_file,
|
||||
'--repeat', '20',
|
||||
'--repeat', '20',
|
||||
'--timers', 'w',
|
||||
'--config', '8888']
|
||||
returncode, output = execute_program(args)
|
||||
if (returncode != 0):
|
||||
return
|
||||
|
||||
matches = re.findall('[\d.]+', output)
|
||||
if len(matches) != 4:
|
||||
matches = re.findall('[\d]+\.[\d]+', output)
|
||||
if len(matches) != 1:
|
||||
return
|
||||
|
||||
rasterTime = float(matches[3])
|
||||
rasterTime = float(matches[0])
|
||||
|
||||
# run gpu config
|
||||
args2 = [self.bench_pictures, '-r', skp_file,
|
||||
'--repeat', '20',
|
||||
'--repeat', '20',
|
||||
'--timers', 'w',
|
||||
'--config', 'gpu']
|
||||
returncode, output = execute_program(args2)
|
||||
if (returncode != 0):
|
||||
return
|
||||
|
||||
matches = re.findall('[\d.]+', output)
|
||||
if len(matches) != 4:
|
||||
matches = re.findall('[\d]+\.[\d]+', output)
|
||||
if len(matches) != 1:
|
||||
return
|
||||
|
||||
gpuTime = float(matches[3])
|
||||
gpuTime = float(matches[0])
|
||||
|
||||
sys.stdout.write('%s: gpuveto: %d raster %.2f gpu: %.2f\n' % (
|
||||
skp_file, suitable, rasterTime, gpuTime))
|
||||
# happens if page is too big it will not render
|
||||
if 0 == gpuTime:
|
||||
return
|
||||
|
||||
if suitable:
|
||||
tolerance = 0.05
|
||||
tol_range = tolerance * gpuTime
|
||||
|
||||
|
||||
if rasterTime > gpuTime - tol_range and rasterTime < gpuTime + tol_range:
|
||||
result = "NONE"
|
||||
self.indeterminate += 1
|
||||
elif suitable:
|
||||
if gpuTime < rasterTime:
|
||||
self.truePositives += 1
|
||||
result = "TP"
|
||||
else:
|
||||
self.falsePositives += 1
|
||||
result = "FP"
|
||||
else:
|
||||
if gpuTime < rasterTime:
|
||||
self.falseNegatives += 1
|
||||
result = "FN"
|
||||
else:
|
||||
self.trueNegatives += 1
|
||||
result = "TN"
|
||||
|
||||
|
||||
sys.stdout.write('%s: gpuveto: %d raster %.2f gpu: %.2f Result: %s\n' % (
|
||||
skp_file, suitable, rasterTime, gpuTime, result))
|
||||
|
||||
def main(main_argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
|
Loading…
Reference in New Issue
Block a user