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);
|
2017-01-06 15:21:56 +00:00
|
|
|
p.append(SkRasterPipeline::move_src_dst);
|
|
|
|
p.append(SkRasterPipeline::load_f16, &load_d_ctx);
|
|
|
|
p.append(SkRasterPipeline::swap);
|
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);
|
Move shader register setup to SkRasterPipelineBlitter.
We've been seeding the initial values of our registers to x+0.5,y+0.5,
1,0, 0,0,0,0 (useful values for shaders to start with) in all pipelines.
This CL changes that to do so only when blitting, and only when we have
a shader.
The nicest part of this change is that SkRasterPipeline itself no longer
needs to have a concept of y, or what x means. It just marches x
through [x,x+n), and the blitter handles y and layers the meaning of
"dst x coordinate" onto x.
This ought to make SkSplicer a little easier to work with too.
dm --src gm --config f16 srgb 565 all draws the same.
Change-Id: I69d8c1cc14a06e5dfdd6a7493364f43a18f8dec5
Reviewed-on: https://skia-review.googlesource.com/7353
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-01-20 20:11:54 +00:00
|
|
|
p.run(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;
|
Move shader register setup to SkRasterPipelineBlitter.
We've been seeding the initial values of our registers to x+0.5,y+0.5,
1,0, 0,0,0,0 (useful values for shaders to start with) in all pipelines.
This CL changes that to do so only when blitting, and only when we have
a shader.
The nicest part of this change is that SkRasterPipeline itself no longer
needs to have a concept of y, or what x means. It just marches x
through [x,x+n), and the blitter handles y and layers the meaning of
"dst x coordinate" onto x.
This ought to make SkSplicer a little easier to work with too.
dm --src gm --config f16 srgb 565 all draws the same.
Change-Id: I69d8c1cc14a06e5dfdd6a7493364f43a18f8dec5
Reviewed-on: https://skia-review.googlesource.com/7353
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-01-20 20:11:54 +00:00
|
|
|
p.run(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);
|
Move shader register setup to SkRasterPipelineBlitter.
We've been seeding the initial values of our registers to x+0.5,y+0.5,
1,0, 0,0,0,0 (useful values for shaders to start with) in all pipelines.
This CL changes that to do so only when blitting, and only when we have
a shader.
The nicest part of this change is that SkRasterPipeline itself no longer
needs to have a concept of y, or what x means. It just marches x
through [x,x+n), and the blitter handles y and layers the meaning of
"dst x coordinate" onto x.
This ought to make SkSplicer a little easier to work with too.
dm --src gm --config f16 srgb 565 all draws the same.
Change-Id: I69d8c1cc14a06e5dfdd6a7493364f43a18f8dec5
Reviewed-on: https://skia-review.googlesource.com/7353
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-01-20 20:11:54 +00:00
|
|
|
p.run(0,20);
|
2016-07-13 15:22:20 +00:00
|
|
|
}
|
2017-01-10 18:42:51 +00:00
|
|
|
|
|
|
|
DEF_TEST(SkRasterPipeline_JIT, r) {
|
|
|
|
// This tests a couple odd corners that a JIT backend can stumble over.
|
|
|
|
|
|
|
|
uint32_t buf[72] = {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
|
|
|
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
const uint32_t* src = buf + 0;
|
|
|
|
uint32_t* dst = buf + 36;
|
|
|
|
|
|
|
|
// Copy buf[x] to buf[x+36] for x in [15,35).
|
|
|
|
SkRasterPipeline p;
|
|
|
|
p.append(SkRasterPipeline:: load_8888, &src);
|
|
|
|
p.append(SkRasterPipeline::store_8888, &dst);
|
2017-02-16 11:51:48 +00:00
|
|
|
p.run(15, 20);
|
2017-01-10 18:42:51 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 36; i++) {
|
|
|
|
if (i < 15 || i == 35) {
|
|
|
|
REPORTER_ASSERT(r, dst[i] == 0);
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(r, dst[i] == (uint32_t)(i - 11));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|