• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -------------------------------------------------
2# drawElements Quality Program OpenGL ES 3.2 Module
3# -------------------------------------------------
4#
5# Copyright 2016 The Android Open Source Project
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11#      http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18
19
20group varying "Varying linkage"
21	group rules "Rules"
22		case input_type_mismatch
23			version 320 es
24			desc "Geometry shader input type mismatch"
25			expect link_fail
26			values { output float out0 = 1.0; }
27			vertex ""
28				#version 320 es
29				${VERTEX_DECLARATIONS}
30				out mediump float geo_in;
31				void main()
32				{
33					geo_in = 1.0;
34					${VERTEX_OUTPUT}
35				}
36			""
37			geometry ""
38				#version 320 es
39				${GEOMETRY_DECLARATIONS}
40				in mediump vec2 geo_in[];
41				out mediump float geo_out;
42				void main()
43				{
44					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
45					{
46						geo_out = geo_in[ndx].x + geo_in[ndx].y;
47						gl_Position = gl_in[ndx].gl_Position;
48						EmitVertex();
49					}
50				}
51			""
52			fragment ""
53				#version 320 es
54				precision mediump float;
55				${FRAGMENT_DECLARATIONS}
56				in mediump float geo_out;
57				void main()
58				{
59					out0 = geo_out;
60					${FRAGMENT_OUTPUT}
61				}
62			""
63		end
64
65		case output_type_mismatch
66			version 320 es
67			desc "Geometry shader output type mismatch"
68			expect link_fail
69			values { output float out0 = 1.0; }
70			vertex ""
71				#version 320 es
72				${VERTEX_DECLARATIONS}
73				void main()
74				{
75					${VERTEX_OUTPUT}
76				}
77			""
78			geometry ""
79				#version 320 es
80				${GEOMETRY_DECLARATIONS}
81				out mediump float geo_out;
82				void main()
83				{
84					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
85					{
86						geo_out = 1.0;
87						gl_Position = gl_in[ndx].gl_Position;
88						EmitVertex();
89					}
90				}
91			""
92			fragment ""
93				#version 320 es
94				precision mediump float;
95				${FRAGMENT_DECLARATIONS}
96				in mediump vec2 geo_out;
97				void main()
98				{
99					out0 = geo_out.x + geo_out.y;
100					${FRAGMENT_OUTPUT}
101				}
102			""
103		end
104
105		case input_different_precision
106			version 320 es
107			desc "Geometry shader input precision mismatch"
108			values { output float out0 = 1.0; }
109			vertex ""
110				#version 320 es
111				${VERTEX_DECLARATIONS}
112				out highp float geo_in;
113				void main()
114				{
115					geo_in = 1.0;
116					${VERTEX_OUTPUT}
117				}
118			""
119			geometry ""
120				#version 320 es
121				${GEOMETRY_DECLARATIONS}
122				in lowp float geo_in[];
123				out mediump float geo_out;
124				void main()
125				{
126					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
127					{
128						geo_out = geo_in[ndx];
129						gl_Position = gl_in[ndx].gl_Position;
130						EmitVertex();
131					}
132				}
133			""
134			fragment ""
135				#version 320 es
136				precision mediump float;
137				${FRAGMENT_DECLARATIONS}
138				in mediump float geo_out;
139				void main()
140				{
141					out0 = geo_out;
142					${FRAGMENT_OUTPUT}
143				}
144			""
145		end
146
147		case output_different_precision
148			version 320 es
149			desc "Geometry shader output precision mismatch"
150			values { output float out0 = 1.0; }
151			vertex ""
152				#version 320 es
153				${VERTEX_DECLARATIONS}
154				void main()
155				{
156					${VERTEX_OUTPUT}
157				}
158			""
159			geometry ""
160				#version 320 es
161				${GEOMETRY_DECLARATIONS}
162				out highp float geo_out;
163				void main()
164				{
165					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
166					{
167						geo_out = 1.0;
168						gl_Position = gl_in[ndx].gl_Position;
169						EmitVertex();
170					}
171				}
172			""
173			fragment ""
174				#version 320 es
175				precision mediump float;
176				${FRAGMENT_DECLARATIONS}
177				in lowp float geo_out;
178				void main()
179				{
180					out0 = geo_out;
181					${FRAGMENT_OUTPUT}
182				}
183			""
184		end
185
186		case input_no_declaration
187			version 320 es
188			desc "Geometry shader input has no matching output"
189			expect link_fail
190			values { output float out0 = 1.0; }
191			vertex ""
192				#version 320 es
193				${VERTEX_DECLARATIONS}
194				void main()
195				{
196					${VERTEX_OUTPUT}
197				}
198			""
199			geometry ""
200				#version 320 es
201				${GEOMETRY_DECLARATIONS}
202				in lowp float geo_in[];
203				out mediump float geo_out;
204				void main()
205				{
206					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
207					{
208						geo_out = geo_in[ndx];
209						gl_Position = gl_in[ndx].gl_Position;
210						EmitVertex();
211					}
212				}
213			""
214			fragment ""
215				#version 320 es
216				precision mediump float;
217				${FRAGMENT_DECLARATIONS}
218				in mediump float geo_out;
219				void main()
220				{
221					out0 = geo_out;
222					${FRAGMENT_OUTPUT}
223				}
224			""
225		end
226
227		case output_no_declaration
228			version 320 es
229			desc "Geometry shader has no output for an input"
230			expect link_fail
231			values { output float out0 = 1.0; }
232			vertex ""
233				#version 320 es
234				${VERTEX_DECLARATIONS}
235				void main()
236				{
237					${VERTEX_OUTPUT}
238				}
239			""
240			geometry ""
241				#version 320 es
242				${GEOMETRY_DECLARATIONS}
243				void main()
244				{
245					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
246					{
247						gl_Position = gl_in[ndx].gl_Position;
248						EmitVertex();
249					}
250				}
251			""
252			fragment ""
253				#version 320 es
254				precision mediump float;
255				${FRAGMENT_DECLARATIONS}
256				in mediump float geo_out;
257				void main()
258				{
259					out0 = geo_out;
260					${FRAGMENT_OUTPUT}
261				}
262			""
263		end
264
265		case input_superfluous_declaration
266			version 320 es
267			desc "Geometry shader has no input for an output"
268			values { output float out0 = 1.0; }
269			vertex ""
270				#version 320 es
271				${VERTEX_DECLARATIONS}
272				out mediump float geo_in;
273				void main()
274				{
275					geo_in = 1.0;
276					${VERTEX_OUTPUT}
277				}
278			""
279			geometry ""
280				#version 320 es
281				${GEOMETRY_DECLARATIONS}
282				out mediump float geo_out;
283				void main()
284				{
285					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
286					{
287						geo_out = 1.0;
288						gl_Position = gl_in[ndx].gl_Position;
289						EmitVertex();
290					}
291				}
292			""
293			fragment ""
294				#version 320 es
295				precision mediump float;
296				${FRAGMENT_DECLARATIONS}
297				in mediump float geo_out;
298				void main()
299				{
300					out0 = geo_out;
301					${FRAGMENT_OUTPUT}
302				}
303			""
304		end
305
306		case output_superfluous_declaration
307			version 320 es
308			desc "Geometry shader has output without an matching input"
309			values { output float out0 = 1.0; }
310			vertex ""
311				#version 320 es
312				${VERTEX_DECLARATIONS}
313				void main()
314				{
315					${VERTEX_OUTPUT}
316				}
317			""
318			geometry ""
319				#version 320 es
320				${GEOMETRY_DECLARATIONS}
321				out mediump float geo_out;
322				void main()
323				{
324					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
325					{
326						geo_out = 1.0;
327						gl_Position = gl_in[ndx].gl_Position;
328						EmitVertex();
329					}
330				}
331			""
332			fragment ""
333				#version 320 es
334				precision mediump float;
335				${FRAGMENT_DECLARATIONS}
336				void main()
337				{
338					out0 = 1.0;
339					${FRAGMENT_OUTPUT}
340				}
341			""
342		end
343
344		case input_array_explicit_size
345			version 320 es
346			desc "Geometry shader input is explicitly sized array"
347			values { output float out0 = 1.0; }
348			vertex ""
349				#version 320 es
350				${VERTEX_DECLARATIONS}
351				out mediump float geo_in;
352				void main()
353				{
354					geo_in = 1.0;
355					${VERTEX_OUTPUT}
356				}
357			""
358			geometry ""
359				#version 320 es
360				${GEOMETRY_DECLARATIONS}
361				in mediump float geo_in[3];
362				out mediump float geo_out;
363				void main()
364				{
365					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
366					{
367						geo_out = geo_in[ndx];
368						gl_Position = gl_in[ndx].gl_Position;
369						EmitVertex();
370					}
371				}
372			""
373			fragment ""
374				#version 320 es
375				precision mediump float;
376				${FRAGMENT_DECLARATIONS}
377				in mediump float geo_out;
378				void main()
379				{
380					out0 = geo_out;
381					${FRAGMENT_OUTPUT}
382				}
383			""
384		end
385
386		case input_non_array
387			version 320 es
388			desc "Geometry shader has no input for an output"
389			expect compile_or_link_fail
390			values { output float out0 = 1.0; }
391			vertex ""
392				#version 320 es
393				${VERTEX_DECLARATIONS}
394				out mediump float geo_in;
395				void main()
396				{
397					geo_in = 1.0;
398					${VERTEX_OUTPUT}
399				}
400			""
401			geometry ""
402				#version 320 es
403				${GEOMETRY_DECLARATIONS}
404				in mediump float geo_in;
405				out mediump float geo_out;
406				void main()
407				{
408					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
409					{
410						geo_out = geo_in;
411						gl_Position = gl_in[ndx].gl_Position;
412						EmitVertex();
413					}
414				}
415			""
416			fragment ""
417				#version 320 es
418				precision mediump float;
419				${FRAGMENT_DECLARATIONS}
420				in mediump float geo_out;
421				void main()
422				{
423					out0 = geo_out;
424					${FRAGMENT_OUTPUT}
425				}
426			""
427		end
428
429		case input_array_size_mismatch
430			version 320 es
431			desc "Geometry shader input is explicitly sized array, but size does not match input primitive"
432			expect compile_or_link_fail
433			values { output float out0 = 1.0; }
434			vertex ""
435				#version 320 es
436				${VERTEX_DECLARATIONS}
437				out mediump float geo_in;
438				void main()
439				{
440					geo_in = 1.0;
441					${VERTEX_OUTPUT}
442				}
443			""
444			geometry ""
445				#version 320 es
446				${GEOMETRY_DECLARATIONS}
447				in mediump float geo_in[4];
448				out mediump float geo_out;
449				void main()
450				{
451					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
452					{
453						geo_out = geo_in[ndx+1];
454						gl_Position = gl_in[ndx].gl_Position;
455						EmitVertex();
456					}
457				}
458			""
459			fragment ""
460				#version 320 es
461				precision mediump float;
462				${FRAGMENT_DECLARATIONS}
463				in mediump float geo_out;
464				void main()
465				{
466					out0 = geo_out;
467					${FRAGMENT_OUTPUT}
468				}
469			""
470		end
471
472		case input_block
473			version 320 es
474			desc "Geometry shader input block"
475			values { output float out0 = 1.0; }
476			vertex ""
477				#version 320 es
478				${VERTEX_DECLARATIONS}
479				out IOBlockName
480				{
481					mediump float var;
482				} outputInstanceName;
483				void main()
484				{
485					outputInstanceName.var = 1.0;
486					${VERTEX_OUTPUT}
487				}
488			""
489			geometry ""
490				#version 320 es
491				${GEOMETRY_DECLARATIONS}
492				in IOBlockName
493				{
494					mediump float var;
495				} inputInstanceName[];
496				out mediump float geo_out;
497				void main()
498				{
499					geo_out = inputInstanceName[0].var;
500					gl_Position = gl_in[0].gl_Position;
501					EmitVertex();
502					geo_out = inputInstanceName[1].var;
503					gl_Position = gl_in[1].gl_Position;
504					EmitVertex();
505					geo_out = inputInstanceName[2].var;
506					gl_Position = gl_in[2].gl_Position;
507					EmitVertex();
508				}
509			""
510			fragment ""
511				#version 320 es
512				precision mediump float;
513				${FRAGMENT_DECLARATIONS}
514				in mediump float geo_out;
515				void main()
516				{
517					out0 = geo_out;
518					${FRAGMENT_OUTPUT}
519				}
520			""
521		end
522
523		case input_block_explicit_size
524			version 320 es
525			desc "Geometry shader input block with explicit size"
526			values { output float out0 = 1.0; }
527			vertex ""
528				#version 320 es
529				${VERTEX_DECLARATIONS}
530				out IOBlockName
531				{
532					mediump float var;
533				} outputInstanceName;
534				void main()
535				{
536					outputInstanceName.var = 1.0;
537					${VERTEX_OUTPUT}
538				}
539			""
540			geometry ""
541				#version 320 es
542				${GEOMETRY_DECLARATIONS}
543				in IOBlockName
544				{
545					mediump float var;
546				} inputInstanceName[3];
547				out mediump float geo_out;
548				void main()
549				{
550					geo_out = inputInstanceName[0].var;
551					gl_Position = gl_in[0].gl_Position;
552					EmitVertex();
553					geo_out = inputInstanceName[1].var;
554					gl_Position = gl_in[1].gl_Position;
555					EmitVertex();
556					geo_out = inputInstanceName[2].var;
557					gl_Position = gl_in[2].gl_Position;
558					EmitVertex();
559				}
560			""
561			fragment ""
562				#version 320 es
563				precision mediump float;
564				${FRAGMENT_DECLARATIONS}
565				in mediump float geo_out;
566				void main()
567				{
568					out0 = geo_out;
569					${FRAGMENT_OUTPUT}
570				}
571			""
572		end
573
574		case input_block_non_array
575			version 320 es
576			desc "Geometry shader input block is non an array"
577			expect compile_or_link_fail
578			values { output float out0 = 1.0; }
579			vertex ""
580				#version 320 es
581				${VERTEX_DECLARATIONS}
582				out IOBlockName
583				{
584					mediump float var;
585				} outputInstanceName;
586				void main()
587				{
588					outputInstanceName.var = 1.0;
589					${VERTEX_OUTPUT}
590				}
591			""
592			geometry ""
593				#version 320 es
594				${GEOMETRY_DECLARATIONS}
595				in IOBlockName
596				{
597					mediump float var;
598				} inputInstanceName;
599				out mediump float geo_out;
600				void main()
601				{
602					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
603					{
604						geo_out = inputInstanceName.var;
605						gl_Position = gl_in[ndx].gl_Position;
606						EmitVertex();
607					}
608				}
609			""
610			fragment ""
611				#version 320 es
612				precision mediump float;
613				${FRAGMENT_DECLARATIONS}
614				in mediump float geo_out;
615				void main()
616				{
617					out0 = geo_out;
618					${FRAGMENT_OUTPUT}
619				}
620			""
621		end
622
623		case input_block_array_size_mismatch
624			version 320 es
625			desc "Geometry shader input block invalid array size"
626			expect compile_or_link_fail
627			values { output float out0 = 1.0; }
628			vertex ""
629				#version 320 es
630				${VERTEX_DECLARATIONS}
631				out IOBlockName
632				{
633					mediump float var;
634				} outputInstanceName;
635				void main()
636				{
637					outputInstanceName.var = 1.0;
638					${VERTEX_OUTPUT}
639				}
640			""
641			geometry ""
642				#version 320 es
643				${GEOMETRY_DECLARATIONS}
644				in IOBlockName
645				{
646					mediump float var;
647				} inputInstanceName[4];
648				out mediump float geo_out;
649				void main()
650				{
651					geo_out = inputInstanceName[0].var;
652					gl_Position = gl_in[0].gl_Position;
653					EmitVertex();
654					geo_out = inputInstanceName[1].var;
655					gl_Position = gl_in[1].gl_Position;
656					EmitVertex();
657					geo_out = inputInstanceName[2].var + inputInstanceName[3].var;
658					gl_Position = gl_in[2].gl_Position;
659					EmitVertex();
660				}
661			""
662			fragment ""
663				#version 320 es
664				precision mediump float;
665				${FRAGMENT_DECLARATIONS}
666				in mediump float geo_out;
667				void main()
668				{
669					out0 = geo_out;
670					${FRAGMENT_OUTPUT}
671				}
672			""
673		end
674
675		case output_block
676			version 320 es
677			desc "Geometry shader output block"
678			values { output float out0 = 1.0; }
679			vertex ""
680				#version 320 es
681				${VERTEX_DECLARATIONS}
682				void main()
683				{
684					${VERTEX_OUTPUT}
685				}
686			""
687			geometry ""
688				#version 320 es
689				${GEOMETRY_DECLARATIONS}
690				out IOBlockName
691				{
692					mediump float var;
693				} outputInstanceName;
694				void main()
695				{
696					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
697					{
698						outputInstanceName.var = 1.0;
699						gl_Position = gl_in[ndx].gl_Position;
700						EmitVertex();
701					}
702				}
703			""
704			fragment ""
705				#version 320 es
706				precision mediump float;
707				${FRAGMENT_DECLARATIONS}
708				in IOBlockName
709				{
710					mediump float var;
711				} inputInstanceName;
712				void main()
713				{
714					out0 = inputInstanceName.var;
715					${FRAGMENT_OUTPUT}
716				}
717			""
718		end
719
720		case output_block_array
721			version 320 es
722			desc "Geometry shader output block array"
723			values { output float out0 = 1.0; }
724			vertex ""
725				#version 320 es
726				${VERTEX_DECLARATIONS}
727				void main()
728				{
729					${VERTEX_OUTPUT}
730				}
731			""
732			geometry ""
733				#version 320 es
734				${GEOMETRY_DECLARATIONS}
735				out IOBlockName
736				{
737					mediump float var;
738				} outputInstanceName[2];
739				void main()
740				{
741					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
742					{
743						outputInstanceName[0].var = 2.0;
744						outputInstanceName[1].var = 1.0;
745						gl_Position = gl_in[ndx].gl_Position;
746						EmitVertex();
747					}
748				}
749			""
750			fragment ""
751				#version 320 es
752				precision mediump float;
753				${FRAGMENT_DECLARATIONS}
754				in IOBlockName
755				{
756					mediump float var;
757				} inputInstanceName[2];
758				void main()
759				{
760					out0 = inputInstanceName[0].var - inputInstanceName[1].var;
761					${FRAGMENT_OUTPUT}
762				}
763			""
764		end
765
766		case unspecified_input_primitive_type
767			version 320 es
768			desc "Geometry shader input type unspecified"
769			expect compile_or_link_fail
770			vertex ""
771				#version 320 es
772				${VERTEX_DECLARATIONS}
773				void main()
774				{
775					${VERTEX_OUTPUT}
776				}
777			""
778			geometry ""
779				#version 320 es
780				layout (triangle_strip, max_vertices=3) out;
781				void main()
782				{
783					gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
784					EmitVertex();
785					gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
786					EmitVertex();
787					gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
788					EmitVertex();
789				}
790			""
791			fragment ""
792				#version 320 es
793				precision mediump float;
794				${FRAGMENT_DECLARATIONS}
795				void main()
796				{
797					${FRAGMENT_OUTPUT}
798				}
799			""
800		end
801
802		case unspecified_output_primitive_type
803			version 320 es
804			desc "Geometry shader output type unspecified"
805			expect compile_or_link_fail
806			vertex ""
807				#version 320 es
808				${VERTEX_DECLARATIONS}
809				void main()
810				{
811					${VERTEX_OUTPUT}
812				}
813			""
814			geometry ""
815				#version 320 es
816				layout (triangles) in;
817				layout (max_vertices=3) out;
818				void main()
819				{
820					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
821					{
822						gl_Position = gl_in[ndx].gl_Position;
823						EmitVertex();
824					}
825				}
826			""
827			fragment ""
828				#version 320 es
829				precision mediump float;
830				${FRAGMENT_DECLARATIONS}
831				void main()
832				{
833					${FRAGMENT_OUTPUT}
834				}
835			""
836		end
837
838		case unspecified_output_primitive_num_vertices
839			version 320 es
840			desc "Geometry shader output type unspecified"
841			expect compile_or_link_fail
842			vertex ""
843				#version 320 es
844				${VERTEX_DECLARATIONS}
845				void main()
846				{
847					${VERTEX_OUTPUT}
848				}
849			""
850			geometry ""
851				#version 320 es
852				layout (triangles) in;
853				layout (triangle_strip) out;
854				void main()
855				{
856					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
857					{
858						gl_Position = gl_in[ndx].gl_Position;
859						EmitVertex();
860					}
861				}
862			""
863			fragment ""
864				#version 320 es
865				precision mediump float;
866				${FRAGMENT_DECLARATIONS}
867				void main()
868				{
869					${FRAGMENT_OUTPUT}
870				}
871			""
872		end
873
874		# access_more_than_available_input_vertices
875		case access_more_than_available_input_vertices
876			version 320 es
877			desc "Geometry shader input block with explicit size"
878			expect compile_or_link_fail
879			vertex ""
880				#version 320 es
881				${VERTEX_DECLARATIONS}
882				void main()
883				{
884					${VERTEX_OUTPUT}
885				}
886			""
887			geometry ""
888				#version 320 es
889				${GEOMETRY_DECLARATIONS}
890				void main()
891				{
892					gl_Position = gl_in[0].gl_Position;
893					EmitVertex();
894					gl_Position = gl_in[1].gl_Position;
895					EmitVertex();
896					gl_Position = gl_in[4].gl_Position; // access more than available
897					EmitVertex();
898				}
899			""
900			fragment ""
901				#version 320 es
902				precision mediump float;
903				${FRAGMENT_DECLARATIONS}
904				void main()
905				{
906					${FRAGMENT_OUTPUT}
907				}
908			""
909		end
910	end
911
912	import "linkage_geometry_varying_types.test"
913
914	group qualifiers "Varying qualifiers"
915		case smooth
916			version 320 es
917			desc "varying with smooth interpolation"
918			values
919			{
920				input float in0		= 1.0;
921				output float out0	= 1.0;
922			}
923			vertex ""
924				#version 320 es
925				${VERTEX_DECLARATIONS}
926				smooth out mediump float vtx_var;
927				void main()
928				{
929					vtx_var = in0;
930					${VERTEX_OUTPUT}
931				}
932			""
933			geometry ""
934				#version 320 es
935				${GEOMETRY_DECLARATIONS}
936				smooth in mediump float vtx_var[];
937				smooth out mediump float geo_var;
938				void main()
939				{
940					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
941					{
942						geo_var = vtx_var[ndx];
943						gl_Position = gl_in[ndx].gl_Position;
944						EmitVertex();
945					}
946				}
947			""
948			fragment ""
949				#version 320 es
950				precision mediump float;
951				${FRAGMENT_DECLARATIONS}
952				smooth in float geo_var;
953				void main()
954				{
955					out0 = geo_var;
956					${FRAGMENT_OUTPUT}
957				}
958			""
959		end
960
961		case flat
962			version 320 es
963			desc "varying with flat interpolation"
964			values
965			{
966				input float in0		= 1.0;
967				output float out0	= 1.0;
968			}
969			vertex ""
970				#version 320 es
971				${VERTEX_DECLARATIONS}
972				flat out mediump float vtx_var;
973				void main()
974				{
975					vtx_var = in0;
976					${VERTEX_OUTPUT}
977				}
978			""
979			geometry ""
980				#version 320 es
981				${GEOMETRY_DECLARATIONS}
982				flat in mediump float vtx_var[];
983				flat out mediump float geo_var;
984				void main()
985				{
986					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
987					{
988						geo_var = vtx_var[ndx];
989						gl_Position = gl_in[ndx].gl_Position;
990						EmitVertex();
991					}
992				}
993			""
994			fragment ""
995				#version 320 es
996				precision mediump float;
997				${FRAGMENT_DECLARATIONS}
998				flat in float geo_var;
999				void main()
1000				{
1001					out0 = geo_var;
1002					${FRAGMENT_OUTPUT}
1003				}
1004			""
1005		end
1006
1007		case centroid
1008			version 320 es
1009			desc "varying declared with centroid qualifier"
1010			values
1011			{
1012				input float in0		= 1.0;
1013				output float out0	= 1.0;
1014			}
1015			vertex ""
1016				#version 320 es
1017				${VERTEX_DECLARATIONS}
1018				centroid out mediump float vtx_var;
1019				void main()
1020				{
1021					vtx_var = in0;
1022					${VERTEX_OUTPUT}
1023				}
1024			""
1025			geometry ""
1026				#version 320 es
1027				${GEOMETRY_DECLARATIONS}
1028				centroid in mediump float vtx_var[];
1029				centroid out mediump float geo_var;
1030				void main()
1031				{
1032					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1033					{
1034						geo_var = vtx_var[ndx];
1035						gl_Position = gl_in[ndx].gl_Position;
1036						EmitVertex();
1037					}
1038				}
1039			""
1040			fragment ""
1041				#version 320 es
1042				precision mediump float;
1043				${FRAGMENT_DECLARATIONS}
1044				centroid in float geo_var;
1045				void main()
1046				{
1047					out0 = geo_var;
1048					${FRAGMENT_OUTPUT}
1049				}
1050			""
1051		end
1052
1053		case sample
1054			version 320 es
1055			desc "varying declared with sample qualifier"
1056			values
1057			{
1058				input float in0		= 1.0;
1059				output float out0	= 1.0;
1060			}
1061			vertex ""
1062				#version 320 es
1063				${VERTEX_DECLARATIONS}
1064				sample out mediump float vtx_var;
1065				void main()
1066				{
1067					vtx_var = in0;
1068					${VERTEX_OUTPUT}
1069				}
1070			""
1071			geometry ""
1072				#version 320 es
1073				${GEOMETRY_DECLARATIONS}
1074				sample in mediump float vtx_var[];
1075				sample out mediump float geo_var;
1076				void main()
1077				{
1078					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1079					{
1080						geo_var = vtx_var[ndx];
1081						gl_Position = gl_in[ndx].gl_Position;
1082						EmitVertex();
1083					}
1084				}
1085			""
1086			fragment ""
1087				#version 320 es
1088				precision mediump float;
1089				${FRAGMENT_DECLARATIONS}
1090				sample in float geo_var;
1091				void main()
1092				{
1093					out0 = geo_var;
1094					${FRAGMENT_OUTPUT}
1095				}
1096			""
1097		end
1098	end
1099end
1100
1101group uniform "Uniform linkage"
1102	group rules "Rules"
1103
1104		case type_mismatch_1
1105			version 320 es
1106			desc "uniforms declared with different types"
1107			expect link_fail
1108			vertex ""
1109				#version 320 es
1110				${VERTEX_DECLARATIONS}
1111				uniform mediump float u_var;
1112				out mediump float vtx_var;
1113				void main()
1114				{
1115					vtx_var = u_var;
1116					${VERTEX_OUTPUT}
1117				}
1118			""
1119			geometry ""
1120				#version 320 es
1121				${GEOMETRY_DECLARATIONS}
1122				uniform mediump vec4 u_var;
1123				in mediump float vtx_var[];
1124				out mediump float geo_var;
1125				void main()
1126				{
1127					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1128					{
1129						geo_var = vtx_var[ndx];
1130						gl_Position = gl_in[ndx].gl_Position + u_var;
1131						EmitVertex();
1132					}
1133				}
1134			""
1135			fragment ""
1136				#version 320 es
1137				precision mediump float;
1138				${FRAGMENT_DECLARATIONS}
1139				in float geo_var;
1140				void main()
1141				{
1142					${FRAG_COLOR} = vec4(geo_var);
1143				}
1144			""
1145		end
1146
1147		case type_mismatch_2
1148			version 320 es
1149			desc "uniforms declared with different types"
1150			expect link_fail
1151			require limit "GL_MAX_VERTEX_ATOMIC_COUNTERS" > 0
1152			vertex ""
1153				#version 320 es
1154				${VERTEX_DECLARATIONS}
1155				layout(binding=0) uniform atomic_uint u_var;
1156				out mediump float vtx_var;
1157				void main()
1158				{
1159					uint result = atomicCounterIncrement(u_var);
1160					vtx_var = float(result);
1161					${VERTEX_OUTPUT}
1162				}
1163			""
1164			geometry ""
1165				#version 320 es
1166				${GEOMETRY_DECLARATIONS}
1167				uniform mediump vec4 u_var;
1168				in mediump float vtx_var[];
1169				out mediump float geo_var;
1170				void main()
1171				{
1172					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1173					{
1174						geo_var = vtx_var[ndx];
1175						gl_Position = gl_in[ndx].gl_Position + u_var;
1176						EmitVertex();
1177					}
1178				}
1179			""
1180			fragment ""
1181				#version 320 es
1182				precision mediump float;
1183				${FRAGMENT_DECLARATIONS}
1184				in float geo_var;
1185				void main()
1186				{
1187					${FRAG_COLOR} = vec4(geo_var);
1188				}
1189			""
1190		end
1191
1192		case type_mismatch_3
1193			version 320 es
1194			desc "uniforms declared with different types"
1195			expect link_fail
1196			require limit "GL_MAX_VERTEX_IMAGE_UNIFORMS" > 0
1197			vertex ""
1198				#version 320 es
1199				${VERTEX_DECLARATIONS}
1200				layout(binding=0) layout(rgba8i) uniform readonly highp iimage2D u_var;
1201				out mediump float vtx_var;
1202				void main()
1203				{
1204					int result = imageSize(u_var).x;
1205					vtx_var = float(result);
1206					${VERTEX_OUTPUT}
1207				}
1208			""
1209			geometry ""
1210				#version 320 es
1211				${GEOMETRY_DECLARATIONS}
1212				uniform mediump vec4 u_var;
1213				in mediump float vtx_var[];
1214				out mediump float geo_var;
1215				void main()
1216				{
1217					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1218					{
1219						geo_var = vtx_var[ndx];
1220						gl_Position = gl_in[ndx].gl_Position + u_var;
1221						EmitVertex();
1222					}
1223				}
1224			""
1225			fragment ""
1226				#version 320 es
1227				precision mediump float;
1228				${FRAGMENT_DECLARATIONS}
1229				in float geo_var;
1230				void main()
1231				{
1232					${FRAG_COLOR} = vec4(geo_var);
1233				}
1234			""
1235		end
1236
1237		case precision_mismatch
1238			version 320 es
1239			desc "uniforms declared with different precisions"
1240			expect link_fail
1241			vertex ""
1242				#version 320 es
1243				${VERTEX_DECLARATIONS}
1244				uniform highp float u_var;
1245				out mediump float vtx_var;
1246				void main()
1247				{
1248					vtx_var = u_var;
1249					${VERTEX_OUTPUT}
1250				}
1251			""
1252			geometry ""
1253				#version 320 es
1254				${GEOMETRY_DECLARATIONS}
1255				uniform mediump float u_var;
1256				in mediump float vtx_var[];
1257				out mediump float geo_var;
1258				void main()
1259				{
1260					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1261					{
1262						geo_var = vtx_var[ndx];
1263						gl_Position = gl_in[ndx].gl_Position + vec4(u_var);
1264						EmitVertex();
1265					}
1266				}
1267			""
1268			fragment ""
1269				#version 320 es
1270				precision mediump float;
1271				${FRAGMENT_DECLARATIONS}
1272				in float geo_var;
1273				void main()
1274				{
1275					${FRAG_COLOR} = vec4(geo_var);
1276				}
1277			""
1278		end
1279
1280		case struct_partial_usage
1281			version 320 es
1282			desc "uniforms struct used partially in different stages"
1283			values
1284			{
1285				uniform float val.vtxValue	= 1.0;
1286				uniform float val.geoValue	= 1.0;
1287				uniform float val.frgValue	= 1.0;
1288			}
1289			vertex ""
1290				#version 320 es
1291				${VERTEX_DECLARATIONS}
1292				struct S
1293				{
1294					mediump float vtxValue;
1295					mediump float geoValue;
1296					mediump float frgValue;
1297				};
1298				uniform S val;
1299				out mediump float vtx_var;
1300				void main()
1301				{
1302					vtx_var = val.vtxValue;
1303					${VERTEX_OUTPUT}
1304				}
1305			""
1306			geometry ""
1307				#version 320 es
1308				${GEOMETRY_DECLARATIONS}
1309				struct S
1310				{
1311					mediump float vtxValue;
1312					mediump float geoValue;
1313					mediump float frgValue;
1314				};
1315				uniform S val;
1316				in mediump float vtx_var[];
1317				out mediump float geo_var;
1318				void main()
1319				{
1320					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
1321					{
1322						geo_var = vtx_var[ndx] + val.geoValue;
1323						gl_Position = gl_in[ndx].gl_Position;
1324						EmitVertex();
1325					}
1326				}
1327			""
1328			fragment ""
1329				#version 320 es
1330				precision mediump float;
1331				${FRAGMENT_DECLARATIONS}
1332				struct S
1333				{
1334					mediump float vtxValue;
1335					mediump float geoValue;
1336					mediump float frgValue;
1337				};
1338				uniform S val;
1339				in float geo_var;
1340				void main()
1341				{
1342					${FRAG_COLOR} = vec4(geo_var + val.frgValue);
1343				}
1344			""
1345		end
1346	end
1347
1348	import "linkage_geometry_uniform_types.test"
1349end
1350