Migrate SkSL inliner tests to golden files.

Our lack of proper caps-bits controls in skslc affects the outcome of
one test: "InlinerWrapsEarlyReturnsWithDoWhileBlock" does not actually
emit the do-while block because the standalone caps bits don't enable
do-while support. This will be fixed in a followup CL that adds caps-bit
support to our tests.

A few tests were renamed for consistency, a few were simplified slightly
and one test was removed because it was simply redundant (there was a
second test that covered the exact same ground as
`ForWithReturnInsideCannotBeInlined`).

Change-Id: I2e3b97cb3aea331b6d806bdb865aa78c35c7a6b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316997
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-09-15 10:10:43 -04:00 committed by Skia Commit-Bot
parent 860ac5b03e
commit f2cdf59d58
62 changed files with 1175 additions and 1241 deletions

View File

@ -59,5 +59,34 @@ sksl_glsl_tests_sources = [
"$_tests/sksl/glsl/VectorConstructors.sksl",
"$_tests/sksl/glsl/VectorFolding.sksl",
"$_tests/sksl/glsl/VertexID.vert",
"$_tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl",
"$_tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl",
"$_tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl",
"$_tests/sksl/inliner/ForInitializerExpressionsCanBeInlined.sksl",
"$_tests/sksl/inliner/ForWithReturnInsideCannotBeInlined.sksl",
"$_tests/sksl/inliner/ForWithoutReturnInsideCanBeInlined.sksl",
"$_tests/sksl/inliner/IfBodyMustBeInlinedIntoAScope.sksl",
"$_tests/sksl/inliner/IfElseBodyMustBeInlinedIntoAScope.sksl",
"$_tests/sksl/inliner/IfElseChainWithReturnsCanBeInlined.sksl",
"$_tests/sksl/inliner/IfTestCanBeInlined.sksl",
"$_tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl",
"$_tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl",
"$_tests/sksl/inliner/InlineThreshold.sksl",
"$_tests/sksl/inliner/InlineWithInoutArgument.sksl",
"$_tests/sksl/inliner/InlineWithModifiedArgument.sksl",
"$_tests/sksl/inliner/InlineWithNestedBigCalls.sksl",
"$_tests/sksl/inliner/InlineWithNestedCalls.sksl",
"$_tests/sksl/inliner/InlineWithUnmodifiedArgument.sksl",
"$_tests/sksl/inliner/InlineWithUnnecessaryBlocks.sksl",
"$_tests/sksl/inliner/InlinerAvoidsVariableNameOverlap.sksl",
"$_tests/sksl/inliner/InlinerManglesNames.sksl",
"$_tests/sksl/inliner/InlinerWrapsEarlyReturnsWithDoWhileBlock.sksl",
"$_tests/sksl/inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl",
"$_tests/sksl/inliner/SwitchWithCastCanBeInlined.sksl",
"$_tests/sksl/inliner/SwitchWithReturnInsideCannotBeInlined.sksl",
"$_tests/sksl/inliner/SwitchWithoutReturnInsideCanBeInlined.sksl",
"$_tests/sksl/inliner/TernaryResultsCannotBeInlined.sksl",
"$_tests/sksl/inliner/TernaryTestCanBeInlined.sksl",
"$_tests/sksl/inliner/WhileBodyMustBeInlinedIntoAScope.sksl",
"$_tests/sksl/inliner/WhileTestCannotBeInlined.sksl",
]

View File

@ -262,7 +262,6 @@ tests_sources = [
"$_tests/SkSLErrorTest.cpp",
"$_tests/SkSLFPTest.cpp",
"$_tests/SkSLGLSLTest.cpp",
"$_tests/SkSLInlinerTest.cpp",
"$_tests/SkSLInterpreterTest.cpp",
"$_tests/SkSLMemoryLayoutTest.cpp",
"$_tests/SkSLMetalTest.cpp",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
inline half4 adjust(half4 v) {
return v + half4(0.125);
}
void main() {
sk_FragColor = half4(0);
do
sk_FragColor = adjust(sk_FragColor);
while (sk_FragColor.x < 0.5);
}

View File

@ -0,0 +1,10 @@
inline bool shouldLoop(half4 v) {
return v.x < 0.5;
}
void main() {
sk_FragColor = half4(0);
do {
sk_FragColor += half4(0.125);
} while (shouldLoop(sk_FragColor));
}

View File

@ -0,0 +1,9 @@
inline half4 adjust(half4 v) {
return v + half4(0.125);
}
void main() {
sk_FragColor = half4(0);
for (int x=0; x<4; ++x)
sk_FragColor = adjust(sk_FragColor);
}

View File

@ -0,0 +1,18 @@
inline half4 initLoopVar() {
return half4(0.0625);
}
inline bool shouldLoop(half4 v) {
return v.x < 0.5;
}
inline half4 grow(half4 v) {
return v + half4(0.125);
}
void main() {
for (sk_FragColor = initLoopVar();
shouldLoop(sk_FragColor);
sk_FragColor = grow(sk_FragColor)) {
}
}

View File

@ -0,0 +1,12 @@
uniform int value;
inline half4 loopy(int v) {
for (int x=0; x<5; ++x) {
if (x == v) return half4(0.5);
}
return half4(1.0);
}
void main() {
sk_FragColor = loopy(value);
}

View File

@ -0,0 +1,13 @@
uniform int value;
inline half4 loopy(int v) {
half4 result = half4(1.0);
for (int x=0; x<5; ++x) {
if (x == v) result = half4(0.5);
}
return result;
}
void main() {
sk_FragColor = loopy(value);
}

View File

@ -0,0 +1,12 @@
uniform half4 color;
inline half4 ifBody() {
return color + half4(0.125);
}
void main() {
half4 c = color;
if (c.x >= 0.5)
c = ifBody();
sk_FragColor = c;
}

View File

@ -0,0 +1,14 @@
uniform half4 color;
inline half4 elseBody() {
return color + half4(0.125);
}
void main() {
half4 c = color;
if (c.x >= 0.5)
;
else
c = elseBody();
sk_FragColor = c;
}

View File

@ -0,0 +1,33 @@
// An if-else statement at the end of a function, with a return as the last statement on all
// paths, are not actually "early" returns. The inliner is able to recognize this pattern.
uniform half4 color;
inline half4 branchy(half4 c) {
c *= 0.5;
if (c.x > 0)
return c.xxxx;
else if (c.y > 0)
return c.yyyy;
else if (c.z > 0)
return c.zzzz;
else
return c.wwww;
}
inline half4 branchyAndBlocky(half4 c) {{{
if (c.x > 0) {
half4 d = c * 0.5;
return d.xxxx;
} else {{{
if (c.x < 0) {
return c.wwww;
} else {
return c.yyyy;
}
}}}
}}}
void main() {
sk_FragColor = branchy(color) * branchyAndBlocky(color);
}

View File

@ -0,0 +1,12 @@
uniform half4 color;
inline bool ifTest(half4 v) {
return color.x >= 0.5;
}
void main() {
if (ifTest(color))
sk_FragColor = half4(1.0);
else
sk_FragColor = half4(0.5);
}

View File

@ -0,0 +1,9 @@
uniform half4 color;
half4 branchy(half4 c) {
if (c.z == c.w) return c.yyyy; else return c.zzzz;
}
void main() {
sk_FragColor = branchy(color);
}

View File

@ -0,0 +1,10 @@
inline void tooBig(inout int x) {
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
}
void main() {
int y = 0;
tooBig(y);
tooBig(y);
}

View File

@ -0,0 +1,10 @@
void tooBig(inout int x) {
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
}
void main() {
int x = 0;
tooBig(x);
tooBig(x);
}

View File

@ -0,0 +1,9 @@
inline void outParameter(inout half x) {
x *= 2;
}
void main() {
half x = 1;
outParameter(x);
sk_FragColor.x = x;
}

View File

@ -0,0 +1,8 @@
inline half parameterWrite(half x) {
x *= 2;
return x;
}
void main() {
sk_FragColor.x = parameterWrite(1);
}

View File

@ -0,0 +1,19 @@
uniform half val;
inline half BigX(half x) {
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
--x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
x = 123;
return x;
}
inline half BigY(half x) {
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
--x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
x = 456;
return x;
}
void main() {
sk_FragColor = BigX(BigY(val)).xxxx;
}

View File

@ -0,0 +1,17 @@
void foo(out half x) {
++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x; ++x;
--x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x; --x;
x = 42;
}
half bar(half y) {
foo(y);
return y;
}
void main() {
half _1_y = 123; // the inliner shouldn't try to reuse this name
half z = 0;
bar(z);
sk_FragColor.x = z;
}

View File

@ -0,0 +1,9 @@
inline half basic(half x) {
return x * 2;
}
void main() {
sk_FragColor.x = basic(1);
half y = 2;
sk_FragColor.y = basic(y);
}

View File

@ -0,0 +1,11 @@
uniform half4 color;
half4 blocky(half4 c) {
{
return c;
}
}
void main() {
sk_FragColor = blocky(color);
}

View File

@ -1,14 +1,17 @@
in half2 x;
inline half2 InlineB(half2 tmp)
{
half2 reusedName = tmp + half2(3, 4);
return reusedName;
}
inline half2 InlineA()
{
half2 reusedName = x + half2(1, 2);
return InlineB(reusedName);
}
half4 main()
{
return InlineA().xyxy;

View File

@ -0,0 +1,21 @@
uniform half4 color;
half add(half a, half b) {
half c = a + b;
return c;
}
half mul(half a, half b) {
return a * b;
}
half fma(half a, half b, half c) {
return add(mul(a, b), c);
}
half4 main() {
half a = fma(color.x, color.y, color.z);
half b = fma(color.y, color.z, color.w);
half c = fma(color.z, color.w, color.x);
return half4(a, b, mul(c, c), mul(a, mul(b, c)));
}

View File

@ -0,0 +1,15 @@
uniform half4 color;
// TODO(johnstiles): the skslc standalone caps bits do not enable do-while support, so this test
// does not actually perform as described; the `returny` function is not inlined at all. This will
// be fixed when customizable caps-bit support is added to the golden tests.
inline half4 returny(half4 c) {
if (c.x > c.y) return c.xxxx;
if (c.y > c.z) return c.yyyy;
return c.zzzz;
}
void main() {
sk_FragColor = returny(color);
}

View File

@ -0,0 +1,19 @@
uniform half4 color;
inline bool testA(half4 v) {
return v.x <= 0.5;
}
inline bool testB(half4 v) {
return v.x > 0.5;
}
void main() {
sk_FragColor = half4(0);
if (testA(color) && testB(color)) {
sk_FragColor = half4(0.5);
}
if (testB(color) || testA(color)) {
sk_FragColor = half4(1.0);
}
}

View File

@ -0,0 +1,14 @@
uniform half4 color;
inline half4 switchy(half4 c) {
half4 result;
switch (int(c.x)) {
case 1: result = c.yyyy; break;
default: result = c.zzzz; break;
}
return result;
}
void main() {
sk_FragColor = switchy(color);
}

View File

@ -0,0 +1,12 @@
uniform int value;
inline half4 switchy(int v) {
switch (v) {
case 0: return half4(0.5);
}
return half4(1.0);
}
void main() {
sk_FragColor = switchy(value);
}

View File

@ -0,0 +1,13 @@
uniform int value;
inline half4 switchy(int v) {
half4 result = half4(1.0);
switch (v) {
case 0: result = half4(0.5);
}
return result;
}
void main() {
sk_FragColor = switchy(value);
}

View File

@ -0,0 +1,17 @@
uniform half4 color;
half count = 0;
inline half4 trueSide(half4 v) {
count += 1;
return half4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
}
inline half4 falseSide(half4 v) {
count += 1;
return half4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
}
void main() {
sk_FragColor = (color.x <= 0.5) ? trueSide(color) : falseSide(color);
sk_FragColor *= count;
}

View File

@ -0,0 +1,9 @@
uniform half4 color;
inline bool test(half4 v) {
return v.x <= 0.5;
}
void main() {
sk_FragColor = test(color) ? half4(0.5) : half4(1.0);
}

View File

@ -0,0 +1,9 @@
inline half4 adjust(half4 v) {
return v + half4(0.125);
}
void main() {
sk_FragColor = half4(0);
while (sk_FragColor.x < 0.5)
sk_FragColor = adjust(sk_FragColor);
}

View File

@ -0,0 +1,10 @@
inline bool shouldLoop(half4 v) {
return v.x < 0.5;
}
void main() {
sk_FragColor = half4(0);
while (shouldLoop(sk_FragColor)) {
sk_FragColor += half4(0.125);
}
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
sk_FragColor = vec4(0.0);
do {
mediump vec4 _0_adjust;
{
_0_adjust = sk_FragColor + vec4(0.125);
}
sk_FragColor = _0_adjust;
} while (sk_FragColor.x < 0.5);
}

View File

@ -0,0 +1,13 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
bool shouldLoop(mediump vec4 v) {
return v.x < 0.5;
}
void main() {
sk_FragColor = vec4(0.0);
do {
sk_FragColor += vec4(0.125);
} while (shouldLoop(sk_FragColor));
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
sk_FragColor = vec4(0.0);
for (highp int x = 0;x < 4; ++x) {
mediump vec4 _0_adjust;
{
_0_adjust = sk_FragColor + vec4(0.125);
}
sk_FragColor = _0_adjust;
}
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
bool shouldLoop(mediump vec4 v) {
return v.x < 0.5;
}
mediump vec4 grow(mediump vec4 v) {
return v + vec4(0.125);
}
void main() {
for (sk_FragColor = vec4(0.0625);
shouldLoop(sk_FragColor); sk_FragColor = grow(sk_FragColor)) {
}
}

View File

@ -0,0 +1,14 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform highp int value;
mediump vec4 loopy(highp int v) {
for (highp int x = 0;x < 5; ++x) {
if (x == v) return vec4(0.5);
}
return vec4(1.0);
}
void main() {
sk_FragColor = loopy(value);
}

View File

@ -0,0 +1,18 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform highp int value;
void main() {
mediump vec4 _0_loopy;
{
mediump vec4 _1_result = vec4(1.0);
for (highp int _2_x = 0;_2_x < 5; ++_2_x) {
if (_2_x == value) _1_result = vec4(0.5);
}
_0_loopy = _1_result;
}
sk_FragColor = _0_loopy;
}

View File

@ -0,0 +1,17 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 c = color;
if (c.x >= 0.5) {
mediump vec4 _0_ifBody;
{
_0_ifBody = color + vec4(0.125);
}
c = _0_ifBody;
}
sk_FragColor = c;
}

View File

@ -0,0 +1,18 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 c = color;
if (c.x >= 0.5) {
} else {
mediump vec4 _0_elseBody;
{
_0_elseBody = color + vec4(0.125);
}
c = _0_elseBody;
}
sk_FragColor = c;
}

View File

@ -0,0 +1,38 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 _0_branchy;
mediump vec4 _1_c = color;
{
_1_c *= 0.5;
if (_1_c.x > 0.0) _0_branchy = _1_c.xxxx; else if (_1_c.y > 0.0) _0_branchy = _1_c.yyyy; else if (_1_c.z > 0.0) _0_branchy = _1_c.zzzz; else _0_branchy = _1_c.wwww;
}
mediump vec4 _2_branchyAndBlocky;
{
{
{
if (color.x > 0.0) {
mediump vec4 _3_d = color * 0.5;
_2_branchyAndBlocky = _3_d.xxxx;
} else {
{
{
if (color.x < 0.0) {
_2_branchyAndBlocky = color.wwww;
} else {
_2_branchyAndBlocky = color.yyyy;
}
}
}
}
}
}
}
sk_FragColor = _0_branchy * _2_branchyAndBlocky;
}

View File

@ -0,0 +1,14 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
bool _0_ifTest;
{
_0_ifTest = color.x >= 0.5;
}
if (_0_ifTest) sk_FragColor = vec4(1.0); else sk_FragColor = vec4(0.5);
}

View File

@ -0,0 +1,14 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 _0_branchy;
{
if (color.z == color.w) _0_branchy = color.yyyy; else _0_branchy = color.zzzz;
}
sk_FragColor = _0_branchy;
}

View File

@ -0,0 +1,82 @@
precision mediump float;
precision mediump sampler2D;
void main() {
highp int y = 0;
{
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
}
{
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
++y;
}
}

View File

@ -0,0 +1,44 @@
precision mediump float;
precision mediump sampler2D;
void tooBig(inout highp int x) {
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
++x;
}
void main() {
highp int x = 0;
tooBig(x);
tooBig(x);
}

View File

@ -0,0 +1,13 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
mediump float x = 1.0;
{
x *= 2.0;
}
sk_FragColor.x = x;
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
mediump float _0_parameterWrite;
mediump float _1_x = 1.0;
{
_1_x *= 2.0;
_0_parameterWrite = _1_x;
}
sk_FragColor.x = _0_parameterWrite;
}

View File

@ -0,0 +1,87 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump float val;
void main() {
mediump float _1_x = val;
{
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
++_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
--_1_x;
_1_x = 456.0;
}
mediump float _3_x = 456.0;
{
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
++_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
--_3_x;
_3_x = 123.0;
}
sk_FragColor = vec4(123.0);
}

View File

@ -0,0 +1,50 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
mediump float _2_y = 0.0;
{
{
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
++_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
--_2_y;
_2_y = 42.0;
}
}
sk_FragColor.x = 0.0;
}

View File

@ -0,0 +1,10 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
sk_FragColor.x = 2.0;
sk_FragColor.y = 4.0;
}

View File

@ -0,0 +1,16 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 _0_blocky;
{
{
_0_blocky = color;
}
}
sk_FragColor = _0_blocky;
}

View File

@ -0,0 +1,89 @@
precision mediump float;
precision mediump sampler2D;
uniform mediump vec4 color;
mediump vec4 main() {
mediump float _3_fma;
mediump float _4_a = color.x;
mediump float _5_b = color.y;
mediump float _6_c = color.z;
{
mediump float _7_0_mul;
{
_7_0_mul = _4_a * _5_b;
}
mediump float _8_1_add;
{
mediump float _9_2_c = _7_0_mul + _6_c;
_8_1_add = _9_2_c;
}
_3_fma = _8_1_add;
}
mediump float a = _3_fma;
mediump float _10_fma;
mediump float _11_a = color.y;
mediump float _12_b = color.z;
mediump float _13_c = color.w;
{
mediump float _14_0_mul;
{
_14_0_mul = _11_a * _12_b;
}
mediump float _15_1_add;
{
mediump float _16_2_c = _14_0_mul + _13_c;
_15_1_add = _16_2_c;
}
_10_fma = _15_1_add;
}
mediump float b = _10_fma;
mediump float _17_fma;
mediump float _18_a = color.z;
mediump float _19_b = color.w;
mediump float _20_c = color.x;
{
mediump float _21_0_mul;
{
_21_0_mul = _18_a * _19_b;
}
mediump float _22_1_add;
{
mediump float _23_2_c = _21_0_mul + _20_c;
_22_1_add = _23_2_c;
}
_17_fma = _22_1_add;
}
mediump float c = _17_fma;
mediump float _24_mul;
{
_24_mul = c * c;
}
mediump float _25_mul;
{
_25_mul = b * c;
}
mediump float _26_mul;
{
_26_mul = a * _25_mul;
}
return vec4(a, b, _24_mul, _26_mul);
}

View File

@ -0,0 +1,13 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
mediump vec4 returny(mediump vec4 c) {
if (c.x > c.y) return c.xxxx;
if (c.y > c.z) return c.yyyy;
return c.zzzz;
}
void main() {
sk_FragColor = returny(color);
}

View File

@ -0,0 +1,32 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
bool testA(mediump vec4 v) {
return v.x <= 0.5;
}
bool testB(mediump vec4 v) {
return v.x > 0.5;
}
void main() {
sk_FragColor = vec4(0.0);
bool _0_testA;
{
_0_testA = color.x <= 0.5;
}
if (_0_testA && testB(color)) {
sk_FragColor = vec4(0.5);
}
bool _1_testB;
{
_1_testB = color.x > 0.5;
}
if (_1_testB || testA(color)) {
sk_FragColor = vec4(1.0);
}
}

View File

@ -0,0 +1,23 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
mediump vec4 _0_switchy;
{
mediump vec4 _1_result;
switch (int(color.x)) {
case 1:
_1_result = color.yyyy;
break;
default:
_1_result = color.zzzz;
break;
}
_0_switchy = _1_result;
}
sk_FragColor = _0_switchy;
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform highp int value;
mediump vec4 switchy(highp int v) {
switch (v) {
case 0:
return vec4(0.5);
}
return vec4(1.0);
}
void main() {
sk_FragColor = switchy(value);
}

View File

@ -0,0 +1,19 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform highp int value;
void main() {
mediump vec4 _0_switchy;
{
mediump vec4 _1_result = vec4(1.0);
switch (value) {
case 0:
_1_result = vec4(0.5);
}
_0_switchy = _1_result;
}
sk_FragColor = _0_switchy;
}

View File

@ -0,0 +1,18 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
mediump float count = 0.0;
mediump vec4 trueSide(mediump vec4 v) {
count += 1.0;
return vec4(sin(v.x), sin(v.y), sin(v.z), sin(v.w));
}
mediump vec4 falseSide(mediump vec4 v) {
count += 1.0;
return vec4(cos(v.y), cos(v.z), cos(v.w), cos(v.z));
}
void main() {
sk_FragColor = color.x <= 0.5 ? trueSide(color) : falseSide(color);
sk_FragColor *= count;
}

View File

@ -0,0 +1,14 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
uniform mediump vec4 color;
void main() {
bool _0_test;
{
_0_test = color.x <= 0.5;
}
sk_FragColor = _0_test ? vec4(0.5) : vec4(1.0);
}

View File

@ -0,0 +1,15 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
void main() {
sk_FragColor = vec4(0.0);
while (sk_FragColor.x < 0.5) {
mediump vec4 _0_adjust;
{
_0_adjust = sk_FragColor + vec4(0.125);
}
sk_FragColor = _0_adjust;
}
}

View File

@ -0,0 +1,13 @@
precision mediump float;
precision mediump sampler2D;
out mediump vec4 sk_FragColor;
bool shouldLoop(mediump vec4 v) {
return v.x < 0.5;
}
void main() {
sk_FragColor = vec4(0.0);
while (shouldLoop(sk_FragColor)) {
sk_FragColor += vec4(0.125);
}
}