skia2/tests/sksl/folding/VectorVectorFolding.glsl
John Stiles 92748af1a5 Inline functions of the form 'return (expr)' only.
This drastically reduces the number of functions which we allow to be
inlined. If this change does not hurt our performance, it will allow us
to trivially remove hundreds of LOC. All current data leads us to
believe that it may affect the Mali 400 but is highly unlikely to change
results on any other device in the tree.

More info: http://go/optimization-in-sksl-inliner

Change-Id: Ia6b706742ce5407453e0e697b6c1f9201084c0e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384858
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-15 19:46:46 +00:00

41 lines
956 B
GLSL

out vec4 sk_FragColor;
uniform float unknownInput;
uniform vec4 colorRed;
uniform vec4 colorGreen;
bool test_half() {
float unknown = unknownInput;
bool ok = true;
vec4 val = vec4(unknown);
val += vec4(1.0);
val -= vec4(1.0);
val = val + vec4(1.0);
val = val - vec4(1.0);
ok = ok && val == vec4(unknown);
val *= vec4(2.0);
val /= vec4(2.0);
val = val * vec4(2.0);
val = val / vec4(2.0);
ok = ok && val == vec4(unknown);
return ok;
}
bool test_int() {
int unknown = int(unknownInput);
bool ok = true;
ivec4 val = ivec4(unknown);
val += ivec4(1);
val -= ivec4(1);
val = val + ivec4(1);
val = val - ivec4(1);
ok = ok && val == ivec4(unknown);
val *= ivec4(2);
val /= ivec4(2);
val = val * ivec4(2);
val = val / ivec4(2);
ok = ok && val == ivec4(unknown);
return ok;
}
vec4 main() {
return test_half() && test_int() ? colorGreen : colorRed;
}