xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fAttribLocationTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 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  *//*!
20  * \file
21  * \brief Attribute location test
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fAttribLocationTests.hpp"
25 
26 #include "glsAttributeLocationTests.hpp"
27 
28 #include "glw.h"
29 
30 using namespace deqp::gls::AttributeLocationTestUtil;
31 using std::vector;
32 
33 namespace deqp
34 {
35 namespace gles3
36 {
37 namespace Functional
38 {
39 
createAttributeLocationTests(Context & context)40 TestCaseGroup *createAttributeLocationTests(Context &context)
41 {
42     const AttribType types[] = {AttribType("float", 1, GL_FLOAT),
43                                 AttribType("vec2", 1, GL_FLOAT_VEC2),
44                                 AttribType("vec3", 1, GL_FLOAT_VEC3),
45                                 AttribType("vec4", 1, GL_FLOAT_VEC4),
46 
47                                 AttribType("mat2", 2, GL_FLOAT_MAT2),
48                                 AttribType("mat3", 3, GL_FLOAT_MAT3),
49                                 AttribType("mat4", 4, GL_FLOAT_MAT4),
50 
51                                 AttribType("int", 1, GL_INT),
52                                 AttribType("ivec2", 1, GL_INT_VEC2),
53                                 AttribType("ivec3", 1, GL_INT_VEC3),
54                                 AttribType("ivec4", 1, GL_INT_VEC4),
55 
56                                 AttribType("uint", 1, GL_UNSIGNED_INT),
57                                 AttribType("uvec2", 1, GL_UNSIGNED_INT_VEC2),
58                                 AttribType("uvec3", 1, GL_UNSIGNED_INT_VEC3),
59                                 AttribType("uvec4", 1, GL_UNSIGNED_INT_VEC4),
60 
61                                 AttribType("mat2x2", 2, GL_FLOAT_MAT2),
62                                 AttribType("mat2x3", 2, GL_FLOAT_MAT2x3),
63                                 AttribType("mat2x4", 2, GL_FLOAT_MAT2x4),
64 
65                                 AttribType("mat3x2", 3, GL_FLOAT_MAT3x2),
66                                 AttribType("mat3x3", 3, GL_FLOAT_MAT3),
67                                 AttribType("mat3x4", 3, GL_FLOAT_MAT3x4),
68 
69                                 AttribType("mat4x2", 4, GL_FLOAT_MAT4x2),
70                                 AttribType("mat4x3", 4, GL_FLOAT_MAT4x3),
71                                 AttribType("mat4x4", 4, GL_FLOAT_MAT4)};
72 
73     const AttribType es2Types[] = {AttribType("float", 1, GL_FLOAT),     AttribType("vec2", 1, GL_FLOAT_VEC2),
74                                    AttribType("vec3", 1, GL_FLOAT_VEC3), AttribType("vec4", 1, GL_FLOAT_VEC4),
75 
76                                    AttribType("mat2", 2, GL_FLOAT_MAT2), AttribType("mat3", 3, GL_FLOAT_MAT3),
77                                    AttribType("mat4", 4, GL_FLOAT_MAT4)};
78 
79     TestCaseGroup *const root = new TestCaseGroup(context, "attribute_location", "Attribute location tests");
80 
81     // Basic bind attribute tests
82     {
83         TestCaseGroup *const bindAttributeGroup =
84             new TestCaseGroup(context, "bind", "Basic bind attribute location tests.");
85 
86         root->addChild(bindAttributeGroup);
87 
88         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
89         {
90             const AttribType &type = types[typeNdx];
91             bindAttributeGroup->addChild(
92                 new gls::BindAttributeTest(context.getTestContext(), context.getRenderContext(), type));
93         }
94     }
95 
96     // Bind max number of attributes
97     {
98         TestCaseGroup *const bindMaxAttributeGroup =
99             new TestCaseGroup(context, "bind_max_attributes", "Use bind with maximum number of attributes.");
100 
101         root->addChild(bindMaxAttributeGroup);
102 
103         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
104         {
105             const AttribType &type = types[typeNdx];
106             bindMaxAttributeGroup->addChild(
107                 new gls::BindMaxAttributesTest(context.getTestContext(), context.getRenderContext(), type));
108         }
109     }
110 
111     // Test aliasing
112     {
113         TestCaseGroup *const aliasingGroup =
114             new TestCaseGroup(context, "bind_aliasing", "Test binding aliasing locations.");
115 
116         root->addChild(aliasingGroup);
117 
118         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(es2Types); typeNdx++)
119         {
120             const AttribType &type = es2Types[typeNdx];
121 
122             // Simple aliasing cases
123             aliasingGroup->addChild(
124                 new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
125 
126             // For types which occupy more than one location. Alias second location.
127             if (type.getLocationSize() > 1)
128                 aliasingGroup->addChild(
129                     new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type, 1));
130 
131             // Use more than maximum attributes with aliasing
132             aliasingGroup->addChild(
133                 new gls::BindMaxAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
134 
135             // Use more than maximum attributes but inactive
136             aliasingGroup->addChild(
137                 new gls::BindInactiveAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
138         }
139     }
140 
141     // Test filling holes in attribute location
142     {
143         TestCaseGroup *const holeGroup = new TestCaseGroup(
144             context, "bind_hole", "Bind all, but one attribute and leave hole in location space for it.");
145 
146         root->addChild(holeGroup);
147 
148         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
149         {
150             const AttribType &type = types[typeNdx];
151 
152             // Bind first location, leave hole size of type and fill rest of locations
153             holeGroup->addChild(
154                 new gls::BindHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
155         }
156     }
157 
158     // Test binding at different times
159     {
160         TestCaseGroup *const bindTimeGroup =
161             new TestCaseGroup(context, "bind_time", "Bind time tests. Test binding at different stages.");
162 
163         root->addChild(bindTimeGroup);
164 
165         bindTimeGroup->addChild(
166             new gls::PreAttachBindAttributeTest(context.getTestContext(), context.getRenderContext()));
167         bindTimeGroup->addChild(
168             new gls::PreLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
169         bindTimeGroup->addChild(
170             new gls::PostLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
171         bindTimeGroup->addChild(new gls::BindRelinkAttributeTest(context.getTestContext(), context.getRenderContext()));
172         bindTimeGroup->addChild(
173             new gls::BindReattachAttributeTest(context.getTestContext(), context.getRenderContext()));
174     }
175 
176     // Basic layout location attribute tests
177     {
178         TestCaseGroup *const layoutAttributeGroup =
179             new TestCaseGroup(context, "layout", "Basic layout location tests.");
180 
181         root->addChild(layoutAttributeGroup);
182 
183         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
184         {
185             const AttribType &type = types[typeNdx];
186             layoutAttributeGroup->addChild(
187                 new gls::LocationAttributeTest(context.getTestContext(), context.getRenderContext(), type));
188         }
189     }
190 
191     // Test max attributes with layout locations
192     {
193         TestCaseGroup *const layoutMaxAttributeGroup = new TestCaseGroup(
194             context, "layout_max_attributes", "Maximum attributes used with layout location qualifiers.");
195 
196         root->addChild(layoutMaxAttributeGroup);
197 
198         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
199         {
200             const AttribType &type = types[typeNdx];
201             layoutMaxAttributeGroup->addChild(
202                 new gls::LocationMaxAttributesTest(context.getTestContext(), context.getRenderContext(), type));
203         }
204     }
205 
206     // Test filling holes in attribute location
207     {
208         TestCaseGroup *const holeGroup =
209             new TestCaseGroup(context, "layout_hole",
210                               "Define layout location for all, but one attribute consuming max attribute locations.");
211 
212         root->addChild(holeGroup);
213 
214         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
215         {
216             const AttribType &type = types[typeNdx];
217 
218             // Location first location, leave hole size of type and fill rest of locations
219             holeGroup->addChild(
220                 new gls::LocationHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
221         }
222     }
223 
224     // Basic mixed mixed attribute tests
225     {
226         TestCaseGroup *const mixedAttributeGroup = new TestCaseGroup(context, "mixed", "Basic mixed location tests.");
227 
228         root->addChild(mixedAttributeGroup);
229 
230         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
231         {
232             const AttribType &type = types[typeNdx];
233             mixedAttributeGroup->addChild(
234                 new gls::MixedAttributeTest(context.getTestContext(), context.getRenderContext(), type));
235         }
236     }
237 
238     {
239         TestCaseGroup *const mixedMaxAttributeGroup = new TestCaseGroup(
240             context, "mixed_max_attributes", "Maximum attributes used with mixed binding and layout qualifiers.");
241 
242         root->addChild(mixedMaxAttributeGroup);
243 
244         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
245         {
246             const AttribType &type = types[typeNdx];
247             mixedMaxAttributeGroup->addChild(
248                 new gls::MixedMaxAttributesTest(context.getTestContext(), context.getRenderContext(), type));
249         }
250     }
251 
252     // Test mixed binding at different times
253     {
254         TestCaseGroup *const mixedTimeGroup =
255             new TestCaseGroup(context, "mixed_time", "Bind time tests. Test binding at different stages.");
256 
257         root->addChild(mixedTimeGroup);
258 
259         mixedTimeGroup->addChild(
260             new gls::PreAttachMixedAttributeTest(context.getTestContext(), context.getRenderContext()));
261         mixedTimeGroup->addChild(
262             new gls::PreLinkMixedAttributeTest(context.getTestContext(), context.getRenderContext()));
263         mixedTimeGroup->addChild(
264             new gls::PostLinkMixedAttributeTest(context.getTestContext(), context.getRenderContext()));
265         mixedTimeGroup->addChild(
266             new gls::MixedRelinkAttributeTest(context.getTestContext(), context.getRenderContext()));
267         mixedTimeGroup->addChild(
268             new gls::MixedReattachAttributeTest(context.getTestContext(), context.getRenderContext()));
269     }
270 
271     {
272         TestCaseGroup *const holeGroup = new TestCaseGroup(
273             context, "mixed_hole",
274             "Use layout location qualifiers and binding. Leave hole in location space for only free attribute.");
275 
276         root->addChild(holeGroup);
277 
278         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
279         {
280             const AttribType &type = types[typeNdx];
281 
282             holeGroup->addChild(
283                 new gls::MixedHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
284         }
285     }
286 
287     // Test hole in location space that moves when relinking
288     {
289         TestCaseGroup *const relinkBindHoleGroup = new TestCaseGroup(
290             context, "bind_relink_hole", "Test relinking with moving hole in attribute location space.");
291 
292         root->addChild(relinkBindHoleGroup);
293 
294         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
295         {
296             const AttribType &type = types[typeNdx];
297 
298             relinkBindHoleGroup->addChild(
299                 new gls::BindRelinkHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
300         }
301     }
302 
303     // Test hole in location space that moves when relinking
304     {
305         TestCaseGroup *const relinkMixedHoleGroup = new TestCaseGroup(
306             context, "mixed_relink_hole", "Test relinking with moving hole in attribute location space.");
307 
308         root->addChild(relinkMixedHoleGroup);
309 
310         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
311         {
312             const AttribType &type = types[typeNdx];
313 
314             relinkMixedHoleGroup->addChild(
315                 new gls::MixedRelinkHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
316         }
317     }
318 
319     return root;
320 }
321 
322 } // namespace Functional
323 } // namespace gles3
324 } // namespace deqp
325