Home | History | Annotate | Download | only in shaders
      1 group trivial "Trivial expressions"
      2 
      3 	case float
      4 		values { output float out0 = 5.0; }
      5 		both ""
      6 
      7 			precision highp float;
      8 			${DECLARATIONS}
      9 
     10 			void main()
     11 			{
     12 				const float a = 5.0;
     13 				out0 = a;
     14 				${OUTPUT}
     15 			}
     16 		""
     17 	end
     18 
     19 	case int
     20 		values { output int out0 = 5; }
     21 		both ""
     22 			precision highp float;
     23 			${DECLARATIONS}
     24 
     25 			void main()
     26 			{
     27 				const int a = 5;
     28 				out0 = a;
     29 				${OUTPUT}
     30 			}
     31 		""
     32 	end
     33 
     34 	case bool
     35 		values { output bool out0 = true; }
     36 		both ""
     37 			precision highp float;
     38 			${DECLARATIONS}
     39 
     40 			void main()
     41 			{
     42 				const bool a = true;
     43 				out0 = a;
     44 				${OUTPUT}
     45 			}
     46 		""
     47 	end
     48 
     49 	case cast
     50 		values { output float out0 = 1.0; }
     51 		both ""
     52 			precision highp float;
     53 			${DECLARATIONS}
     54 
     55 			void main()
     56 			{
     57 				const float a = float(int(bool(true)));
     58 				out0 = a;
     59 				${OUTPUT}
     60 			}
     61 		""
     62 	end
     63 
     64 end # trivial
     65 
     66 group operators "Operators"
     67 
     68 	case math_float
     69 		values { output float out0 = 2.19; }
     70 		both ""
     71 			precision highp float;
     72 			${DECLARATIONS}
     73 
     74 			void main()
     75 			{
     76 				const float a = 6.0/3.5 + 1.8*2.6 - 4.2;
     77 				out0 = a;
     78 				${OUTPUT}
     79 			}
     80 		""
     81 	end
     82 
     83 	case math_vec
     84 		values { output float out0 = 15.0; }
     85 		both ""
     86 			precision highp float;
     87 			${DECLARATIONS}
     88 
     89 			void main()
     90 			{
     91 				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;
     92 				out0 = a.x + a.y + a.z;
     93 				${OUTPUT}
     94 			}
     95 		""
     96 	end
     97 
     98 	case math_int
     99 		values { output int out0 = 7; }
    100 		both ""
    101 			precision highp int;
    102 			${DECLARATIONS}
    103 
    104 			void main()
    105 			{
    106 				const int a = 5-1 + 2*3 - 9/3;
    107 				out0 = a;
    108 				${OUTPUT}
    109 			}
    110 		""
    111 	end
    112 
    113 	case math_ivec
    114 		values { output int out0 = 21; }
    115 		both ""
    116 			precision highp int;
    117 			${DECLARATIONS}
    118 
    119 			void main()
    120 			{
    121 				const ivec3 a = ivec2(5-1, 4).xxy + ivec4(1*3, 9/3, 1+2, 8/4).xyz;
    122 				out0 = a.x + a.y + a.z;
    123 				${OUTPUT}
    124 			}
    125 		""
    126 	end
    127 
    128 	case math_mat
    129 		values { output float out0 = 8.0; }
    130 		both ""
    131 			precision highp float;
    132 			${DECLARATIONS}
    133 
    134 			void main()
    135 			{
    136 				const mat3 a = mat3(3.0) * mat3(4.0);
    137 				const mat4 b = mat4(a[1][1])*2.0;
    138 				const mat2 c = mat2(b[0][0]) / 3.0;
    139 				out0 = c[0][0]+c[1][0];
    140 				${OUTPUT}
    141 			}
    142 		""
    143 	end
    144 
    145 	case logical
    146 		values { output bool out0 = true; }
    147 		both ""
    148 			precision highp int;
    149 			${DECLARATIONS}
    150 
    151 			void main()
    152 			{
    153 				const bool a = (!false || false) && (true ^^ false);
    154 				out0 = a;
    155 				${OUTPUT}
    156 			}
    157 		""
    158 	end
    159 
    160 	case compare
    161 		values { output bool out0 = true; }
    162 		both ""
    163 			precision highp int;
    164 			${DECLARATIONS}
    165 
    166 			void main()
    167 			{
    168 				const bool a = (false == false) && (true != false) && (1 < 2) && (3 <= 3) && ((1 > 1) != (1 >= 1));
    169 				out0 = a;
    170 				${OUTPUT}
    171 			}
    172 		""
    173 	end
    174 
    175 	case selection
    176 		values { output float out0 = 5.3; }
    177 		both ""
    178 			precision highp float;
    179 			${DECLARATIONS}
    180 
    181 			void main()
    182 			{
    183 				const float a = false ? 0.0 : (true ? 5.3 : 1.0);
    184 				out0 = a;
    185 				${OUTPUT}
    186 			}
    187 		""
    188 	end
    189 
    190 end # operators
    191 
    192 group complex_types "Arrays, structs & nested calls"
    193 
    194 	case struct
    195 		values { output float out0 = 260.922; }
    196 		both ""
    197 			precision highp float;
    198 			${DECLARATIONS}
    199 
    200 			struct S
    201 			{
    202 				vec4 a;
    203 				int  b;
    204 			};
    205 
    206 			void main()
    207 			{
    208 				const S s = S(vec4(1.5), 123);
    209 				out0 = length(s.a.xy)*float(s.b);
    210 				${OUTPUT}
    211 			}
    212 		""
    213 	end
    214 
    215 	case nested_struct
    216 		values { output float out0 = 965.9; }
    217 		both ""
    218 			precision highp float;
    219 			${DECLARATIONS}
    220 
    221 			struct S
    222 			{
    223 				vec4 v;
    224 				int  i;
    225 			};
    226 
    227 			struct T
    228 			{
    229 				S s;
    230 				bool b;
    231 				int i;
    232 			};
    233 
    234 			struct U
    235 			{
    236 				S s;
    237 				T t;
    238 			};
    239 
    240 			void main()
    241 			{
    242 				const S s = S(vec4(1.5), 123);
    243 				const T t = T(s, false, 3);
    244 				const U u = U(s, t);
    245 				const U v = U(S(vec4(1.3), 4), T(S(vec4(2.0), 5), true, 6));
    246 				out0 = float(u.s.i*v.t.i + v.t.s.i)*v.s.v.x; // float(123*6 + 5)*1.3
    247 				${OUTPUT}
    248 			}
    249 		""
    250 	end
    251 
    252 	case array
    253 		values
    254 		{
    255 			input float in0 = [ 0.0 | 1.0];
    256 			output float out0 = [0.0 | 1.0];
    257 		}
    258 		both ""
    259 			precision highp float;
    260 			${DECLARATIONS}
    261 
    262 			void main()
    263 			{
    264 				float a[int(max(-1.0, 2.0))];
    265 				a[0] = -1.0;
    266 				a[1] = in0;
    267 				out0 = a[int(min(1.0, 2.0))];
    268 				${OUTPUT}
    269 			}
    270 		""
    271 	end
    272 
    273 	case nested_builtin_funcs
    274 		values { output float out0 = 3.05; }
    275 		both ""
    276 			precision highp float;
    277 			${DECLARATIONS}
    278 
    279 			void main()
    280 			{
    281 				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*/);
    282 				out0 = a;
    283 				${OUTPUT}
    284 			}
    285 		""
    286 	end
    287 
    288 end # complex_types
    289