Fix asserts in SkRuntimeEffect color filter benchmarks

The interpreter doesn't (yet) support all GPU intrinsics, so adjust the
code to avoid 'max' and 'saturate'.

The interpreter is more picky about uniform blocks being the correct
size, so don't pass the color matrix data to the "None" effect, which
has no uniforms.

Change-Id: I4609f913eaa762ca171b2875eb25d23141a0646c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261931
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Osman 2020-01-02 11:29:50 -05:00 committed by Skia Commit-Bot
parent c2b6d7f50b
commit 1bf3199970

View File

@ -128,6 +128,7 @@ const char RuntimeNone_GPU_SRC[] = R"(
void main(inout half4 c) {} void main(inout half4 c) {}
)"; )";
// TODO: Use intrinsic max/saturate when those are implemented by the interpreter
const char RuntimeColorMatrix_GPU_SRC[] = R"( const char RuntimeColorMatrix_GPU_SRC[] = R"(
// WTB matrix/vector inputs. // WTB matrix/vector inputs.
uniform half m0 , m1 , m2 , m3 , m4 , uniform half m0 , m1 , m2 , m3 , m4 ,
@ -135,7 +136,7 @@ const char RuntimeColorMatrix_GPU_SRC[] = R"(
m10, m11, m12, m13, m14, m10, m11, m12, m13, m14,
m15, m16, m17, m18, m19; m15, m16, m17, m18, m19;
void main(inout half4 c) { void main(inout half4 c) {
half nonZeroAlpha = max(c.a, 0.0001); half nonZeroAlpha = c.a < 0.0001 ? 0.0001 : c.a;
c = half4(c.rgb / nonZeroAlpha, nonZeroAlpha); c = half4(c.rgb / nonZeroAlpha, nonZeroAlpha);
half4x4 m = half4x4(m0, m5, m10, m15, half4x4 m = half4x4(m0, m5, m10, m15,
@ -144,7 +145,7 @@ const char RuntimeColorMatrix_GPU_SRC[] = R"(
m3, m8, m13, m18); m3, m8, m13, m18);
c = m * c + half4 (m4, m9, m14, m19); c = m * c + half4 (m4, m9, m14, m19);
c = saturate(c); // c = saturate(c);
c.rgb *= c.a; c.rgb *= c.a;
} }
)"; )";
@ -186,7 +187,7 @@ DEF_BENCH( return new ColorMatrixBench("lerp_src",
DEF_BENCH( return new ColorMatrixBench("src_runtime", []() { DEF_BENCH( return new ColorMatrixBench("src_runtime", []() {
static sk_sp<SkRuntimeEffect> gEffect = std::get<0>( static sk_sp<SkRuntimeEffect> gEffect = std::get<0>(
SkRuntimeEffect::Make(SkString(RuntimeNone_GPU_SRC))); SkRuntimeEffect::Make(SkString(RuntimeNone_GPU_SRC)));
return gEffect->makeColorFilter(SkData::MakeWithCopy(gColorMatrix, sizeof(gColorMatrix))); return gEffect->makeColorFilter(SkData::MakeEmpty());
});) });)
DEF_BENCH( return new ColorMatrixBench("matrix_runtime", []() { DEF_BENCH( return new ColorMatrixBench("matrix_runtime", []() {
static sk_sp<SkRuntimeEffect> gEffect = std::get<0>( static sk_sp<SkRuntimeEffect> gEffect = std::get<0>(