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