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