Merge "Remove a few preprocessor cases testing undefined behavior" into nougat-cts-dev
[platform/upstream/VK-GL-CTS.git] / data / gles31 / shaders / linkage_shader_storage_block.test
1
2 case mismatch_number_of_declarations
3         version 310 es
4         desc "Shader storage block mismatch: different number of declarations"
5         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
6         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
7         expect link_fail
8         vertex ""
9                 #version 310 es
10                 ${VERTEX_DECLARATIONS}
11                 layout(binding=0) buffer BufferBlockName
12                 {
13                         mediump float variable1;
14                 };
15
16                 out mediump float vtx_val;
17                 void main()
18                 {
19                         vtx_val = variable1;
20                         ${VERTEX_OUTPUT}
21                 }
22         ""
23         fragment ""
24                 #version 310 es
25                 precision mediump float;
26                 ${FRAGMENT_DECLARATIONS}
27                 layout(binding=0) buffer BufferBlockName
28                 {
29                         mediump float variable1;
30                         mediump float variable2;
31                 };
32
33                 in mediump float vtx_val;
34                 void main()
35                 {
36                         ${FRAG_COLOR} = vec4(vtx_val + variable1 + variable2);
37                 }
38         ""
39 end
40
41 case mismatch_order
42         version 310 es
43         desc "Shader storage block mismatch: different number of declarations"
44         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
45         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
46         expect link_fail
47         vertex ""
48                 #version 310 es
49                 ${VERTEX_DECLARATIONS}
50                 layout(binding=0) buffer BufferBlockName
51                 {
52                         mediump float variable1;
53                         mediump float variable2;
54                 };
55
56                 out mediump float vtx_val;
57                 void main()
58                 {
59                         vtx_val = variable1 + variable2;
60                         ${VERTEX_OUTPUT}
61                 }
62         ""
63         fragment ""
64                 #version 310 es
65                 precision mediump float;
66                 ${FRAGMENT_DECLARATIONS}
67                 layout(binding=0) buffer BufferBlockName
68                 {
69                         mediump float variable2;
70                         mediump float variable1;
71                 };
72
73                 in mediump float vtx_val;
74                 void main()
75                 {
76                         ${FRAG_COLOR} = vec4(vtx_val + variable1 + variable2);
77                 }
78         ""
79 end
80
81 case mismatch_type
82         version 310 es
83         desc "Shader storage block mismatch: different number of declarations"
84         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
85         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
86         expect link_fail
87         vertex ""
88                 #version 310 es
89                 ${VERTEX_DECLARATIONS}
90                 layout(binding=0) buffer BufferBlockName
91                 {
92                         mediump vec2 variable;
93                 };
94
95                 out mediump float vtx_val;
96                 void main()
97                 {
98                         vtx_val = variable.y;
99                         ${VERTEX_OUTPUT}
100                 }
101         ""
102         fragment ""
103                 #version 310 es
104                 precision mediump float;
105                 ${FRAGMENT_DECLARATIONS}
106                 layout(binding=0) buffer BufferBlockName
107                 {
108                         mediump float variable;
109                 };
110
111                 in mediump float vtx_val;
112                 void main()
113                 {
114                         ${FRAG_COLOR} = vec4(vtx_val + variable);
115                 }
116         ""
117 end
118
119 case mismatch_member_name
120         version 310 es
121         desc "Shader storage block mismatch: different number of declarations"
122         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
123         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
124         expect link_fail
125         vertex ""
126                 #version 310 es
127                 ${VERTEX_DECLARATIONS}
128                 layout(binding=0) buffer BufferBlockName
129                 {
130                         mediump float variable1;
131                 };
132
133                 out mediump float vtx_val;
134                 void main()
135                 {
136                         vtx_val = variable1;
137                         ${VERTEX_OUTPUT}
138                 }
139         ""
140         fragment ""
141                 #version 310 es
142                 precision mediump float;
143                 ${FRAGMENT_DECLARATIONS}
144                 layout(binding=0) buffer BufferBlockName
145                 {
146                         mediump float variable2;
147                 };
148
149                 in mediump float vtx_val;
150                 void main()
151                 {
152                         ${FRAG_COLOR} = vec4(vtx_val + variable2);
153                 }
154         ""
155 end
156
157 case mismatch_member_unsized_sized_array
158         version 310 es
159         desc "Shader storage block mismatch: different number of declarations"
160         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
161         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
162         expect link_fail
163         vertex ""
164                 #version 310 es
165                 ${VERTEX_DECLARATIONS}
166                 layout(binding=0) buffer BufferBlockName
167                 {
168                         mediump float variable[];
169                 };
170
171                 out mediump float vtx_val;
172                 void main()
173                 {
174                         vtx_val = variable[0];
175                         ${VERTEX_OUTPUT}
176                 }
177         ""
178         fragment ""
179                 #version 310 es
180                 precision mediump float;
181                 ${FRAGMENT_DECLARATIONS}
182                 layout(binding=0) buffer BufferBlockName
183                 {
184                         mediump float variable[1];
185                 };
186
187                 in mediump float vtx_val;
188                 void main()
189                 {
190                         ${FRAG_COLOR} = vec4(vtx_val + variable[0]);
191                 }
192         ""
193 end
194
195 case mismatch_member_array_size
196         version 310 es
197         desc "Shader storage block mismatch: different number of declarations"
198         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
199         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
200         expect link_fail
201         vertex ""
202                 #version 310 es
203                 ${VERTEX_DECLARATIONS}
204                 layout(binding=0) buffer BufferBlockName
205                 {
206                         mediump float variable[1];
207                 };
208
209                 out mediump float vtx_val;
210                 void main()
211                 {
212                         vtx_val = variable[0];
213                         ${VERTEX_OUTPUT}
214                 }
215         ""
216         fragment ""
217                 #version 310 es
218                 precision mediump float;
219                 ${FRAGMENT_DECLARATIONS}
220                 layout(binding=0) buffer BufferBlockName
221                 {
222                         mediump float variable[2];
223                 };
224
225                 in mediump float vtx_val;
226                 void main()
227                 {
228                         ${FRAG_COLOR} = vec4(vtx_val + variable[0]);
229                 }
230         ""
231 end
232
233 case mismatch_with_and_without_instance_name
234         version 310 es
235         desc "Shader storage block mismatch: different number of declarations"
236         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
237         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
238         expect link_fail
239         vertex ""
240                 #version 310 es
241                 ${VERTEX_DECLARATIONS}
242                 layout(binding=0) buffer BufferBlockName
243                 {
244                         mediump float variable;
245                 } instanceName;
246
247                 out mediump float vtx_val;
248                 void main()
249                 {
250                         vtx_val = instanceName.variable;
251                         ${VERTEX_OUTPUT}
252                 }
253         ""
254         fragment ""
255                 #version 310 es
256                 precision mediump float;
257                 ${FRAGMENT_DECLARATIONS}
258                 layout(binding=0) buffer BufferBlockName
259                 {
260                         mediump float variable;
261                 };
262
263                 in mediump float vtx_val;
264                 void main()
265                 {
266                         ${FRAG_COLOR} = vec4(vtx_val + variable);
267                 }
268         ""
269 end
270
271 case mismatch_block_array_size
272         version 310 es
273         desc "Shader storage block mismatch: different number of declarations"
274         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
275         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
276         expect link_fail
277         vertex ""
278                 #version 310 es
279                 ${VERTEX_DECLARATIONS}
280                 layout(binding=0) buffer BufferBlockName
281                 {
282                         mediump float variable;
283                 } instanceName[1];
284
285                 out mediump float vtx_val;
286                 void main()
287                 {
288                         vtx_val = instanceName[0].variable;
289                         ${VERTEX_OUTPUT}
290                 }
291         ""
292         fragment ""
293                 #version 310 es
294                 precision mediump float;
295                 ${FRAGMENT_DECLARATIONS}
296                 layout(binding=0) buffer BufferBlockName
297                 {
298                         mediump float variable;
299                 } instanceName[2];
300
301                 in mediump float vtx_val;
302                 void main()
303                 {
304                         ${FRAG_COLOR} = vec4(vtx_val + instanceName[0].variable + instanceName[1].variable);
305                 }
306         ""
307 end
308
309 case ambiguous_variable_name_1
310         version 310 es
311         desc "Unnamed shader storage block variable and global variable with identical names"
312         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
313         expect compile_or_link_fail
314         vertex ""
315                 #version 310 es
316                 ${VERTEX_DECLARATIONS}
317                 float variable;
318                 layout(binding=0) buffer BufferBlockName
319                 {
320                         mediump float variable;
321                 };
322
323                 out mediump float vtx_val;
324                 void main()
325                 {
326                         vtx_val = variable;
327                         ${VERTEX_OUTPUT}
328                 }
329         ""
330         fragment ""
331                 #version 310 es
332                 precision mediump float;
333                 ${FRAGMENT_DECLARATIONS}
334                 in mediump float vtx_val;
335                 void main()
336                 {
337                         ${FRAG_COLOR} = vec4(vtx_val);
338                 }
339         ""
340 end
341
342 case ambiguous_variable_name_2
343         version 310 es
344         desc "Two unnamed shader storage blocks with variables with identical names"
345         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 1
346         expect compile_or_link_fail
347         vertex ""
348                 #version 310 es
349                 ${VERTEX_DECLARATIONS}
350                 layout(binding=0) buffer BufferBlockNameA
351                 {
352                         mediump float variable;
353                 };
354                 layout(binding=1) buffer BufferBlockNameB
355                 {
356                         mediump float variable;
357                 };
358
359                 out mediump float vtx_val;
360                 void main()
361                 {
362                         vtx_val = variable;
363                         ${VERTEX_OUTPUT}
364                 }
365         ""
366         fragment ""
367                 #version 310 es
368                 precision mediump float;
369                 ${FRAGMENT_DECLARATIONS}
370                 in mediump float vtx_val;
371                 void main()
372                 {
373                         ${FRAG_COLOR} = vec4(vtx_val);
374                 }
375         ""
376 end
377
378 case ambiguous_variable_name_3
379         version 310 es
380         desc "Two unnamed shader storage blocks in different stages with variables with identical names"
381         require limit "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS" > 0
382         require limit "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS" > 0
383         # language to make link error explicitly defined. ("Within an interface, ...")
384         require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { vertex, fragment }
385         expect link_fail
386         vertex ""
387                 #version 310 es
388                 ${VERTEX_DECLARATIONS}
389                 layout(binding=0) buffer BufferBlockNameA
390                 {
391                         mediump float variable;
392                 };
393
394                 out mediump float vtx_val;
395                 void main()
396                 {
397                         vtx_val = variable;
398                         ${VERTEX_OUTPUT}
399                 }
400         ""
401         fragment ""
402                 #version 310 es
403                 precision mediump float;
404                 ${FRAGMENT_DECLARATIONS}
405                 layout(binding=1) buffer BufferBlockNameB
406                 {
407                         mediump float variable;
408                 };
409
410                 in mediump float vtx_val;
411                 void main()
412                 {
413                         ${FRAG_COLOR} = vec4(vtx_val + variable);
414                 }
415         ""
416 end