tidy up dither stage
Using the float iota was just an expedient to write the stage... this CL adds the U32 iota that dither really wants. Change-Id: I7990b10afd0c5277186b6b8e730245d291bcef0c Reviewed-on: https://skia-review.googlesource.com/17441 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
9f52e98e60
commit
5d7f2b5301
@ -22,7 +22,8 @@
|
||||
// It's fine to rearrange and add new ones if you update SkJumper_constants.
|
||||
using K = const SkJumper_constants;
|
||||
static K kConstants = {
|
||||
{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f},
|
||||
{0,1,2,3,4,5,6,7},
|
||||
{0,1,2,3,4,5,6,7},
|
||||
};
|
||||
|
||||
// We can't express the real types of most stage functions portably, so we use a stand-in.
|
||||
|
@ -51,7 +51,8 @@
|
||||
static const int SkJumper_kMaxStride = 8;
|
||||
|
||||
struct SkJumper_constants {
|
||||
float iota[SkJumper_kMaxStride]; // 0,1,2,3,4,...
|
||||
float iota_F [SkJumper_kMaxStride]; // 0,1,2,3,4,...
|
||||
uint32_t iota_U32[SkJumper_kMaxStride]; // 0,1,2,3,4,...
|
||||
};
|
||||
|
||||
struct SkJumper_GatherCtx {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -286,7 +286,7 @@ STAGE(seed_shader) {
|
||||
// It's important for speed to explicitly cast(x) and cast(y),
|
||||
// which has the effect of splatting them to vectors before converting to floats.
|
||||
// On Intel this breaks a data dependency on previous loop iterations' registers.
|
||||
r = cast(x) + 0.5f + unaligned_load<F>(k->iota);
|
||||
r = cast(x) + 0.5f + unaligned_load<F>(k->iota_F);
|
||||
g = cast(y) + 0.5f;
|
||||
b = 1.0f;
|
||||
a = 0;
|
||||
@ -297,7 +297,7 @@ STAGE(dither) {
|
||||
auto c = (const SkJumper_DitherCtx*)ctx;
|
||||
|
||||
// Get [(x,y), (x+1,y), (x+2,y), ...] loaded up in integer vectors.
|
||||
U32 X = trunc_((int)x + unaligned_load<F>(k->iota)), // Going through float is kind of lazy..
|
||||
U32 X = x + unaligned_load<U32>(k->iota_U32),
|
||||
Y = (uint32_t)*c->y;
|
||||
|
||||
// We're doing 8x8 ordered dithering, see https://en.wikipedia.org/wiki/Ordered_dithering.
|
||||
|
Loading…
Reference in New Issue
Block a user