Add tests and benches to support the sRGB blitter for SkOpts
1,370.85 LinearSrcOvericonstrip.pngVSkOptsSSE41
2,359.69 LinearSrcOvericonstrip.pngVSkOptsDefault
1,828.72 LinearSrcOvericonstrip.pngVSkOptsNonSimdCore
3,277.40 LinearSrcOvericonstrip.pngVSkOptsTrivial
9,862.34 LinearSrcOvericonstrip.pngVSkOptsBruteForce
633.55 LinearSrcOvermandrill_512.pngVSkOptsSSE41
684.29 LinearSrcOvermandrill_512.pngVSkOptsDefault
1,201.88 LinearSrcOvermandrill_512.pngVSkOptsNonSimdCore
2,382.63 LinearSrcOvermandrill_512.pngVSkOptsTrivial
10,888.74 LinearSrcOvermandrill_512.pngVSkOptsBruteForce
209.14 LinearSrcOverplane.pngVSkOptsSSE41
562.24 LinearSrcOverplane.pngVSkOptsDefault
272.64 LinearSrcOverplane.pngVSkOptsNonSimdCore
436.46 LinearSrcOverplane.pngVSkOptsTrivial
1,327.23 LinearSrcOverplane.pngVSkOptsBruteForce
318.01 LinearSrcOverbaby_tux.pngVSkOptsSSE41
529.05 LinearSrcOverbaby_tux.pngVSkOptsDefault
441.33 LinearSrcOverbaby_tux.pngVSkOptsNonSimdCore
720.50 LinearSrcOverbaby_tux.pngVSkOptsTrivial
2,191.10 LinearSrcOverbaby_tux.pngVSkOptsBruteForce
479.68 LinearSrcOveryellow_rose.pngVSkOptsSSE41
1,095.03 LinearSrcOveryellow_rose.pngVSkOptsDefault
668.60 LinearSrcOveryellow_rose.pngVSkOptsNonSimdCore
1,257.19 LinearSrcOveryellow_rose.pngVSkOptsTrivial
4,970.25 LinearSrcOveryellow_rose.pngVSkOptsBruteForce
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1939513002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/554784cd85029c05d9ed04b1aeb71520d196153a
Committed: https://skia.googlesource.com/skia/+/bc927548db17accec2195af6e15053f7918bb3f5
Review-Url: https://codereview.chromium.org/1939513002
2016-05-17 16:57:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
#include "Benchmark.h"
|
|
|
|
#include "Resources.h"
|
|
|
|
#include "SkCpu.h"
|
|
|
|
#include "SkImage.h"
|
|
|
|
#include "SkImage_Base.h"
|
|
|
|
#include "SkNx.h"
|
|
|
|
#include "SkOpts.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
|
|
|
|
#define INNER_LOOPS 10
|
|
|
|
|
|
|
|
namespace sk_default {
|
|
|
|
extern void brute_force_srcover_srgb_srgb(
|
|
|
|
uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class SrcOverVSkOptsBruteForce {
|
|
|
|
public:
|
|
|
|
static SkString Name() { return SkString{"VSkOptsBruteForce"}; }
|
|
|
|
static bool WorksOnCpu() { return true; }
|
|
|
|
static void BlendN(uint32_t* dst, int count, const uint32_t* src) {
|
|
|
|
sk_default::brute_force_srcover_srgb_srgb(dst, src, count, count);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace sk_default {
|
|
|
|
extern void trivial_srcover_srgb_srgb(
|
|
|
|
uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class SrcOverVSkOptsTrivial {
|
|
|
|
public:
|
|
|
|
static SkString Name() { return SkString{"VSkOptsTrivial"}; }
|
|
|
|
static bool WorksOnCpu() { return true; }
|
|
|
|
static void BlendN(uint32_t* dst, int count, const uint32_t* src) {
|
|
|
|
sk_default::trivial_srcover_srgb_srgb(dst, src, count, count);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace sk_default {
|
|
|
|
extern void best_non_simd_srcover_srgb_srgb(
|
|
|
|
uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class SrcOverVSkOptsNonSimdCore {
|
|
|
|
public:
|
|
|
|
static SkString Name() { return SkString{"VSkOptsNonSimdCore"}; }
|
|
|
|
static bool WorksOnCpu() { return true; }
|
|
|
|
static void BlendN(uint32_t* dst, int count, const uint32_t* src) {
|
|
|
|
sk_default::best_non_simd_srcover_srgb_srgb(dst, src, count, count);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace sk_default {
|
|
|
|
extern void srcover_srgb_srgb(
|
|
|
|
uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class SrcOverVSkOptsDefault {
|
|
|
|
public:
|
|
|
|
static SkString Name() { return SkString{"VSkOptsDefault"}; }
|
|
|
|
static bool WorksOnCpu() { return true; }
|
|
|
|
static void BlendN(uint32_t* dst, int count, const uint32_t* src) {
|
|
|
|
sk_default::srcover_srgb_srgb(dst, src, count, count);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace sk_sse41 {
|
|
|
|
extern void srcover_srgb_srgb(
|
|
|
|
uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
class SrcOverVSkOptsSSE41 {
|
|
|
|
public:
|
|
|
|
static SkString Name() { return SkString{"VSkOptsSSE41"}; }
|
|
|
|
static bool WorksOnCpu() { return SkCpu::Supports(SkCpu::SSE41); }
|
|
|
|
static void BlendN(uint32_t* dst, int count, const uint32_t* src) {
|
|
|
|
sk_sse41::srcover_srgb_srgb(dst, src, count, count);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <typename Blender>
|
|
|
|
class LinearSrcOverBench : public Benchmark {
|
|
|
|
public:
|
2016-05-20 15:54:23 +00:00
|
|
|
LinearSrcOverBench(const char* fileName) : fFileName(fileName) {
|
Add tests and benches to support the sRGB blitter for SkOpts
1,370.85 LinearSrcOvericonstrip.pngVSkOptsSSE41
2,359.69 LinearSrcOvericonstrip.pngVSkOptsDefault
1,828.72 LinearSrcOvericonstrip.pngVSkOptsNonSimdCore
3,277.40 LinearSrcOvericonstrip.pngVSkOptsTrivial
9,862.34 LinearSrcOvericonstrip.pngVSkOptsBruteForce
633.55 LinearSrcOvermandrill_512.pngVSkOptsSSE41
684.29 LinearSrcOvermandrill_512.pngVSkOptsDefault
1,201.88 LinearSrcOvermandrill_512.pngVSkOptsNonSimdCore
2,382.63 LinearSrcOvermandrill_512.pngVSkOptsTrivial
10,888.74 LinearSrcOvermandrill_512.pngVSkOptsBruteForce
209.14 LinearSrcOverplane.pngVSkOptsSSE41
562.24 LinearSrcOverplane.pngVSkOptsDefault
272.64 LinearSrcOverplane.pngVSkOptsNonSimdCore
436.46 LinearSrcOverplane.pngVSkOptsTrivial
1,327.23 LinearSrcOverplane.pngVSkOptsBruteForce
318.01 LinearSrcOverbaby_tux.pngVSkOptsSSE41
529.05 LinearSrcOverbaby_tux.pngVSkOptsDefault
441.33 LinearSrcOverbaby_tux.pngVSkOptsNonSimdCore
720.50 LinearSrcOverbaby_tux.pngVSkOptsTrivial
2,191.10 LinearSrcOverbaby_tux.pngVSkOptsBruteForce
479.68 LinearSrcOveryellow_rose.pngVSkOptsSSE41
1,095.03 LinearSrcOveryellow_rose.pngVSkOptsDefault
668.60 LinearSrcOveryellow_rose.pngVSkOptsNonSimdCore
1,257.19 LinearSrcOveryellow_rose.pngVSkOptsTrivial
4,970.25 LinearSrcOveryellow_rose.pngVSkOptsBruteForce
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1939513002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/554784cd85029c05d9ed04b1aeb71520d196153a
Committed: https://skia.googlesource.com/skia/+/bc927548db17accec2195af6e15053f7918bb3f5
Review-Url: https://codereview.chromium.org/1939513002
2016-05-17 16:57:34 +00:00
|
|
|
fName = "LinearSrcOver";
|
|
|
|
fName.append(fileName);
|
|
|
|
fName.append(Blender::Name());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend && Blender::WorksOnCpu();
|
|
|
|
}
|
|
|
|
const char* onGetName() override { return fName.c_str(); }
|
2016-05-20 15:54:23 +00:00
|
|
|
|
|
|
|
void onPreDraw(SkCanvas*) override {
|
|
|
|
if (!fPixmap.addr()) {
|
|
|
|
sk_sp<SkImage> image = GetResourceAsImage(fFileName.c_str());
|
|
|
|
SkBitmap bm;
|
|
|
|
if (!as_IB(image)->getROPixels(&bm)) {
|
|
|
|
SkFAIL("Could not read resource");
|
|
|
|
}
|
|
|
|
bm.peekPixels(&fPixmap);
|
|
|
|
fCount = fPixmap.rowBytesAsPixels();
|
|
|
|
fDst.reset(fCount);
|
|
|
|
memset(fDst.get(), 0, fPixmap.rowBytes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add tests and benches to support the sRGB blitter for SkOpts
1,370.85 LinearSrcOvericonstrip.pngVSkOptsSSE41
2,359.69 LinearSrcOvericonstrip.pngVSkOptsDefault
1,828.72 LinearSrcOvericonstrip.pngVSkOptsNonSimdCore
3,277.40 LinearSrcOvericonstrip.pngVSkOptsTrivial
9,862.34 LinearSrcOvericonstrip.pngVSkOptsBruteForce
633.55 LinearSrcOvermandrill_512.pngVSkOptsSSE41
684.29 LinearSrcOvermandrill_512.pngVSkOptsDefault
1,201.88 LinearSrcOvermandrill_512.pngVSkOptsNonSimdCore
2,382.63 LinearSrcOvermandrill_512.pngVSkOptsTrivial
10,888.74 LinearSrcOvermandrill_512.pngVSkOptsBruteForce
209.14 LinearSrcOverplane.pngVSkOptsSSE41
562.24 LinearSrcOverplane.pngVSkOptsDefault
272.64 LinearSrcOverplane.pngVSkOptsNonSimdCore
436.46 LinearSrcOverplane.pngVSkOptsTrivial
1,327.23 LinearSrcOverplane.pngVSkOptsBruteForce
318.01 LinearSrcOverbaby_tux.pngVSkOptsSSE41
529.05 LinearSrcOverbaby_tux.pngVSkOptsDefault
441.33 LinearSrcOverbaby_tux.pngVSkOptsNonSimdCore
720.50 LinearSrcOverbaby_tux.pngVSkOptsTrivial
2,191.10 LinearSrcOverbaby_tux.pngVSkOptsBruteForce
479.68 LinearSrcOveryellow_rose.pngVSkOptsSSE41
1,095.03 LinearSrcOveryellow_rose.pngVSkOptsDefault
668.60 LinearSrcOveryellow_rose.pngVSkOptsNonSimdCore
1,257.19 LinearSrcOveryellow_rose.pngVSkOptsTrivial
4,970.25 LinearSrcOveryellow_rose.pngVSkOptsBruteForce
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1939513002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/554784cd85029c05d9ed04b1aeb71520d196153a
Committed: https://skia.googlesource.com/skia/+/bc927548db17accec2195af6e15053f7918bb3f5
Review-Url: https://codereview.chromium.org/1939513002
2016-05-17 16:57:34 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
SkASSERT(fPixmap.colorType() == kN32_SkColorType);
|
|
|
|
|
|
|
|
const int width = fPixmap.rowBytesAsPixels();
|
|
|
|
|
|
|
|
for (int i = 0; i < loops * INNER_LOOPS; ++i) {
|
|
|
|
const uint32_t* src = fPixmap.addr32();
|
|
|
|
for (int y = 0; y < fPixmap.height(); y++) {
|
|
|
|
Blender::BlendN(fDst.get(), width, src);
|
|
|
|
src += width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onPostDraw(SkCanvas*) override {
|
|
|
|
// Make sure the compiler does not optimize away the operation.
|
|
|
|
volatile uint32_t v = 0;
|
|
|
|
for (int i = 0; i < fCount; i++) {
|
|
|
|
v ^= fDst[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fCount;
|
|
|
|
SkAutoTArray<uint32_t> fDst;
|
2016-05-20 15:54:23 +00:00
|
|
|
SkString fFileName;
|
Add tests and benches to support the sRGB blitter for SkOpts
1,370.85 LinearSrcOvericonstrip.pngVSkOptsSSE41
2,359.69 LinearSrcOvericonstrip.pngVSkOptsDefault
1,828.72 LinearSrcOvericonstrip.pngVSkOptsNonSimdCore
3,277.40 LinearSrcOvericonstrip.pngVSkOptsTrivial
9,862.34 LinearSrcOvericonstrip.pngVSkOptsBruteForce
633.55 LinearSrcOvermandrill_512.pngVSkOptsSSE41
684.29 LinearSrcOvermandrill_512.pngVSkOptsDefault
1,201.88 LinearSrcOvermandrill_512.pngVSkOptsNonSimdCore
2,382.63 LinearSrcOvermandrill_512.pngVSkOptsTrivial
10,888.74 LinearSrcOvermandrill_512.pngVSkOptsBruteForce
209.14 LinearSrcOverplane.pngVSkOptsSSE41
562.24 LinearSrcOverplane.pngVSkOptsDefault
272.64 LinearSrcOverplane.pngVSkOptsNonSimdCore
436.46 LinearSrcOverplane.pngVSkOptsTrivial
1,327.23 LinearSrcOverplane.pngVSkOptsBruteForce
318.01 LinearSrcOverbaby_tux.pngVSkOptsSSE41
529.05 LinearSrcOverbaby_tux.pngVSkOptsDefault
441.33 LinearSrcOverbaby_tux.pngVSkOptsNonSimdCore
720.50 LinearSrcOverbaby_tux.pngVSkOptsTrivial
2,191.10 LinearSrcOverbaby_tux.pngVSkOptsBruteForce
479.68 LinearSrcOveryellow_rose.pngVSkOptsSSE41
1,095.03 LinearSrcOveryellow_rose.pngVSkOptsDefault
668.60 LinearSrcOveryellow_rose.pngVSkOptsNonSimdCore
1,257.19 LinearSrcOveryellow_rose.pngVSkOptsTrivial
4,970.25 LinearSrcOveryellow_rose.pngVSkOptsBruteForce
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1939513002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/554784cd85029c05d9ed04b1aeb71520d196153a
Committed: https://skia.googlesource.com/skia/+/bc927548db17accec2195af6e15053f7918bb3f5
Review-Url: https://codereview.chromium.org/1939513002
2016-05-17 16:57:34 +00:00
|
|
|
SkString fName;
|
|
|
|
SkPixmap fPixmap;
|
|
|
|
|
|
|
|
typedef Benchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
2016-06-01 14:08:56 +00:00
|
|
|
#if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
|
Add tests and benches to support the sRGB blitter for SkOpts
1,370.85 LinearSrcOvericonstrip.pngVSkOptsSSE41
2,359.69 LinearSrcOvericonstrip.pngVSkOptsDefault
1,828.72 LinearSrcOvericonstrip.pngVSkOptsNonSimdCore
3,277.40 LinearSrcOvericonstrip.pngVSkOptsTrivial
9,862.34 LinearSrcOvericonstrip.pngVSkOptsBruteForce
633.55 LinearSrcOvermandrill_512.pngVSkOptsSSE41
684.29 LinearSrcOvermandrill_512.pngVSkOptsDefault
1,201.88 LinearSrcOvermandrill_512.pngVSkOptsNonSimdCore
2,382.63 LinearSrcOvermandrill_512.pngVSkOptsTrivial
10,888.74 LinearSrcOvermandrill_512.pngVSkOptsBruteForce
209.14 LinearSrcOverplane.pngVSkOptsSSE41
562.24 LinearSrcOverplane.pngVSkOptsDefault
272.64 LinearSrcOverplane.pngVSkOptsNonSimdCore
436.46 LinearSrcOverplane.pngVSkOptsTrivial
1,327.23 LinearSrcOverplane.pngVSkOptsBruteForce
318.01 LinearSrcOverbaby_tux.pngVSkOptsSSE41
529.05 LinearSrcOverbaby_tux.pngVSkOptsDefault
441.33 LinearSrcOverbaby_tux.pngVSkOptsNonSimdCore
720.50 LinearSrcOverbaby_tux.pngVSkOptsTrivial
2,191.10 LinearSrcOverbaby_tux.pngVSkOptsBruteForce
479.68 LinearSrcOveryellow_rose.pngVSkOptsSSE41
1,095.03 LinearSrcOveryellow_rose.pngVSkOptsDefault
668.60 LinearSrcOveryellow_rose.pngVSkOptsNonSimdCore
1,257.19 LinearSrcOveryellow_rose.pngVSkOptsTrivial
4,970.25 LinearSrcOveryellow_rose.pngVSkOptsBruteForce
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1939513002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/554784cd85029c05d9ed04b1aeb71520d196153a
Committed: https://skia.googlesource.com/skia/+/bc927548db17accec2195af6e15053f7918bb3f5
Review-Url: https://codereview.chromium.org/1939513002
2016-05-17 16:57:34 +00:00
|
|
|
#define BENCHES(fileName) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsSSE41>(fileName); )
|
|
|
|
#else
|
|
|
|
#define BENCHES(fileName) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName); ) \
|
|
|
|
DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BENCHES("yellow_rose.png")
|
|
|
|
BENCHES("baby_tux.png")
|
|
|
|
BENCHES("plane.png")
|
|
|
|
BENCHES("mandrill_512.png")
|
|
|
|
BENCHES("iconstrip.png")
|