aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkRasterPipelineTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-09-29 09:04:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-29 16:20:26 +0000
commitbaaf8ad95237d1defdb7d93077d9bf8410d8ad7f (patch)
tree4635750d0b6c5b792a6d0e226e7fe8042a394fa9 /tests/SkRasterPipelineTest.cpp
parent8e6791fb9a79c38228339ffc5c75d73b58893fa8 (diff)
Start moving SkRasterPipeline stages to SkOpts.
This lets them pick up runtime CPU specializations. Here I've plugged in SSE4.1. This is still one of the N prelude CLs to full 8-at-a-time AVX. I've moved the union of the stages used by SkRasterPipelineBench and SkRasterPipelineBlitter to SkOpts... they'll all be used by the blitter eventually. Picking up SSE4.1 specialization here (even still just 4 pixels at a time) is a significant speedup, especially to store_srgb(), so much that it's no longer really interesting to compare against the fused-but-default-instruction-set version in the bench. So that's gone now. That left the SkRasterPipeline unit test as the only other user of the EasyFn simplified interface to SkRasterPipeline. So I converted that back down to the bare-metal interface, and EasyFn and its friends became SkRasterPipeline_opts.h exclusive abbreviations (now called Kernel_Sk4f). This isn't really unexpected: SkXfermode also wanted to build up its own little abstractions, and once you build your own abstraction, the value of an additional EasyFn-like layer plummets to negative. For simplicity I've left the SkXfermode stages alone, except srcover() which was always part of the blitter. No particular reason except keeping the churn down while I hack. These _can_ be in SkOpts, but don't have to be until we go 8-at-a-time. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2752 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Change-Id: I3b476b18232a1598d8977e425be2150059ab71dc Reviewed-on: https://skia-review.googlesource.com/2752 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tests/SkRasterPipelineTest.cpp')
-rw-r--r--tests/SkRasterPipelineTest.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp
index 867baf7918..ccc728e64a 100644
--- a/tests/SkRasterPipelineTest.cpp
+++ b/tests/SkRasterPipelineTest.cpp
@@ -8,25 +8,33 @@
#include "Test.h"
#include "SkRasterPipeline.h"
-SK_RASTER_STAGE(load) {
- auto ptr = (const float*)ctx + x;
+static void SK_VECTORCALL load(SkRasterPipeline::Stage* st, size_t x, size_t tail,
+ Sk4f r, Sk4f g, Sk4f b, Sk4f a,
+ Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) {
+ auto ptr = st->ctx<const float*>() + x;
switch(tail&3) {
case 0: a = Sk4f{ptr[3]};
case 3: b = Sk4f{ptr[2]};
case 2: g = Sk4f{ptr[1]};
case 1: r = Sk4f{ptr[0]};
}
+ st->next(x,tail, r,g,b,a, dr,dg,db,da);
}
-SK_RASTER_STAGE(square) {
+static void SK_VECTORCALL square(SkRasterPipeline::Stage* st, size_t x, size_t tail,
+ Sk4f r, Sk4f g, Sk4f b, Sk4f a,
+ Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) {
r *= r;
g *= g;
b *= b;
a *= a;
+ st->next(x,tail, r,g,b,a, dr,dg,db,da);
}
-SK_RASTER_STAGE(store) {
- auto ptr = (float*)ctx + x;
+static void SK_VECTORCALL store(SkRasterPipeline::Stage* st, size_t x, size_t tail,
+ Sk4f r, Sk4f g, Sk4f b, Sk4f a,
+ Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) {
+ auto ptr = st->ctx<float*>() + x;
switch (tail&3) {
case 0: ptr[3] = a[0];
case 3: ptr[2] = b[0];
@@ -41,6 +49,8 @@ DEF_TEST(SkRasterPipeline, r) {
// - context pointers (load,store)
// - stages sensitive to the number of pixels (load,store)
// - stages insensitive to the number of pixels (square)
+ // - stages that chain to the next stage (load,square)
+ // - stages that terminate the pipeline (store)
//
// This pipeline loads up some values, squares them, then writes them back to memory.
@@ -48,9 +58,9 @@ DEF_TEST(SkRasterPipeline, r) {
float dst_vals[] = { 0,0,0,0,0 };
SkRasterPipeline p;
- p.append<load>(src_vals);
- p.append<square>();
- p.append<store>(dst_vals);
+ p.append(load, src_vals);
+ p.append(square);
+ p.append(store, dst_vals);
p.run(5);
@@ -71,6 +81,6 @@ DEF_TEST(SkRasterPipeline_nonsense, r) {
// No asserts... just a test that this is safe to run and terminates.
// square() always calls st->next(); this makes sure we've always got something there to call.
SkRasterPipeline p;
- p.append<square>();
+ p.append(square);
p.run(20);
}