• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1group trivial "Trivial expressions"
2
3	case float
4		version 300 es
5		values { output float out0 = 5.0; }
6		both ""
7			#version 300 es
8			precision highp float;
9			${DECLARATIONS}
10
11			void main()
12			{
13				const float a = 5.0;
14				out0 = a;
15				${OUTPUT}
16			}
17		""
18	end
19
20	case int
21		version 300 es
22		values { output int out0 = 5; }
23		both ""
24			#version 300 es
25			precision highp float;
26			${DECLARATIONS}
27
28			void main()
29			{
30				const int a = 5;
31				out0 = a;
32				${OUTPUT}
33			}
34		""
35	end
36
37	case bool
38		version 300 es
39		values { output bool out0 = true; }
40		both ""
41			#version 300 es
42			precision highp float;
43			${DECLARATIONS}
44
45			void main()
46			{
47				const bool a = true;
48				out0 = a;
49				${OUTPUT}
50			}
51		""
52	end
53
54	case cast
55		version 300 es
56		values { output float out0 = 1.0; }
57		both ""
58			#version 300 es
59			precision highp float;
60			${DECLARATIONS}
61
62			void main()
63			{
64				const float a = float(int(bool(true)));
65				out0 = a;
66				${OUTPUT}
67			}
68		""
69	end
70
71end # trivial
72
73group operators "Operators"
74
75	case math_float
76		version 300 es
77		values { output float out0 = 2.19; }
78		both ""
79			#version 300 es
80			precision highp float;
81			${DECLARATIONS}
82
83			void main()
84			{
85				const float a = 6.0/3.5 + 1.8*2.6 - 4.2;
86				out0 = a;
87				${OUTPUT}
88			}
89		""
90	end
91
92	case math_vec
93		version 300 es
94		values { output float out0 = 15.0; }
95		both ""
96			#version 300 es
97			precision highp float;
98			${DECLARATIONS}
99
100			void main()
101			{
102				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;
103				out0 = a.x + a.y + a.z;
104				${OUTPUT}
105			}
106		""
107	end
108
109	case math_int
110		version 300 es
111		values { output int out0 = 7; }
112		both ""
113			#version 300 es
114			precision highp int;
115			${DECLARATIONS}
116
117			void main()
118			{
119				const int a = 25%7 + 2*3 - 9/3;
120				out0 = a;
121				${OUTPUT}
122			}
123		""
124	end
125
126	case math_ivec
127		version 300 es
128		values { output int out0 = 21; }
129		both ""
130			#version 300 es
131			precision highp int;
132			${DECLARATIONS}
133
134			void main()
135			{
136				const ivec3 a = ivec2(25%7, 4).xxy + ivec4(1*3, 9/3, 1+2, 8/4).xyz;
137				out0 = a.x + a.y + a.z;
138				${OUTPUT}
139			}
140		""
141	end
142
143	case math_mat
144		version 300 es
145		values { output float out0 = 8.0; }
146		both ""
147			#version 300 es
148			precision highp float;
149			${DECLARATIONS}
150
151			void main()
152			{
153				const mat3 a = mat3(3.0) * mat3(4.0);
154				const mat4 b = mat4(a[1][1])*2.0;
155				const mat2 c = mat2(b[0][0]) / 3.0;
156				out0 = c[0][0]+c[1][0];
157				${OUTPUT}
158			}
159		""
160	end
161
162	case bitwise
163		version 300 es
164		values { output int out0 = 678332; }
165		both ""
166			#version 300 es
167			precision highp int;
168			${DECLARATIONS}
169
170			void main()
171			{
172				const int a = (((0xABBA<<4) ^ 0xCAFE) | (0xDCBA & (0xABCD>>2))) ^ (~0xDEAD & 0xBEEF);
173				out0 = a;
174				${OUTPUT}
175			}
176		""
177	end
178
179	case logical
180		version 300 es
181		values { output bool out0 = true; }
182		both ""
183			#version 300 es
184			precision highp int;
185			${DECLARATIONS}
186
187			void main()
188			{
189				const bool a = (!false || false) && (true ^^ false);
190				out0 = a;
191				${OUTPUT}
192			}
193		""
194	end
195
196	case compare
197		version 300 es
198		values { output bool out0 = true; }
199		both ""
200			#version 300 es
201			precision highp int;
202			${DECLARATIONS}
203
204			void main()
205			{
206				const bool a = (false == false) && (true != false) && (1 < 2) && (3 <= 3) && ((1 > 1) != (1 >= 1));
207				out0 = a;
208				${OUTPUT}
209			}
210		""
211	end
212
213	case selection
214		version 300 es
215		values { output float out0 = 5.3; }
216		both ""
217			#version 300 es
218			precision highp float;
219			${DECLARATIONS}
220
221			void main()
222			{
223				const float a = false ? 0.0 : (true ? 5.3 : 1.0);
224				out0 = a;
225				${OUTPUT}
226			}
227		""
228	end
229
230end # operators
231
232group complex_types "Arrays & Structs"
233
234	case struct
235		version 300 es
236		values { output float out0 = 260.922; }
237		both ""
238			#version 300 es
239			precision highp float;
240			${DECLARATIONS}
241
242			struct S
243			{
244				vec4 a;
245				int  b;
246			};
247
248			void main()
249			{
250				const S s = S(vec4(1.5), 123);
251				out0 = length(s.a.xy)*float(s.b);
252				${OUTPUT}
253			}
254		""
255	end
256
257	case nested_struct
258		version 300 es
259		values { output float out0 = 965.9; }
260		both ""
261			#version 300 es
262			precision highp float;
263			${DECLARATIONS}
264
265			struct S
266			{
267				vec4 v;
268				int  i;
269			};
270
271			struct T
272			{
273				S s;
274				bool b;
275				int i;
276			};
277
278			struct U
279			{
280				S s;
281				T t;
282			};
283
284			void main()
285			{
286				const S s = S(vec4(1.5), 123);
287				const T t = T(s, false, 3);
288				const U u = U(s, t);
289				const U v = U(S(vec4(1.3), 4), T(S(vec4(2.0), 5), true, 6));
290				out0 = float(u.s.i*v.t.i + v.t.s.i)*v.s.v.x; // float(123*6 + 5)*1.3
291				${OUTPUT}
292			}
293		""
294	end
295
296	case array_size
297		version 300 es
298		values { output int out0 = 1; }
299		both ""
300			#version 300 es
301			precision highp float;
302			${DECLARATIONS}
303
304			void main()
305			{
306				const int a[max(-1, 1)] = int[1](1);
307				out0 = a[0];
308				${OUTPUT}
309			}
310		""
311	end
312
313	case array_length
314		version 300 es
315		values { output int out0 = 2; }
316		both ""
317			#version 300 es
318			precision highp float;
319			${DECLARATIONS}
320
321			void main()
322			{
323				const int a[1] = int[1](1);
324				out0 = a.length() + a[0];
325				${OUTPUT}
326			}
327		""
328	end
329
330	case array
331		version 300 es
332		values { output float out0 = 4.0; }
333		both ""
334			#version 300 es
335			precision highp float;
336			${DECLARATIONS}
337
338			void main()
339			{
340				const float a[1+2+5] = float[8](0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0);
341				const float f = a[1+2+4];
342				out0 = f + float(a.length()-8);
343				${OUTPUT}
344			}
345		""
346	end
347
348end # complex_types
349
350group other "Other operations"
351
352	case switch_case
353		version 300 es
354		values
355		{
356			input float in0 = [ 0.0 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 ];
357			output int out0 = [ 0 | 1 | 2 | 3 | 4 | 10];
358		}
359
360		both ""
361			#version 300 es
362			precision highp float;
363			${DECLARATIONS}
364
365			void main()
366			{
367				const int _0 = 0;
368				const int _1 = 1;
369				const int _2 = 2;
370				const int _3 = 3;
371				const int _4 = 4;
372
373				switch(int(in0))
374				{
375					case _0:
376						out0 = 0;
377						break;
378					case _1:
379						out0 = 1;
380						break;
381					case _2:
382						out0 = 2;
383						break;
384					case _3:
385						out0 = 3;
386						break;
387					case _4:
388						out0 = 4;
389						break;
390					case 5:
391						out0 = 10;
392						break;
393					default:
394						out0 = 100;
395
396				}
397				${OUTPUT}
398			}
399		""
400	end
401
402	case nested_builtin_funcs
403		version 300 es
404		values { output float out0 = 3.05; }
405		both ""
406			#version 300 es
407			precision highp float;
408			${DECLARATIONS}
409
410			void main()
411			{
412				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*/);
413				out0 = a;
414				${OUTPUT}
415			}
416		""
417	end
418
419	case complex
420		version 300 es
421		values
422		{
423			input float in0 = [ 0.0 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 ];
424			output int out0 = [ 0 | 1 | 2 | 3 | 4 | 10];
425		}
426
427		both ""
428			#version 300 es
429			precision highp float;
430			${DECLARATIONS}
431
432			struct T
433			{
434				vec4 v;
435			};
436
437			struct S
438			{
439				T t;
440				int i;
441				bool b;
442			};
443
444			void main()
445			{
446				const T   t  = T(vec4(1.0));
447				const S   s  = S(t, 42, true);
448				const int _0 = int(sin(0.0));
449				const int _1 = int(1.0);
450				const int _2 = 2 + int(float(_0>_1));
451				const int _3 = min(gl_MaxVertexAttribs, 16)/4 - 1;
452				const int _4 = min(gl_MaxDrawBuffers, 4);
453				const ivec4 nums = ivec4(0, 1, 2, 3);
454
455				switch(int(in0))
456				{
457					case int(float(_0)):
458						out0 = ((true!=false) && (!false)) ? 0 : 25;
459						break;
460					case ivec3(_1).x:
461						out0 = 3*18/9-5;
462						break;
463					case nums[_2]:
464						out0 = int(length(vec4(1.0))+0.001);
465						break;
466					case _3:
467						out0 = 3;
468						break;
469					case clamp(_4, 1, 6):
470						out0 = (s.i-2)/10;
471						break;
472					case max(3, 5):
473						out0 = 10;
474						break;
475					default:
476						out0 = 100;
477
478				}
479				${OUTPUT}
480			}
481		""
482	end
483end
484