• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Tests todo:
2# - inout with varyings, attributes, uniforms (and arrays of 'em)
3# - inout with arrays, array elements
4# - inout with array elements
5# - inout by-value semantics (arrays & elements & structs)
6
7# Done:
8# - control flow: return, return in loop, etc.
9
10group datatypes "Function Parameter Data Types"
11
12	case float_float
13		version 300 es
14		values
15		{
16			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
17			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
18		}
19
20		both ""
21			#version 300 es
22			precision mediump float;
23			${DECLARATIONS}
24
25			float func (float a)
26			{
27				return -a;
28			}
29
30			void main()
31			{
32				out0 = func(in0);
33				${OUTPUT}
34			}
35		""
36	end
37
38	case float_vec2
39		version 300 es
40		values
41		{
42			input vec2 in0		= [ vec2(0.0, 1.0) | vec2(2.0, 2.5) ];
43			output float out0	= [ -1.0 | -4.5 ];
44		}
45
46		both ""
47			#version 300 es
48			precision mediump float;
49			${DECLARATIONS}
50
51			float func (vec2 a)
52			{
53				return -(a.x + a.y);
54			}
55
56			void main()
57			{
58				out0 = func(in0);
59				${OUTPUT}
60			}
61		""
62	end
63
64	case float_vec3
65		version 300 es
66		values
67		{
68			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
69			output float out0	= [ 1.0 | -0.5 ];
70		}
71
72		both ""
73			#version 300 es
74			precision mediump float;
75			${DECLARATIONS}
76
77			float func (vec3 a)
78			{
79				return -(a.x + a.y + a.z);
80			}
81
82			void main()
83			{
84				out0 = func(in0);
85				${OUTPUT}
86			}
87		""
88	end
89
90	case float_vec4
91		version 300 es
92		values
93		{
94			input vec4 in0		= [ vec4(0.0, 1.0, -2.0, 0.5) | vec4(2.0, 2.5, 4.0, -7.0) ];
95			output float out0	= [ 0.5 | -1.5 ];
96		}
97
98		both ""
99			#version 300 es
100			precision mediump float;
101			${DECLARATIONS}
102
103			float func (vec4 a)
104			{
105				return -(a.x + a.y + a.z + a.w);
106			}
107
108			void main()
109			{
110				out0 = func(in0);
111				${OUTPUT}
112			}
113		""
114	end
115
116	case float_mat2
117		version 300 es
118		values
119		{
120			input mat2 in0		= [ mat2(0.0, 1.0, -2.0, 0.5) | mat2(2.0, 2.5, 4.0, -7.0) ];
121			output float out0	= [ 0.5 | -1.5 ];
122		}
123
124		both ""
125			#version 300 es
126			precision mediump float;
127			${DECLARATIONS}
128
129			float func (mat2 a)
130			{
131				return -(a[0][0] + a[0][1] + a[1][0] + a[1][1]);
132			}
133
134			void main()
135			{
136				out0 = func(in0);
137				${OUTPUT}
138			}
139		""
140	end
141
142	case float_mat3
143		version 300 es
144		values
145		{
146			input mat3 in0		= [ mat3(0.0, 1.0, -2.0, 0.5, 1.0, -1.0, 2.0, 4.0, -1.0) | mat3(2.0, 2.5, 4.0, -7.0, 2.5, 3.0, 0.5, -3.5, 1.0) ];
147			output float out0	= [ -4.5 | -5.0 ];
148		}
149
150		both ""
151			#version 300 es
152			precision mediump float;
153			${DECLARATIONS}
154
155			float func (mat3 a)
156			{
157				return -(a[0][0] + a[0][1] + a[0][2] + a[1][0] + a[1][1] + a[1][2] + a[2][0] + a[2][1] + a[2][2]);
158			}
159
160			void main()
161			{
162				out0 = func(in0);
163				${OUTPUT}
164			}
165		""
166	end
167
168	case float_mat4
169		version 300 es
170		values
171		{
172			input mat4 in0		= [ mat4(0.0, 1.0, -2.0, 0.5, 1.0, -1.0, 2.0, 4.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -2.0, -2.0) | mat4(2.0, 2.5, 4.0, -7.0, 2.5, 3.0, 0.5, -3.5, 1.0, 0.0, 2.0, -1.0, 1.0, 0.0, -1.0, 3.0) ];
173			output float out0	= [ -5.5 | -9.0 ];
174		}
175
176		both ""
177			#version 300 es
178			precision mediump float;
179			${DECLARATIONS}
180
181			float func (mat4 a)
182			{
183				return -(a[0][0] + a[0][1] + a[0][2] + a[0][3] + a[1][0] + a[1][1] + a[1][2] + a[1][3] + a[2][0] + a[2][1] + a[2][2] + a[2][3] + a[3][0] + a[3][1] + a[3][2] + a[3][3]);
184			}
185
186			void main()
187			{
188				out0 = func(in0);
189				${OUTPUT}
190			}
191		""
192	end
193
194	case int_int
195		version 300 es
196		values
197		{
198			input int in0		= [ -1 | 0 | 1 | 4 ];
199			output int out0		= [ 1 | 0 | -1 | -4 ];
200		}
201
202		both ""
203			#version 300 es
204			precision mediump float;
205			precision mediump int;
206			${DECLARATIONS}
207
208			int func (int a)
209			{
210				return -a;
211			}
212
213			void main()
214			{
215				${SETUP}
216				out0 = func(in0);
217				${OUTPUT}
218			}
219		""
220	end
221
222	case int_ivec2
223		version 300 es
224		values
225		{
226			input ivec2 in0		= [ ivec2(-1, 0) | ivec2(1, 4) ];
227			output int out0		= [ 1 | -5 ];
228		}
229
230		both ""
231			#version 300 es
232			precision mediump float;
233			precision mediump int;
234			${DECLARATIONS}
235
236			int func (ivec2 a)
237			{
238				return -(a.x + a.y);
239			}
240
241			void main()
242			{
243				${SETUP}
244				out0 = func(in0);
245				${OUTPUT}
246			}
247		""
248	end
249
250	case int_ivec3
251		version 300 es
252		values
253		{
254			input ivec3 in0		= [ ivec3(-1, 0, 2) | ivec3(1, 4, -8) ];
255			output int out0		= [ -1 | 3 ];
256		}
257
258		both ""
259			#version 300 es
260			precision mediump float;
261			precision mediump int;
262			${DECLARATIONS}
263
264			int func (ivec3 a)
265			{
266				return -(a.x + a.y + a.z);
267			}
268
269			void main()
270			{
271				${SETUP}
272				out0 = func(in0);
273				${OUTPUT}
274			}
275		""
276	end
277
278	case int_ivec4
279		version 300 es
280		values
281		{
282			input ivec4 in0		= [ ivec4(-1, 0, 2, 2) | ivec4(1, 4, -8, 2) ];
283			output int out0		= [ -3 | 1 ];
284		}
285
286		both ""
287			#version 300 es
288			precision mediump float;
289			precision mediump int;
290			${DECLARATIONS}
291
292			int func (ivec4 a)
293			{
294				return -(a.x + a.y + a.z + a.w);
295			}
296
297			void main()
298			{
299				${SETUP}
300				out0 = func(in0);
301				${OUTPUT}
302			}
303		""
304	end
305
306	case uint_uint
307		version 300 es
308		values
309		{
310			input uint in0		= [ 1 | 0 | 2 | 4 ];
311			output uint out0	= [ 1 | 0 | 4 | 16 ];
312		}
313
314		both ""
315			#version 300 es
316			precision mediump float;
317			precision mediump int;
318			${DECLARATIONS}
319
320			uint func (uint a)
321			{
322				return a*a;
323			}
324
325			void main()
326			{
327				${SETUP}
328				out0 = func(in0);
329				${OUTPUT}
330			}
331		""
332	end
333
334	case uint_uvec2
335		version 300 es
336		values
337		{
338			input uvec2 in0		= [ uvec2(1, 0) | uvec2(2, 4) ];
339			output uint out0	= [ 1 | 6 ];
340		}
341
342		both ""
343			#version 300 es
344			precision mediump float;
345			precision mediump int;
346			${DECLARATIONS}
347
348			uint func (uvec2 a)
349			{
350				return (a.x + a.y);
351			}
352
353			void main()
354			{
355				${SETUP}
356				out0 = func(in0);
357				${OUTPUT}
358			}
359		""
360	end
361
362	case uint_uvec3
363		version 300 es
364		values
365		{
366			input uvec3 in0		= [ uvec3(1, 0, 2) | uvec3(1, 4, 8) ];
367			output uint out0		= [ 3 | 13 ];
368		}
369
370		both ""
371			#version 300 es
372			precision mediump float;
373			precision mediump int;
374			${DECLARATIONS}
375
376			uint func (uvec3 a)
377			{
378				return (a.x + a.y + a.z);
379			}
380
381			void main()
382			{
383				${SETUP}
384				out0 = func(in0);
385				${OUTPUT}
386			}
387		""
388	end
389
390	case uint_uvec4
391		version 300 es
392		values
393		{
394			input uvec4 in0		= [ uvec4(1, 0, 2, 2) | uvec4(1, 4, 8, 2) ];
395			output uint out0	= [ 5 | 15 ];
396		}
397
398		both ""
399			#version 300 es
400			precision mediump float;
401			precision mediump int;
402			${DECLARATIONS}
403
404			uint func (uvec4 a)
405			{
406				return (a.x + a.y + a.z + a.w);
407			}
408
409			void main()
410			{
411				${SETUP}
412				out0 = func(in0);
413				${OUTPUT}
414			}
415		""
416	end
417
418	case bool_bool
419		version 300 es
420		values
421		{
422			input bool in0		= [ true | false ];
423			output bool out0	= [ false | true ];
424		}
425
426		both ""
427			#version 300 es
428			precision mediump float;
429			${DECLARATIONS}
430
431			bool func (bool a)
432			{
433				return !a;
434			}
435
436			void main()
437			{
438				${SETUP}
439				out0 = func(in0);
440				${OUTPUT}
441			}
442		""
443	end
444
445	case bool_bvec2
446		version 300 es
447		values
448		{
449			input bvec2 in0		= [ bvec2(true, true) | bvec2(false, true) ];
450			output bool out0	= [ false | true ];
451		}
452
453		both ""
454			#version 300 es
455			precision mediump float;
456			${DECLARATIONS}
457
458			bool func (bvec2 a)
459			{
460				return !(a.x == a.y);
461			}
462
463			void main()
464			{
465				${SETUP}
466				out0 = func(in0);
467				${OUTPUT}
468			}
469		""
470	end
471
472	case bool_bvec3
473		version 300 es
474		values
475		{
476			input bvec3 in0		= [ bvec3(true, true, false) | bvec3(true, false, false) ];
477			output bool out0	= [ false | true ];
478		}
479
480		both ""
481			#version 300 es
482			precision mediump float;
483			${DECLARATIONS}
484
485			bool func (bvec3 a)
486			{
487				return (a.x == a.y) == a.z;
488			}
489
490			void main()
491			{
492				${SETUP}
493				out0 = func(in0);
494				${OUTPUT}
495			}
496		""
497	end
498
499	case bool_bvec4
500		version 300 es
501		values
502		{
503			input bvec4 in0		= [ bvec4(true, true, true, false) | bvec4(false, false, true, true) | bvec4(true, false, false, true) ];
504			output bool out0	= [ false | true | true ];
505		}
506
507		both ""
508			#version 300 es
509			precision mediump float;
510			${DECLARATIONS}
511
512			bool func (bvec4 a)
513			{
514				return ((a.x == a.y) == (a.z == a.w));
515			}
516
517			void main()
518			{
519				${SETUP}
520				out0 = func(in0);
521				${OUTPUT}
522			}
523		""
524	end
525
526	case mat2
527		version 300 es
528		values
529		{
530			input mat2 in0	= [ mat2(-2.0, 0.5, -1.0, 1.0) | mat2(1.0, -3.5, -3.5, 2.5) | mat2(-2.0, -2.0, 3.5, 0.0) ];
531			output mat2 out0	= [ mat2(4.0, -1.0, 2.0, -2.0) | mat2(-2.0, 7.0, 7.0, -5.0) | mat2(4.0, 4.0, -7.0, -0.0) ];
532		}
533
534		both ""
535			#version 300 es
536			precision mediump float;
537			${DECLARATIONS}
538
539			mat2 func (mat2 a)
540			{
541				return -2.0*a;
542			}
543
544			void main()
545			{
546				${SETUP}
547				out0 = func(in0);
548				${OUTPUT}
549			}
550		""
551	end
552
553
554	case mat2x3
555		version 300 es
556		values
557		{
558			input mat2x3 in0	= [ mat2x3(2.5, 0.0, 1.0, -2.5, 1.0, 3.0) | mat2x3(0.0, 2.0, 1.5, -3.5, 2.0, 0.5) | mat2x3(-1.5, -3.5, 2.5, 0.0, 1.5, 3.0) ];
559			output mat2x3 out0	= [ mat2x3(-5.0, -0.0, -2.0, 5.0, -2.0, -6.0) | mat2x3(-0.0, -4.0, -3.0, 7.0, -4.0, -1.0) | mat2x3(3.0, 7.0, -5.0, -0.0, -3.0, -6.0) ];
560		}
561
562		both ""
563			#version 300 es
564			precision mediump float;
565			${DECLARATIONS}
566
567			mat2x3 func (mat2x3 a)
568			{
569				return -2.0*a;
570			}
571
572			void main()
573			{
574				${SETUP}
575				out0 = func(in0);
576				${OUTPUT}
577			}
578		""
579	end
580
581
582	case mat2x4
583		version 300 es
584		values
585		{
586			input mat2x4 in0	= [ mat2x4(1.5, 3.0, -1.0, 2.5, -0.5, 3.5, 3.0, -3.0) | mat2x4(-2.5, -2.0, 3.5, -0.5, 1.0, -1.5, 0.0, -1.0) | mat2x4(-1.0, 0.5, 0.5, 3.0, 1.5, 3.0, 2.5, 3.5) ];
587			output mat2x4 out0	= [ mat2x4(-3.0, -6.0, 2.0, -5.0, 1.0, -7.0, -6.0, 6.0) | mat2x4(5.0, 4.0, -7.0, 1.0, -2.0, 3.0, -0.0, 2.0) | mat2x4(2.0, -1.0, -1.0, -6.0, -3.0, -6.0, -5.0, -7.0) ];
588		}
589
590		both ""
591			#version 300 es
592			precision mediump float;
593			${DECLARATIONS}
594
595			mat2x4 func (mat2x4 a)
596			{
597				return -2.0*a;
598			}
599
600			void main()
601			{
602				${SETUP}
603				out0 = func(in0);
604				${OUTPUT}
605			}
606		""
607	end
608
609
610	case mat3x2
611		version 300 es
612		values
613		{
614			input mat3x2 in0	= [ mat3x2(1.5, -2.5, 2.5, 3.5, 3.0, 0.5) | mat3x2(1.5, -2.0, 2.5, 0.5, -1.5, -3.5) | mat3x2(2.5, 3.5, -3.0, 2.5, -0.5, -2.5) ];
615			output mat3x2 out0	= [ mat3x2(-3.0, 5.0, -5.0, -7.0, -6.0, -1.0) | mat3x2(-3.0, 4.0, -5.0, -1.0, 3.0, 7.0) | mat3x2(-5.0, -7.0, 6.0, -5.0, 1.0, 5.0) ];
616		}
617
618		both ""
619			#version 300 es
620			precision mediump float;
621			${DECLARATIONS}
622
623			mat3x2 func (mat3x2 a)
624			{
625				return -2.0*a;
626			}
627
628			void main()
629			{
630				${SETUP}
631				out0 = func(in0);
632				${OUTPUT}
633			}
634		""
635	end
636
637
638	case mat3
639		version 300 es
640		values
641		{
642			input mat3 in0	= [ mat3(-1.5, 2.0, 3.0, -3.5, 1.0, -3.5, 1.5, -1.5, 3.0) | mat3(3.5, 0.0, 3.5, -1.5, -3.0, 0.5, -3.5, -2.5, -0.5) | mat3(1.0, -2.5, -3.5, 3.0, -1.5, 3.5, 3.0, -1.0, -0.5) ];
643			output mat3 out0	= [ mat3(3.0, -4.0, -6.0, 7.0, -2.0, 7.0, -3.0, 3.0, -6.0) | mat3(-7.0, -0.0, -7.0, 3.0, 6.0, -1.0, 7.0, 5.0, 1.0) | mat3(-2.0, 5.0, 7.0, -6.0, 3.0, -7.0, -6.0, 2.0, 1.0) ];
644		}
645
646		both ""
647			#version 300 es
648			precision mediump float;
649			${DECLARATIONS}
650
651			mat3 func (mat3 a)
652			{
653				return -2.0*a;
654			}
655
656			void main()
657			{
658				${SETUP}
659				out0 = func(in0);
660				${OUTPUT}
661			}
662		""
663	end
664
665
666	case mat3x4
667		version 300 es
668		values
669		{
670			input mat3x4 in0	= [ mat3x4(0.0, 1.0, 0.5, 0.5, 1.0, 3.5, 0.0, -0.5, 1.5, -2.0, -1.5, 3.5) | mat3x4(0.0, 0.5, -3.5, -0.5, 0.5, -3.5, 1.0, 1.0, -3.5, 1.0, -0.5, 1.5) | mat3x4(-1.0, 1.5, 2.0, -3.5, -3.5, 1.5, 3.5, -2.0, -0.5, 0.5, -1.5, -1.0) ];
671			output mat3x4 out0	= [ mat3x4(-0.0, -2.0, -1.0, -1.0, -2.0, -7.0, -0.0, 1.0, -3.0, 4.0, 3.0, -7.0) | mat3x4(-0.0, -1.0, 7.0, 1.0, -1.0, 7.0, -2.0, -2.0, 7.0, -2.0, 1.0, -3.0) | mat3x4(2.0, -3.0, -4.0, 7.0, 7.0, -3.0, -7.0, 4.0, 1.0, -1.0, 3.0, 2.0) ];
672		}
673
674		both ""
675			#version 300 es
676			precision mediump float;
677			${DECLARATIONS}
678
679			mat3x4 func (mat3x4 a)
680			{
681				return -2.0*a;
682			}
683
684			void main()
685			{
686				${SETUP}
687				out0 = func(in0);
688				${OUTPUT}
689			}
690		""
691	end
692
693
694	case mat4x2
695		version 300 es
696		values
697		{
698			input mat4x2 in0	= [ mat4x2(-1.5, -1.0, 0.5, -1.5, -1.0, 2.0, -3.5, 0.5) | mat4x2(2.0, -1.5, -2.0, 2.5, -2.0, -2.5, -0.5, 1.5) | mat4x2(-3.0, -1.5, -1.0, 2.5, -0.5, 2.5, -2.5, -1.0) ];
699			output mat4x2 out0	= [ mat4x2(3.0, 2.0, -1.0, 3.0, 2.0, -4.0, 7.0, -1.0) | mat4x2(-4.0, 3.0, 4.0, -5.0, 4.0, 5.0, 1.0, -3.0) | mat4x2(6.0, 3.0, 2.0, -5.0, 1.0, -5.0, 5.0, 2.0) ];
700		}
701
702		both ""
703			#version 300 es
704			precision mediump float;
705			${DECLARATIONS}
706
707			mat4x2 func (mat4x2 a)
708			{
709				return -2.0*a;
710			}
711
712			void main()
713			{
714				${SETUP}
715				out0 = func(in0);
716				${OUTPUT}
717			}
718		""
719	end
720
721
722	case mat4x3
723		version 300 es
724		values
725		{
726			input mat4x3 in0	= [ mat4x3(1.0, 3.0, -0.5, -2.0, -3.0, 0.0, -2.5, 2.5, 2.5, -2.5, -1.5, 2.5) | mat4x3(1.0, 2.5, -1.0, -3.0, -1.5, 2.0, -1.5, -1.0, -0.5, -0.5, -0.5, 3.0) | mat4x3(-2.5, -3.5, 3.5, 3.0, 3.5, -0.5, 3.5, 3.0, -2.0, 2.0, 2.5, 1.0) ];
727			output mat4x3 out0	= [ mat4x3(-2.0, -6.0, 1.0, 4.0, 6.0, -0.0, 5.0, -5.0, -5.0, 5.0, 3.0, -5.0) | mat4x3(-2.0, -5.0, 2.0, 6.0, 3.0, -4.0, 3.0, 2.0, 1.0, 1.0, 1.0, -6.0) | mat4x3(5.0, 7.0, -7.0, -6.0, -7.0, 1.0, -7.0, -6.0, 4.0, -4.0, -5.0, -2.0) ];
728		}
729
730		both ""
731			#version 300 es
732			precision mediump float;
733			${DECLARATIONS}
734
735			mat4x3 func (mat4x3 a)
736			{
737				return -2.0*a;
738			}
739
740			void main()
741			{
742				${SETUP}
743				out0 = func(in0);
744				${OUTPUT}
745			}
746		""
747	end
748
749
750	case mat4
751		version 300 es
752		values
753		{
754			input mat4 in0	= [ mat4(0.0, -1.5, -1.0, -2.0, -3.0, 0.5, -1.5, 2.5, -3.5, 3.0, 1.5, 3.0, 3.0, 3.0, 0.5, -3.5) | mat4(2.0, -2.5, -1.5, 1.0, 0.0, -0.5, 3.5, 1.0, -1.0, -2.0, 2.5, 0.0, 2.0, -1.0, -2.5, 0.5) | mat4(2.5, -2.5, 2.0, 3.0, 2.5, 2.5, -3.5, 1.0, 2.5, -3.5, -1.5, -1.5, 0.0, -0.5, 0.0, 2.0) ];
755			output mat4 out0	= [ mat4(-0.0, 3.0, 2.0, 4.0, 6.0, -1.0, 3.0, -5.0, 7.0, -6.0, -3.0, -6.0, -6.0, -6.0, -1.0, 7.0) | mat4(-4.0, 5.0, 3.0, -2.0, -0.0, 1.0, -7.0, -2.0, 2.0, 4.0, -5.0, -0.0, -4.0, 2.0, 5.0, -1.0) | mat4(-5.0, 5.0, -4.0, -6.0, -5.0, -5.0, 7.0, -2.0, -5.0, 7.0, 3.0, 3.0, -0.0, 1.0, -0.0, -4.0) ];
756		}
757
758		both ""
759			#version 300 es
760			precision mediump float;
761			${DECLARATIONS}
762
763			mat4 func (mat4 a)
764			{
765				return -2.0*a;
766			}
767
768			void main()
769			{
770				${SETUP}
771				out0 = func(in0);
772				${OUTPUT}
773			}
774		""
775	end
776
777	case float_struct
778		version 300 es
779		values
780		{
781			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
782			output float out0	= [ 1.0 | -0.5 ];
783		}
784
785		both ""
786			#version 300 es
787			precision mediump float;
788			${DECLARATIONS}
789
790			struct Pos { float a, b, c; };
791
792			float func (Pos p)
793			{
794				return -(p.a + p.b + p.c);
795			}
796
797			void main()
798			{
799				Pos p = Pos(in0.x, in0.y, in0.z);
800				out0 = func(p);
801				${OUTPUT}
802			}
803		""
804	end
805
806	case struct_struct
807		version 300 es
808		values
809		{
810			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
811			output float out0	= [ 1.0 | -0.5 ];
812		}
813
814		both ""
815			#version 300 es
816			precision mediump float;
817			${DECLARATIONS}
818
819			struct Pos { float a, b, c; };
820
821			Pos func (Pos p)
822			{
823				return Pos(-p.a, -p.b, -p.c);
824			}
825
826			void main()
827			{
828				Pos p = Pos(in0.x, in0.y, in0.z);
829				p = func(p);
830				out0 = p.a + p.b + p.c;
831				${OUTPUT}
832			}
833		""
834	end
835
836	case struct_nested_struct
837		version 300 es
838		values
839		{
840			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
841			output float out0	= [ 1.0 | -0.5 ];
842		}
843
844		both ""
845			#version 300 es
846			precision mediump float;
847			${DECLARATIONS}
848
849			struct Pos { float a, b, c; };
850			struct Line { Pos start, end; };
851
852			Line func (Pos p)
853			{
854				return Line(p, Pos(-p.a, -p.b, -p.c));
855			}
856
857			float sum (Pos p)
858			{
859				return (p.a + p.b + p.c);
860			}
861
862			void main()
863			{
864				Pos p = Pos(in0.x, in0.y, in0.z);
865				Line line = func(p);
866				out0 = sum(line.start) + (2.0 * sum(line.end));
867				${OUTPUT}
868			}
869		""
870	end
871
872	case struct_constructor_highp_in_fragment
873		version 300 es
874		desc "passing highp vector to struct constructor in fragment shader yields all zeros"
875		vertex ""
876			#version 300 es
877			${VERTEX_DECLARATIONS}
878			void main()
879			{
880				${VERTEX_OUTPUT}
881			}
882		""
883		fragment ""
884			#version 300 es
885			${FRAGMENT_DECLARATIONS}
886			#ifdef GL_FRAGMENT_PRECISION_HIGH
887			#define PRECISION highp
888			#else
889			#define PRECISION mediump
890			#endif
891			struct Test {
892				PRECISION vec3 color;
893			} ;
894			void main() {
895				PRECISION vec3 color = vec3(0.2, 2.0, 0.1);
896				Test test = Test(color);
897				// Bias the color so all components are guaranteed > 1.0.
898				${FRAG_COLOR} = vec4(vec3(0.25, 0.55, 0.65) + vec3(4.0, 0.25, 4.0) * test.color, 1.0);
899			}
900		""
901	end
902
903
904end # datatypes
905
906group qualifiers "Function Parameter Qualifiers"
907
908	case in_float
909		version 300 es
910		values
911		{
912			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
913			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
914		}
915
916		both ""
917			#version 300 es
918			precision mediump float;
919			precision mediump int;
920			${DECLARATIONS}
921
922			float func (in float a)
923			{
924				a = -a;
925				return 2.0 * a;
926			}
927
928			void main()
929			{
930				${SETUP}
931				float f = in0;
932				float g = func(f);
933				out0 = f + g;
934				${OUTPUT}
935			}
936		""
937	end
938
939	case out_float
940		version 300 es
941		values
942		{
943			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
944			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
945		}
946
947		both ""
948			#version 300 es
949			precision mediump float;
950			precision mediump int;
951			${DECLARATIONS}
952
953			void func (out float a)
954			{
955				a = -1.0;
956			}
957
958			void main()
959			{
960				${SETUP}
961				float f = 1.0;
962				func(f);
963				out0 = f * in0;
964				${OUTPUT}
965			}
966		""
967	end
968
969	case inout_float
970		version 300 es
971		values
972		{
973			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
974			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
975		}
976
977		both ""
978			#version 300 es
979			precision mediump float;
980			precision mediump int;
981			${DECLARATIONS}
982
983			void func (inout float a)
984			{
985				a = -a;
986			}
987
988			void main()
989			{
990				${SETUP}
991				float f = 1.0;
992				func(f);
993				out0 = f * in0;
994				${OUTPUT}
995			}
996		""
997	end
998
999	case in_lowp_float
1000		version 300 es
1001		values
1002		{
1003			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1004			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1005		}
1006
1007		both ""
1008			#version 300 es
1009			precision mediump float;
1010			precision mediump int;
1011			${DECLARATIONS}
1012
1013			float func (in lowp float a)
1014			{
1015				a = -a;
1016				return 2.0 * a;
1017			}
1018
1019			void main()
1020			{
1021				${SETUP}
1022				float f = in0;
1023				float g = func(f);
1024				out0 = f + g;
1025				${OUTPUT}
1026			}
1027		""
1028	end
1029
1030	case out_lowp_float
1031		version 300 es
1032		values
1033		{
1034			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1035			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1036		}
1037
1038		both ""
1039			#version 300 es
1040			precision mediump float;
1041			precision mediump int;
1042			${DECLARATIONS}
1043
1044			void func (out lowp float a)
1045			{
1046				a = -1.0;
1047			}
1048
1049			void main()
1050			{
1051				${SETUP}
1052				float f = 1.0;
1053				func(f);
1054				out0 = f * in0;
1055				${OUTPUT}
1056			}
1057		""
1058	end
1059
1060	case inout_lowp_float
1061		version 300 es
1062		values
1063		{
1064			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1065			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1066		}
1067
1068		both ""
1069			#version 300 es
1070			precision mediump float;
1071			precision mediump int;
1072			${DECLARATIONS}
1073
1074			void func (inout lowp float a)
1075			{
1076				a = -a;
1077			}
1078
1079			void main()
1080			{
1081				${SETUP}
1082				float f = 1.0;
1083				func(f);
1084				out0 = f * in0;
1085				${OUTPUT}
1086			}
1087		""
1088	end
1089
1090	case in_highp_float
1091		version 300 es
1092		values
1093		{
1094			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1095			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1096		}
1097
1098		both ""
1099			#version 300 es
1100			precision mediump float;
1101			precision mediump int;
1102			${DECLARATIONS}
1103
1104			float func (in highp float a)
1105			{
1106				a = -a;
1107				return 2.0 * a;
1108			}
1109
1110			void main()
1111			{
1112				${SETUP}
1113				float f = in0;
1114				float g = func(f);
1115				out0 = f + g;
1116				${OUTPUT}
1117			}
1118		""
1119	end
1120
1121	case out_highp_float
1122		version 300 es
1123		values
1124		{
1125			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1126			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1127		}
1128
1129		both ""
1130			#version 300 es
1131			precision mediump float;
1132			precision mediump int;
1133			${DECLARATIONS}
1134
1135			void func (out highp float a)
1136			{
1137				a = -1.0;
1138			}
1139
1140			void main()
1141			{
1142				${SETUP}
1143				float f = 1.0;
1144				func(f);
1145				out0 = f * in0;
1146				${OUTPUT}
1147			}
1148		""
1149	end
1150
1151	case inout_highp_float
1152		version 300 es
1153		values
1154		{
1155			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1156			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1157		}
1158
1159		both ""
1160			#version 300 es
1161			precision mediump float;
1162			precision mediump int;
1163			${DECLARATIONS}
1164
1165			void func (inout highp float a)
1166			{
1167				a = -a;
1168			}
1169
1170			void main()
1171			{
1172				${SETUP}
1173				float f = 1.0;
1174				func(f);
1175				out0 = f * in0;
1176				${OUTPUT}
1177			}
1178		""
1179	end
1180
1181	case const_float
1182		version 300 es
1183		values
1184		{
1185			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1186			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1187		}
1188
1189		both ""
1190			#version 300 es
1191			precision mediump float;
1192			precision mediump int;
1193			${DECLARATIONS}
1194
1195			float func (const float a)
1196			{
1197				float b = -a;
1198				return 2.0 * b;
1199			}
1200
1201			void main()
1202			{
1203				${SETUP}
1204				float f = in0;
1205				float g = func(f);
1206				out0 = f + g;
1207				${OUTPUT}
1208			}
1209		""
1210	end
1211
1212	case const_in_float
1213		version 300 es
1214		values
1215		{
1216			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1217			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1218		}
1219
1220		both ""
1221			#version 300 es
1222			precision mediump float;
1223			precision mediump int;
1224			${DECLARATIONS}
1225
1226			float func (const in float a)
1227			{
1228				float b = -a;
1229				return 2.0 * b;
1230			}
1231
1232			void main()
1233			{
1234				${SETUP}
1235				float f = in0;
1236				float g = func(f);
1237				out0 = f + g;
1238				${OUTPUT}
1239			}
1240		""
1241	end
1242
1243	case in_int
1244		version 300 es
1245		values
1246		{
1247			input int in0		= [ 0 | 1 | -2 | 4 ];
1248			output int out0		= [ 0 | -1 | 2 | -4 ];
1249		}
1250
1251		both ""
1252			#version 300 es
1253			precision mediump float;
1254			precision mediump int;
1255			${DECLARATIONS}
1256
1257			int func (in int a)
1258			{
1259				a = -a;
1260				return 2 * a;
1261			}
1262
1263			void main()
1264			{
1265				${SETUP}
1266				int f = in0;
1267				int g = func(f);
1268				out0 = f + g;
1269				${OUTPUT}
1270			}
1271		""
1272	end
1273
1274	case out_int
1275		version 300 es
1276		values
1277		{
1278			input int in0		= [ 0 | 1 | -2 | 6 ];
1279			output int out0		= [ 0 | -1 | 2 | -6 ];
1280		}
1281
1282		both ""
1283			#version 300 es
1284			precision mediump float;
1285			precision mediump int;
1286			${DECLARATIONS}
1287
1288			void func (out int a)
1289			{
1290				a = -1;
1291			}
1292
1293			void main()
1294			{
1295				${SETUP}
1296				int f = 1;
1297				func(f);
1298				out0 = f * in0;
1299				${OUTPUT}
1300			}
1301		""
1302	end
1303
1304	case inout_int
1305		version 300 es
1306		values
1307		{
1308			input int in0		= [ 0 | 1 | -2 | 6 ];
1309			output int out0		= [ 0 | -1 | 2 | -6 ];
1310		}
1311
1312		both ""
1313			#version 300 es
1314			precision mediump float;
1315			precision mediump int;
1316			${DECLARATIONS}
1317
1318			void func (inout int a)
1319			{
1320				a = -a;
1321			}
1322
1323			void main()
1324			{
1325				${SETUP}
1326				int f = 1;
1327				func(f);
1328				out0 = f * in0;
1329				${OUTPUT}
1330			}
1331		""
1332	end
1333
1334	case in_lowp_int
1335		version 300 es
1336		values
1337		{
1338			input int in0		= [ 0 | 1 | -2 | 4 ];
1339			output int out0		= [ 0 | -1 | 2 | -4 ];
1340		}
1341
1342		both ""
1343			#version 300 es
1344			precision mediump float;
1345			precision mediump int;
1346			${DECLARATIONS}
1347
1348			int func (in lowp int a)
1349			{
1350				a = -a;
1351				return 2 * a;
1352			}
1353
1354			void main()
1355			{
1356				${SETUP}
1357				int f = in0;
1358				int g = func(f);
1359				out0 = f + g;
1360				${OUTPUT}
1361			}
1362		""
1363	end
1364
1365	case out_lowp_int
1366		version 300 es
1367		values
1368		{
1369			input int in0		= [ 0 | 1 | -2 | 6 ];
1370			output int out0		= [ 0 | -1 | 2 | -6 ];
1371		}
1372
1373		both ""
1374			#version 300 es
1375			precision mediump float;
1376			precision mediump int;
1377			${DECLARATIONS}
1378
1379			void func (out lowp int a)
1380			{
1381				a = -1;
1382			}
1383
1384			void main()
1385			{
1386				${SETUP}
1387				int f = 1;
1388				func(f);
1389				out0 = f * in0;
1390				${OUTPUT}
1391			}
1392		""
1393	end
1394
1395	case inout_lowp_int
1396		version 300 es
1397		values
1398		{
1399			input int in0		= [ 0 | 1 | -2 | 6 ];
1400			output int out0		= [ 0 | -1 | 2 | -6 ];
1401		}
1402
1403		both ""
1404			#version 300 es
1405			precision mediump float;
1406			precision mediump int;
1407			${DECLARATIONS}
1408
1409			void func (inout lowp int a)
1410			{
1411				a = -a;
1412			}
1413
1414			void main()
1415			{
1416				${SETUP}
1417				int f = 1;
1418				func(f);
1419				out0 = f * in0;
1420				${OUTPUT}
1421			}
1422		""
1423	end
1424
1425	case in_highp_int
1426		version 300 es
1427		values
1428		{
1429			input int in0		= [ 0 | 1 | -2 | 4 ];
1430			output int out0		= [ 0 | -1 | 2 | -4 ];
1431		}
1432
1433		both ""
1434			#version 300 es
1435			precision mediump float;
1436			precision mediump int;
1437			${DECLARATIONS}
1438
1439			int func (in highp int a)
1440			{
1441				a = -a;
1442				return 2 * a;
1443			}
1444
1445			void main()
1446			{
1447				${SETUP}
1448				int f = in0;
1449				int g = func(f);
1450				out0 = f + g;
1451				${OUTPUT}
1452			}
1453		""
1454	end
1455
1456	case out_highp_int
1457		version 300 es
1458		values
1459		{
1460			input int in0		= [ 0 | 1 | -2 | 6 ];
1461			output int out0		= [ 0 | -1 | 2 | -6 ];
1462		}
1463
1464		both ""
1465			#version 300 es
1466			precision mediump float;
1467			precision mediump int;
1468			${DECLARATIONS}
1469
1470			void func (out highp int a)
1471			{
1472				a = -1;
1473			}
1474
1475			void main()
1476			{
1477				${SETUP}
1478				int f = 1;
1479				func(f);
1480				out0 = f * in0;
1481				${OUTPUT}
1482			}
1483		""
1484	end
1485
1486	case inout_highp_int
1487		version 300 es
1488		values
1489		{
1490			input int in0		= [ 0 | 1 | -2 | 6 ];
1491			output int out0		= [ 0 | -1 | 2 | -6 ];
1492		}
1493
1494		both ""
1495			#version 300 es
1496			precision mediump float;
1497			precision mediump int;
1498			${DECLARATIONS}
1499
1500			void func (inout highp int a)
1501			{
1502				a = -a;
1503			}
1504
1505			void main()
1506			{
1507				${SETUP}
1508				int f = 1;
1509				func(f);
1510				out0 = f * in0;
1511				${OUTPUT}
1512			}
1513		""
1514	end
1515
1516	case const_int
1517		version 300 es
1518		values
1519		{
1520			input int in0		= [ 0 | 1 | -2 | 4 ];
1521			output int out0		= [ 0 | -1 | 2 | -4 ];
1522		}
1523
1524		both ""
1525			#version 300 es
1526			precision mediump float;
1527			precision mediump int;
1528			${DECLARATIONS}
1529
1530			int func (const int a)
1531			{
1532				int b = -a;
1533				return 2 * b;
1534			}
1535
1536			void main()
1537			{
1538				${SETUP}
1539				int f = in0;
1540				int g = func(f);
1541				out0 = f + g;
1542				${OUTPUT}
1543			}
1544		""
1545	end
1546
1547	case const_in_int
1548		version 300 es
1549		values
1550		{
1551			input int in0		= [ 0 | 1 | -2 | 4 ];
1552			output int out0		= [ 0 | -1 | 2 | -4 ];
1553		}
1554
1555		both ""
1556			#version 300 es
1557			precision mediump float;
1558			precision mediump int;
1559			${DECLARATIONS}
1560
1561			int func (const in int a)
1562			{
1563				int b = -a;
1564				return 2 * b;
1565			}
1566
1567			void main()
1568			{
1569				${SETUP}
1570				int f = in0;
1571				int g = func(f);
1572				out0 = f + g;
1573				${OUTPUT}
1574			}
1575		""
1576	end
1577
1578	case in_bool
1579		version 300 es
1580		values
1581		{
1582			input bool in0		= [ true | false ];
1583			output bool out0	= [ true | true ];
1584		}
1585
1586		both ""
1587			#version 300 es
1588			precision mediump float;
1589			${DECLARATIONS}
1590
1591			bool func (in bool a)
1592			{
1593				a = !a;
1594				return a;
1595			}
1596
1597			void main()
1598			{
1599				${SETUP}
1600				bool f = in0;
1601				bool g = func(f);
1602				out0 = (f != g);
1603				${OUTPUT}
1604			}
1605		""
1606	end
1607
1608	case out_bool
1609		version 300 es
1610		values
1611		{
1612			input bool in0		= [ true | false ];
1613			output bool out0	= [ false | true ];
1614		}
1615
1616		both ""
1617			#version 300 es
1618			precision mediump float;
1619			${DECLARATIONS}
1620
1621			void func (out bool a)
1622			{
1623				a = false;
1624			}
1625
1626			void main()
1627			{
1628				${SETUP}
1629				bool f = true;
1630				func(f);
1631				out0 = (in0 == f);
1632				${OUTPUT}
1633			}
1634		""
1635	end
1636
1637	case inout_bool
1638		version 300 es
1639		values
1640		{
1641			input bool in0		= [ true | false ];
1642			output bool out0	= [ false | true ];
1643		}
1644
1645		both ""
1646			#version 300 es
1647			precision mediump float;
1648			${DECLARATIONS}
1649
1650			void func (inout bool a)
1651			{
1652				a = !a;
1653			}
1654
1655			void main()
1656			{
1657				${SETUP}
1658				bool f = true;
1659				func(f);
1660				out0 = (in0 == f);
1661				${OUTPUT}
1662			}
1663		""
1664	end
1665
1666	case const_bool
1667		version 300 es
1668		values
1669		{
1670			input bool in0		= [ true | false ];
1671			output bool out0	= [ true | true ];
1672		}
1673
1674		both ""
1675			#version 300 es
1676			precision mediump float;
1677			${DECLARATIONS}
1678
1679			bool func (const bool a)
1680			{
1681				bool b = !a;
1682				return b;
1683			}
1684
1685			void main()
1686			{
1687				${SETUP}
1688				bool f = in0;
1689				bool g = func(f);
1690				out0 = (f != g);
1691				${OUTPUT}
1692			}
1693		""
1694	end
1695
1696end # qualifiers
1697
1698group declarations "Function Declarations"
1699
1700	case basic
1701		version 300 es
1702		values
1703		{
1704			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1705			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1706		}
1707
1708		both ""
1709			#version 300 es
1710			precision mediump float;
1711			${DECLARATIONS}
1712
1713			float func (void);
1714
1715			float func (void)
1716			{
1717				return -1.0;
1718			}
1719
1720			void main()
1721			{
1722				out0 = func() * in0;
1723				${OUTPUT}
1724			}
1725		""
1726	end
1727
1728	case basic_arg
1729		version 300 es
1730		values
1731		{
1732			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1733			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1734		}
1735
1736		both ""
1737			#version 300 es
1738			precision mediump float;
1739			${DECLARATIONS}
1740
1741			float func (float f);
1742
1743			float func (float f)
1744			{
1745				return -f;
1746			}
1747
1748			void main()
1749			{
1750				out0 = func(in0);
1751				${OUTPUT}
1752			}
1753		""
1754	end
1755
1756	case define_after_use
1757		version 300 es
1758		values
1759		{
1760			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1761			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1762		}
1763
1764		both ""
1765			#version 300 es
1766			precision mediump float;
1767			${DECLARATIONS}
1768
1769			float func (void);
1770
1771			void main()
1772			{
1773				out0 = func() * in0;
1774				${OUTPUT}
1775			}
1776
1777			float func (void)
1778			{
1779				return -1.0;
1780			}
1781		""
1782	end
1783
1784	case double_declare
1785		version 300 es
1786		values
1787		{
1788			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1789			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1790		}
1791
1792		both ""
1793			#version 300 es
1794			precision mediump float;
1795			${DECLARATIONS}
1796
1797			float func (void);
1798
1799			float func (void);
1800
1801			float func (void)
1802			{
1803				return -1.0;
1804			}
1805
1806			void main()
1807			{
1808				out0 = func() * in0;
1809				${OUTPUT}
1810			}
1811		""
1812	end
1813
1814	case declare_after_define
1815		version 300 es
1816		values
1817		{
1818			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1819			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1820		}
1821
1822		both ""
1823			#version 300 es
1824			precision mediump float;
1825			${DECLARATIONS}
1826
1827			float func (void)
1828			{
1829				return -1.0;
1830			}
1831
1832			float func (void);
1833
1834			void main()
1835			{
1836				out0 = func() * in0;
1837				${OUTPUT}
1838			}
1839		""
1840	end
1841
1842	case void_vs_no_void
1843		version 300 es
1844		values
1845		{
1846			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1847			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1848		}
1849
1850		both ""
1851			#version 300 es
1852			precision mediump float;
1853			${DECLARATIONS}
1854
1855			float func ();
1856
1857			void main()
1858			{
1859				out0 = func() * in0;
1860				${OUTPUT}
1861			}
1862
1863			float func (void)
1864			{
1865				return -1.0;
1866			}
1867		""
1868	end
1869
1870	case in_vs_no_in
1871		version 300 es
1872		values
1873		{
1874			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1875			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1876		}
1877
1878		both ""
1879			#version 300 es
1880			precision mediump float;
1881			${DECLARATIONS}
1882
1883			float func (float f);
1884
1885			void main()
1886			{
1887				out0 = func(in0);
1888				${OUTPUT}
1889			}
1890
1891			float func (in float f)
1892			{
1893				return -f;
1894			}
1895		""
1896	end
1897
1898	case default_vs_explicit_precision
1899		version 300 es
1900		values
1901		{
1902			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1903			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1904		}
1905
1906		both ""
1907			#version 300 es
1908			precision mediump float;
1909			${DECLARATIONS}
1910
1911			float func (float f);
1912
1913			void main()
1914			{
1915				out0 = func(in0);
1916				${OUTPUT}
1917			}
1918
1919			float func (mediump float f)
1920			{
1921				return -f;
1922			}
1923		""
1924	end
1925
1926
1927end # declarations
1928
1929group overloading "Function Overloading"
1930
1931	case user_func_arg_type_simple
1932		version 300 es
1933		values
1934		{
1935			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1936			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1937		}
1938
1939		both ""
1940			#version 300 es
1941			precision mediump float;
1942			precision mediump int;
1943			${DECLARATIONS}
1944
1945			float func (float a)
1946			{
1947				return -a;
1948			}
1949
1950			int func (int a)
1951			{
1952				return -a;
1953			}
1954
1955			void main()
1956			{
1957				out0 = func(in0) * float(func(-1));
1958				${OUTPUT}
1959			}
1960		""
1961	end
1962
1963	case user_func_arg_float_types
1964		version 300 es
1965		values
1966		{
1967			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1968			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1969		}
1970
1971		both ""
1972			#version 300 es
1973			precision mediump float;
1974			precision mediump int;
1975			${DECLARATIONS}
1976
1977			float func (float a) { return -a; }
1978			vec2 func (vec2 a) { return a.yx; }
1979			vec3 func (vec3 a) { return a.xxx; }
1980			vec4 func (vec4 a) { return a.wwww; }
1981
1982			void main()
1983			{
1984				out0 = func(func(func(func(vec4(in0)).xyz).xy).x);
1985				${OUTPUT}
1986			}
1987		""
1988	end
1989
1990	case user_func_arg_int_types
1991		version 300 es
1992		values
1993		{
1994			input int in0		= [ 0 | 1 | -2 | 6 ];
1995			output int out0		= [ 0 | -1 | 2 | -6 ];
1996		}
1997
1998		both ""
1999			#version 300 es
2000			precision mediump float;
2001			precision mediump int;
2002			${DECLARATIONS}
2003
2004			int func (int a) { return -a; }
2005			ivec2 func (ivec2 a) { return a.yx; }
2006			ivec3 func (ivec3 a) { return a.xxx; }
2007			ivec4 func (ivec4 a) { return a.wwww; }
2008
2009			void main()
2010			{
2011				${SETUP}
2012				out0 = func(func(func(func(ivec4(in0)).xyz).xy).x);
2013				${OUTPUT}
2014			}
2015		""
2016	end
2017
2018	case user_func_arg_bool_types
2019		version 300 es
2020		values
2021		{
2022			input bool in0		= [ true | false ];
2023			output bool out0	= [ false | true ];
2024		}
2025
2026		both ""
2027			#version 300 es
2028			precision mediump float;
2029			${DECLARATIONS}
2030
2031			bool func (bool a) { return !a; }
2032			bvec2 func (bvec2 a) { return a.yx; }
2033			bvec3 func (bvec3 a) { return a.xxx; }
2034			bvec4 func (bvec4 a) { return a.wwww; }
2035
2036			void main()
2037			{
2038				${SETUP}
2039				out0 = func(func(func(func(bvec4(in0)).xyz).xy).x);
2040				${OUTPUT}
2041			}
2042		""
2043	end
2044
2045	case user_func_arg_basic_types
2046		version 300 es
2047		values
2048		{
2049			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2050			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2051		}
2052
2053		both ""
2054			#version 300 es
2055			precision mediump float;
2056			precision mediump int;
2057			${DECLARATIONS}
2058
2059			float func (float a) { return -a; }
2060			vec2 func (vec2 a) { return a.yx; }
2061			vec3 func (vec3 a) { return a.xxx; }
2062			vec4 func (vec4 a) { return a.wwww; }
2063			int func (int a) { return -a; }
2064			ivec2 func (ivec2 a) { return a.yx; }
2065			ivec3 func (ivec3 a) { return a.xxx; }
2066			ivec4 func (ivec4 a) { return a.wwww; }
2067			bool func (bool a) { return !a; }
2068			bvec2 func (bvec2 a) { return a.yx; }
2069			bvec3 func (bvec3 a) { return a.xxx; }
2070			bvec4 func (bvec4 a) { return a.wwww; }
2071
2072			void main()
2073			{
2074				${SETUP}
2075				if (func(func(bvec4(false)).x))
2076					out0 = func(in0) * float(func(-1));
2077				else
2078					out0 = float(func(func(ivec4(func(func(func(vec4(0.5)).xyz).xy).xxxx)).xy).x);
2079				${OUTPUT}
2080			}
2081		""
2082	end
2083
2084	case user_func_arg_complex_types
2085		version 300 es
2086		values
2087		{
2088			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2089			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2090		}
2091
2092		both ""
2093			#version 300 es
2094			precision mediump float;
2095			precision mediump int;
2096			${DECLARATIONS}
2097
2098			struct Pos { float a, b, c; };
2099			struct Line { Pos start, end; };
2100
2101			float func (float a) { return -a; }
2102			float func (float a[4]) { return a[0] + a[3]; }
2103			vec2 func (vec2 a) { return a.yx; }
2104			vec3 func (vec3 a) { return a.xxx; }
2105			vec4 func (vec4 a) { return a.wwww; }
2106			vec4 func (vec4 a[4]) { return a[1] + a[2]; }
2107			int func (int a) { return -a; }
2108			ivec2 func (ivec2 a) { return a.yx; }
2109			ivec3 func (ivec3 a) { return a.xxx; }
2110			ivec4 func (ivec4 a) { return a.wwww; }
2111			bool func (bool a) { return !a; }
2112			bvec2 func (bvec2 a) { return a.yx; }
2113			bvec3 func (bvec3 a) { return a.xxx; }
2114			bvec4 func (bvec4 a) { return a.wwww; }
2115			Pos func (Pos a) { return a; }
2116			Line func (Line a) { return Line(a.end, a.start); }
2117
2118			void main()
2119			{
2120				${SETUP}
2121				float arr[4];
2122				vec4 arr2[4];
2123				out0 = func(arr) + func(arr2).x;
2124				if (func(func(bvec4(false)).x))
2125					out0 = func(in0) * float(func(-1));
2126				else
2127					out0 = float(func(func(ivec4(func(func(func(vec4(0.5)).xyz).xy).xxxx)).xy).x);
2128				${OUTPUT}
2129			}
2130		""
2131	end
2132
2133	case user_func_arguments
2134		version 300 es
2135		values
2136		{
2137			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2138			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2139		}
2140
2141		both ""
2142			#version 300 es
2143			precision mediump float;
2144			${DECLARATIONS}
2145
2146			float func (float a)
2147			{
2148				return -a;
2149			}
2150
2151			float func (float a, float b)
2152			{
2153				return a * b;
2154			}
2155
2156			void main()
2157			{
2158				out0 = func(in0) * func(-0.5, -2.0);
2159				${OUTPUT}
2160			}
2161		""
2162	end
2163
2164	case array_size
2165		version 300 es
2166		values
2167		{
2168			output float out0	= [ 1.0 ];
2169		}
2170
2171		both ""
2172			#version 300 es
2173			precision mediump float;
2174			${DECLARATIONS}
2175
2176			float func (float f[3])
2177			{
2178				return f[0];
2179			}
2180
2181			float func (float f[4])
2182			{
2183				return f[1];
2184			}
2185
2186			void main ()
2187			{
2188				${SETUP}
2189				float[4] x = float[4] (-1.0, 1.0, 0.0, 0.0);
2190				out0 = func(x);
2191				${OUTPUT}
2192			}
2193		""
2194	end
2195
2196end # overloading
2197
2198group array_arguments "Arrays as Arguments"
2199
2200	case local_in_float
2201		version 300 es
2202		values
2203		{
2204			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2205			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2206		}
2207
2208		both ""
2209			#version 300 es
2210			precision mediump float;
2211			${DECLARATIONS}
2212
2213			float func (in float a[4])
2214			{
2215				a[0] = -1.0;
2216				a[2] = -4.0;
2217				a[3] = -3.0 * a[1];
2218				return a[0];
2219			}
2220
2221			void main()
2222			{
2223				float arr[4];
2224				arr[0] = in0.x;
2225				arr[1] = in0.y;
2226				arr[2] = in0.z;
2227				arr[3] = in0.w;
2228				float f = func(arr);
2229				out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
2230				${OUTPUT}
2231			}
2232		""
2233	end
2234
2235	case global_in_float
2236		version 300 es
2237		values
2238		{
2239			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2240			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2241		}
2242
2243		both ""
2244			#version 300 es
2245			precision mediump float;
2246			${DECLARATIONS}
2247
2248			float func (in float a[4])
2249			{
2250				a[0] = -1.0;
2251				a[2] = -4.0;
2252				a[3] = -3.0 * a[1];
2253				return a[0];
2254			}
2255
2256			float arr[4];
2257
2258			void main()
2259			{
2260				arr[0] = in0.x;
2261				arr[1] = in0.y;
2262				arr[2] = in0.z;
2263				arr[3] = in0.w;
2264				float f = func(arr);
2265				out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
2266				${OUTPUT}
2267			}
2268		""
2269	end
2270
2271	case local_in_int
2272		version 300 es
2273		values
2274		{
2275			input ivec4 in0		= [ ivec4(0, 1, 2, -4) | ivec4(-7, -11, 13, 19) ];
2276			output ivec4 out0	= [ ivec4(0, -1, -2, 4) | ivec4(7, 11, -13, -19) ];
2277		}
2278
2279		both ""
2280			#version 300 es
2281			precision mediump float;
2282			precision mediump int;
2283			${DECLARATIONS}
2284
2285			int func (in int a[4])
2286			{
2287				a[0] = -1;
2288				a[2] = -4;
2289				a[3] = -3 * a[1];
2290				return a[0];
2291			}
2292
2293			void main()
2294			{
2295				${SETUP}
2296				int arr[4];
2297				arr[0] = in0.x;
2298				arr[1] = in0.y;
2299				arr[2] = in0.z;
2300				arr[3] = in0.w;
2301				int f = func(arr);
2302				out0 = f * ivec4(arr[0], arr[1], arr[2], arr[3]);
2303				${OUTPUT}
2304			}
2305		""
2306	end
2307
2308	case global_in_int
2309		version 300 es
2310		values
2311		{
2312			input ivec4 in0		= [ ivec4(0, 1, 2, 4) | ivec4(-7, -11, 13, 19) ];
2313			output ivec4 out0	= [ ivec4(0, -1, -2, -4) | ivec4(7, 11, -13, -19) ];
2314		}
2315
2316		both ""
2317			#version 300 es
2318			precision mediump float;
2319			precision mediump int;
2320			${DECLARATIONS}
2321
2322			int func (in int a[4])
2323			{
2324				a[0] = -1;
2325				a[2] = -4;
2326				a[3] = -3 * a[1];
2327				return a[0];
2328			}
2329
2330			int arr[4];
2331
2332			void main()
2333			{
2334				${SETUP}
2335				arr[0] = in0.x;
2336				arr[1] = in0.y;
2337				arr[2] = in0.z;
2338				arr[3] = in0.w;
2339				int f = func(arr);
2340				out0 = f * ivec4(arr[0], arr[1], arr[2], arr[3]);
2341				${OUTPUT}
2342			}
2343
2344		""
2345	end
2346
2347	case local_in_bool
2348		version 300 es
2349		values
2350		{
2351			input bvec4 in0		= [ bvec4(true, true, false, true) | bvec4(false, false, false, false) ];
2352			output bvec4 out0	= [ bvec4(false, false, true, false) | bvec4(true, true, true, true) ];
2353		}
2354
2355		both ""
2356			#version 300 es
2357			precision mediump float;
2358			${DECLARATIONS}
2359
2360			bool func (in bool a[4])
2361			{
2362				a[0] = false;
2363				a[2] = true;
2364				a[3] = !a[1];
2365				return a[0];
2366			}
2367
2368			void main()
2369			{
2370				${SETUP}
2371				bool arr[4];
2372				arr[0] = !in0.x;
2373				arr[1] = !in0.y;
2374				arr[2] = !in0.z;
2375				arr[3] = !in0.w;
2376				func(arr);
2377				out0 = bvec4(arr[0], arr[1], arr[2], arr[3]);
2378				${OUTPUT}
2379			}
2380		""
2381	end
2382
2383	case global_in_bool
2384		version 300 es
2385		values
2386		{
2387			input bvec4 in0		= [ bvec4(true, true, false, true) | bvec4(false, false, false, false) ];
2388			output bvec4 out0	= [ bvec4(false, false, true, false) | bvec4(true, true, true, true) ];
2389		}
2390
2391		both ""
2392			#version 300 es
2393			precision mediump float;
2394			${DECLARATIONS}
2395
2396			bool func (in bool a[4])
2397			{
2398				a[0] = false;
2399				a[2] = true;
2400				a[3] = !a[1];
2401				return a[0];
2402			}
2403
2404			bool arr[4];
2405
2406			void main()
2407			{
2408				${SETUP}
2409				arr[0] = !in0.x;
2410				arr[1] = !in0.y;
2411				arr[2] = !in0.z;
2412				arr[3] = !in0.w;
2413				func(arr);
2414				out0 = bvec4(arr[0], arr[1], arr[2], arr[3]);
2415				${OUTPUT}
2416			}
2417		""
2418	end
2419
2420	case test_helpers
2421		version 300 es
2422		desc "Check that helper functions are supported properly."
2423		values
2424		{
2425			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2426			output float out0	= [ 1.0 | 1.0 ];
2427		}
2428
2429		both ""
2430			#version 300 es
2431			precision mediump float;
2432			${DECLARATIONS}
2433
2434			vec4 get (in float arr[4]);
2435			void set (out float arr[4], vec4 val);
2436			void negate (inout float arr[4]);
2437			bool test (in float arr[4], vec4 ref);
2438			bool isEqual (in float a[4], in float b[4]);
2439
2440			void main()
2441			{
2442				float arr[4];
2443				set(arr, in0);
2444				negate(arr);
2445				out0 = float(test(arr, -in0));
2446				${OUTPUT}
2447			}
2448
2449			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2450			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2451			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2452			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2453			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2454			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2455		""
2456	end
2457
2458	case copy_local_in_on_call
2459		version 300 es
2460		desc "Check that local 'in' arguments are copied on call and don't alias."
2461		values
2462		{
2463			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2464			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2465		}
2466
2467		both ""
2468			#version 300 es
2469			precision mediump float;
2470			${DECLARATIONS}
2471
2472			vec4 get (in float arr[4]);
2473			void set (out float arr[4], vec4 val);
2474			void negate (inout float arr[4]);
2475			bool test (in float arr[4], vec4 ref);
2476			bool isEqual (in float a[4], in float b[4]);
2477
2478			float func (in float a[4], in float b[4])
2479			{
2480				a[0] = 2.123;
2481				a[2] = -4.123;
2482				return isEqual(a, b) ? 1.0 : -1.0;
2483			}
2484
2485			void main()
2486			{
2487				float arr[4];
2488				set(arr, in0);
2489				out0 = in0 * func(arr, arr);
2490				${OUTPUT}
2491			}
2492
2493			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2494			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2495			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2496			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2497			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2498			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2499		""
2500	end
2501
2502	case copy_global_in_on_call
2503		version 300 es
2504		desc "Check that global 'in' arguments are copied on call and don't alias."
2505		values
2506		{
2507			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2508			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2509		}
2510
2511		both ""
2512			#version 300 es
2513			precision mediump float;
2514			${DECLARATIONS}
2515
2516			vec4 get (in float arr[4]);
2517			void set (out float arr[4], vec4 val);
2518			void negate (inout float arr[4]);
2519			bool test (in float arr[4], vec4 ref);
2520			bool isEqual (in float a[4], in float b[4]);
2521
2522			float func (in float a[4], in float b[4])
2523			{
2524				a[0] = 2.123;
2525				a[2] = -4.123;
2526				return isEqual(a, b) ? 1.0 : -1.0;
2527			}
2528
2529			float arr[4];
2530
2531			void main()
2532			{
2533				set(arr, in0);
2534				out0 = in0 * func(arr, arr);
2535				${OUTPUT}
2536			}
2537
2538			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2539			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2540			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2541			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2542			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2543			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2544		""
2545	end
2546
2547	case copy_local_inout_on_call
2548		version 300 es
2549		desc "Check that local 'in' arguments are copied on call and don't alias."
2550		values
2551		{
2552			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2553			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2554		}
2555
2556		both ""
2557			#version 300 es
2558			precision mediump float;
2559			${DECLARATIONS}
2560
2561			vec4 get (in float arr[4]);
2562			void set (out float arr[4], vec4 val);
2563			void negate (inout float arr[4]);
2564			bool test (in float arr[4], vec4 ref);
2565			bool isEqual (in float a[4], in float b[4]);
2566
2567			float func (inout float a[4], inout float b[4])
2568			{
2569				negate(a);
2570				return isEqual(a, b) ? 1.0 : -1.0;
2571			}
2572
2573			void main()
2574			{
2575				float arr[4];
2576				set(arr, in0);
2577				float m = func(arr, arr); // returns -1.0
2578				float n = float(test(arr, in0) || test(arr, -in0));
2579				out0 = in0 * m * n;
2580				${OUTPUT}
2581			}
2582
2583			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2584			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2585			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2586			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2587			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2588			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2589		""
2590	end
2591
2592	case copy_global_inout_on_call
2593		version 300 es
2594		desc "Check that global 'in' arguments are copied on call and don't alias."
2595		values
2596		{
2597			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2598			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2599		}
2600
2601		both ""
2602			#version 300 es
2603			precision mediump float;
2604			${DECLARATIONS}
2605
2606			vec4 get (in float arr[4]);
2607			void set (out float arr[4], vec4 val);
2608			void negate (inout float arr[4]);
2609			bool test (in float arr[4], vec4 ref);
2610			bool isEqual (in float a[4], in float b[4]);
2611
2612			float func (in float a[4], in float b[4])
2613			{
2614				negate(a);
2615				return isEqual(a, b) ? 1.0 : -1.0;
2616			}
2617
2618			float arr[4];
2619
2620			void main()
2621			{
2622				set(arr, in0);
2623				float m = func(arr, arr); // returns -1.0
2624				float n = float(test(arr, in0) || test(arr, -in0));
2625				out0 = in0 * m * n;
2626				${OUTPUT}
2627			}
2628
2629			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2630			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2631			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2632			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2633			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2634			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2635		""
2636	end
2637
2638#			vec4 get (in float arr[4]);
2639#			void set (out float arr[4], vec4 val);
2640#			void negate (inout float arr[4]);
2641#			bool test (in float arr[4], vec4 ref);
2642#			bool isEqual (in float a[4], in float b[4]);
2643
2644#			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2645#			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2646#			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2647#			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2648#			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2649#			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2650
2651end # array_arguments
2652
2653#group qualifiers "Function Parameter Qualifiers"
2654#
2655#end # qualifiers
2656
2657group control_flow "Control Flow In Functions"
2658
2659	case simple_return
2660		version 300 es
2661		values
2662		{
2663			input float in0		= [ -0.5 | 1.5 ];
2664			output float out0	= [ 0.5 | -1.5 ];
2665		}
2666
2667		both ""
2668			#version 300 es
2669			precision mediump float;
2670			${DECLARATIONS}
2671
2672			float func (float a)
2673			{
2674				return -a;
2675				a = a * -1.0;
2676				return 1.0;
2677			}
2678
2679			void main()
2680			{
2681				${SETUP}
2682				out0 = func(in0);
2683				${OUTPUT}
2684			}
2685		""
2686	end
2687
2688	case return_in_if
2689		version 300 es
2690		values
2691		{
2692			input float in0		= [ -0.5 | 1.5 ];
2693			output float out0	= [ 0.5 | -1.5 ];
2694		}
2695
2696		both ""
2697			#version 300 es
2698			precision mediump float;
2699			${DECLARATIONS}
2700
2701			float func (float a)
2702			{
2703				if (a != 0.0)
2704					return -a;
2705				return 1.0;
2706			}
2707
2708			void main()
2709			{
2710				${SETUP}
2711				out0 = func(in0);
2712				${OUTPUT}
2713			}
2714		""
2715	end
2716
2717	case return_in_else
2718		version 300 es
2719		values
2720		{
2721			input float in0		= [ -0.5 | 1.5 ];
2722			output float out0	= [ 0.5 | -1.5 ];
2723		}
2724
2725		both ""
2726			#version 300 es
2727			precision mediump float;
2728			${DECLARATIONS}
2729
2730			float func (float a)
2731			{
2732				if (a == 0.0)
2733					return 1.0;
2734				else
2735					return -a;
2736				return 1.0;
2737			}
2738
2739			void main()
2740			{
2741				${SETUP}
2742				out0 = func(in0);
2743				${OUTPUT}
2744			}
2745		""
2746	end
2747
2748	case return_in_loop
2749		version 300 es
2750		values
2751		{
2752			input float in0		= [ -0.5 | 1.5 ];
2753			output float out0	= [ 0.5 | -1.5 ];
2754		}
2755
2756		both ""
2757			#version 300 es
2758			precision mediump float;
2759			${DECLARATIONS}
2760
2761			float func (float a)
2762			{
2763				while (a < 100.0)
2764					return -a;
2765				return 1.0;
2766			}
2767
2768			void main()
2769			{
2770				${SETUP}
2771				out0 = func(in0);
2772				${OUTPUT}
2773			}
2774		""
2775	end
2776
2777	case return_in_loop_if
2778		version 300 es
2779		values
2780		{
2781			input float in0		= [ -0.5 | 1.5 ];
2782			output float out0	= [ 0.5 | -1.5 ];
2783		}
2784
2785		both ""
2786			#version 300 es
2787			precision mediump float;
2788			${DECLARATIONS}
2789
2790			float func (float a)
2791			{
2792				while (a < 100.0)
2793				{
2794					a = -a;
2795					if (a != 0.0)
2796						return a;
2797					else
2798						return -1.0;
2799				}
2800				return 1.0;
2801			}
2802
2803			void main()
2804			{
2805				${SETUP}
2806				out0 = func(in0);
2807				${OUTPUT}
2808			}
2809		""
2810	end
2811
2812	case return_after_loop
2813		version 300 es
2814		values
2815		{
2816			input float in0		= [ -0.5 | 1.5 ];
2817			output float out0	= [ 0.5 | -1.5 ];
2818		}
2819
2820		both ""
2821			#version 300 es
2822			precision mediump float;
2823			${DECLARATIONS}
2824
2825			float func (float a)
2826			{
2827				for (int i = 0; i < 5; i++)
2828					a = -a;
2829				return a;
2830			}
2831
2832			void main()
2833			{
2834				${SETUP}
2835				out0 = func(in0);
2836				${OUTPUT}
2837			}
2838		""
2839	end
2840
2841	case return_after_break
2842		version 300 es
2843		values
2844		{
2845			input float in0		= [ -0.5 | 1.5 ];
2846			output float out0	= [ 0.5 | -1.5 ];
2847		}
2848
2849		both ""
2850			#version 300 es
2851			precision mediump float;
2852			${DECLARATIONS}
2853
2854			float func (float a)
2855			{
2856				for (int i = 0; i < 6; i++)
2857				{
2858					a = -a;
2859					if (i == 4)
2860						break;
2861				}
2862				return a;
2863			}
2864
2865			void main()
2866			{
2867				${SETUP}
2868				out0 = func(in0);
2869				${OUTPUT}
2870			}
2871		""
2872	end
2873
2874	case return_after_continue
2875		version 300 es
2876		values
2877		{
2878			input float in0		= [ -0.5 | 1.5 ];
2879			output float out0	= [ 0.5 | -1.5 ];
2880		}
2881
2882		both ""
2883			#version 300 es
2884			precision mediump float;
2885			${DECLARATIONS}
2886
2887			float func (float a)
2888			{
2889				for (int i = 0; i < 6; i++)
2890				{
2891					if (i == 4)
2892						continue;
2893					a = -a;
2894				}
2895				return a;
2896			}
2897
2898			void main()
2899			{
2900				${SETUP}
2901				out0 = func(in0);
2902				${OUTPUT}
2903			}
2904		""
2905	end
2906
2907	case return_in_nested_loop
2908		version 300 es
2909		values
2910		{
2911			input float in0		= [ -0.5 | 1.5 ];
2912			output float out0	= [ 0.5 | -1.5 ];
2913		}
2914
2915		both ""
2916			#version 300 es
2917			precision mediump float;
2918			${DECLARATIONS}
2919
2920			float func (float a)
2921			{
2922				for (int i = 0; i < 6; i++)
2923				{
2924					a = -a;
2925					for (int j = 0; j < 4; j++)
2926					{
2927						a = -a;
2928						if (i == 1)
2929							return a;
2930					}
2931					if (i == 4)
2932						return 1.0;
2933				}
2934				return 1.0;
2935			}
2936
2937			void main()
2938			{
2939				${SETUP}
2940				out0 = func(in0);
2941				${OUTPUT}
2942			}
2943		""
2944	end
2945
2946	case return_after_loop_sequence
2947		version 300 es
2948		values
2949		{
2950			input float in0		= [ -0.5 | 1.5 ];
2951			output float out0	= [ 0.5 | -1.5 ];
2952		}
2953
2954		both ""
2955			#version 300 es
2956			precision mediump float;
2957			${DECLARATIONS}
2958
2959			float func (float a)
2960			{
2961				int i;
2962				for (i = 0; i < 6; i++) // negate a
2963				{
2964					a = -a;
2965					if (i == 4)
2966						a = -a;
2967				}
2968
2969				for (; i < 10; i++) // keep a
2970				{
2971					if (i == 8)
2972						continue;
2973					else if (i == 9)
2974						break;
2975					a = -a;
2976				}
2977
2978				return a;
2979			}
2980
2981			void main()
2982			{
2983				${SETUP}
2984				out0 = func(in0);
2985				${OUTPUT}
2986			}
2987		""
2988	end
2989
2990	case mixed_return_break_continue
2991		version 300 es
2992		values
2993		{
2994			input float in0		= [ -0.5 | 1.5 ];
2995			output float out0	= [ 0.5 | -1.5 ];
2996		}
2997
2998		both ""
2999			#version 300 es
3000			precision mediump float;
3001			${DECLARATIONS}
3002
3003			float func (float a)
3004			{
3005				int i;
3006				for (i = 0; i < 6; i++)
3007				{
3008					if (i == 0)
3009						continue;
3010					else if (i == 1)
3011					{
3012					}
3013					else if (i == 3)
3014						break;
3015					else
3016						return a;
3017					a = -a;
3018				}
3019
3020				return 1.0;
3021			}
3022
3023			void main()
3024			{
3025				${SETUP}
3026				out0 = func(in0);
3027				${OUTPUT}
3028			}
3029		""
3030	end
3031
3032end # control_flow
3033
3034group misc "Miscellaneous"
3035
3036	case multi_arg_float
3037		version 300 es
3038		values
3039		{
3040			input vec4 in0		= [ vec4(0.0, 1.0, -2.0, 0.5) | vec4(2.0, 2.5, 4.0, -7.0) ];
3041			output float out0	= [ 0.5 | -1.5 ]; # -sum(in0)
3042		}
3043
3044		both ""
3045			#version 300 es
3046			precision mediump float;
3047			${DECLARATIONS}
3048
3049			float sum(vec4 v) { return (v.x + v.y + v.z + v.w); }
3050
3051			float func (float a, vec3 b, vec2 c, vec2 d, vec4 e)
3052			{
3053				return -sum(vec4(a, b) + vec4(c, d)) + sum(e);
3054			}
3055
3056			void main()
3057			{
3058				${SETUP}
3059				out0 = func(in0.y, in0.xzw, in0.wz, in0.yx, in0);
3060				${OUTPUT}
3061			}
3062		""
3063	end
3064
3065	case multi_arg_int
3066		version 300 es
3067		values
3068		{
3069			input ivec4 in0		= [ ivec4(-1, 0, 2, 2) | ivec4(1, 4, -8, 2) ];
3070			output int out0		= [ -3 | 1 ];
3071		}
3072
3073		both ""
3074			#version 300 es
3075			precision mediump float;
3076			precision mediump int;
3077			${DECLARATIONS}
3078
3079			int sum(ivec4 v) { return (v.x + v.y + v.z + v.w); }
3080
3081			int func (int a, ivec3 b, ivec2 c, ivec2 d, ivec4 e)
3082			{
3083				return -sum(ivec4(a, b) + ivec4(c, d)) + sum(e);
3084			}
3085
3086			void main()
3087			{
3088				${SETUP}
3089				out0 = func(in0.y, in0.xzw, in0.wz, in0.yx, in0);
3090				${OUTPUT}
3091			}
3092		""
3093	end
3094
3095	case argument_eval_order_1
3096		version 300 es
3097		values
3098		{
3099			input int in0	= [  0 | 1 | 3 | 5 ];
3100			output int out0	= [ -1 | 5 | 11 | 17 ];
3101		}
3102
3103		both ""
3104			#version 300 es
3105			precision highp float;
3106			${DECLARATIONS}
3107
3108			int func (float a, int b, bool c, int d)
3109			{
3110				if (c)
3111					return b + int(a) + d;
3112				else
3113					return -1;
3114			}
3115
3116			void main ()
3117			{
3118				${SETUP}
3119				float v0 = float(in0);
3120				int v1 = in0;
3121				out0 = func((v0 += 1.0), v1++, (v0 > 1.5), v1);
3122				${OUTPUT}
3123			}
3124		""
3125	end
3126
3127	case argument_eval_order_2
3128		version 300 es
3129		values
3130		{
3131			input int in0	= [ 0 | -1 | 3 | 5 ];
3132			output int out0	= [ 3 | -1 | 9 | 13 ];
3133		}
3134
3135		both ""
3136			#version 300 es
3137			precision highp float;
3138			${DECLARATIONS}
3139
3140			int g;
3141
3142			int modG (int v)
3143			{
3144				g += v;
3145				return v;
3146			}
3147
3148			int func (float a, int b, bool c, int d)
3149			{
3150				if (c)
3151					return b + int(a) + d;
3152				else
3153					return -1;
3154			}
3155
3156			void main ()
3157			{
3158				${SETUP}
3159				out0 = func(float(g = in0), modG(2), --g > 0, g);
3160				${OUTPUT}
3161			}
3162		""
3163	end
3164
3165end # misc
3166
3167group invalid "Invalid Functions"
3168	case break_in_body
3169		version 300 es
3170		expect compile_fail
3171		both ""
3172			#version 300 es
3173			precision mediump float;
3174			${DECLARATIONS}
3175
3176			void func ()
3177			{
3178				break;
3179			}
3180
3181			void main ()
3182			{
3183				${POSITION_FRAG_COLOR} = vec4(1.0);
3184			}
3185		""
3186	end
3187
3188	case continue_in_body
3189		version 300 es
3190		expect compile_fail
3191		both ""
3192			#version 300 es
3193			precision mediump float;
3194			${DECLARATIONS}
3195
3196			void func ()
3197			{
3198				continue;
3199			}
3200
3201			void main ()
3202			{
3203				${POSITION_FRAG_COLOR} = vec4(1.0);
3204			}
3205		""
3206	end
3207
3208	case return_value_from_void_function
3209		version 300 es
3210		expect compile_fail
3211		both ""
3212			#version 300 es
3213			precision mediump float;
3214			${DECLARATIONS}
3215
3216			void func ()
3217			{
3218				return 1.0;
3219			}
3220
3221			void main ()
3222			{
3223				${POSITION_FRAG_COLOR} = vec4(1.0);
3224			}
3225		""
3226	end
3227
3228	case extra_arguments
3229		version 300 es
3230		expect compile_fail
3231		both ""
3232			#version 300 es
3233			precision mediump float;
3234			${DECLARATIONS}
3235
3236			void func (float f)
3237			{
3238			}
3239
3240			void main ()
3241			{
3242				func(1.0, 2.0);
3243				${POSITION_FRAG_COLOR} = vec4(1.0);
3244			}
3245		""
3246	end
3247
3248	case missing_arguments
3249		version 300 es
3250		expect compile_fail
3251		both ""
3252			#version 300 es
3253			precision mediump float;
3254			${DECLARATIONS}
3255
3256			void func (float f)
3257			{
3258			}
3259
3260			void main ()
3261			{
3262				func();
3263				${POSITION_FRAG_COLOR} = vec4(1.0);
3264			}
3265		""
3266	end
3267
3268	case missing_argument_type
3269		version 300 es
3270		expect compile_fail
3271		both ""
3272			#version 300 es
3273			precision mediump float;
3274			${DECLARATIONS}
3275
3276			void func (in f)
3277			{
3278			}
3279
3280			void main ()
3281			{
3282				${POSITION_FRAG_COLOR} = vec4(1.0);
3283			}
3284		""
3285	end
3286
3287	case argument_basetype_mismatch
3288		version 300 es
3289		expect compile_fail
3290		both ""
3291			#version 300 es
3292			precision mediump float;
3293			precision mediump int;
3294			${DECLARATIONS}
3295
3296			void func (float f)
3297			{
3298			}
3299
3300			void main ()
3301			{
3302				func(2);
3303				${POSITION_FRAG_COLOR} = vec4(1.0);
3304			}
3305		""
3306	end
3307
3308	case argument_scalar_vector_mismatch
3309		version 300 es
3310		expect compile_fail
3311		both ""
3312			#version 300 es
3313			precision mediump float;
3314			${DECLARATIONS}
3315
3316			void func (vec2 f)
3317			{
3318			}
3319
3320			void main ()
3321			{
3322				func(2.0);
3323				${POSITION_FRAG_COLOR} = vec4(1.0);
3324			}
3325		""
3326	end
3327
3328	case argument_vector_size_mismatch
3329		version 300 es
3330		expect compile_fail
3331		both ""
3332			#version 300 es
3333			precision mediump float;
3334			${DECLARATIONS}
3335
3336			void func (vec3 f)
3337			{
3338			}
3339
3340			void main ()
3341			{
3342				func(vec2(2.0));
3343				${POSITION_FRAG_COLOR} = vec4(1.0);
3344			}
3345		""
3346	end
3347
3348	case duplicate_function
3349		version 300 es
3350		expect compile_fail
3351		both ""
3352			#version 300 es
3353			precision mediump float;
3354			${DECLARATIONS}
3355
3356			void func (vec3 f);
3357
3358			void func (vec3 f)
3359			{
3360			}
3361
3362			void func (vec3 f)
3363			{
3364			}
3365
3366			void main ()
3367			{
3368				${POSITION_FRAG_COLOR} = vec4(1.0);
3369			}
3370		""
3371	end
3372
3373	case prototype_mismatch_return_type
3374		version 300 es
3375		expect compile_fail
3376		both ""
3377			#version 300 es
3378			precision mediump float;
3379			${DECLARATIONS}
3380
3381			void func (vec3 f);
3382
3383			void main ()
3384			{
3385				${POSITION_FRAG_COLOR} = vec4(1.0);
3386			}
3387
3388			float func (vec3 f)
3389			{
3390				return f.x;
3391			}
3392		""
3393	end
3394
3395	case prototype_unspecified_array_size
3396		version 300 es
3397		expect compile_fail
3398		both ""
3399			#version 300 es
3400			precision mediump float;
3401			${DECLARATIONS}
3402
3403			void func (vec3 f[]);
3404
3405			void main ()
3406			{
3407				${POSITION_FRAG_COLOR} = vec4(1.0);
3408			}
3409		""
3410	end
3411
3412	case call_mismatch_argument_array_size
3413		version 300 es
3414		expect compile_fail
3415		both ""
3416			#version 300 es
3417			precision mediump float;
3418			${DECLARATIONS}
3419
3420			void func (vec3 f[3]);
3421			void func (vec3 f[3])
3422			{
3423			}
3424
3425			void main ()
3426			{
3427				vec3 array[4];
3428				func(array);
3429				${POSITION_FRAG_COLOR} = vec4(1.0);
3430			}
3431		""
3432	end
3433
3434	case prototype_mismatch_argument_const
3435		version 300 es
3436		expect compile_fail
3437		both ""
3438			#version 300 es
3439			precision mediump float;
3440			${DECLARATIONS}
3441
3442			void func (vec3 f);
3443			void func (const vec3 f)
3444			{
3445			}
3446
3447			void main ()
3448			{
3449				${POSITION_FRAG_COLOR} = vec4(1.0);
3450			}
3451		""
3452	end
3453
3454	case prototype_mismatch_argument_array_const
3455		version 300 es
3456		expect compile_fail
3457		both ""
3458			#version 300 es
3459			precision mediump float;
3460			${DECLARATIONS}
3461
3462			void func (vec3 f[3]);
3463			void func (const vec3 f[3])
3464			{
3465			}
3466
3467			void main ()
3468			{
3469				${POSITION_FRAG_COLOR} = vec4(1.0);
3470			}
3471		""
3472	end
3473
3474	case prototype_mismatch_array_inout
3475		version 300 es
3476		expect compile_fail
3477		both ""
3478			#version 300 es
3479			precision mediump float;
3480			${DECLARATIONS}
3481
3482			void func (out vec3 f);
3483			void func (inout vec3 f)
3484			{
3485			}
3486
3487			void main ()
3488			{
3489				${POSITION_FRAG_COLOR} = vec4(1.0);
3490			}
3491		""
3492	end
3493
3494	case missing_return_type
3495		version 300 es
3496		expect compile_fail
3497		both ""
3498			#version 300 es
3499			precision mediump float;
3500			${DECLARATIONS}
3501
3502			func (float f);
3503			func (inout vec3 f[3])
3504			{
3505			}
3506
3507			void main ()
3508			{
3509				${POSITION_FRAG_COLOR} = vec4(1.0);
3510			}
3511		""
3512	end
3513
3514	case call_before_definition
3515		version 300 es
3516		expect compile_fail
3517		both ""
3518			#version 300 es
3519			precision mediump float;
3520			${DECLARATIONS}
3521
3522			void main ()
3523			{
3524				func(1.0);
3525				${POSITION_FRAG_COLOR} = vec4(1.0);
3526			}
3527
3528			void func (float f)
3529			{
3530			}
3531
3532		""
3533	end
3534
3535	case argument_precision_overload
3536		version 300 es
3537		expect compile_fail
3538		both ""
3539			#version 300 es
3540			precision mediump float;
3541			${DECLARATIONS}
3542
3543			float func (lowp float f)
3544			{
3545				return f;
3546			}
3547
3548			float func (mediump float f)
3549			{
3550				return f;
3551			}
3552
3553			void main ()
3554			{
3555				${POSITION_FRAG_COLOR} = vec4(1.0);
3556			}
3557		""
3558	end
3559
3560	case argument_in_out_overload
3561		version 300 es
3562		expect compile_fail
3563		both ""
3564			#version 300 es
3565			precision mediump float;
3566			${DECLARATIONS}
3567
3568			void func (in float f)
3569			{
3570			}
3571
3572			void func (out float f)
3573			{
3574				f = 1.0;
3575			}
3576
3577			void main ()
3578			{
3579				${POSITION_FRAG_COLOR} = vec4(1.0);
3580			}
3581		""
3582	end
3583
3584	case argument_in_inout_overload
3585		version 300 es
3586		expect compile_fail
3587		both ""
3588			#version 300 es
3589			precision mediump float;
3590			${DECLARATIONS}
3591
3592			void func (in float f)
3593			{
3594			}
3595
3596			void func (inout float f)
3597			{
3598				f = -f;
3599			}
3600
3601			void main ()
3602			{
3603				${POSITION_FRAG_COLOR} = vec4(1.0);
3604			}
3605		""
3606	end
3607
3608	case argument_out_inout_overload
3609		version 300 es
3610		expect compile_fail
3611		both ""
3612			#version 300 es
3613			precision mediump float;
3614			${DECLARATIONS}
3615
3616			void func (out float f)
3617			{
3618				f = -1.0;
3619			}
3620
3621			void func (inout float f)
3622			{
3623				f = -f;
3624			}
3625
3626			void main ()
3627			{
3628				${POSITION_FRAG_COLOR} = vec4(1.0);
3629			}
3630		""
3631	end
3632
3633	case return_type_overload
3634		version 300 es
3635		expect compile_fail
3636		both ""
3637			#version 300 es
3638			precision mediump float;
3639			${DECLARATIONS}
3640
3641			float func (float f)
3642			{
3643				return f;
3644			}
3645
3646			int func (float f)
3647			{
3648				return int(f);
3649			}
3650
3651			void main ()
3652			{
3653				${POSITION_FRAG_COLOR} = vec4(1.0);
3654			}
3655		""
3656	end
3657
3658	case return_type_precision_overload
3659		version 300 es
3660		expect compile_fail
3661		both ""
3662			#version 300 es
3663			precision mediump float;
3664			${DECLARATIONS}
3665
3666			lowp float func (float f)
3667			{
3668				return f;
3669			}
3670
3671			mediump float func (float f)
3672			{
3673				return f;
3674			}
3675
3676			void main ()
3677			{
3678				${POSITION_FRAG_COLOR} = vec4(1.0);
3679			}
3680		""
3681	end
3682
3683	case return_type_const_overload
3684		version 300 es
3685		expect compile_fail
3686		both ""
3687			#version 300 es
3688			precision mediump float;
3689			${DECLARATIONS}
3690
3691			float func (float f)
3692			{
3693				return f;
3694			}
3695
3696			const float func (float f)
3697			{
3698				return f;
3699			}
3700
3701			void main ()
3702			{
3703				${POSITION_FRAG_COLOR} = vec4(1.0);
3704			}
3705		""
3706	end
3707
3708	case return_without_value
3709		version 300 es
3710		expect compile_fail
3711		both ""
3712			#version 300 es
3713			precision mediump float;
3714			${DECLARATIONS}
3715
3716			float func (float f)
3717			{
3718				return;
3719				return 1.0;
3720			}
3721
3722			void main ()
3723			{
3724				${POSITION_FRAG_COLOR} = vec4(1.0);
3725			}
3726		""
3727	end
3728
3729	case local_function_prototype
3730		version 300 es
3731		expect compile_fail
3732		both ""
3733			#version 300 es
3734			precision mediump float;
3735			${DECLARATIONS}
3736
3737			void main ()
3738			{
3739				float func (float f);
3740
3741				${POSITION_FRAG_COLOR} = vec4(1.0);
3742			}
3743		""
3744	end
3745
3746	case local_function_definition
3747		version 300 es
3748		expect compile_fail
3749		both ""
3750			#version 300 es
3751			precision mediump float;
3752			${DECLARATIONS}
3753
3754			void main ()
3755			{
3756				float func (float f)
3757				{
3758					return 1.0;
3759				}
3760
3761				${POSITION_FRAG_COLOR} = vec4(1.0);
3762			}
3763		""
3764	end
3765
3766	case name_type_conflict
3767		version 300 es
3768		expect compile_fail
3769		both ""
3770			#version 300 es
3771			precision mediump float;
3772			${DECLARATIONS}
3773
3774			struct foo { float a; }
3775
3776			float foo (float f)
3777			{
3778				return 1.0;
3779			}
3780
3781			void main ()
3782			{
3783				${POSITION_FRAG_COLOR} = vec4(1.0);
3784			}
3785		""
3786	end
3787
3788	case const_overload
3789		version 300 es
3790		expect compile_fail
3791		both ""
3792			#version 300 es
3793			precision mediump float;
3794			${DECLARATIONS}
3795
3796			void func (vec3 f)
3797			{
3798			}
3799
3800			void func (const vec3 f)
3801			{
3802			}
3803
3804			void main ()
3805			{
3806				${POSITION_FRAG_COLOR} = vec4(1.0);
3807			}
3808		""
3809	end
3810
3811	case uniform_local
3812		version 300 es
3813		expect compile_fail
3814		both ""
3815			#version 300 es
3816			precision mediump float;
3817			${DECLARATIONS}
3818
3819			void func (vec3 f)
3820			{
3821				uniform float u;
3822			}
3823
3824			void main ()
3825			{
3826				${POSITION_FRAG_COLOR} = vec4(1.0);
3827			}
3828		""
3829	end
3830
3831	case in_local
3832		version 300 es
3833		expect compile_fail
3834		both ""
3835			#version 300 es
3836			precision mediump float;
3837			${DECLARATIONS}
3838
3839			void func (vec3 f)
3840			{
3841				in float v;
3842			}
3843
3844			void main ()
3845			{
3846				${POSITION_FRAG_COLOR} = vec4(1.0);
3847			}
3848		""
3849	end
3850
3851	case out_local
3852		version 300 es
3853		expect compile_fail
3854		both ""
3855			#version 300 es
3856			precision mediump float;
3857			${DECLARATIONS}
3858
3859			void func (vec3 f)
3860			{
3861				in float a;
3862			}
3863
3864			void main ()
3865			{
3866				${POSITION_FRAG_COLOR} = vec4(1.0);
3867			}
3868		""
3869	end
3870
3871	case inout_local
3872		version 300 es
3873		expect compile_fail
3874		both ""
3875			#version 300 es
3876			precision mediump float;
3877			${DECLARATIONS}
3878
3879			void func (vec3 f)
3880			{
3881				inout float a;
3882			}
3883
3884			void main ()
3885			{
3886				${POSITION_FRAG_COLOR} = vec4(1.0);
3887			}
3888		""
3889	end
3890
3891	case uniform_argument
3892		version 300 es
3893		expect compile_fail
3894		both ""
3895			#version 300 es
3896			precision mediump float;
3897			${DECLARATIONS}
3898
3899			void func (uniform vec3 f)
3900			{
3901			}
3902
3903			void main ()
3904			{
3905				${POSITION_FRAG_COLOR} = vec4(1.0);
3906			}
3907		""
3908	end
3909
3910	case uniform_return_type
3911		version 300 es
3912		expect compile_fail
3913		both ""
3914			#version 300 es
3915			precision mediump float;
3916			${DECLARATIONS}
3917
3918			uniform float func (vec3 f)
3919			{
3920				return f.x;
3921			}
3922
3923			void main ()
3924			{
3925				${POSITION_FRAG_COLOR} = vec4(1.0);
3926			}
3927		""
3928	end
3929
3930	case in_return_type
3931		version 300 es
3932		expect compile_fail
3933		both ""
3934			#version 300 es
3935			precision mediump float;
3936			${DECLARATIONS}
3937
3938			in float func (vec3 f)
3939			{
3940				return f.x;
3941			}
3942
3943			void main ()
3944			{
3945				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3946			}
3947		""
3948	end
3949
3950	case out_return_type
3951		version 300 es
3952		expect compile_fail
3953		both ""
3954			#version 300 es
3955			precision mediump float;
3956			${DECLARATIONS}
3957
3958			out float func (vec3 f)
3959			{
3960				return f.x;
3961			}
3962
3963			void main ()
3964			{
3965				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3966			}
3967		""
3968	end
3969
3970	case inout_return_type
3971		version 300 es
3972		expect compile_fail
3973		both ""
3974			#version 300 es
3975			precision mediump float;
3976			${DECLARATIONS}
3977
3978			inout float func (vec3 f)
3979			{
3980				return f.x;
3981			}
3982
3983			void main ()
3984			{
3985				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3986			}
3987		""
3988	end
3989
3990	case main_invalid_return_type
3991		version 300 es
3992		expect compile_fail
3993		both ""
3994			#version 300 es
3995			precision mediump float;
3996			${DECLARATIONS}
3997
3998			float main ()
3999			{
4000				${POSITION_FRAG_COLOR} = vec4(1.0);
4001			}
4002		""
4003	end
4004
4005	case main_has_arguments
4006		version 300 es
4007		expect compile_fail
4008		both ""
4009			#version 300 es
4010			precision mediump float;
4011			${DECLARATIONS}
4012
4013			void main (float f)
4014			{
4015				${POSITION_FRAG_COLOR} = vec4(1.0);
4016			}
4017		""
4018	end
4019
4020	case main_missing_return_type
4021		version 300 es
4022		expect compile_fail
4023		both ""
4024			#version 300 es
4025			precision mediump float;
4026			${DECLARATIONS}
4027
4028			main ()
4029			{
4030				${POSITION_FRAG_COLOR} = vec4(1.0);
4031			}
4032		""
4033	end
4034
4035	case write_const_arg
4036		version 300 es
4037		expect compile_fail
4038		both ""
4039			#version 300 es
4040			precision mediump float;
4041			${DECLARATIONS}
4042
4043			float func (const float f)
4044			{
4045				f = 1.0;
4046			}
4047
4048			void main ()
4049			{
4050				${POSITION_FRAG_COLOR} = vec4(1.0);
4051			}
4052		""
4053	end
4054
4055	case write_const_array_arg
4056		version 300 es
4057		expect compile_fail
4058		both ""
4059			#version 300 es
4060			precision mediump float;
4061			${DECLARATIONS}
4062
4063			float func (const float f[3])
4064			{
4065				f[0] = 1.0;
4066			}
4067
4068			void main ()
4069			{
4070				${POSITION_FRAG_COLOR} = vec4(1.0);
4071			}
4072		""
4073	end
4074
4075	case use_const_arg_in_const_expr
4076		version 300 es
4077		expect compile_fail
4078		both ""
4079			#version 300 es
4080			precision mediump float;
4081			${DECLARATIONS}
4082
4083			float func (const int i)
4084			{
4085				const int z = i+1;
4086				return float(z);
4087			}
4088
4089			void main ()
4090			{
4091				${POSITION_FRAG_COLOR} = vec4(func(1));
4092			}
4093		""
4094	end
4095
4096	case use_const_arg_as_array_size
4097		version 300 es
4098		expect compile_fail
4099		both ""
4100			#version 300 es
4101			precision mediump float;
4102			${DECLARATIONS}
4103
4104			float func (const int i)
4105			{
4106				float f[i];
4107				f[0] = 1.0;
4108				return f[0];
4109			}
4110
4111			void main ()
4112			{
4113				${POSITION_FRAG_COLOR} = vec4(func(1));
4114			}
4115		""
4116	end
4117
4118	case overload_builtin_function
4119		version 300 es
4120		expect compile_fail
4121		both ""
4122			#version 300 es
4123			precision mediump float;
4124			${DECLARATIONS}
4125
4126			int sin (int x)
4127			{
4128				return int(sin(float(x)));
4129			}
4130
4131			void main ()
4132			{
4133				${POSITION_FRAG_COLOR} = vec4(sin(1));
4134			}
4135		""
4136	end
4137
4138	case redefine_builtin_function
4139		version 300 es
4140		expect compile_fail
4141		both ""
4142			#version 300 es
4143			precision mediump float;
4144			${DECLARATIONS}
4145
4146			float sin (float x)
4147			{
4148				return 0.0;
4149			}
4150
4151			void main ()
4152			{
4153				${POSITION_FRAG_COLOR} = vec4(sin(1.0));
4154			}
4155		""
4156	end
4157
4158	case basic_recursion
4159		version 300 es
4160		expect compile_fail
4161		both ""
4162			#version 300 es
4163			precision mediump float;
4164			${DECLARATIONS}
4165
4166			float fib (float x)
4167			{
4168				if (x <= 1.0)
4169					return x;
4170				else
4171					return fib(x-2.0) + fib(x-1.0);
4172			}
4173
4174			void main ()
4175			{
4176				${POSITION_FRAG_COLOR} = vec4(fib(5.0));
4177			}
4178		""
4179	end
4180
4181	case simple_tail_recursion
4182		version 300 es
4183		expect compile_fail
4184		both ""
4185			#version 300 es
4186			precision mediump float;
4187			${DECLARATIONS}
4188
4189			float rec (float x)
4190			{
4191				if (x <= 0.0)
4192					return 0.0;
4193				else
4194					return rec(x-1.0);
4195			}
4196
4197			void main ()
4198			{
4199				${POSITION_FRAG_COLOR} = vec4(rec(5.0));
4200			}
4201		""
4202	end
4203
4204	case dynamic_conditional_recursion
4205		version 300 es
4206		expect compile_fail
4207		both ""
4208			#version 300 es
4209			precision mediump float;
4210			${DECLARATIONS}
4211			uniform float ua;
4212			uniform float ub;
4213
4214			float funcA (float x);
4215			float funcB (float x);
4216
4217			float funcA (float x)
4218			{
4219				if (ub+x > 0.0)
4220					funcB(x*2.0);
4221				else
4222					return ub;
4223			}
4224
4225			float funcB (float x)
4226			{
4227				return sqrt(funcA(x));
4228			}
4229
4230			void main ()
4231			{
4232				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4233			}
4234		""
4235	end
4236
4237	case dynamic_loop_recursion
4238		version 300 es
4239		expect compile_fail
4240		both ""
4241			#version 300 es
4242			precision mediump float;
4243			${DECLARATIONS}
4244			uniform float ua;
4245			uniform float ub;
4246
4247			float funcA (float x);
4248			float funcB (float x);
4249
4250			float funcA (float x)
4251			{
4252				for (float z = 0.0; z < ub+x; z++)
4253				{
4254					if (z > 2.0)
4255						funcB(z*2.0);
4256					else
4257						return z;
4258				}
4259			}
4260
4261			float funcB (float x)
4262			{
4263				return sqrt(funcA(x));
4264			}
4265
4266			void main ()
4267			{
4268				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4269			}
4270		""
4271	end
4272
4273	case dynamic_switch_recursion
4274		version 300 es
4275		expect compile_fail
4276		both ""
4277			#version 300 es
4278			precision mediump float;
4279			${DECLARATIONS}
4280			uniform float ua;
4281			uniform mediump int ub;
4282
4283			float funcA (float x);
4284			float funcB (float x);
4285
4286			float funcA (float x)
4287			{
4288				switch (ub + int(x))
4289				{
4290					case 0: return ua-1.0;
4291					case 1: return ua;
4292					case 2: return funcB(x*2.0);
4293					default: return 0.0;
4294				}
4295			}
4296
4297			float funcB (float x)
4298			{
4299				return sqrt(funcA(x));
4300			}
4301
4302			void main ()
4303			{
4304				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4305			}
4306		""
4307	end
4308
4309	case modify_const_arg
4310		version 300 es
4311		expect compile_fail
4312		both ""
4313			#version 300 es
4314			precision mediump float;
4315			precision mediump int;
4316			${DECLARATIONS}
4317
4318			int func (const int a)
4319			{
4320				a = -a;
4321				return 2 * a;
4322			}
4323
4324			void main()
4325			{
4326				${POSITION_FRAG_COLOR} = vec4(func(3));
4327			}
4328		""
4329	end
4330
4331	case init_const_local_from_const_arg
4332		version 300 es
4333		expect compile_fail
4334		both ""
4335			#version 300 es
4336			precision mediump float;
4337			precision mediump int;
4338			${DECLARATIONS}
4339
4340			int func (const int a)
4341			{
4342				const int b = -a;
4343				return 2 * b;
4344			}
4345
4346			void main()
4347			{
4348				${POSITION_FRAG_COLOR} = vec4(func(3));
4349			}
4350		""
4351	end
4352
4353	case array_size_from_const_arg
4354		version 300 es
4355		expect compile_fail
4356		both ""
4357			#version 300 es
4358			precision mediump float;
4359			precision mediump int;
4360			${DECLARATIONS}
4361
4362			int func (const int a)
4363			{
4364				int arr[a];
4365				arr[1] = 3;
4366				return arr[1];
4367			}
4368
4369			void main()
4370			{
4371				${POSITION_FRAG_COLOR} = vec4(func(3));
4372			}
4373		""
4374	end
4375
4376end # invalid
4377