xref: /aosp_15_r20/external/skia/tests/sksl/shared/UnaryPositiveNegative.glsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker
2*c8dee2aaSAndroid Build Coastguard Workerout vec4 sk_FragColor;
3*c8dee2aaSAndroid Build Coastguard Workeruniform vec4 colorWhite;
4*c8dee2aaSAndroid Build Coastguard Workeruniform vec4 colorGreen;
5*c8dee2aaSAndroid Build Coastguard Workeruniform vec4 colorRed;
6*c8dee2aaSAndroid Build Coastguard Workeruniform mat2 testMatrix2x2;
7*c8dee2aaSAndroid Build Coastguard Workeruniform mat3 testMatrix3x3;
8*c8dee2aaSAndroid Build Coastguard Workeruniform mat4 testMatrix4x4;
9*c8dee2aaSAndroid Build Coastguard Workerbool test_iscalar_b() {
10*c8dee2aaSAndroid Build Coastguard Worker    int x = int(colorWhite.x);
11*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
12*c8dee2aaSAndroid Build Coastguard Worker    return x == -1;
13*c8dee2aaSAndroid Build Coastguard Worker}
14*c8dee2aaSAndroid Build Coastguard Workerbool test_fvec_b() {
15*c8dee2aaSAndroid Build Coastguard Worker    vec2 x = colorWhite.xy;
16*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
17*c8dee2aaSAndroid Build Coastguard Worker    return x == vec2(-1.0);
18*c8dee2aaSAndroid Build Coastguard Worker}
19*c8dee2aaSAndroid Build Coastguard Workerbool test_ivec_b() {
20*c8dee2aaSAndroid Build Coastguard Worker    ivec2 x = ivec2(int(colorWhite.x));
21*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
22*c8dee2aaSAndroid Build Coastguard Worker    return x == ivec2(-1);
23*c8dee2aaSAndroid Build Coastguard Worker}
24*c8dee2aaSAndroid Build Coastguard Workerbool test_mat2_b() {
25*c8dee2aaSAndroid Build Coastguard Worker    const mat2 negated = mat2(-1.0, -2.0, -3.0, -4.0);
26*c8dee2aaSAndroid Build Coastguard Worker    mat2 x = testMatrix2x2;
27*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
28*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
29*c8dee2aaSAndroid Build Coastguard Worker}
30*c8dee2aaSAndroid Build Coastguard Workerbool test_mat3_b() {
31*c8dee2aaSAndroid Build Coastguard Worker    const mat3 negated = mat3(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0);
32*c8dee2aaSAndroid Build Coastguard Worker    mat3 x = testMatrix3x3;
33*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
34*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
35*c8dee2aaSAndroid Build Coastguard Worker}
36*c8dee2aaSAndroid Build Coastguard Workerbool test_mat4_b() {
37*c8dee2aaSAndroid Build Coastguard Worker    const mat4 negated = mat4(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0);
38*c8dee2aaSAndroid Build Coastguard Worker    mat4 x = testMatrix4x4;
39*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
40*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
41*c8dee2aaSAndroid Build Coastguard Worker}
42*c8dee2aaSAndroid Build Coastguard Workerbool test_hmat2_b() {
43*c8dee2aaSAndroid Build Coastguard Worker    const mat2 negated = mat2(-1.0, -2.0, -3.0, -4.0);
44*c8dee2aaSAndroid Build Coastguard Worker    mat2 x = testMatrix2x2;
45*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
46*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
47*c8dee2aaSAndroid Build Coastguard Worker}
48*c8dee2aaSAndroid Build Coastguard Workerbool test_hmat3_b() {
49*c8dee2aaSAndroid Build Coastguard Worker    const mat3 negated = mat3(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0);
50*c8dee2aaSAndroid Build Coastguard Worker    mat3 x = testMatrix3x3;
51*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
52*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
53*c8dee2aaSAndroid Build Coastguard Worker}
54*c8dee2aaSAndroid Build Coastguard Workerbool test_hmat4_b() {
55*c8dee2aaSAndroid Build Coastguard Worker    const mat4 negated = mat4(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0);
56*c8dee2aaSAndroid Build Coastguard Worker    mat4 x = testMatrix4x4;
57*c8dee2aaSAndroid Build Coastguard Worker    x = -x;
58*c8dee2aaSAndroid Build Coastguard Worker    return x == negated;
59*c8dee2aaSAndroid Build Coastguard Worker}
60*c8dee2aaSAndroid Build Coastguard Workervec4 main() {
61*c8dee2aaSAndroid Build Coastguard Worker    float _0_x = colorWhite.x;
62*c8dee2aaSAndroid Build Coastguard Worker    _0_x = -_0_x;
63*c8dee2aaSAndroid Build Coastguard Worker    return ((((((((_0_x == -1.0 && test_iscalar_b()) && test_fvec_b()) && test_ivec_b()) && test_mat2_b()) && test_mat3_b()) && test_mat4_b()) && test_hmat2_b()) && test_hmat3_b()) && test_hmat4_b() ? colorGreen : colorRed;
64*c8dee2aaSAndroid Build Coastguard Worker}
65