1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Attribute location test
22 *//*--------------------------------------------------------------------*/
24 goog.provide('functional.gles3.es3fAttribLocationTests');
25 goog.require('framework.opengl.gluShaderUtil');
26 goog.require('modules.shared.glsAttributeLocationTests');
28 goog.scope(function() {
30 var es3fAttribLocationTests = functional.gles3.es3fAttribLocationTests;
31 var glsAttributeLocationTests = modules.shared.glsAttributeLocationTests;
32 var tcuTestCase = framework.common.tcuTestCase;
33 var gluShaderUtil = framework.opengl.gluShaderUtil;
35 es3fAttribLocationTests.createAttributeLocationTests = function() {
37 /** @type {Array<glsAttributeLocationTests.AttribType>} */
39 new glsAttributeLocationTests.AttribType('float', 1, gl.FLOAT),
40 new glsAttributeLocationTests.AttribType('vec2', 1, gl.FLOAT_VEC2),
41 new glsAttributeLocationTests.AttribType('vec3', 1, gl.FLOAT_VEC3),
42 new glsAttributeLocationTests.AttribType('vec4', 1, gl.FLOAT_VEC4),
44 new glsAttributeLocationTests.AttribType('mat2', 2, gl.FLOAT_MAT2),
45 new glsAttributeLocationTests.AttribType('mat3', 3, gl.FLOAT_MAT3),
46 new glsAttributeLocationTests.AttribType('mat4', 4, gl.FLOAT_MAT4),
48 new glsAttributeLocationTests.AttribType('int', 1, gl.INT),
49 new glsAttributeLocationTests.AttribType('ivec2', 1, gl.INT_VEC2),
50 new glsAttributeLocationTests.AttribType('ivec3', 1, gl.INT_VEC3),
51 new glsAttributeLocationTests.AttribType('ivec4', 1, gl.INT_VEC4),
53 new glsAttributeLocationTests.AttribType('uint', 1, gl.UNSIGNED_INT),
54 new glsAttributeLocationTests.AttribType('uvec2', 1, gl.UNSIGNED_INT_VEC2),
55 new glsAttributeLocationTests.AttribType('uvec3', 1, gl.UNSIGNED_INT_VEC3),
56 new glsAttributeLocationTests.AttribType('uvec4', 1, gl.UNSIGNED_INT_VEC4),
58 new glsAttributeLocationTests.AttribType('mat2x2', 2, gl.FLOAT_MAT2),
59 new glsAttributeLocationTests.AttribType('mat2x3', 2, gl.FLOAT_MAT2x3),
60 new glsAttributeLocationTests.AttribType('mat2x4', 2, gl.FLOAT_MAT2x4),
62 new glsAttributeLocationTests.AttribType('mat3x2', 3, gl.FLOAT_MAT3x2),
63 new glsAttributeLocationTests.AttribType('mat3x3', 3, gl.FLOAT_MAT3),
64 new glsAttributeLocationTests.AttribType('mat3x4', 3, gl.FLOAT_MAT3x4),
66 new glsAttributeLocationTests.AttribType('mat4x2', 4, gl.FLOAT_MAT4x2),
67 new glsAttributeLocationTests.AttribType('mat4x3', 4, gl.FLOAT_MAT4x3),
68 new glsAttributeLocationTests.AttribType('mat4x4', 4, gl.FLOAT_MAT4)
71 /** @type {Array<glsAttributeLocationTests.AttribType>} */
73 new glsAttributeLocationTests.AttribType('float', 1, gl.FLOAT),
74 new glsAttributeLocationTests.AttribType('vec2', 1, gl.FLOAT_VEC2),
75 new glsAttributeLocationTests.AttribType('vec3', 1, gl.FLOAT_VEC3),
76 new glsAttributeLocationTests.AttribType('vec4', 1, gl.FLOAT_VEC4),
78 new glsAttributeLocationTests.AttribType('mat2', 2, gl.FLOAT_MAT2),
79 new glsAttributeLocationTests.AttribType('mat3', 3, gl.FLOAT_MAT3),
80 new glsAttributeLocationTests.AttribType('mat4', 4, gl.FLOAT_MAT4)
83 /** @type {tcuTestCase.DeqpTest} */
84 var root = tcuTestCase.newTest('attribute_location', 'Attribute location tests');
86 /** @type {number} */ var typeNdx;
87 /** @type {glsAttributeLocationTests.AttribType} */ var type;
89 // Basic bind attribute tests
90 /** @type {tcuTestCase.DeqpTest} */
91 var bindAttributeGroup = tcuTestCase.newTest('bind', 'Basic bind attribute location tests.');
93 root.addChild(bindAttributeGroup);
95 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
96 type = types[typeNdx];
97 bindAttributeGroup.addChild(new glsAttributeLocationTests.BindAttributeTest(type));
100 // Bind max number of attributes
101 /** @type {tcuTestCase.DeqpTest} */
102 var bindMaxAttributeGroup = tcuTestCase.newTest('bind_max_attributes', 'Use bind with maximum number of attributes.');
104 root.addChild(bindMaxAttributeGroup);
106 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
107 type = types[typeNdx];
108 bindMaxAttributeGroup.addChild(new glsAttributeLocationTests.BindMaxAttributesTest(type));
111 // Test filling holes in attribute location
112 /** @type {tcuTestCase.DeqpTest} */
113 var holeGroup = tcuTestCase.newTest('bind_hole', 'Bind all, but one attribute and leave hole in location space for it.');
115 root.addChild(holeGroup);
117 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
118 type = types[typeNdx];
120 // Bind first location, leave hole size of type and fill rest of locations
121 holeGroup.addChild(new glsAttributeLocationTests.BindHoleAttributeTest(type));
124 // Test binding at different times
125 /** @type {tcuTestCase.DeqpTest} */
126 var bindTimeGroup = tcuTestCase.newTest('bind_time', 'Bind time tests. Test binding at different stages.');
128 root.addChild(bindTimeGroup);
130 bindTimeGroup.addChild(new glsAttributeLocationTests.PreAttachBindAttributeTest());
131 bindTimeGroup.addChild(new glsAttributeLocationTests.PreLinkBindAttributeTest());
132 bindTimeGroup.addChild(new glsAttributeLocationTests.PostLinkBindAttributeTest());
133 bindTimeGroup.addChild(new glsAttributeLocationTests.BindRelinkAttributeTest());
134 bindTimeGroup.addChild(new glsAttributeLocationTests.BindReattachAttributeTest());
136 // Basic layout location attribute tests
137 /** @type {tcuTestCase.DeqpTest} */
138 var layoutAttributeGroup = tcuTestCase.newTest('layout', 'Basic layout location tests.');
140 root.addChild(layoutAttributeGroup);
142 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
143 type = types[typeNdx];
144 layoutAttributeGroup.addChild(new glsAttributeLocationTests.LocationAttributeTest(type));
147 // Test max attributes with layout locations
148 /** @type {tcuTestCase.DeqpTest} */
149 var layoutMaxAttributeGroup = tcuTestCase.newTest('layout_max_attributes', 'Maximum attributes used with layout location qualifiers.');
151 root.addChild(layoutMaxAttributeGroup);
153 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
154 type = types[typeNdx];
155 layoutMaxAttributeGroup.addChild(new glsAttributeLocationTests.LocationMaxAttributesTest(type));
158 // Test filling holes in attribute location
159 holeGroup = tcuTestCase.newTest('layout_hole', 'Define layout location for all, but one attribute consuming max attribute locations.');
161 root.addChild(holeGroup);
163 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
164 type = types[typeNdx];
166 // Location first location, leave hole size of type and fill rest of locations
167 holeGroup.addChild(new glsAttributeLocationTests.LocationHoleAttributeTest(type));
170 // Basic mixed mixed attribute tests
171 /** @type {tcuTestCase.DeqpTest} */
172 var mixedAttributeGroup = tcuTestCase.newTest('mixed', 'Basic mixed location tests.');
174 root.addChild(mixedAttributeGroup);
176 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
177 type = types[typeNdx];
178 mixedAttributeGroup.addChild(new glsAttributeLocationTests.MixedAttributeTest(type));
181 /** @type {tcuTestCase.DeqpTest} */
182 var mixedMaxAttributeGroup = tcuTestCase.newTest('mixed_max_attributes', 'Maximum attributes used with mixed binding and layout qualifiers.');
184 root.addChild(mixedMaxAttributeGroup);
186 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
187 type = types[typeNdx];
188 mixedMaxAttributeGroup.addChild(new glsAttributeLocationTests.MixedMaxAttributesTest(type));
191 // Test mixed binding at different times
192 /** @type {tcuTestCase.DeqpTest} */
193 var mixedTimeGroup = tcuTestCase.newTest('mixed_time', 'Bind time tests. Test binding at different stages.');
195 root.addChild(mixedTimeGroup);
197 mixedTimeGroup.addChild(new glsAttributeLocationTests.PreAttachMixedAttributeTest());
198 mixedTimeGroup.addChild(new glsAttributeLocationTests.PreLinkMixedAttributeTest());
199 mixedTimeGroup.addChild(new glsAttributeLocationTests.PostLinkMixedAttributeTest());
200 mixedTimeGroup.addChild(new glsAttributeLocationTests.MixedRelinkAttributeTest());
201 mixedTimeGroup.addChild(new glsAttributeLocationTests.MixedReattachAttributeTest());
203 holeGroup = tcuTestCase.newTest('mixed_hole', 'Use layout location qualifiers and binding. Leave hole in location space for only free attribute.');
205 root.addChild(holeGroup);
207 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
208 type = types[typeNdx];
210 holeGroup.addChild(new glsAttributeLocationTests.MixedHoleAttributeTest(type));
213 // Test hole in location space that moves when relinking
214 /** @type {tcuTestCase.DeqpTest} */
215 var relinkBindHoleGroup = tcuTestCase.newTest('bind_relink_hole', 'Test relinking with moving hole in attribute location space.');
217 root.addChild(relinkBindHoleGroup);
219 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
220 type = types[typeNdx];
222 relinkBindHoleGroup.addChild(new glsAttributeLocationTests.BindRelinkHoleAttributeTest(type));
225 // Test hole in location space that moves when relinking
226 /** @type {tcuTestCase.DeqpTest} */
227 var relinkMixedHoleGroup = tcuTestCase.newTest('mixed_relink_hole', 'Test relinking with moving hole in attribute location space.');
229 root.addChild(relinkMixedHoleGroup);
231 for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
232 type = types[typeNdx];
234 relinkMixedHoleGroup.addChild(new glsAttributeLocationTests.MixedRelinkHoleAttributeTest(type));
240 es3fAttribLocationTests.run = function(context) {
243 var state = tcuTestCase.runner;
245 var test = es3fAttribLocationTests.createAttributeLocationTests();
246 var testName = test.fullName();
247 var testDescription = test.getDescription() === undefined ? '' : test.getDescription();
249 state.testName = testName;
251 //Set up name and description of this test series.
252 setCurrentTestName(testName);
253 description(testDescription);
259 tcuTestCase.runTestCases();
262 bufferedLogToConsole('Exception: ' + err);
263 testFailedOptions('Failed to es3fAttribLocationTests.run tests', false);
264 tcuTestCase.runner.terminate();