xref: /aosp_15_r20/external/deqp/data/gles31/shaders/gl45/linkage_tessellation_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
23        case type_mismatch
24            version 450
25            desc "Tessellation output and geometry input type mismatch"
26            expect link_fail
27            values
28            {
29                input float in0 = 1.0;
30                output float out0 = 1.0;
31            }
32            vertex ""
33                #version 450
34                ${VERTEX_DECLARATIONS}
35                out mediump float vtx_out;
36                void main()
37                {
38                    vtx_out = in0;
39                    ${VERTEX_OUTPUT}
40                }
41            ""
42            tessellation_control ""
43                #version 450
44                ${TESSELLATION_CONTROL_DECLARATIONS}
45                in mediump float vtx_out[];
46                out mediump float tc_out[];
47                void main()
48                {
49                    tc_out[gl_InvocationID] = vtx_out[gl_InvocationID];
50                    ${TESSELLATION_CONTROL_OUTPUT}
51                }
52            ""
53            tessellation_evaluation ""
54                #version 450
55                ${TESSELLATION_EVALUATION_DECLARATIONS}
56                in mediump float tc_out[];
57                out mediump float te_out;
58                void main()
59                {
60                    te_out = tc_out[2];
61                    ${TESSELLATION_EVALUATION_OUTPUT}
62                }
63            ""
64            geometry ""
65                #version 450
66                ${GEOMETRY_DECLARATIONS}
67                in mediump vec2 te_out[];
68                out mediump float geo_out;
69                void main()
70                {
71                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
72                    {
73                        geo_out = te_out[ndx].y;
74                        gl_Position = gl_in[ndx].gl_Position;
75                        EmitVertex();
76                    }
77                }
78            ""
79            fragment ""
80                #version 450
81                precision mediump float;
82                ${FRAGMENT_DECLARATIONS}
83                in mediump float geo_out;
84                void main()
85                {
86                    out0 = geo_out;
87                    ${FRAGMENT_OUTPUT}
88                }
89            ""
90        end
91
92        case different_precision
93            version 450
94            desc "Tessellation output and geometry input precisions are different"
95            values
96            {
97                input float in0 = 1.0;
98                output float out0 = 1.0;
99            }
100            vertex ""
101                #version 450
102                ${VERTEX_DECLARATIONS}
103                out mediump float vtx_out;
104                void main()
105                {
106                    vtx_out = in0;
107                    ${VERTEX_OUTPUT}
108                }
109            ""
110            tessellation_control ""
111                #version 450
112                ${TESSELLATION_CONTROL_DECLARATIONS}
113                in mediump float vtx_out[];
114                out mediump float tc_out[];
115                void main()
116                {
117                    tc_out[gl_InvocationID] = vtx_out[gl_InvocationID];
118                    ${TESSELLATION_CONTROL_OUTPUT}
119                }
120            ""
121            tessellation_evaluation ""
122                #version 450
123                ${TESSELLATION_EVALUATION_DECLARATIONS}
124                in mediump float tc_out[];
125                out mediump float te_out;
126                void main()
127                {
128                    te_out = tc_out[2];
129                    ${TESSELLATION_EVALUATION_OUTPUT}
130                }
131            ""
132            geometry ""
133                #version 450
134                ${GEOMETRY_DECLARATIONS}
135                in highp float te_out[];
136                out mediump float geo_out;
137                void main()
138                {
139                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
140                    {
141                        geo_out = te_out[ndx];
142                        gl_Position = gl_in[ndx].gl_Position;
143                        EmitVertex();
144                    }
145                }
146            ""
147            fragment ""
148                #version 450
149                precision mediump float;
150                ${FRAGMENT_DECLARATIONS}
151                in mediump float geo_out;
152                void main()
153                {
154                    out0 = geo_out;
155                    ${FRAGMENT_OUTPUT}
156                }
157            ""
158        end
159
160        case superfluous_output_declaration
161            version 450
162            desc "Tessellation shader output is never used"
163            values
164            {
165                input float in0 = 1.0;
166                output float out0 = 1.0;
167            }
168            vertex ""
169                #version 450
170                ${VERTEX_DECLARATIONS}
171                out mediump float vtx_out;
172                void main()
173                {
174                    vtx_out = in0;
175                    ${VERTEX_OUTPUT}
176                }
177            ""
178            tessellation_control ""
179                #version 450
180                ${TESSELLATION_CONTROL_DECLARATIONS}
181                in mediump float vtx_out[];
182                out mediump float tc_out[];
183                void main()
184                {
185                    tc_out[gl_InvocationID] = vtx_out[gl_InvocationID];
186                    ${TESSELLATION_CONTROL_OUTPUT}
187                }
188            ""
189            tessellation_evaluation ""
190                #version 450
191                ${TESSELLATION_EVALUATION_DECLARATIONS}
192                in mediump float tc_out[];
193                out mediump float te_out;
194                out mediump float te_out_nonexistent;
195                void main()
196                {
197                    te_out = tc_out[2];
198                    te_out_nonexistent = tc_out[0];
199                    ${TESSELLATION_EVALUATION_OUTPUT}
200                }
201            ""
202            geometry ""
203                #version 450
204                ${GEOMETRY_DECLARATIONS}
205                in mediump float te_out[];
206                out mediump float geo_out;
207                void main()
208                {
209                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
210                    {
211                        geo_out = te_out[ndx];
212                        gl_Position = gl_in[ndx].gl_Position;
213                        EmitVertex();
214                    }
215                }
216            ""
217            fragment ""
218                #version 450
219                precision mediump float;
220                ${FRAGMENT_DECLARATIONS}
221                in mediump float geo_out;
222                void main()
223                {
224                    out0 = geo_out;
225                    ${FRAGMENT_OUTPUT}
226                }
227            ""
228        end
229
230        case vertex_geometry_same_varying_name_1
231            version 450
232            desc "Vertex output and geometry input share the same name"
233            values
234            {
235                input float in0 = 1.0;
236                output float out0 = 1.0;
237            }
238            vertex ""
239                #version 450
240                ${VERTEX_DECLARATIONS}
241                out mediump float sharedVaringName;
242                void main()
243                {
244                    sharedVaringName = in0;
245                    ${VERTEX_OUTPUT}
246                }
247            ""
248            tessellation_control ""
249                #version 450
250                ${TESSELLATION_CONTROL_DECLARATIONS}
251                in mediump float sharedVaringName[];
252                out mediump float tc_out[];
253                void main()
254                {
255                    tc_out[gl_InvocationID] = sharedVaringName[gl_InvocationID];
256                    ${TESSELLATION_CONTROL_OUTPUT}
257                }
258            ""
259            tessellation_evaluation ""
260                #version 450
261                ${TESSELLATION_EVALUATION_DECLARATIONS}
262                in mediump float tc_out[];
263                out mediump float sharedVaringName;
264                void main()
265                {
266                    sharedVaringName = tc_out[2];
267                    ${TESSELLATION_EVALUATION_OUTPUT}
268                }
269            ""
270            geometry ""
271                #version 450
272                ${GEOMETRY_DECLARATIONS}
273                in mediump float sharedVaringName[];
274                out mediump float geo_out;
275                void main()
276                {
277                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
278                    {
279                        geo_out = sharedVaringName[ndx];
280                        gl_Position = gl_in[ndx].gl_Position;
281                        EmitVertex();
282                    }
283                }
284            ""
285            fragment ""
286                #version 450
287                precision mediump float;
288                ${FRAGMENT_DECLARATIONS}
289                in mediump float geo_out;
290                void main()
291                {
292                    out0 = geo_out;
293                    ${FRAGMENT_OUTPUT}
294                }
295            ""
296        end
297
298        case vertex_geometry_same_varying_name_2
299            version 450
300            desc "Vertex output and geometry input share the same name"
301            values
302            {
303                input vec2 in0 = vec2(1.0, 1.0);
304                output float out0 = 1.0;
305            }
306            vertex ""
307                #version 450
308                ${VERTEX_DECLARATIONS}
309                out mediump vec2 sharedVaringName;
310                void main()
311                {
312                    sharedVaringName = in0;
313                    ${VERTEX_OUTPUT}
314                }
315            ""
316            tessellation_control ""
317                #version 450
318                ${TESSELLATION_CONTROL_DECLARATIONS}
319                in mediump vec2 sharedVaringName[];
320                out mediump float tc_out[];
321                void main()
322                {
323                    tc_out[gl_InvocationID] = 2.0 * sharedVaringName[gl_InvocationID].x - sharedVaringName[gl_InvocationID].y;
324                    ${TESSELLATION_CONTROL_OUTPUT}
325                }
326            ""
327            tessellation_evaluation ""
328                #version 450
329                ${TESSELLATION_EVALUATION_DECLARATIONS}
330                in mediump float tc_out[];
331                out mediump float sharedVaringName;
332                void main()
333                {
334                    sharedVaringName = tc_out[2];
335                    ${TESSELLATION_EVALUATION_OUTPUT}
336                }
337            ""
338            geometry ""
339                #version 450
340                ${GEOMETRY_DECLARATIONS}
341                in mediump float sharedVaringName[];
342                out mediump float geo_out;
343                void main()
344                {
345                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
346                    {
347                        geo_out = sharedVaringName[ndx];
348                        gl_Position = gl_in[ndx].gl_Position;
349                        EmitVertex();
350                    }
351                }
352            ""
353            fragment ""
354                #version 450
355                precision mediump float;
356                ${FRAGMENT_DECLARATIONS}
357                in mediump float geo_out;
358                void main()
359                {
360                    out0 = geo_out;
361                    ${FRAGMENT_OUTPUT}
362                }
363            ""
364        end
365
366        case io_block
367            version 450
368            desc "Use of io block between tessellation and geometry shaders"
369            values
370            {
371                input float in0 = 1.0;
372                output float out0 = 1.0;
373            }
374            vertex ""
375                #version 450
376                ${VERTEX_DECLARATIONS}
377                out mediump float vtx_out;
378                void main()
379                {
380                    vtx_out = in0;
381                    ${VERTEX_OUTPUT}
382                }
383            ""
384            tessellation_control ""
385                #version 450
386                ${TESSELLATION_CONTROL_DECLARATIONS}
387                in mediump float vtx_out[];
388                out mediump float tc_out[];
389                void main()
390                {
391                    tc_out[gl_InvocationID] = vtx_out[gl_InvocationID];
392                    ${TESSELLATION_CONTROL_OUTPUT}
393                }
394            ""
395            tessellation_evaluation ""
396                #version 450
397                ${TESSELLATION_EVALUATION_DECLARATIONS}
398                in mediump float tc_out[];
399                out IOBlockName { mediump float val; } instanceName;
400                void main()
401                {
402                    instanceName.val = tc_out[2];
403                    ${TESSELLATION_EVALUATION_OUTPUT}
404                }
405            ""
406            geometry ""
407                #version 450
408                ${GEOMETRY_DECLARATIONS}
409                in IOBlockName { mediump float val; } instanceName[];
410                out mediump float geo_out;
411                void main()
412                {
413                    geo_out = instanceName[0].val;
414                    gl_Position = gl_in[0].gl_Position;
415                    EmitVertex();
416
417                    geo_out = instanceName[1].val;
418                    gl_Position = gl_in[1].gl_Position;
419                    EmitVertex();
420
421                    geo_out = instanceName[2].val;
422                    gl_Position = gl_in[2].gl_Position;
423                    EmitVertex();
424                }
425            ""
426            fragment ""
427                #version 450
428                precision mediump float;
429                ${FRAGMENT_DECLARATIONS}
430                in mediump float geo_out;
431                void main()
432                {
433                    out0 = geo_out;
434                    ${FRAGMENT_OUTPUT}
435                }
436            ""
437        end
438
439        case array_in_io_block
440            version 450
441            desc "Float array in a io block between tessellation and geometry shaders"
442            values
443            {
444                input float in0 = 1.0;
445                output float out0 = 1.0;
446            }
447            vertex ""
448                #version 450
449                ${VERTEX_DECLARATIONS}
450                out mediump float vtx_out;
451                void main()
452                {
453                    vtx_out = in0;
454                    ${VERTEX_OUTPUT}
455                }
456            ""
457            tessellation_control ""
458                #version 450
459                ${TESSELLATION_CONTROL_DECLARATIONS}
460                in mediump float vtx_out[];
461                out mediump float tc_out[];
462                void main()
463                {
464                    tc_out[gl_InvocationID] = vtx_out[gl_InvocationID];
465                    ${TESSELLATION_CONTROL_OUTPUT}
466                }
467            ""
468            tessellation_evaluation ""
469                #version 450
470                ${TESSELLATION_EVALUATION_DECLARATIONS}
471                in mediump float tc_out[];
472                out IOBlockName { mediump float val[2]; } instanceName;
473                void main()
474                {
475                    instanceName.val[0] = tc_out[2] + 1.0;
476                    instanceName.val[1] = -1.0;
477                    ${TESSELLATION_EVALUATION_OUTPUT}
478                }
479            ""
480            geometry ""
481                #version 450
482                ${GEOMETRY_DECLARATIONS}
483                in IOBlockName { mediump float val[2]; } instanceName[];
484                out mediump float geo_out;
485                void main()
486                {
487                    geo_out = instanceName[0].val[0] + instanceName[0].val[1];
488                    gl_Position = gl_in[0].gl_Position;
489                    EmitVertex();
490
491                    geo_out = instanceName[1].val[0] + instanceName[1].val[1];
492                    gl_Position = gl_in[1].gl_Position;
493                    EmitVertex();
494
495                    geo_out = instanceName[2].val[0] + instanceName[2].val[1];
496                    gl_Position = gl_in[2].gl_Position;
497                    EmitVertex();
498                }
499            ""
500            fragment ""
501                #version 450
502                precision mediump float;
503                ${FRAGMENT_DECLARATIONS}
504                in mediump float geo_out;
505                void main()
506                {
507                    out0 = geo_out;
508                    ${FRAGMENT_OUTPUT}
509                }
510            ""
511        end
512    end
513
514    import "linkage_tessellation_geometry_varying_types.test"
515end
516
517group uniform "Uniform linkage"
518    group rules "Rules"
519        case type_mismatch_1
520            version 450
521            desc "Uniform type mismatch"
522            expect link_fail
523            vertex ""
524                #version 450
525                ${VERTEX_DECLARATIONS}
526                void main()
527                {
528                    ${VERTEX_OUTPUT}
529                }
530            ""
531            tessellation_control ""
532                #version 450
533                ${TESSELLATION_CONTROL_DECLARATIONS}
534                void main()
535                {
536                    ${TESSELLATION_CONTROL_OUTPUT}
537                }
538            ""
539            tessellation_evaluation ""
540                #version 450
541                ${TESSELLATION_EVALUATION_DECLARATIONS}
542                uniform mediump float u_value;
543                out mediump float te_out;
544                void main()
545                {
546                    te_out = u_value;
547                    ${TESSELLATION_EVALUATION_OUTPUT}
548                }
549            ""
550            geometry ""
551                #version 450
552                ${GEOMETRY_DECLARATIONS}
553                uniform mediump vec2 u_value;
554                in mediump float te_out[];
555                out mediump float geo_out;
556                void main()
557                {
558                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
559                    {
560                        geo_out = te_out[ndx] + u_value.y;
561                        gl_Position = gl_in[ndx].gl_Position;
562                        EmitVertex();
563                    }
564                }
565            ""
566            fragment ""
567                #version 450
568                precision mediump float;
569                ${FRAGMENT_DECLARATIONS}
570                in mediump float geo_out;
571                void main()
572                {
573                    ${FRAG_COLOR} = vec4(geo_out);
574                }
575            ""
576        end
577
578        case struct_partial_usage
579            version 450
580            desc "Uniform precision mismatch"
581            values
582            {
583                uniform float u_value.teVal = 1.0;
584                uniform float u_value.geoVal = 2.0;
585                output float out0 = 5.0;
586            }
587            vertex ""
588                #version 450
589                ${VERTEX_DECLARATIONS}
590                void main()
591                {
592                    ${VERTEX_OUTPUT}
593                }
594            ""
595            tessellation_control ""
596                #version 450
597                ${TESSELLATION_CONTROL_DECLARATIONS}
598                void main()
599                {
600                    ${TESSELLATION_CONTROL_OUTPUT}
601                }
602            ""
603            tessellation_evaluation ""
604                #version 450
605                ${TESSELLATION_EVALUATION_DECLARATIONS}
606                struct S
607                {
608                    mediump float teVal;
609                    mediump float geoVal;
610                };
611                uniform S u_value;
612                out mediump float te_out;
613                void main()
614                {
615                    te_out = u_value.teVal;
616                    ${TESSELLATION_EVALUATION_OUTPUT}
617                }
618            ""
619            geometry ""
620                #version 450
621                ${GEOMETRY_DECLARATIONS}
622                struct S
623                {
624                    mediump float teVal;
625                    mediump float geoVal;
626                };
627                uniform S u_value;
628                in mediump float te_out[];
629                out mediump float geo_out;
630                void main()
631                {
632                    for (int ndx = 0; ndx < gl_in.length(); ++ndx)
633                    {
634                        geo_out = te_out[ndx] + 2.0 * u_value.geoVal;
635                        gl_Position = gl_in[ndx].gl_Position;
636                        EmitVertex();
637                    }
638                }
639            ""
640            fragment ""
641                #version 450
642                precision mediump float;
643                ${FRAGMENT_DECLARATIONS}
644                in mediump float geo_out;
645                void main()
646                {
647                    out0 = geo_out;
648                    ${FRAGMENT_OUTPUT}
649                }
650            ""
651        end
652    end
653end
654