2016-07-12 22:01:26 +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 "Test.h"
|
2016-10-04 18:03:27 +00:00
|
|
|
#include "SkHalf.h"
|
2016-07-12 22:01:26 +00:00
|
|
|
#include "SkRasterPipeline.h"
|
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline, r) {
|
2016-10-04 18:03:27 +00:00
|
|
|
// Build and run a simple pipeline to exercise SkRasterPipeline,
|
|
|
|
// drawing 50% transparent blue over opaque red in half-floats.
|
2016-10-05 14:36:38 +00:00
|
|
|
uint64_t red = 0x3c00000000003c00ull,
|
|
|
|
blue = 0x3800380000000000ull,
|
|
|
|
result;
|
2016-10-05 13:36:26 +00:00
|
|
|
|
2016-10-25 19:43:46 +00:00
|
|
|
void* load_s_ctx = &blue;
|
|
|
|
void* load_d_ctx = &red;
|
|
|
|
void* store_ctx = &result;
|
|
|
|
|
2016-07-12 22:01:26 +00:00
|
|
|
SkRasterPipeline p;
|
Consistent naming.
For stages that have {r,g,b,a} and {dr,dg,db,da} versions, name the {r,g,b,a} one "foo" and the {dr,dg,db,da} on "foo_d". The {r,g,b,a} registers are the ones most commonly used and fastest, so they get short ordinary names, and the d-registers are less commonly used and sometimes slower, so they get a suffix.
Some stages naturally opearate on all 8 registers (the xfermodes, accumulate). These names for those look fine and aren't ambiguous.
Also, a bit more re-arrangement in _opts.h.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: Ia20029247642798a60a2566e8a26b84ed101dbd0
Reviewed-on: https://skia-review.googlesource.com/5291
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-28 23:23:23 +00:00
|
|
|
p.append(SkRasterPipeline::load_f16, &load_s_ctx);
|
|
|
|
p.append(SkRasterPipeline::load_f16_d, &load_d_ctx);
|
2016-10-04 18:03:27 +00:00
|
|
|
p.append(SkRasterPipeline::srcover);
|
2016-10-25 19:43:46 +00:00
|
|
|
p.append(SkRasterPipeline::store_f16, &store_ctx);
|
Start each pipeline with (x,y) in (dr,dg) registers for the shader.
Image shaders need to do some geometry work before sampling the image colors:
1) determine dst coordinates
2) map back to src coordinates
3) tiling
Feeding (x,y) through as (dr,dg) registers makes step 1) easy, perhaps trivial, while leaving (r,g,b,a) with their usual meanings, "the color", starting with the paint color.
This is easy to tweak into something like (x+0.5, y+0.5, 1) in (dr,dg,db) once this lands. Mostly I just want to get all the uninteresting boilerplate out of the way first.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4791
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Change-Id: Ia07815d942ded6672dc1df785caf80a508fc8f37
Reviewed-on: https://skia-review.googlesource.com/4791
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-15 13:52:04 +00:00
|
|
|
p.compile()(0,0, 1);
|
2016-10-04 18:03:27 +00:00
|
|
|
|
|
|
|
// We should see half-intensity magenta.
|
2016-10-05 14:36:38 +00:00
|
|
|
REPORTER_ASSERT(r, ((result >> 0) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 16) & 0xffff) == 0x0000);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 32) & 0xffff) == 0x3800);
|
|
|
|
REPORTER_ASSERT(r, ((result >> 48) & 0xffff) == 0x3c00);
|
2016-07-12 22:01:26 +00:00
|
|
|
}
|
2016-07-13 15:22:20 +00:00
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline_empty, r) {
|
|
|
|
// No asserts... just a test that this is safe to run.
|
|
|
|
SkRasterPipeline p;
|
Start each pipeline with (x,y) in (dr,dg) registers for the shader.
Image shaders need to do some geometry work before sampling the image colors:
1) determine dst coordinates
2) map back to src coordinates
3) tiling
Feeding (x,y) through as (dr,dg) registers makes step 1) easy, perhaps trivial, while leaving (r,g,b,a) with their usual meanings, "the color", starting with the paint color.
This is easy to tweak into something like (x+0.5, y+0.5, 1) in (dr,dg,db) once this lands. Mostly I just want to get all the uninteresting boilerplate out of the way first.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4791
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Change-Id: Ia07815d942ded6672dc1df785caf80a508fc8f37
Reviewed-on: https://skia-review.googlesource.com/4791
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-15 13:52:04 +00:00
|
|
|
p.compile()(0,0, 20);
|
2016-07-13 15:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline_nonsense, r) {
|
|
|
|
// No asserts... just a test that this is safe to run and terminates.
|
2016-10-04 18:03:27 +00:00
|
|
|
// srcover() calls st->next(); this makes sure we've always got something there to call.
|
2016-07-13 15:22:20 +00:00
|
|
|
SkRasterPipeline p;
|
2016-10-04 18:03:27 +00:00
|
|
|
p.append(SkRasterPipeline::srcover);
|
Start each pipeline with (x,y) in (dr,dg) registers for the shader.
Image shaders need to do some geometry work before sampling the image colors:
1) determine dst coordinates
2) map back to src coordinates
3) tiling
Feeding (x,y) through as (dr,dg) registers makes step 1) easy, perhaps trivial, while leaving (r,g,b,a) with their usual meanings, "the color", starting with the paint color.
This is easy to tweak into something like (x+0.5, y+0.5, 1) in (dr,dg,db) once this lands. Mostly I just want to get all the uninteresting boilerplate out of the way first.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4791
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Change-Id: Ia07815d942ded6672dc1df785caf80a508fc8f37
Reviewed-on: https://skia-review.googlesource.com/4791
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-15 13:52:04 +00:00
|
|
|
p.compile()(0,0, 20);
|
2016-07-13 15:22:20 +00:00
|
|
|
}
|