From 1ae6ac81e68a98067d82b64a22af141a3c06f288 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Mon, 24 Jun 2019 15:00:35 -0400 Subject: [PATCH] add RP comparison for SkVM_Overhead Looks like ~50ns overhead for RP vs ~14,000ns for SkVM. Change-Id: I85ef73d3387657b14615fcfa5cfd9df5c2325343 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223302 Reviewed-by: Herb Derby Commit-Queue: Mike Klein --- bench/SkVMBench.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/bench/SkVMBench.cpp b/bench/SkVMBench.cpp index 91bb277fee..41895ccf6c 100644 --- a/bench/SkVMBench.cpp +++ b/bench/SkVMBench.cpp @@ -129,18 +129,35 @@ DEF_BENCH(return (new SkVMBench{4096, I32_SWAR});) class SkVM_Overhead : public Benchmark { public: - SkVM_Overhead() {} + explicit SkVM_Overhead(bool rp) : fRP(rp) {} private: - const char* onGetName() override { return "SkVM_Overhead"; } + const char* onGetName() override { return fRP ? "SkVM_Overhead_RP" : "SkVM_Overhead_VM"; } bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } void onDraw(int loops, SkCanvas*) override { - while (loops --> 0) { - float dummy; - skvm::Program program = SrcoverBuilder_F32{}.done(); - program.eval(0, &dummy, &dummy); + float dummy; + if (fRP) { + while (loops --> 0) { + SkRasterPipeline_<256> rp; + SkRasterPipeline_MemoryCtx src = { &dummy, 0}, + dst = { &dummy, 0}; + rp.append_load (SkColorType::kRGBA_F32_SkColorType, &src); + rp.append_load_dst(SkColorType::kRGBA_F32_SkColorType, &dst); + rp.append (SkRasterPipeline::srcover); + rp.append_store (SkColorType::kRGBA_F32_SkColorType, &dst); + + (void)rp.compile(); + } + } else { + while (loops --> 0) { + skvm::Program program = SrcoverBuilder_F32{}.done(); + program.eval(0, &dummy, &dummy); + } } } + + bool fRP; }; -DEF_BENCH(return new SkVM_Overhead;) +DEF_BENCH(return new SkVM_Overhead{ true};) +DEF_BENCH(return new SkVM_Overhead{false};)