1 2out vec4 sk_FragColor; 3uniform vec4 colorRed; 4uniform vec4 colorGreen; 5bool test_matrix_op_matrix_half_b() { 6 bool ok = true; 7 { 8 const mat3 splat_4 = mat3(4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0); 9 const mat3 splat_2 = mat3(2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0); 10 mat3 m; 11 m = mat3(2.0); 12 m += splat_4; 13 ok = ok && m == mat3(6.0, 4.0, 4.0, 4.0, 6.0, 4.0, 4.0, 4.0, 6.0); 14 m = mat3(2.0); 15 m -= splat_4; 16 ok = ok && m == mat3(-2.0, -4.0, -4.0, -4.0, -2.0, -4.0, -4.0, -4.0, -2.0); 17 m = mat3(2.0); 18 m /= splat_4; 19 ok = ok && m == mat3(0.5); 20 m = splat_4; 21 m += mat3(2.0); 22 ok = ok && m == mat3(6.0, 4.0, 4.0, 4.0, 6.0, 4.0, 4.0, 4.0, 6.0); 23 m = splat_4; 24 m -= mat3(2.0); 25 ok = ok && m == mat3(2.0, 4.0, 4.0, 4.0, 2.0, 4.0, 4.0, 4.0, 2.0); 26 m = splat_4; 27 m /= splat_2; 28 ok = ok && m == mat3(2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0); 29 } 30 { 31 mat4 m = 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); 32 m += mat4(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); 33 ok = ok && m == mat4(17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0); 34 } 35 { 36 mat2 m = mat2(10.0, 20.0, 30.0, 40.0); 37 m -= mat2(1.0, 2.0, 3.0, 4.0); 38 ok = ok && m == mat2(9.0, 18.0, 27.0, 36.0); 39 } 40 { 41 mat2 m = mat2(2.0, 4.0, 6.0, 8.0); 42 m /= mat2(2.0, 2.0, 2.0, 4.0); 43 ok = ok && m == mat2(1.0, 2.0, 3.0, 2.0); 44 } 45 { 46 mat2 m = mat2(1.0, 2.0, 7.0, 4.0); 47 m *= mat2(3.0, 5.0, 3.0, 2.0); 48 ok = ok && m == mat2(38.0, 26.0, 17.0, 14.0); 49 } 50 { 51 mat3 m = mat3(10.0, 4.0, 2.0, 20.0, 5.0, 3.0, 10.0, 6.0, 5.0); 52 m *= mat3(3.0, 3.0, 4.0, 2.0, 3.0, 4.0, 4.0, 9.0, 2.0); 53 ok = ok && m == mat3(130.0, 51.0, 35.0, 120.0, 47.0, 33.0, 240.0, 73.0, 45.0); 54 } 55 return ok; 56} 57vec4 main() { 58 bool _0_ok = true; 59 { 60 const mat3 _1_splat_4 = mat3(4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0); 61 const mat3 _2_splat_2 = mat3(2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0); 62 mat3 _3_m; 63 _3_m = mat3(2.0); 64 _3_m += _1_splat_4; 65 _0_ok = _0_ok && _3_m == mat3(6.0, 4.0, 4.0, 4.0, 6.0, 4.0, 4.0, 4.0, 6.0); 66 _3_m = mat3(2.0); 67 _3_m -= _1_splat_4; 68 _0_ok = _0_ok && _3_m == mat3(-2.0, -4.0, -4.0, -4.0, -2.0, -4.0, -4.0, -4.0, -2.0); 69 _3_m = mat3(2.0); 70 _3_m /= _1_splat_4; 71 _0_ok = _0_ok && _3_m == mat3(0.5); 72 _3_m = _1_splat_4; 73 _3_m += mat3(2.0); 74 _0_ok = _0_ok && _3_m == mat3(6.0, 4.0, 4.0, 4.0, 6.0, 4.0, 4.0, 4.0, 6.0); 75 _3_m = _1_splat_4; 76 _3_m -= mat3(2.0); 77 _0_ok = _0_ok && _3_m == mat3(2.0, 4.0, 4.0, 4.0, 2.0, 4.0, 4.0, 4.0, 2.0); 78 _3_m = _1_splat_4; 79 _3_m /= _2_splat_2; 80 _0_ok = _0_ok && _3_m == mat3(2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0); 81 } 82 { 83 mat4 _4_m = 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); 84 _4_m += mat4(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); 85 _0_ok = _0_ok && _4_m == mat4(17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0); 86 } 87 { 88 mat2 _5_m = mat2(10.0, 20.0, 30.0, 40.0); 89 _5_m -= mat2(1.0, 2.0, 3.0, 4.0); 90 _0_ok = _0_ok && _5_m == mat2(9.0, 18.0, 27.0, 36.0); 91 } 92 { 93 mat2 _6_m = mat2(2.0, 4.0, 6.0, 8.0); 94 _6_m /= mat2(2.0, 2.0, 2.0, 4.0); 95 _0_ok = _0_ok && _6_m == mat2(1.0, 2.0, 3.0, 2.0); 96 } 97 { 98 mat2 _7_m = mat2(1.0, 2.0, 7.0, 4.0); 99 _7_m *= mat2(3.0, 5.0, 3.0, 2.0); 100 _0_ok = _0_ok && _7_m == mat2(38.0, 26.0, 17.0, 14.0); 101 } 102 { 103 mat3 _8_m = mat3(10.0, 4.0, 2.0, 20.0, 5.0, 3.0, 10.0, 6.0, 5.0); 104 _8_m *= mat3(3.0, 3.0, 4.0, 2.0, 3.0, 4.0, 4.0, 9.0, 2.0); 105 _0_ok = _0_ok && _8_m == mat3(130.0, 51.0, 35.0, 120.0, 47.0, 33.0, 240.0, 73.0, 45.0); 106 } 107 return _0_ok && test_matrix_op_matrix_half_b() ? colorGreen : colorRed; 108} 109