1group basic "Default block uniforms of scalar and vector types"
2	case precision_conflict_1
3		version 310 es
4		desc "Vertex side uniform has highp, fragment side uniform mediump."
5		expect link_fail
6		values {output float out0 = 3.0;}
7		vertex ""
8			#version 310 es
9			${VERTEX_DECLARATIONS}
10			uniform highp float u_val;
11			out mediump float res;
12			void main()
13			{
14				res = u_val;
15				${VERTEX_OUTPUT}
16			}
17		""
18		fragment ""
19			#version 310 es
20			precision mediump float;
21			uniform float u_val;
22			${FRAGMENT_DECLARATIONS}
23			in mediump float res;
24			void main()
25			{
26				out0 = u_val + res;
27				${FRAGMENT_OUTPUT}
28			}
29		""
30	end
31	case precision_conflict_2
32		version 310 es
33		desc "Vertex side uniform has highp, fragment side uniform mediump."
34		expect link_fail
35		values {output float out0 = 3.0;}
36		vertex ""
37			#version 310 es
38			${VERTEX_DECLARATIONS}
39			uniform highp float u_val;
40			out mediump float res;
41			void main()
42			{
43				res = u_val;
44				${VERTEX_OUTPUT}
45			}
46		""
47		fragment ""
48			#version 310 es
49			precision highp float;
50			uniform mediump float u_val;
51			${FRAGMENT_DECLARATIONS}
52			in mediump float res;
53			void main()
54			{
55				out0 = u_val + res;
56				${FRAGMENT_OUTPUT}
57			}
58		""
59	end
60	case precision_conflict_3
61		version 310 es
62		desc "Vertex side uniform has lowp, fragment side uniform highp."
63		expect link_fail
64		values {output float out0 = 3.0;}
65		vertex ""
66			#version 310 es
67			${VERTEX_DECLARATIONS}
68			uniform lowp int u_val;
69			out mediump float res;
70			void main()
71			{
72				res = float(u_val);
73				${VERTEX_OUTPUT}
74			}
75		""
76		fragment ""
77			#version 310 es
78			precision highp float;
79			uniform highp int u_val;
80			${FRAGMENT_DECLARATIONS}
81			in mediump float res;
82			void main()
83			{
84				out0 = float(u_val) + res;
85				${FRAGMENT_OUTPUT}
86			}
87		""
88	end
89	case precision_conflict_4
90		version 310 es
91		desc "Vertex side uniform has lowp, fragment side uniform mediump."
92		expect link_fail
93		values {output float out0 = 3.0;}
94		vertex ""
95			#version 310 es
96			${VERTEX_DECLARATIONS}
97			uniform lowp vec3 u_val;
98			out mediump float res;
99			void main()
100			{
101				res = u_val.y;
102				${VERTEX_OUTPUT}
103			}
104		""
105		fragment ""
106			#version 310 es
107			precision highp float;
108			uniform mediump vec3 u_val;
109			${FRAGMENT_DECLARATIONS}
110			in mediump float res;
111			void main()
112			{
113				out0 = u_val.z + res;
114				${FRAGMENT_OUTPUT}
115			}
116		""
117	end
118end
119
120group struct "Uniform structs"
121	# Struct linkage handling
122	case basic
123		version 310 es
124		desc "Same uniform struct in both shaders"
125		values {
126			uniform float val.a = 1.0;
127			uniform float val.b = 2.0;
128			output float out0 = 3.0;
129		}
130		vertex ""
131			#version 310 es
132			${VERTEX_DECLARATIONS}
133			struct Struct {mediump float a; mediump float b;};
134			uniform Struct val;
135			out mediump float dummy;
136			void main()
137			{
138				dummy = val.a + val.b;
139				${VERTEX_OUTPUT}
140			}
141		""
142		fragment ""
143			#version 310 es
144			precision mediump float;
145			struct Struct {mediump float a; mediump float b;};
146			uniform Struct val;
147			in mediump float dummy;
148			${FRAGMENT_DECLARATIONS}
149			void main()
150			{
151				out0 = val.b + val.a;
152				out0 = out0 + dummy;
153				out0 = out0 - dummy;
154				${FRAGMENT_OUTPUT}
155			}
156		""
157	end
158
159	case vertex_only
160		version 310 es
161		desc "Uniform struct declared in both, used only in vertex."
162		values {
163			uniform float val.a = 1.0;
164			uniform float val.b = 2.0;
165			output float out0 = 3.0;
166		}
167		vertex ""
168			#version 310 es
169			${VERTEX_DECLARATIONS}
170			struct Struct {mediump float a; mediump float b;};
171			uniform Struct val;
172			out mediump float res;
173			void main()
174			{
175				res = val.a + val.b;
176				${VERTEX_OUTPUT}
177			}
178		""
179		fragment ""
180			#version 310 es
181			precision mediump float;
182			struct Struct {mediump float a; mediump float b;};
183			uniform Struct val;
184			in mediump float res;
185			${FRAGMENT_DECLARATIONS}
186			void main()
187			{
188				out0 = res;
189				${FRAGMENT_OUTPUT}
190			}
191		""
192	end
193
194	case fragment_only
195		version 310 es
196		desc "Uniform struct declared in both, used only in fragment."
197		values {
198			uniform float val.a = 1.0;
199			uniform float val.b = 2.0;
200			output float out0 = 3.0;
201		}
202		vertex ""
203			#version 310 es
204			${VERTEX_DECLARATIONS}
205			struct Struct {mediump float a; mediump float b;};
206			uniform Struct val;
207			void main()
208			{
209				${VERTEX_OUTPUT}
210			}
211		""
212		fragment ""
213			#version 310 es
214			precision mediump float;
215			struct Struct {mediump float a; mediump float b;};
216			uniform Struct val;
217			${FRAGMENT_DECLARATIONS}
218			void main()
219			{
220				out0 = val.a + val.b;
221				${FRAGMENT_OUTPUT}
222			}
223		""
224	end
225
226	case partial
227		version 310 es
228		desc "Uniform struct declared in both, used partially in both."
229		values {
230			uniform float val.a = 1.0;
231			uniform float val.b = 2.0;
232			output float out0 = 3.0;
233		}
234		vertex ""
235			#version 310 es
236			${VERTEX_DECLARATIONS}
237			struct Struct {mediump float a; mediump float b;};
238			uniform Struct val;
239			out mediump float res;
240			void main()
241			{
242				res = val.a;
243				${VERTEX_OUTPUT}
244			}
245		""
246		fragment ""
247			#version 310 es
248			precision mediump float;
249			struct Struct {mediump float a; mediump float b;};
250			uniform Struct val;
251			${FRAGMENT_DECLARATIONS}
252			in mediump float res;
253			void main()
254			{
255				out0 = res + val.b;
256				${FRAGMENT_OUTPUT}
257			}
258		""
259	end
260
261	case vec4
262		version 310 es
263		desc "Same uniform struct in both shaders. Datatype vec4"
264		values {
265			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
266			uniform vec4 val.b = vec4(1.0, 2.0, 3.0, 4.0);
267			output float out0 = 3.0;
268		}
269		vertex ""
270			#version 310 es
271			${VERTEX_DECLARATIONS}
272			struct Struct {mediump vec4 a; mediump vec4 b;};
273			uniform Struct val;
274			out mediump float dummy;
275			void main()
276			{
277				dummy = val.a.x + val.b.y;
278				${VERTEX_OUTPUT}
279			}
280		""
281		fragment ""
282			#version 310 es
283			precision mediump float;
284			struct Struct {mediump vec4 a; mediump vec4 b;};
285			uniform Struct val;
286			in mediump float dummy;
287			${FRAGMENT_DECLARATIONS}
288			void main()
289			{
290				out0 = val.b.y + val.a.x;
291				out0 = out0 + dummy;
292				out0 = out0 - dummy;
293				${FRAGMENT_OUTPUT}
294			}
295		""
296	end
297
298	case vertex_only_vec4
299		version 310 es
300		desc "Uniform struct declared in both, used only in vertex. Datatype vec4	"
301		values {
302			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
303			uniform vec4 val.b = vec4(1.0, 2.0, 3.0, 4.0);
304			output float out0 = 3.0;
305		}
306		vertex ""
307			#version 310 es
308			${VERTEX_DECLARATIONS}
309			struct Struct {mediump vec4 a; mediump vec4 b;};
310			uniform Struct val;
311			out mediump float res;
312			void main()
313			{
314				res = val.a.x + val.b.y;
315				${VERTEX_OUTPUT}
316			}
317		""
318		fragment ""
319			#version 310 es
320			precision mediump float;
321			struct Struct {mediump vec4 a; mediump vec4 b;};
322			uniform Struct val;
323			in mediump float res;
324			${FRAGMENT_DECLARATIONS}
325			void main()
326			{			out0 = res;
327				${FRAGMENT_OUTPUT}
328			}
329		""
330	end
331
332	case fragment_only_vec4
333		version 310 es
334		desc "Uniform struct declared in both, used only in fragment. Datatype vec4"
335		values {
336			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
337			uniform vec4 val.b = vec4(1.0, 2.0, 3.0, 4.0);
338			output float out0 = 3.0;
339		}
340		vertex ""
341			#version 310 es
342			${VERTEX_DECLARATIONS}
343			struct Struct {mediump vec4 a; mediump vec4 b;};
344			uniform Struct val;
345			void main()
346			{
347				${VERTEX_OUTPUT}
348			}
349		""
350		fragment ""
351			#version 310 es
352			precision mediump float;
353			struct Struct {mediump vec4 a; mediump vec4 b;};
354			uniform Struct val;
355			${FRAGMENT_DECLARATIONS}
356			void main()
357			{			out0 = val.a.x + val.b.y;
358				${FRAGMENT_OUTPUT}
359			}
360		""
361	end
362
363	case partial_vec4
364		version 310 es
365		desc "Uniform struct declared in both, used partially in both. Datatype vec4"
366		values {
367			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
368			uniform vec4 val.b = vec4(1.0, 2.0, 3.0, 4.0);
369			output float out0 = 3.0;
370		}
371		vertex ""
372			#version 310 es
373			${VERTEX_DECLARATIONS}
374			struct Struct {mediump vec4 a; mediump vec4 b;};
375			uniform Struct val;
376			out mediump float res;
377			void main()
378			{
379				res = val.a.x;
380				${VERTEX_OUTPUT}
381			}
382		""
383		fragment ""
384			#version 310 es
385			precision mediump float;
386			struct Struct {mediump vec4 a; mediump vec4 b;};
387			uniform Struct val;
388			${FRAGMENT_DECLARATIONS}
389			in mediump float res;
390			void main()
391			{			out0 = res + val.b.y;
392				${FRAGMENT_OUTPUT}
393			}
394		""
395	end
396
397	case vec4_vec3
398		version 310 es
399		desc "Same uniform struct in both shaders. Datatype vec4 and vec3"
400		values {
401			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
402			uniform vec3 val.b = vec3(1.0, 2.0, 3.0);
403			output float out0 = 3.0;
404		}
405		vertex ""
406			#version 310 es
407			${VERTEX_DECLARATIONS}
408			struct Struct {mediump vec4 a; mediump vec3 b;};
409			uniform Struct val;
410			out mediump float dummy;
411			void main()
412			{
413				dummy = val.a.x + val.b.y;
414				${VERTEX_OUTPUT}
415			}
416		""
417		fragment ""
418			#version 310 es
419			precision mediump float;
420			struct Struct {mediump vec4 a; mediump vec3 b;};
421			uniform Struct val;
422			in mediump float dummy;
423			${FRAGMENT_DECLARATIONS}
424			void main()
425			{			out0 = val.b.y + val.a.x;
426				out0 = out0 + dummy;
427				out0 = out0 - dummy;
428				${FRAGMENT_OUTPUT}
429			}
430		""
431	end
432
433	case vertex_only_vec4_vec3
434		version 310 es
435		desc "Uniform struct declared in both, used only in vertex. Datatype vec4 and vec3"
436		values {
437			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
438			uniform vec3 val.b = vec3(1.0, 2.0, 3.0);
439			output float out0 = 3.0;
440		}
441		vertex ""
442			#version 310 es
443			${VERTEX_DECLARATIONS}
444			struct Struct {mediump vec4 a; mediump vec3 b;};
445			uniform Struct val;
446			out mediump float res;
447			void main()
448			{
449				res = val.a.x + val.b.y;
450				${VERTEX_OUTPUT}
451			}
452		""
453		fragment ""
454			#version 310 es
455			precision mediump float;
456			struct Struct {mediump vec4 a; mediump vec3 b;};
457			uniform Struct val;
458			in mediump float res;
459			${FRAGMENT_DECLARATIONS}
460			void main()
461			{			out0 = res;
462				${FRAGMENT_OUTPUT}
463			}
464		""
465	end
466
467	case fragment_only_vec4_vec3
468		version 310 es
469		desc "Uniform struct declared in both, used only in fragment. Datatype vec4 and vec3"
470		values {
471			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
472			uniform vec3 val.b = vec3(1.0, 2.0, 3.0);
473			output float out0 = 3.0;
474		}
475		vertex ""
476			#version 310 es
477			${VERTEX_DECLARATIONS}
478			struct Struct {mediump vec4 a; mediump vec3 b;};
479			uniform Struct val;
480			void main()
481			{
482				${VERTEX_OUTPUT}
483			}
484		""
485		fragment ""
486			#version 310 es
487			precision mediump float;
488			struct Struct {mediump vec4 a; mediump vec3 b;};
489			uniform Struct val;
490			${FRAGMENT_DECLARATIONS}
491			void main()
492			{			out0 = val.a.x + val.b.y;
493				${FRAGMENT_OUTPUT}
494			}
495		""
496	end
497
498	case partial_vec4_vec3
499		version 310 es
500		desc "Uniform struct declared in both, used partially in both. Datatype vec4 and vec3"
501		values {
502			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
503			uniform vec3 val.b = vec3(1.0, 2.0, 3.0);
504			output float out0 = 3.0;
505		}
506		vertex ""
507			#version 310 es
508			${VERTEX_DECLARATIONS}
509			struct Struct {mediump vec4 a; mediump vec3 b;};
510			uniform Struct val;
511			out mediump float res;
512			void main()
513			{
514				res = val.a.x;
515				${VERTEX_OUTPUT}
516			}
517		""
518		fragment ""
519			#version 310 es
520			precision mediump float;
521			struct Struct {mediump vec4 a; mediump vec3 b;};
522			uniform Struct val;
523			${FRAGMENT_DECLARATIONS}
524			in mediump float res;
525			void main()
526			{			out0 = res + val.b.y;
527				${FRAGMENT_OUTPUT}
528			}
529		""
530	end
531
532	case vec4_float
533		version 310 es
534		desc "Same uniform struct in both shaders. Datatype vec4 and float"
535		values {
536			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
537			uniform float val.b = 2.0;
538			output float out0 = 3.0;
539		}
540		vertex ""
541			#version 310 es
542			${VERTEX_DECLARATIONS}
543			struct Struct {mediump vec4 a; mediump float b;};
544			uniform Struct val;
545			out mediump float dummy;
546			void main()
547			{
548				dummy = val.a.x + val.b;
549				${VERTEX_OUTPUT}
550			}
551		""
552		fragment ""
553			#version 310 es
554			precision mediump float;
555			struct Struct {mediump vec4 a; mediump float b;};
556			uniform Struct val;
557			in mediump float dummy;
558			${FRAGMENT_DECLARATIONS}
559			void main()
560			{			out0 = val.b + val.a.x;
561				out0 = out0 + dummy;
562				out0 = out0 - dummy;
563				${FRAGMENT_OUTPUT}
564			}
565		""
566	end
567
568	case vertex_only_vec4_float
569		version 310 es
570		desc "Uniform struct declared in both, used only in vertex. Datatype vec4 and float"
571		values {
572			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
573			uniform float val.b = 2.0;
574			output float out0 = 3.0;
575		}
576		vertex ""
577			#version 310 es
578			${VERTEX_DECLARATIONS}
579			struct Struct {mediump vec4 a; mediump float b;};
580			uniform Struct val;
581			out mediump float res;
582			void main()
583			{
584				res = val.a.x + val.b;
585				${VERTEX_OUTPUT}
586			}
587		""
588		fragment ""
589			#version 310 es
590			precision mediump float;
591			struct Struct {mediump vec4 a; mediump float b;};
592			uniform Struct val;
593			in mediump float res;
594			${FRAGMENT_DECLARATIONS}
595			void main()
596			{			out0 = res;
597				${FRAGMENT_OUTPUT}
598			}
599		""
600	end
601
602	case fragment_only_vec4_float
603		version 310 es
604		desc "Uniform struct declared in both, used only in fragment. Datatype vec4 and float"
605		values {
606			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
607			uniform float val.b = 2.0;
608			output float out0 = 3.0;
609		}
610		vertex ""
611			#version 310 es
612			${VERTEX_DECLARATIONS}
613			struct Struct {mediump vec4 a; mediump float b;};
614			uniform Struct val;
615			void main()
616			{
617				${VERTEX_OUTPUT}
618			}
619		""
620		fragment ""
621			#version 310 es
622			precision mediump float;
623			struct Struct {mediump vec4 a; mediump float b;};
624			uniform Struct val;
625			${FRAGMENT_DECLARATIONS}
626			void main()
627			{			out0 = val.a.x + val.b;
628				${FRAGMENT_OUTPUT}
629			}
630		""
631	end
632
633	case partial_vec4_float
634		version 310 es
635		desc "Uniform struct declared in both, used partially in both. Datatype vec4 and float"
636		values {
637			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
638			uniform float val.b = 2.0;
639			output float out0 = 3.0;
640		}
641		vertex ""
642			#version 310 es
643			${VERTEX_DECLARATIONS}
644			struct Struct {mediump vec4 a; mediump float b;};
645			uniform Struct val;
646			out mediump float res;
647			void main()
648			{
649				res = val.a.x;
650				${VERTEX_OUTPUT}
651			}
652		""
653		fragment ""
654			#version 310 es
655			precision mediump float;
656			struct Struct {mediump vec4 a; mediump float b;};
657			uniform Struct val;
658			${FRAGMENT_DECLARATIONS}
659			in mediump float res;
660			void main()
661			{			out0 = res + val.b;
662				${FRAGMENT_OUTPUT}
663			}
664		""
665	end
666
667	case partial_vec4_struct
668		version 310 es
669		desc "Uniform struct declared in both, used partially in both. Datatype vec4 and struct with vec4"
670		values {
671			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
672			uniform vec4 val.b.c = vec4(1.0, 2.0, 3.0, 4.0);
673			output float out0 = 3.0;
674		}
675		vertex ""
676			#version 310 es
677			${VERTEX_DECLARATIONS}
678			struct Inner {mediump vec4 c;};
679			struct Struct {mediump vec4 a; Inner b;};
680			uniform Struct val;
681			out mediump float res;
682			void main()
683			{
684				res = val.a.x;
685				${VERTEX_OUTPUT}
686			}
687		""
688		fragment ""
689			#version 310 es
690			precision mediump float;
691			struct Inner {mediump vec4 c;};
692			struct Struct {mediump vec4 a; Inner b;};
693			uniform Struct val;
694			${FRAGMENT_DECLARATIONS}
695			in mediump float res;
696			void main()
697			{			out0 = res + val.b.c.y;
698				${FRAGMENT_OUTPUT}
699			}
700		""
701	end
702
703	case partial_vec4_vec3_struct
704		version 310 es
705		desc "Uniform struct declared in both, used partially in both. Datatype vec4 and struct with vec3"
706		values {
707			uniform vec4 val.a = vec4(1.0, 2.0, 3.0, 4.0);
708			uniform vec3 val.b.c = vec3(1.0, 2.0, 3.0);
709			output float out0 = 3.0;
710		}
711		vertex ""
712			#version 310 es
713			${VERTEX_DECLARATIONS}
714			struct Inner {mediump vec3 c;};
715			struct Struct {mediump vec4 a; Inner b;};
716			uniform Struct val;
717			out mediump float res;
718			void main()
719			{
720				res = val.a.x;
721				${VERTEX_OUTPUT}
722			}
723		""
724		fragment ""
725			#version 310 es
726			precision mediump float;
727			struct Inner {mediump vec3 c;};
728			struct Struct {mediump vec4 a; Inner b;};
729			uniform Struct val;
730			${FRAGMENT_DECLARATIONS}
731			in mediump float res;
732			void main()
733			{			out0 = res + val.b.c.y;
734				${FRAGMENT_OUTPUT}
735			}
736		""
737	end
738
739	case partial_vec2_vec3
740		version 310 es
741		desc "Uniform struct declared in both, used partially in both. Datatype vec2 and vec3"
742		values {
743			uniform vec2 val.a = vec2(1.0, 2.0);
744			uniform vec3 val.b = vec3(1.0, 2.0, 3.0);
745			output float out0 = 3.0;
746		}
747		vertex ""
748			#version 310 es
749			${VERTEX_DECLARATIONS}
750			struct Struct {mediump vec2 a; mediump vec3 b;};
751			uniform Struct val;
752			out mediump float res;
753			void main()
754			{
755				res = val.a.x;
756				${VERTEX_OUTPUT}
757			}
758		""
759		fragment ""
760			#version 310 es
761			precision mediump float;
762			struct Struct {mediump vec2 a; mediump vec3 b;};
763			uniform Struct val;
764			${FRAGMENT_DECLARATIONS}
765			in mediump float res;
766			void main()
767			{			out0 = res + val.b.y;
768				${FRAGMENT_OUTPUT}
769			}
770		""
771	end
772
773	case partial_vec2_int
774		version 310 es
775		desc "Uniform struct declared in both, used partially in both. Datatype vec2 and int"
776		values {
777			uniform vec2 val.a = vec2(1.0, 2.0);
778			uniform int val.b = 2;
779			output float out0 = 3.0;
780		}
781		vertex ""
782			#version 310 es
783			${VERTEX_DECLARATIONS}
784			struct Struct {mediump vec2 a; mediump int b;};
785			uniform Struct val;
786			out mediump float res;
787			void main()
788			{
789				res = val.a.x;
790				${VERTEX_OUTPUT}
791			}
792		""
793		fragment ""
794			#version 310 es
795			precision mediump float;
796			struct Struct {mediump vec2 a; mediump int b;};
797			uniform Struct val;
798			${FRAGMENT_DECLARATIONS}
799			in mediump float res;
800			void main()
801			{			out0 = res + float(val.b);
802				${FRAGMENT_OUTPUT}
803			}
804		""
805	end
806
807	case partial_int_float
808		version 310 es
809		desc "Uniform struct declared in both, used partially in both. Datatype int and float"
810		values {
811			uniform float val.a = 1.0;
812			uniform int val.b = 2;
813			output float out0 = 3.0;
814		}
815		vertex ""
816			#version 310 es
817			${VERTEX_DECLARATIONS}
818			struct Struct {mediump float a; mediump int b;};
819			uniform Struct val;
820			out mediump float res;
821			void main()
822			{
823				res = val.a;
824				${VERTEX_OUTPUT}
825			}
826		""
827		fragment ""
828			#version 310 es
829			precision mediump float;
830			struct Struct {mediump float a; mediump int b;};
831			uniform Struct val;
832			${FRAGMENT_DECLARATIONS}
833			in mediump float res;
834			void main()
835			{			out0 = res + float(val.b);
836				${FRAGMENT_OUTPUT}
837			}
838		""
839	end
840
841	case partial_bvec2_vec2
842		version 310 es
843		desc "Uniform struct declared in both, used partially in both. Datatype bvec2 and vec2"
844		values {
845			uniform bvec2 val.a = bvec2(true, true);
846			uniform vec2 val.b = vec2(1.0, 2.0);
847			output float out0 = 3.0;
848		}
849		vertex ""
850			#version 310 es
851			${VERTEX_DECLARATIONS}
852			struct Struct {bvec2 a; mediump vec2 b;};
853			uniform Struct val;
854			out mediump float res;
855			void main()
856			{
857				res = float(val.a.x);
858				${VERTEX_OUTPUT}
859			}
860		""
861		fragment ""
862			#version 310 es
863			precision mediump float;
864			struct Struct {bvec2 a; mediump vec2 b;};
865			uniform Struct val;
866			${FRAGMENT_DECLARATIONS}
867			in mediump float res;
868			void main()
869			{			out0 = res + val.b.y;
870				${FRAGMENT_OUTPUT}
871			}
872		""
873	end
874
875	case partial_ivec2_vec2
876		version 310 es
877		desc "Uniform struct declared in both, used partially in both. Datatype ivec2 and vec2"
878		values {
879			uniform ivec2 val.a = ivec2(1, 2);
880			uniform vec2 val.b = vec2(1.0, 2.0);
881			output float out0 = 3.0;
882		}
883		vertex ""
884			#version 310 es
885			${VERTEX_DECLARATIONS}
886			struct Struct {mediump ivec2 a; mediump vec2 b;};
887			uniform Struct val;
888			out mediump float res;
889			void main()
890			{
891				res = vec2(val.a).x;
892				${VERTEX_OUTPUT}
893			}
894		""
895		fragment ""
896			#version 310 es
897			precision mediump float;
898			struct Struct {mediump ivec2 a; mediump vec2 b;};
899			uniform Struct val;
900			${FRAGMENT_DECLARATIONS}
901			in mediump float res;
902			void main()
903			{			out0 = res + val.b.y;
904				${FRAGMENT_OUTPUT}
905			}
906		""
907	end
908
909	case partial_ivec2_ivec2
910		version 310 es
911		desc "Uniform struct declared in both, used partially in both. Datatype ivec2 and ivec2"
912		values {
913			uniform ivec2 val.a = ivec2(1, 2);
914			uniform ivec2 val.b = ivec2(1, 2);
915			output float out0 = 3.0;
916		}
917		vertex ""
918			#version 310 es
919			${VERTEX_DECLARATIONS}
920			struct Struct {mediump ivec2 a; mediump ivec2 b;};
921			uniform Struct val;
922			out mediump float res;
923			void main()
924			{
925				res = vec2(val.a).x;
926				${VERTEX_OUTPUT}
927			}
928		""
929		fragment ""
930			#version 310 es
931			precision mediump float;
932			struct Struct {mediump ivec2 a; mediump ivec2 b;};
933			uniform Struct val;
934			${FRAGMENT_DECLARATIONS}
935			in mediump float res;
936			void main()
937			{			out0 = res + vec2(val.b).y;
938				${FRAGMENT_OUTPUT}
939			}
940		""
941	end
942
943	case type_conflict_1
944		version 310 es
945		desc "Fragment struct has one less member than fragment version"
946		expect link_fail
947		values {output float out0 = 3.0;}
948		vertex ""
949			#version 310 es
950			${VERTEX_DECLARATIONS}
951			struct Struct {mediump float a; mediump float b;};
952			uniform Struct val;
953			out mediump float res;
954			void main()
955			{
956				res = val.a;
957				${VERTEX_OUTPUT}
958			}
959		""
960		fragment ""
961			#version 310 es
962			precision mediump float;
963			struct Struct {mediump float a;};
964			uniform Struct val;
965			${FRAGMENT_DECLARATIONS}
966			in mediump float res;
967			void main()
968			{			out0 = res + val.a;
969				${FRAGMENT_OUTPUT}
970			}
971		""
972	end
973
974	case type_conflict_2
975		version 310 es
976		desc "Vertex struct has int, fragment struct has float."
977		expect link_fail
978		values {output float out0 = 3.0;}
979		vertex ""
980			#version 310 es
981			${VERTEX_DECLARATIONS}
982			struct Struct {mediump int a;};
983			uniform Struct val;
984			out mediump float res;
985			void main()
986			{
987				res = float(val.a);
988				${VERTEX_OUTPUT}
989			}
990		""
991		fragment ""
992			#version 310 es
993			precision mediump float;
994			struct Struct {mediump float a;};
995			uniform Struct val;
996			${FRAGMENT_DECLARATIONS}
997			in mediump float res;
998			void main()
999			{			out0 = val.a;
1000				${FRAGMENT_OUTPUT}
1001			}
1002		""
1003	end
1004
1005	case type_conflict_3
1006		version 310 es
1007		desc "Vertex struct has vec3, fragment struct has vec4."
1008		expect link_fail
1009		values {output float out0 = 3.0;}
1010		vertex ""
1011			#version 310 es
1012			${VERTEX_DECLARATIONS}
1013			struct Struct {mediump vec3 a;};
1014			uniform Struct val;
1015			out mediump float res;
1016			void main()
1017			{
1018				res = float(val.a.x);
1019				${VERTEX_OUTPUT}
1020			}
1021		""
1022		fragment ""
1023			#version 310 es
1024			precision mediump float;
1025			struct Struct {mediump vec4 a;};
1026			uniform Struct val;
1027			${FRAGMENT_DECLARATIONS}
1028			in mediump float res;
1029			void main()
1030			{			out0 = val.a.x;
1031				${FRAGMENT_OUTPUT}
1032			}
1033		""
1034	end
1035
1036	case precision_conflict_1
1037		version 310 es
1038		desc "Vertex side struct has highp, fragment side struct mediump."
1039		expect link_fail
1040		values {output float out0 = 3.0;}
1041		vertex ""
1042			#version 310 es
1043			${VERTEX_DECLARATIONS}
1044			struct Struct {highp float a;};
1045			uniform Struct val;
1046			out mediump float res;
1047			void main()
1048			{
1049				res = val.a;
1050				${VERTEX_OUTPUT}
1051			}
1052		""
1053		fragment ""
1054			#version 310 es
1055			precision mediump float;
1056			struct Struct {mediump float a;};
1057			uniform Struct val;
1058			${FRAGMENT_DECLARATIONS}
1059			in mediump float res;
1060			void main()
1061			{			out0 = val.a;
1062				${FRAGMENT_OUTPUT}
1063			}
1064		""
1065	end
1066
1067	case precision_conflict_2
1068		version 310 es
1069		desc "Vertex side struct has mediump, fragment side struct lowp."
1070		expect link_fail
1071		values {output float out0 = 3.0;}
1072		vertex ""
1073			#version 310 es
1074			${VERTEX_DECLARATIONS}
1075			struct Struct {mediump float a;};
1076			uniform Struct val;
1077			out mediump float res;
1078			void main()
1079			{
1080				res = val.a;
1081				${VERTEX_OUTPUT}
1082			}
1083		""
1084		fragment ""
1085			#version 310 es
1086			precision mediump float;
1087			struct Struct {lowp float a;};
1088			uniform Struct val;
1089			${FRAGMENT_DECLARATIONS}
1090			in mediump float res;
1091			void main()
1092			{			out0 = val.a;
1093				${FRAGMENT_OUTPUT}
1094			}
1095		""
1096	end
1097
1098	case precision_conflict_3
1099		version 310 es
1100		desc "Vertex side struct has lowp, fragment side struct mediump."
1101		expect link_fail
1102		values {output float out0 = 3.0;}
1103		vertex ""
1104			#version 310 es
1105			${VERTEX_DECLARATIONS}
1106			struct Struct {lowp float a;};
1107			uniform Struct val;
1108			out mediump float res;
1109			void main()
1110			{
1111				res = val.a;
1112				${VERTEX_OUTPUT}
1113			}
1114		""
1115		fragment ""
1116			#version 310 es
1117			precision mediump float;
1118			struct Struct {mediump float a;};
1119			uniform Struct val;
1120			${FRAGMENT_DECLARATIONS}
1121			in mediump float res;
1122			void main()
1123			{			out0 = val.a;
1124				${FRAGMENT_OUTPUT}
1125			}
1126		""
1127	end
1128
1129	case precision_conflict_4
1130		version 310 es
1131		desc "Vertex side struct has lowp, fragment side struct implicit mediump."
1132		expect link_fail
1133		values {output float out0 = 3.0;}
1134		vertex ""
1135			#version 310 es
1136			${VERTEX_DECLARATIONS}
1137			struct Struct {lowp float a;};
1138			uniform Struct val;
1139			out mediump float res;
1140			void main()
1141			{
1142				res = val.a;
1143				${VERTEX_OUTPUT}
1144			}
1145		""
1146		fragment ""
1147			#version 310 es
1148			precision mediump float;
1149			struct Struct {float a;};
1150			uniform Struct val;
1151			${FRAGMENT_DECLARATIONS}
1152			in mediump float res;
1153			void main()
1154			{			out0 = val.a;
1155				${FRAGMENT_OUTPUT}
1156			}
1157		""
1158	end
1159
1160	case light_struct_highp
1161		version 310 es
1162		desc "Complex Light struct from use case tests."
1163		values {
1164			uniform float val.constantAttenuation = 1.0;
1165			uniform float val.quadraticAttenuation = 1.0;
1166			output float out0 = 2.0;
1167		}
1168		vertex ""
1169			#version 310 es
1170			struct Light
1171			{
1172				mediump vec3	color;
1173				highp vec4		position;
1174				highp vec3		direction;
1175				mediump float	constantAttenuation;
1176				mediump float	linearAttenuation;
1177				mediump float	quadraticAttenuation;
1178			};
1179			${VERTEX_DECLARATIONS}
1180			uniform Light val;
1181			out mediump float res;
1182			void main()
1183			{
1184				res = val.constantAttenuation;
1185				${VERTEX_OUTPUT}
1186			}
1187		""
1188		fragment ""
1189			#version 310 es
1190			precision mediump float;
1191			struct Light
1192			{
1193				mediump vec3	color;
1194				highp vec4		position;
1195				highp vec3		direction;
1196				mediump float	constantAttenuation;
1197				mediump float	linearAttenuation;
1198				mediump float	quadraticAttenuation;
1199			};
1200			struct Struct {float a;};
1201			uniform Light val;
1202			${FRAGMENT_DECLARATIONS}
1203			in mediump float res;
1204			void main()
1205			{
1206				out0 = res + val.quadraticAttenuation;
1207				${FRAGMENT_OUTPUT}
1208			}
1209		""
1210	end
1211
1212	case light_struct_mediump
1213		version 310 es
1214		desc "Complex Light struct from use case tests, without highp usage"
1215		values {
1216			uniform float val.constantAttenuation = 1.0;
1217			uniform float val.quadraticAttenuation = 1.0;
1218			output float out0 = 2.0;
1219		}
1220		vertex ""
1221			#version 310 es
1222			struct Light
1223			{
1224				mediump vec3	color;
1225				mediump vec4	position;
1226				mediump vec3	direction;
1227				mediump float	constantAttenuation;
1228				mediump float	linearAttenuation;
1229				mediump float	quadraticAttenuation;
1230			};
1231			${VERTEX_DECLARATIONS}
1232			uniform Light val;
1233			out mediump float res;
1234			void main()
1235			{
1236				res = val.constantAttenuation;
1237				${VERTEX_OUTPUT}
1238			}
1239		""
1240		fragment ""
1241			#version 310 es
1242			precision mediump float;
1243			struct Light
1244			{
1245				mediump vec3	color;
1246				mediump vec4	position;
1247				mediump vec3	direction;
1248				mediump float	constantAttenuation;
1249				mediump float	linearAttenuation;
1250				mediump float	quadraticAttenuation;
1251			};
1252			struct Struct {float a;};
1253			uniform Light val;
1254			${FRAGMENT_DECLARATIONS}
1255			in mediump float res;
1256			void main()
1257			{
1258				out0 = res + val.quadraticAttenuation;
1259				${FRAGMENT_OUTPUT}
1260			}
1261		""
1262	end
1263end
1264
1265group block "Uniform blocks"
1266	case differing_precision
1267		version 310 es
1268		expect build_successful
1269		vertex ""
1270			#version 310 es
1271
1272			uniform Block
1273			{
1274				highp vec4 val;
1275			};
1276
1277			${VERTEX_DECLARATIONS}
1278			out mediump float res;
1279			void main()
1280			{
1281				res = val.x;
1282				${VERTEX_OUTPUT}
1283			}
1284		""
1285		fragment ""
1286			#version 310 es
1287
1288			uniform Block
1289			{
1290				mediump vec4 val;
1291			};
1292
1293			precision mediump float;
1294			${FRAGMENT_DECLARATIONS}
1295			in mediump float res;
1296			void main()
1297			{
1298				dEQP_FragColor = val;
1299			}
1300		""
1301	end
1302
1303	case type_mismatch
1304		version 310 es
1305		expect link_fail
1306		vertex ""
1307			#version 310 es
1308
1309			uniform Block
1310			{
1311				highp vec4 val;
1312			};
1313
1314			${VERTEX_DECLARATIONS}
1315			out mediump float res;
1316			void main()
1317			{
1318				res = val.x;
1319				${VERTEX_OUTPUT}
1320			}
1321		""
1322		fragment ""
1323			#version 310 es
1324
1325			uniform Block
1326			{
1327				highp vec3 val;
1328			};
1329
1330			precision mediump float;
1331			${FRAGMENT_DECLARATIONS}
1332			in mediump float res;
1333			void main()
1334			{
1335				dEQP_FragColor = vec4(val, 1.0);
1336			}
1337		""
1338	end
1339
1340	case members_mismatch
1341		version 310 es
1342		expect link_fail
1343		vertex ""
1344			#version 310 es
1345
1346			uniform Block
1347			{
1348				highp vec4 val;
1349			};
1350
1351			${VERTEX_DECLARATIONS}
1352			out mediump float res;
1353			void main()
1354			{
1355				res = val.x;
1356				${VERTEX_OUTPUT}
1357			}
1358		""
1359		fragment ""
1360			#version 310 es
1361
1362			uniform Block
1363			{
1364				highp vec4 val;
1365				lowp uint u;
1366			};
1367
1368			precision mediump float;
1369			${FRAGMENT_DECLARATIONS}
1370			in mediump float res;
1371			void main()
1372			{
1373				dEQP_FragColor = vec4(val);
1374			}
1375		""
1376	end
1377
1378	case layout_qualifier_mismatch_1
1379		version 310 es
1380		expect link_fail
1381		vertex ""
1382			#version 310 es
1383
1384			layout(std140) uniform Block
1385			{
1386				highp vec4 val;
1387			};
1388
1389			${VERTEX_DECLARATIONS}
1390			out mediump float res;
1391			void main()
1392			{
1393				res = val.x;
1394				${VERTEX_OUTPUT}
1395			}
1396		""
1397		fragment ""
1398			#version 310 es
1399
1400			uniform Block
1401			{
1402				highp vec4 val;
1403			};
1404
1405			precision mediump float;
1406			${FRAGMENT_DECLARATIONS}
1407			in mediump float res;
1408			void main()
1409			{
1410				dEQP_FragColor = vec4(val);
1411			}
1412		""
1413	end
1414
1415	case layout_qualifier_mismatch_2
1416		version 310 es
1417		expect link_fail
1418		vertex ""
1419			#version 310 es
1420
1421			layout(shared) uniform Block
1422			{
1423				highp vec4 val;
1424			};
1425
1426			${VERTEX_DECLARATIONS}
1427			out mediump float res;
1428			void main()
1429			{
1430				res = val.x;
1431				${VERTEX_OUTPUT}
1432			}
1433		""
1434		fragment ""
1435			#version 310 es
1436
1437			layout(packed) uniform Block
1438			{
1439				highp vec4 val;
1440			};
1441
1442			precision mediump float;
1443			${FRAGMENT_DECLARATIONS}
1444			in mediump float res;
1445			void main()
1446			{
1447				dEQP_FragColor = vec4(val);
1448			}
1449		""
1450	end
1451
1452	case layout_qualifier_mismatch_3
1453		version 310 es
1454		expect link_fail
1455		vertex ""
1456			#version 310 es
1457
1458			layout(row_major) uniform Block
1459			{
1460				highp vec4 val;
1461			};
1462
1463			${VERTEX_DECLARATIONS}
1464			out mediump float res;
1465			void main()
1466			{
1467				res = val.x;
1468				${VERTEX_OUTPUT}
1469			}
1470		""
1471		fragment ""
1472			#version 310 es
1473
1474			layout(column_major) uniform Block
1475			{
1476				highp vec4 val;
1477			};
1478
1479			precision mediump float;
1480			${FRAGMENT_DECLARATIONS}
1481			in mediump float res;
1482			void main()
1483			{
1484				dEQP_FragColor = vec4(val);
1485			}
1486		""
1487	end
1488
1489	case layout_qualifier_mismatch_4
1490		version 310 es
1491		expect link_fail
1492		vertex ""
1493			#version 310 es
1494
1495			layout(row_major) uniform Block
1496			{
1497				highp mat3 val;
1498			};
1499
1500			${VERTEX_DECLARATIONS}
1501			out mediump float res;
1502			void main()
1503			{
1504				res = val[0][1];
1505				${VERTEX_OUTPUT}
1506			}
1507		""
1508		fragment ""
1509			#version 310 es
1510
1511			layout(column_major) uniform Block
1512			{
1513				highp mat3 val;
1514			};
1515
1516			precision mediump float;
1517			${FRAGMENT_DECLARATIONS}
1518			in mediump float res;
1519			void main()
1520			{
1521				dEQP_FragColor = vec4(val[2], 1.0);
1522			}
1523		""
1524	end
1525
1526	case layout_qualifier_mismatch_5
1527		version 310 es
1528		expect link_fail
1529		vertex ""
1530			#version 310 es
1531
1532			uniform Block
1533			{
1534				layout(row_major) uniform highp mat3 val;
1535			};
1536
1537			${VERTEX_DECLARATIONS}
1538			out mediump float res;
1539			void main()
1540			{
1541				res = val[0][1];
1542				${VERTEX_OUTPUT}
1543			}
1544		""
1545		fragment ""
1546			#version 310 es
1547
1548			uniform Block
1549			{
1550				layout(column_major) uniform highp mat3 val;
1551			};
1552
1553			precision mediump float;
1554			${FRAGMENT_DECLARATIONS}
1555			in mediump float res;
1556			void main()
1557			{
1558				dEQP_FragColor = vec4(val[2], 1.0);
1559			}
1560		""
1561	end
1562end
1563