skia2/tests/sksl/folding/MatrixFoldingES2.glsl
John Stiles 2ac7682b53 Implement constant-folding for vector/matrix multiplication.
This closes one of the last gaps in SkSL's constant-folding abilities.

Change-Id: I65c0f2e5fe11a7d47ab2069b2992403fca78b8a7
Bug: skia:12819
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524761
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-03-25 21:42:47 +00:00

54 lines
1.6 KiB
GLSL

out vec4 sk_FragColor;
uniform mat2 testMatrix2x2;
uniform vec4 colorRed;
uniform vec4 colorGreen;
uniform float unknownInput;
bool test_matrix_op_scalar_float_b() {
bool ok = true;
return ok;
}
bool test_matrix_op_scalar_half_b() {
bool ok = true;
return ok;
}
bool test_matrix_op_matrix_float_b() {
bool ok = true;
return ok;
}
bool test_matrix_op_matrix_half_b() {
bool ok = true;
return ok;
}
bool test_vector_op_matrix_float_b() {
bool ok = true;
return ok;
}
bool test_vector_op_matrix_half_b() {
bool ok = true;
return ok;
}
bool test_matrix_op_vector_float_b() {
bool ok = true;
return ok;
}
bool test_matrix_op_vector_half_b() {
bool ok = true;
return ok;
}
vec4 main() {
bool _0_ok = true;
_0_ok = _0_ok && mat3(unknownInput) == mat3(mat2(1.0));
_0_ok = _0_ok && mat3(9.0, 0.0, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, unknownInput) == mat3(mat2(9.0));
_0_ok = _0_ok && vec4(testMatrix2x2) == vec4(1.0, 2.0, 3.0, 4.0);
{
float _3_five = 5.0;
_0_ok = _0_ok && mat3(1.0, 2.0, 3.0, 4.0, _3_five, 6.0, 7.0, 8.0, 9.0)[1] == vec3(4.0, _3_five, 6.0);
}
{
_0_ok = _0_ok && mat4(mat3(testMatrix2x2))[0] == vec4(1.0, 2.0, 0.0, 0.0);
_0_ok = _0_ok && mat4(mat3(testMatrix2x2))[1] == vec4(3.0, 4.0, 0.0, 0.0);
}
return (((((((_0_ok && test_matrix_op_scalar_float_b()) && test_matrix_op_scalar_half_b()) && test_matrix_op_matrix_float_b()) && test_matrix_op_matrix_half_b()) && test_vector_op_matrix_float_b()) && test_vector_op_matrix_half_b()) && test_matrix_op_vector_float_b()) && test_matrix_op_vector_half_b() ? colorGreen : colorRed;
}