xref: /aosp_15_r20/external/skia/tests/sksl/shared/MatricesNonsquare.glsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1
2out vec4 sk_FragColor;
3uniform vec4 colorGreen;
4uniform vec4 colorRed;
5bool test_half_b() {
6    bool ok = true;
7    mat2x3 m23 = mat2x3(2.0);
8    ok = ok && m23 == mat2x3(2.0, 0.0, 0.0, 0.0, 2.0, 0.0);
9    mat2x4 m24 = mat2x4(3.0);
10    ok = ok && m24 == mat2x4(3.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0);
11    mat3x2 m32 = mat3x2(4.0);
12    ok = ok && m32 == mat3x2(4.0, 0.0, 0.0, 4.0, 0.0, 0.0);
13    mat3x4 m34 = mat3x4(5.0);
14    ok = ok && m34 == mat3x4(5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0);
15    mat4x2 m42 = (mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * 6.0);
16    ok = ok && m42 == mat4x2(6.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0);
17    mat4x3 m43 = mat4x3(7.0);
18    ok = ok && m43 == mat4x3(7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0);
19    mat2 m22 = m32 * m23;
20    ok = ok && m22 == mat2(8.0);
21    mat3 m33 = m43 * m34;
22    ok = ok && m33 == mat3(35.0);
23    m23 += 1.0;
24    ok = ok && m23 == mat2x3(3.0, 1.0, 1.0, 1.0, 3.0, 1.0);
25    m32 -= 2.0;
26    ok = ok && m32 == mat3x2(2.0, -2.0, -2.0, 2.0, -2.0, -2.0);
27    m24 *= 0.25;
28    ok = ok && m24 == mat2x4(0.75, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0);
29    return ok;
30}
31vec4 main() {
32    bool _0_ok = true;
33    mat2x3 _1_m23 = mat2x3(2.0);
34    _0_ok = _0_ok && _1_m23 == mat2x3(2.0, 0.0, 0.0, 0.0, 2.0, 0.0);
35    mat2x4 _2_m24 = mat2x4(3.0);
36    _0_ok = _0_ok && _2_m24 == mat2x4(3.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0);
37    mat3x2 _3_m32 = mat3x2(4.0);
38    _0_ok = _0_ok && _3_m32 == mat3x2(4.0, 0.0, 0.0, 4.0, 0.0, 0.0);
39    mat2 _7_m22 = _3_m32 * _1_m23;
40    _0_ok = _0_ok && _7_m22 == mat2(8.0);
41    _1_m23 += 1.0;
42    _0_ok = _0_ok && _1_m23 == mat2x3(3.0, 1.0, 1.0, 1.0, 3.0, 1.0);
43    _3_m32 -= 2.0;
44    _0_ok = _0_ok && _3_m32 == mat3x2(2.0, -2.0, -2.0, 2.0, -2.0, -2.0);
45    _2_m24 *= 0.25;
46    _0_ok = _0_ok && _2_m24 == mat2x4(0.75, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0);
47    return _0_ok && test_half_b() ? colorGreen : colorRed;
48}
49