remove SkRP-based runtime effects
The SkVM backend can draw all the existing GMs. Image diffs look good. Rough local perf changes: spiral_rt: 14.3ms -> 5.9ms w/o JIT, or 2.5ms w/JIT overdrawcolorfilter: 4.2 4.9* 2.6 overdraw_canvas: 10.1 8.9 2.7 runtimecolorfilter: 8.5 8.5 7.5 with one regression marked with a *. Change-Id: Ib4f11422f3c2e8756960794a965385fa616ad8bf Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308193 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
be3ea68fee
commit
2b8940ee5e
@ -37,7 +37,7 @@ class SkData;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define SK_RASTER_PIPELINE_STAGES(M) \
|
#define SK_RASTER_PIPELINE_STAGES(M) \
|
||||||
M(callback) M(interpreter) \
|
M(callback) \
|
||||||
M(move_src_dst) M(move_dst_src) \
|
M(move_src_dst) M(move_dst_src) \
|
||||||
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_gamut) \
|
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_gamut) \
|
||||||
M(unpremul) M(premul) M(premul_dst) \
|
M(unpremul) M(premul) M(premul_dst) \
|
||||||
@ -166,16 +166,6 @@ class ByteCode;
|
|||||||
class ByteCodeFunction;
|
class ByteCodeFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SkRasterPipeline_InterpreterCtx {
|
|
||||||
const SkSL::ByteCode* byteCode;
|
|
||||||
const SkSL::ByteCodeFunction* fn;
|
|
||||||
|
|
||||||
SkColor4f paintColor;
|
|
||||||
sk_sp<SkData> inputs;
|
|
||||||
int ninputs;
|
|
||||||
bool shaderConvention; // if false, we're a colorfilter
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkRasterPipeline_GradientCtx {
|
struct SkRasterPipeline_GradientCtx {
|
||||||
size_t stopCount;
|
size_t stopCount;
|
||||||
float* fs[4];
|
float* fs[4];
|
||||||
|
@ -717,25 +717,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
|
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
|
||||||
auto ctx = rec.fAlloc->make<SkRasterPipeline_InterpreterCtx>();
|
|
||||||
// don't need to set ctx->paintColor
|
|
||||||
ctx->inputs = fInputs;
|
|
||||||
ctx->ninputs = fEffect->uniformSize() / 4;
|
|
||||||
ctx->shaderConvention = false;
|
|
||||||
|
|
||||||
ctx->byteCode = this->byteCode();
|
|
||||||
if (!ctx->byteCode || !ctx->byteCode->canRun()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->fn = ctx->byteCode->getFunction("main");
|
|
||||||
if (!ctx->fn) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rec.fPipeline->append(SkRasterPipeline::interpreter, ctx);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
skvm::Color onProgram(skvm::Builder* p, skvm::Color c,
|
skvm::Color onProgram(skvm::Builder* p, skvm::Color c,
|
||||||
SkColorSpace* /*dstCS*/,
|
SkColorSpace* /*dstCS*/,
|
||||||
skvm::Uniforms* uniforms, SkArenaAlloc*) const override {
|
skvm::Uniforms* uniforms, SkArenaAlloc*) const override {
|
||||||
@ -918,35 +902,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool onAppendStages(const SkStageRec& rec) const override {
|
bool onAppendStages(const SkStageRec& rec) const override {
|
||||||
SkMatrix inverse;
|
|
||||||
if (!this->computeTotalInverse(rec.fMatrixProvider.localToDevice(), rec.fLocalM,
|
|
||||||
&inverse)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ctx = rec.fAlloc->make<SkRasterPipeline_InterpreterCtx>();
|
|
||||||
ctx->paintColor = rec.fPaint.getColor4f();
|
|
||||||
ctx->inputs = this->getUniforms(rec.fMatrixProvider, rec.fDstCS);
|
|
||||||
if (!ctx->inputs) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ctx->ninputs = fEffect->uniformSize() / 4;
|
|
||||||
ctx->shaderConvention = true;
|
|
||||||
|
|
||||||
ctx->byteCode = this->byteCode();
|
|
||||||
if (!ctx->byteCode || !ctx->byteCode->canRun()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ctx->fn = ctx->byteCode->getFunction("main");
|
|
||||||
if (!ctx->fn) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rec.fPipeline->append(SkRasterPipeline::seed_shader);
|
|
||||||
rec.fPipeline->append_matrix(rec.fAlloc, inverse);
|
|
||||||
rec.fPipeline->append(SkRasterPipeline::interpreter, ctx);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
skvm::Color onProgram(skvm::Builder* p,
|
skvm::Color onProgram(skvm::Builder* p,
|
||||||
skvm::Coord device, skvm::Coord local, skvm::Color paint,
|
skvm::Coord device, skvm::Coord local, skvm::Color paint,
|
||||||
const SkMatrixProvider& matrices, const SkMatrix* localM,
|
const SkMatrixProvider& matrices, const SkMatrix* localM,
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "include/core/SkData.h"
|
#include "include/core/SkData.h"
|
||||||
#include "include/core/SkTypes.h"
|
#include "include/core/SkTypes.h"
|
||||||
#include "src/core/SkUtils.h" // unaligned_{load,store}
|
#include "src/core/SkUtils.h" // unaligned_{load,store}
|
||||||
#include "src/sksl/SkSLByteCode.h"
|
|
||||||
|
|
||||||
// Every function in this file should be marked static and inline using SI.
|
// Every function in this file should be marked static and inline using SI.
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@ -2662,44 +2661,6 @@ STAGE(callback, SkRasterPipeline_CallbackCtx* c) {
|
|||||||
load4(c->read_from,0, &r,&g,&b,&a);
|
load4(c->read_from,0, &r,&g,&b,&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// shader: void main(float2 p, inout half4 color)
|
|
||||||
// colorfilter: void main(inout half4 color)
|
|
||||||
STAGE(interpreter, SkRasterPipeline_InterpreterCtx* c) {
|
|
||||||
// If N is less than the interpreter's VecWidth, then we are doing more work than necessary in
|
|
||||||
// the interpreter. This is a known issue, and will be addressed at some point.
|
|
||||||
float xx[N], yy[N],
|
|
||||||
rr[N], gg[N], bb[N], aa[N];
|
|
||||||
|
|
||||||
float* args[] = { xx, yy, rr, gg, bb, aa };
|
|
||||||
float** in_args = args;
|
|
||||||
int in_count = 6;
|
|
||||||
|
|
||||||
if (c->shaderConvention) {
|
|
||||||
// our caller must have called seed_shader to set these
|
|
||||||
sk_unaligned_store(xx, r);
|
|
||||||
sk_unaligned_store(yy, g);
|
|
||||||
sk_unaligned_store(rr, F(c->paintColor.fR));
|
|
||||||
sk_unaligned_store(gg, F(c->paintColor.fG));
|
|
||||||
sk_unaligned_store(bb, F(c->paintColor.fB));
|
|
||||||
sk_unaligned_store(aa, F(c->paintColor.fA));
|
|
||||||
} else {
|
|
||||||
in_args += 2; // skip x,y
|
|
||||||
in_count = 4;
|
|
||||||
sk_unaligned_store(rr, r);
|
|
||||||
sk_unaligned_store(gg, g);
|
|
||||||
sk_unaligned_store(bb, b);
|
|
||||||
sk_unaligned_store(aa, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkAssertResult(c->byteCode->runStriped(c->fn, tail ? tail : N, in_args, in_count, nullptr, 0,
|
|
||||||
(const float*)c->inputs->data(), c->ninputs));
|
|
||||||
|
|
||||||
r = sk_unaligned_load<F>(rr);
|
|
||||||
g = sk_unaligned_load<F>(gg);
|
|
||||||
b = sk_unaligned_load<F>(bb);
|
|
||||||
a = sk_unaligned_load<F>(aa);
|
|
||||||
}
|
|
||||||
|
|
||||||
STAGE(gauss_a_to_rgba, Ctx::None) {
|
STAGE(gauss_a_to_rgba, Ctx::None) {
|
||||||
// x = 1 - x;
|
// x = 1 - x;
|
||||||
// exp(-x * x * 4) - 0.018f;
|
// exp(-x * x * 4) - 0.018f;
|
||||||
|
Loading…
Reference in New Issue
Block a user