change load/store_rgba to have src and dst variants

somewhat motivated by future mixer stages

Bug: skia:
Change-Id: Icd41ec9311f0da966164451324d28e7b3dfb3213
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/199280
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Reed 2019-03-08 11:50:35 -05:00 committed by Skia Commit-Bot
parent dd51aacdb1
commit 5e398c2b5e
4 changed files with 38 additions and 24 deletions

View File

@ -308,18 +308,17 @@ public:
};
auto state = alloc->make<State>();
p->append(SkRasterPipeline::store_rgba, state->orig_rgba);
p->append(SkRasterPipeline::store_src, state->orig_rgba);
if (!fCF1) {
fCF0->appendStages(p, dst, alloc, shaderIsOpaque);
p->append(SkRasterPipeline::move_src_dst);
p->append(SkRasterPipeline::load_rgba, state->orig_rgba);
p->append(SkRasterPipeline::load_src, state->orig_rgba);
} else {
fCF1->appendStages(p, dst, alloc, shaderIsOpaque);
p->append(SkRasterPipeline::store_rgba, state->filtered_rgba);
p->append(SkRasterPipeline::load_rgba, state->orig_rgba);
fCF0->appendStages(p, dst, alloc, shaderIsOpaque);
p->append(SkRasterPipeline::move_src_dst);
p->append(SkRasterPipeline::load_rgba, state->filtered_rgba);
p->append(SkRasterPipeline::store_src, state->filtered_rgba);
p->append(SkRasterPipeline::load_src, state->orig_rgba);
fCF1->appendStages(p, dst, alloc, shaderIsOpaque);
p->append(SkRasterPipeline::load_dst, state->filtered_rgba);
}
float* storage = alloc->make<float>(fWeight);
p->append(SkRasterPipeline::lerp_1_float, storage);

View File

@ -52,7 +52,7 @@
M(alpha_to_gray) M(alpha_to_gray_dst) M(luminance_to_alpha) \
M(bilerp_clamp_8888) \
M(store_u16_be) \
M(load_rgba) M(store_rgba) \
M(load_src) M(store_src) M(load_dst) M(store_dst) \
M(scale_u8) M(scale_565) M(scale_1_float) \
M( lerp_u8) M( lerp_565) M( lerp_1_float) \
M(dstatop) M(dstin) M(dstout) M(dstover) \

View File

@ -1066,7 +1066,7 @@ STAGE(white_color, Ctx::None) {
}
// load registers r,g,b,a from context (mirrors store_rgba)
STAGE(load_rgba, const float* ptr) {
STAGE(load_src, const float* ptr) {
r = unaligned_load<F>(ptr + 0*N);
g = unaligned_load<F>(ptr + 1*N);
b = unaligned_load<F>(ptr + 2*N);
@ -1074,13 +1074,29 @@ STAGE(load_rgba, const float* ptr) {
}
// store registers r,g,b,a into context (mirrors load_rgba)
STAGE(store_rgba, float* ptr) {
STAGE(store_src, float* ptr) {
unaligned_store(ptr + 0*N, r);
unaligned_store(ptr + 1*N, g);
unaligned_store(ptr + 2*N, b);
unaligned_store(ptr + 3*N, a);
}
// load registers dr,dg,db,da from context (mirrors store_dst)
STAGE(load_dst, const float* ptr) {
dr = unaligned_load<F>(ptr + 0*N);
dg = unaligned_load<F>(ptr + 1*N);
db = unaligned_load<F>(ptr + 2*N);
da = unaligned_load<F>(ptr + 3*N);
}
// store registers dr,dg,db,da into context (mirrors load_dst)
STAGE(store_dst, float* ptr) {
unaligned_store(ptr + 0*N, dr);
unaligned_store(ptr + 1*N, dg);
unaligned_store(ptr + 2*N, db);
unaligned_store(ptr + 3*N, da);
}
// Most blend modes apply the same logic to each channel.
#define BLEND_MODE(name) \
SI F name##_channel(F s, F d, F sa, F da); \
@ -3344,8 +3360,10 @@ STAGE_GP(bilerp_clamp_8888, const SkRasterPipeline_GatherCtx* ctx) {
// If a pipeline uses these stages, it'll boot it out of lowp into highp.
#define NOT_IMPLEMENTED(st) static void (*st)(void) = nullptr;
NOT_IMPLEMENTED(callback)
NOT_IMPLEMENTED(load_rgba)
NOT_IMPLEMENTED(store_rgba)
NOT_IMPLEMENTED(load_src)
NOT_IMPLEMENTED(store_src)
NOT_IMPLEMENTED(load_dst)
NOT_IMPLEMENTED(store_dst)
NOT_IMPLEMENTED(unbounded_set_rgb)
NOT_IMPLEMENTED(unbounded_uniform_color)
NOT_IMPLEMENTED(unpremul)

View File

@ -85,21 +85,18 @@ bool SkComposeShader::onAppendStages(const StageRec& rec) const {
};
auto storage = rec.fAlloc->make<Storage>();
if (!as_SB(fSrc)->appendStages(rec)) {
return false;
}
// This outputs r,g,b,a, which we'll need later when we apply the mode, but we save it off now
// since fShaderB will overwrite them.
rec.fPipeline->append(SkRasterPipeline::store_rgba, storage->fRGBA);
if (!as_SB(fDst)->appendStages(rec)) {
return false;
}
// We now have our logical 'dst' in r,g,b,a, but we need it in dr,dg,db,da for the mode/lerp
// so we have to shuttle them. If we had a stage the would load_into_dst, then we could
// reverse the two shader invocations, and avoid this move...
rec.fPipeline->append(SkRasterPipeline::move_src_dst);
rec.fPipeline->append(SkRasterPipeline::load_rgba, storage->fRGBA);
// This outputs r,g,b,a, which we'll need later when we apply the mode, so we save it off now
rec.fPipeline->append(SkRasterPipeline::store_src, storage->fRGBA);
if (!as_SB(fSrc)->appendStages(rec)) {
return false;
}
// r,g,b,a now have the right input for the next step (lerp and/or mode), but we need to
// reload dr,dg,db,da from memory, since we stashed that from our fDst invocation earlier.
rec.fPipeline->append(SkRasterPipeline::load_dst, storage->fRGBA);
if (!this->isJustLerp()) {
SkBlendMode_AppendStages(fMode, rec.fPipeline);