xref: /aosp_15_r20/external/deqp/data/gles31/shaders/es32/uniform_location.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
20case duplicate_location
21    expect compile_or_link_fail
22    version 320 es
23    values { output float out0 = 0.0; }
24
25    both ""
26        #version 320 es
27        precision highp float;
28        layout(location = 0) uniform float uni0;
29        layout(location = 0) uniform float uni1;
30        ${DECLARATIONS}
31
32        void main()
33        {
34            out0 = uni0 + uni1;
35            ${OUTPUT}
36        }
37    ""
38end
39
40case duplicate_location_unused
41    expect compile_or_link_fail
42    version 320 es
43    values { output float out0 = 0.0; }
44
45    both ""
46        #version 320 es
47        precision highp float;
48        layout(location = 0) uniform float uni0;
49        layout(location = 0) uniform float uni1;
50        ${DECLARATIONS}
51
52        void main()
53        {
54            out0 = 0.0;
55            ${OUTPUT}
56        }
57    ""
58end
59
60case duplicate_location_split
61    expect compile_or_link_fail
62    version 320 es
63    values{ output float out0 = 0.0; }
64
65    vertex ""
66        #version 320 es
67        precision highp float;
68        layout(location = 0) uniform float uni0;
69
70        in highp vec4 dEQP_Position;
71
72        void main()
73        {
74            gl_Position = dEQP_Position;
75        }
76    ""
77
78    fragment ""
79        #version 320 es
80        precision highp float;
81        layout(location = 0) uniform float uni1;
82
83        layout(location = 0) out mediump vec4 dEQP_FragColor;
84
85        void main()
86        {
87            dEQP_FragColor = vec4(1);
88        }
89    ""
90end
91
92case array_overlap
93    expect compile_or_link_fail
94    version 320 es
95    values { output float out0 = 0.0; }
96
97    both ""
98        #version 320 es
99        precision highp float;
100        layout(location = 0) uniform float uni0[8];
101        layout(location = 5) uniform float uni1;
102        ${DECLARATIONS}
103
104        void main()
105        {
106            out0 = uni0[0] + uni1;
107            ${OUTPUT}
108        }
109    ""
110end
111
112case array_overlap_unused
113    expect compile_or_link_fail
114    version 320 es
115    values { output float out0 = 0.0; }
116
117    both ""
118        #version 320 es
119        precision highp float;
120        layout(location = 0) uniform float uni0[8];
121        layout(location = 5) uniform float uni1;
122        ${DECLARATIONS}
123
124        void main()
125        {
126            out0 = 0.0;
127            ${OUTPUT}
128        }
129    ""
130end
131
132case array_overlap_split
133    expect compile_or_link_fail
134    version 320 es
135    values{ output float out0 = 0.0; }
136
137    vertex ""
138        #version 320 es
139        precision highp float;
140        layout(location = 0) uniform float uni0[8];
141
142        in highp vec4 dEQP_Position;
143
144        void main()
145        {
146            gl_Position = dEQP_Position;
147        }
148    ""
149
150    fragment ""
151        #version 320 es
152        precision highp float;
153        layout(location = 7) uniform float uni1[4];
154
155        layout(location = 0) out mediump vec4 dEQP_FragColor;
156
157        void main()
158        {
159            dEQP_FragColor = vec4(1);
160        }
161    ""
162end
163
164case struct_overlap
165    expect compile_or_link_fail
166    version 320 es
167    values { output float out0 = 0.0; }
168
169    both ""
170        #version 320 es
171        precision highp float;
172
173        struct S
174        {
175            vec4 a;
176            int  b;
177            mat4 c;
178        };
179
180        layout(location = 0) uniform S uni0;
181        layout(location = 2) uniform float uni1;
182        ${DECLARATIONS}
183
184        void main()
185        {
186            out0 = uni0.a.x + uni1;
187            ${OUTPUT}
188        }
189    ""
190end
191
192case struct_overlap_unused
193    expect compile_or_link_fail
194    version 320 es
195    values { output float out0 = 0.0; }
196
197    both ""
198        #version 320 es
199        precision highp float;
200
201        struct S
202        {
203            vec4 a;
204            int  b;
205            mat4 c;
206        };
207
208        layout(location = 0) uniform S uni0;
209        layout(location = 2) uniform float uni1;
210        ${DECLARATIONS}
211
212        void main()
213        {
214            out0 = 0.0;
215            ${OUTPUT}
216        }
217    ""
218end
219
220case struct_overlap_split
221    expect compile_or_link_fail
222    version 320 es
223    values{ output float out0 = 0.0; }
224
225    vertex ""
226        #version 320 es
227        precision highp float;
228
229        struct S
230        {
231            vec4 a;
232            int  b;
233            uint c;
234            vec2 d;
235        };
236
237        layout(location = 7) uniform S uni0;
238        layout(location = 12) uniform float uni2;
239
240        in highp vec4 dEQP_Position;
241
242        void main()
243        {
244            gl_Position = dEQP_Position;
245        }
246    ""
247
248    fragment ""
249        #version 320 es
250        precision highp float;
251        layout(location = 9) uniform float uni1[4];
252
253        layout(location = 0) out mediump vec4 dEQP_FragColor;
254
255        void main()
256        {
257            dEQP_FragColor = vec4(1);
258        }
259    ""
260end
261
262case complex_overlap
263    expect compile_or_link_fail
264    version 320 es
265    values { output float out0 = 0.0; }
266
267    both ""
268        #version 320 es
269        precision highp float;
270
271        struct S // size 2
272        {
273            vec3 a;
274            float b;
275        };
276
277        struct T // size 5
278        {
279            S s[2];
280            mat2 a;
281        };
282
283        struct U // size 6
284        {
285            S s;
286            float a[4];
287        };
288
289        layout(location = 0) uniform S  uni0; // good
290        layout(location = 1) uniform T  uni1; // bad
291        layout(location = 6) uniform T  uni2; // good
292        layout(location = 11) uniform U uni3[3]; // good
293        layout(location = 20) uniform S uni4; // bad
294        layout(location = 28) uniform int uni5; // bad
295        ${DECLARATIONS}
296
297        void main()
298        {
299            out0 = 0.0;
300            ${OUTPUT}
301        }
302    ""
303end
304
305case atomic
306    # \todo [2014-02-14 otto] invalid layout qualifier is generally a compiler error but spec does not yet say that this should be an error. Verify & fix once final 3.1 spec is out
307    expect compile_fail
308    version 320 es
309    values { output float out0 = 0.0; }
310
311    both ""
312        #version 320 es
313        precision highp float;
314        layout(location = 3, binding = 0, offset = 0) uniform atomic_uint uni0;
315        ${DECLARATIONS}
316
317        void main()
318        {
319            out0 = 0.0;
320            ${OUTPUT}
321        }
322    ""
323end
324