skia2/tests/sksl/shared/Matrices.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

44 lines
1.0 KiB
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
bool test_float() {
vec3 v1 = mat3(1.0) * vec3(2.0);
vec3 v2 = vec3(2.0) * mat3(1.0);
mat2 m1 = mat2(1.0, 2.0, 3.0, 4.0);
mat2 m2 = mat2(vec4(0.0));
mat2 m3 = m1;
mat2 m4 = mat2(1.0);
m3 *= m4;
mat2 m5 = mat2(m1[0].x);
mat2 m6 = mat2(1.0, 2.0, 3.0, 4.0);
m6 += m5;
mat2 m7 = mat2(5.0, 6.0, 7.0, 8.0);
mat3 m9 = mat3(1.0);
mat4 m10 = mat4(1.0);
mat4 m11 = mat4(2.0);
m11 -= m10;
return true;
}
bool test_half() {
vec3 v1 = mat3(1.0) * vec3(2.0);
vec3 v2 = vec3(2.0) * mat3(1.0);
mat2 m1 = mat2(1.0, 2.0, 3.0, 4.0);
mat2 m2 = mat2(vec4(0.0));
mat2 m3 = m1;
mat2 m4 = mat2(1.0);
m3 *= m4;
mat2 m5 = mat2(m1[0].x);
mat2 m6 = mat2(1.0, 2.0, 3.0, 4.0);
m6 += m5;
mat2 m7 = mat2(5.0, 6.0, 7.0, 8.0);
mat3 m9 = mat3(1.0);
mat4 m10 = mat4(1.0);
mat4 m11 = mat4(2.0);
m11 -= m10;
return true;
}
vec4 main() {
return test_float() && test_half() ? colorGreen : colorRed;
}