| group trivial "Trivial expressions" | |
| case float | |
| version 300 es | |
| values { output float out0 = 5.0; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a = 5.0; | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case int | |
| version 300 es | |
| values { output int out0 = 5; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int a = 5; | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case bool | |
| version 300 es | |
| values { output bool out0 = true; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const bool a = true; | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case cast | |
| version 300 es | |
| values { output float out0 = 1.0; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a = float(int(bool(true))); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| end # trivial | |
| group operators "Operators" | |
| case math_float | |
| version 300 es | |
| values { output float out0 = 2.19; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a = 6.0/3.5 + 1.8*2.6 - 4.2; | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case math_vec | |
| version 300 es | |
| values { output float out0 = 15.0; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const vec3 a = (vec4(1.0, 2.0, 3.0, 4.0).zyx * vec3(1.0, 1.5, 3.0).xyz).xzy + (vec2(5.0)/vec2(2.5)).xxy; | |
| out0 = a.x + a.y + a.z; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case math_int | |
| version 300 es | |
| values { output int out0 = 7; } | |
| both "" | |
| #version 300 es | |
| precision highp int; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int a = 25%7 + 2*3 - 9/3; | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case math_ivec | |
| version 300 es | |
| values { output int out0 = 21; } | |
| both "" | |
| #version 300 es | |
| precision highp int; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const ivec3 a = ivec2(25%7, 4).xxy + ivec4(1*3, 9/3, 1+2, 8/4).xyz; | |
| out0 = a.x + a.y + a.z; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case math_mat | |
| version 300 es | |
| values { output float out0 = 8.0; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const mat3 a = mat3(3.0) * mat3(4.0); | |
| const mat4 b = mat4(a[1][1])*2.0; | |
| const mat2 c = mat2(b[0][0]) / 3.0; | |
| out0 = c[0][0]+c[1][0]; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case bitwise | |
| version 300 es | |
| values { output int out0 = 678332; } | |
| both "" | |
| #version 300 es | |
| precision highp int; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int a = (((0xABBA<<4) ^ 0xCAFE) | (0xDCBA & (0xABCD>>2))) ^ (~0xDEAD & 0xBEEF); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case logical | |
| version 300 es | |
| values { output bool out0 = true; } | |
| both "" | |
| #version 300 es | |
| precision highp int; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const bool a = (!false || false) && (true ^^ false); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case compare | |
| version 300 es | |
| values { output bool out0 = true; } | |
| both "" | |
| #version 300 es | |
| precision highp int; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const bool a = (false == false) && (true != false) && (1 < 2) && (3 <= 3) && ((1 > 1) != (1 >= 1)); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case selection | |
| version 300 es | |
| values { output float out0 = 5.3; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a = false ? 0.0 : (true ? 5.3 : 1.0); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| end # operators | |
| group complex_types "Arrays & Structs" | |
| case struct | |
| version 300 es | |
| values { output float out0 = 260.922; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| struct S | |
| { | |
| vec4 a; | |
| int b; | |
| }; | |
| void main() | |
| { | |
| const S s = S(vec4(1.5), 123); | |
| out0 = length(s.a.xy)*float(s.b); | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case nested_struct | |
| version 300 es | |
| values { output float out0 = 965.9; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| struct S | |
| { | |
| vec4 v; | |
| int i; | |
| }; | |
| struct T | |
| { | |
| S s; | |
| bool b; | |
| int i; | |
| }; | |
| struct U | |
| { | |
| S s; | |
| T t; | |
| }; | |
| void main() | |
| { | |
| const S s = S(vec4(1.5), 123); | |
| const T t = T(s, false, 3); | |
| const U u = U(s, t); | |
| const U v = U(S(vec4(1.3), 4), T(S(vec4(2.0), 5), true, 6)); | |
| out0 = float(u.s.i*v.t.i + v.t.s.i)*v.s.v.x; // float(123*6 + 5)*1.3 | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case array_size | |
| version 300 es | |
| values { output int out0 = 1; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int a[max(-1, 1)] = int[1](1); | |
| out0 = a[0]; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case array_length | |
| version 300 es | |
| values { output int out0 = 2; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int a[1] = int[1](1); | |
| out0 = a.length() + a[0]; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case array | |
| version 300 es | |
| values { output float out0 = 4.0; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a[1+2+5] = float[8](0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0); | |
| const float f = a[1+2+4]; | |
| out0 = f + float(a.length()-8); | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| end # complex_types | |
| group other "Other operations" | |
| case switch_case | |
| version 300 es | |
| values | |
| { | |
| input float in0 = [ 0.0 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 ]; | |
| output int out0 = [ 0 | 1 | 2 | 3 | 4 | 10]; | |
| } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const int _0 = 0; | |
| const int _1 = 1; | |
| const int _2 = 2; | |
| const int _3 = 3; | |
| const int _4 = 4; | |
| switch(int(in0)) | |
| { | |
| case _0: | |
| out0 = 0; | |
| break; | |
| case _1: | |
| out0 = 1; | |
| break; | |
| case _2: | |
| out0 = 2; | |
| break; | |
| case _3: | |
| out0 = 3; | |
| break; | |
| case _4: | |
| out0 = 4; | |
| break; | |
| case 5: | |
| out0 = 10; | |
| break; | |
| default: | |
| out0 = 100; | |
| } | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case nested_builtin_funcs | |
| version 300 es | |
| values { output float out0 = 3.05; } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| void main() | |
| { | |
| const float a = sqrt( atan(sin(1.5)/cos(1.5)) /*1.5*/ * log2(exp2(log(exp(6.2) + 0.1)) + 0.1) /*~6.2*/); | |
| out0 = a; | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| case complex | |
| version 300 es | |
| values | |
| { | |
| input float in0 = [ 0.0 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 ]; | |
| output int out0 = [ 0 | 1 | 2 | 3 | 4 | 10]; | |
| } | |
| both "" | |
| #version 300 es | |
| precision highp float; | |
| ${DECLARATIONS} | |
| struct T | |
| { | |
| vec4 v; | |
| }; | |
| struct S | |
| { | |
| T t; | |
| int i; | |
| bool b; | |
| }; | |
| void main() | |
| { | |
| const T t = T(vec4(1.0)); | |
| const S s = S(t, 42, true); | |
| const int _0 = int(sin(0.0)); | |
| const int _1 = int(1.0); | |
| const int _2 = 2 + int(float(_0>_1)); | |
| const int _3 = min(gl_MaxVertexAttribs, 16)/4 - 1; | |
| const int _4 = min(gl_MaxDrawBuffers, 4); | |
| const ivec4 nums = ivec4(0, 1, 2, 3); | |
| switch(int(in0)) | |
| { | |
| case int(float(_0)): | |
| out0 = ((true!=false) && (!false)) ? 0 : 25; | |
| break; | |
| case ivec3(_1).x: | |
| out0 = 3*18/9-5; | |
| break; | |
| case nums[_2]: | |
| out0 = int(length(vec4(1.0))+0.001); | |
| break; | |
| case _3: | |
| out0 = 3; | |
| break; | |
| case clamp(_4, 1, 6): | |
| out0 = (s.i-2)/10; | |
| break; | |
| case max(3, 5): | |
| out0 = 10; | |
| break; | |
| default: | |
| out0 = 100; | |
| } | |
| ${OUTPUT} | |
| } | |
| "" | |
| end | |
| end |