Backed out changeset 8fc3326bce7f (bug 1943032) for causing failures at browser_tab_g...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / deqp / functional / gles3 / es3fVertexArrayTests.js
blobccfd34331357afb5268cbe5392ba3113ed491f53
1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
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 'use strict';
22 goog.provide('functional.gles3.es3fVertexArrayTests');
23 goog.require('framework.common.tcuSurface');
24 goog.require('framework.common.tcuTestCase');
25 goog.require('framework.common.tcuTexture');
26 goog.require('framework.delibs.debase.deMath');
27 goog.require('framework.delibs.debase.deRandom');
28 goog.require('framework.delibs.debase.deString');
29 goog.require('framework.delibs.debase.deUtil');
30 goog.require('framework.opengl.gluDrawUtil');
31 goog.require('framework.opengl.gluShaderProgram');
32 goog.require('framework.opengl.gluShaderUtil');
33 goog.require('framework.opengl.gluTexture');
34 goog.require('framework.opengl.gluVarType');
35 goog.require('modules.shared.glsVertexArrayTests');
37 goog.scope(function() {
39 var es3fVertexArrayTests = functional.gles3.es3fVertexArrayTests;
40 var gluDrawUtil = framework.opengl.gluDrawUtil;
41 var gluShaderUtil = framework.opengl.gluShaderUtil;
42 var gluShaderProgram = framework.opengl.gluShaderProgram;
43 var gluTexture = framework.opengl.gluTexture;
44 var gluVarType = framework.opengl.gluVarType;
45 var tcuTestCase = framework.common.tcuTestCase;
46 var tcuSurface = framework.common.tcuSurface;
47 var tcuTexture = framework.common.tcuTexture;
48 var deMath = framework.delibs.debase.deMath;
49 var deString = framework.delibs.debase.deString;
50 var deRandom = framework.delibs.debase.deRandom;
51 var deUtil = framework.delibs.debase.deUtil;
52 var glsVertexArrayTests = modules.shared.glsVertexArrayTests;
54 var DE_ASSERT = function(x) {
55 if (!x)
56 throw new Error('Assert failed');
59 /**
60 * es3fVertexArrayTests.SingleVertexArrayUsageGroup
61 * @constructor
62 * @extends {tcuTestCase.DeqpTest}
63 * @param {glsVertexArrayTests.deArray.Usage} usage
65 es3fVertexArrayTests.SingleVertexArrayUsageGroup = function(usage) {
66 tcuTestCase.DeqpTest.call(
67 this,
68 "single_attribute.usages." + glsVertexArrayTests.deArray.usageTypeToString(usage),
69 glsVertexArrayTests.deArray.usageTypeToString(usage)
71 this.makeExecutable();
72 this.m_usage = usage;
75 es3fVertexArrayTests.SingleVertexArrayUsageGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
76 es3fVertexArrayTests.SingleVertexArrayUsageGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayUsageGroup;
78 /**
79 * init
81 es3fVertexArrayTests.SingleVertexArrayUsageGroup.prototype.init = function() {
82 /** @type {Array<number>} */ var counts = [1, 256];
83 /** @type {Array<number>} */ var strides = [0, -1, 17, 32]; // Treat negative value as sizeof input. Same as 0, but done outside of GL.
84 /** @type {Array<glsVertexArrayTests.deArray.InputType>} */ var inputTypes = [
85 glsVertexArrayTests.deArray.InputType.FLOAT,
86 /*glsVertexArrayTests.deArray.InputType.FIXED,*/
87 glsVertexArrayTests.deArray.InputType.SHORT,
88 glsVertexArrayTests.deArray.InputType.BYTE
91 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
92 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
93 for (var strideNdx = 0; strideNdx < strides.length; strideNdx++) {
94 /** @type {number} */ var stride = (strides[strideNdx] < 0 ? glsVertexArrayTests.deArray.inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
95 /** @type {boolean} */ var aligned = (stride % glsVertexArrayTests.deArray.inputTypeSize(inputTypes[inputTypeNdx])) == 0;
96 /** @type {string} */ var name = 'stride' + stride + '_' + glsVertexArrayTests.deArray.inputTypeToString(inputTypes[inputTypeNdx]) + '_quads' + counts[countNdx];
98 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
99 inputTypes[inputTypeNdx],
100 glsVertexArrayTests.deArray.OutputType.VEC2,
101 glsVertexArrayTests.deArray.Storage.BUFFER,
102 this.m_usage,
105 stride,
106 false,
107 glsVertexArrayTests.GLValue.getMinValue(inputTypes[inputTypeNdx]),
108 glsVertexArrayTests.GLValue.getMaxValue(inputTypes[inputTypeNdx])
111 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
112 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
113 spec.drawCount = counts[countNdx];
114 spec.first = 0;
115 spec.arrays.push(arraySpec);
117 if (aligned)
118 this.addChild(
119 new glsVertexArrayTests.MultiVertexArrayTest(
120 spec, name, name
129 * es3fVertexArrayTests.SingleVertexArrayStrideGroup
130 * @constructor
131 * @extends {tcuTestCase.DeqpTest}
132 * @param {glsVertexArrayTests.deArray.InputType} type
134 es3fVertexArrayTests.SingleVertexArrayStrideGroup = function(type) {
135 tcuTestCase.DeqpTest.call(this, glsVertexArrayTests.deArray.inputTypeToString(type), glsVertexArrayTests.deArray.inputTypeToString(type));
136 this.makeExecutable();
137 this.m_type = type;
140 es3fVertexArrayTests.SingleVertexArrayStrideGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
141 es3fVertexArrayTests.SingleVertexArrayStrideGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayStrideGroup;
144 * init
146 es3fVertexArrayTests.SingleVertexArrayStrideGroup.prototype.init = function() {
147 /** @type {Array<glsVertexArrayTests.deArray.Storage>} */ var storages = [
148 // User storage not supported in WebGL - glsVertexArrayTests.deArray.Storage.USER,
149 glsVertexArrayTests.deArray.Storage.BUFFER
151 var counts = [1, 256];
152 var strides = [/*0,*/ -1, 17, 32]; // Treat negative value as sizeof input. Same as 0, but done outside of GL.
154 for (var storageNdx = 0; storageNdx < storages.length; storageNdx++) {
155 for (var componentCount = 2; componentCount < 5; componentCount++) {
156 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
157 for (var strideNdx = 0; strideNdx < strides.length; strideNdx++) {
158 /** @type {boolean} */ var packed = this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 || this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10;
159 /** @type {number} */ var stride = (strides[strideNdx] < 0) ? ((packed) ? (16) : (glsVertexArrayTests.deArray.inputTypeSize(this.m_type) * componentCount)) : (strides[strideNdx]);
160 /** @type {number} */ var alignment = (packed) ? (glsVertexArrayTests.deArray.inputTypeSize(this.m_type) * componentCount) : (glsVertexArrayTests.deArray.inputTypeSize(this.m_type));
161 /** @type {boolean} */ var bufferUnaligned = (storages[storageNdx] == glsVertexArrayTests.deArray.Storage.BUFFER) && (stride % alignment) != 0;
163 /** @type {string} */ var name = glsVertexArrayTests.deArray.storageToString(storages[storageNdx]) + '_stride' + stride + '_components' + componentCount + '_quads' + counts[countNdx];
165 if ((this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
166 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10) && componentCount != 4)
167 continue;
169 /** @type {glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec} */ var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
170 this.m_type,
171 glsVertexArrayTests.deArray.OutputType.VEC4,
172 storages[storageNdx],
173 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
174 componentCount,
176 stride,
177 false,
178 glsVertexArrayTests.GLValue.getMinValue(this.m_type),
179 glsVertexArrayTests.GLValue.getMaxValue(this.m_type)
182 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
184 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
185 spec.drawCount = counts[countNdx];
186 spec.first = 0;
187 spec.arrays.push(arraySpec);
189 if (!bufferUnaligned)
190 this.addChild(
191 new glsVertexArrayTests.MultiVertexArrayTest(
192 spec, name, name
202 * es3fVertexArrayTests.SingleVertexArrayStrideTests
203 * @constructor
204 * @extends {tcuTestCase.DeqpTest}
206 es3fVertexArrayTests.SingleVertexArrayStrideTests = function() {
207 tcuTestCase.DeqpTest.call(this, 'single_attribute.strides', 'Single stride vertex atribute');
208 this.makeExecutable();
211 es3fVertexArrayTests.SingleVertexArrayStrideTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
212 es3fVertexArrayTests.SingleVertexArrayStrideTests.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayStrideTests;
214 es3fVertexArrayTests.SingleVertexArrayStrideTests.prototype.init = function() {
215 /** @type {Array<glsVertexArrayTests.deArray.InputType>} */ var inputTypes = [
216 glsVertexArrayTests.deArray.InputType.FLOAT,
217 glsVertexArrayTests.deArray.InputType.SHORT,
218 glsVertexArrayTests.deArray.InputType.BYTE,
219 /*glsVertexArrayTests.deArray.InputType.UNSIGNED_SHORT,
220 glsVertexArrayTests.deArray.InputType.UNSIGNED_BYTE,
221 glsVertexArrayTests.deArray.InputType.FIXED,*/
222 glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
225 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++)
226 this.addChild(
227 new es3fVertexArrayTests.SingleVertexArrayStrideGroup(
228 inputTypes[inputTypeNdx]
234 * @constructor
235 * @extends {tcuTestCase.DeqpTest}
236 * @param {glsVertexArrayTests.deArray.InputType} type
238 es3fVertexArrayTests.SingleVertexArrayFirstGroup = function(type) {
239 tcuTestCase.DeqpTest.call(
240 this,
241 glsVertexArrayTests.deArray.inputTypeToString(type),
242 glsVertexArrayTests.deArray.inputTypeToString(type)
244 this.makeExecutable();
246 this.m_type = type;
249 es3fVertexArrayTests.SingleVertexArrayFirstGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
250 es3fVertexArrayTests.SingleVertexArrayFirstGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayFirstGroup;
253 * init
255 es3fVertexArrayTests.SingleVertexArrayFirstGroup.prototype.init = function() {
256 var counts = [5, 256];
257 var firsts = [6, 24];
258 var offsets = [1, 16, 17];
259 var strides = [/*0,*/ -1, 17, 32]; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
261 for (var offsetNdx = 0; offsetNdx < offsets.length; offsetNdx++) {
262 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
263 for (var strideNdx = 0; strideNdx < strides.length; strideNdx++) {
264 for (var firstNdx = 0; firstNdx < firsts.length; firstNdx++) {
265 var packed = this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
266 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10;
267 var componentCount = packed ? 4 : 2;
268 var stride = strides[strideNdx] < 0 ?
269 (packed ? 8 : (glsVertexArrayTests.deArray.inputTypeSize(this.m_type) * componentCount)) :
270 (strides[strideNdx]);
271 var alignment = packed ?
272 (glsVertexArrayTests.deArray.inputTypeSize(this.m_type) * componentCount) :
273 (glsVertexArrayTests.deArray.inputTypeSize(this.m_type));
274 var aligned = ((stride % alignment) == 0) &&
275 ((offsets[offsetNdx] % alignment) == 0);
276 var name = 'first' + firsts[firstNdx] + '_offset' + offsets[offsetNdx] + '_stride' + stride + '_quads' + counts[countNdx];
278 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
279 this.m_type,
280 glsVertexArrayTests.deArray.OutputType.VEC2,
281 glsVertexArrayTests.deArray.Storage.BUFFER,
282 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
283 componentCount,
284 offsets[offsetNdx],
285 stride,
286 false,
287 glsVertexArrayTests.GLValue.getMinValue(this.m_type),
288 glsVertexArrayTests.GLValue.getMaxValue(this.m_type)
291 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
292 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
293 spec.drawCount = counts[countNdx];
294 spec.first = firsts[firstNdx];
295 spec.arrays.push(arraySpec);
297 if (aligned)
298 this.addChild(
299 new glsVertexArrayTests.MultiVertexArrayTest(
300 spec, name, name
310 * @constructor
311 * @extends {tcuTestCase.DeqpTest}
313 es3fVertexArrayTests.SingleVertexArrayFirstTests = function() {
314 tcuTestCase.DeqpTest.call(this, 'single_attribute.first', 'Single vertex attribute, different first values to drawArrays');
315 this.makeExecutable();
318 es3fVertexArrayTests.SingleVertexArrayFirstTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
319 es3fVertexArrayTests.SingleVertexArrayFirstTests.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayFirstTests;
322 * init
324 es3fVertexArrayTests.SingleVertexArrayFirstTests.prototype.init = function() {
325 // Test offset with different input types, component counts and storage, Usage(?)
326 var inputTypes = [
327 glsVertexArrayTests.deArray.InputType.FLOAT,
328 glsVertexArrayTests.deArray.InputType.BYTE,
329 glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
332 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
333 this.addChild(
334 new es3fVertexArrayTests.SingleVertexArrayFirstGroup(
335 inputTypes[inputTypeNdx]
342 * @constructor
343 * @extends {tcuTestCase.DeqpTest}
344 * @param {glsVertexArrayTests.deArray.InputType} type
346 es3fVertexArrayTests.SingleVertexArrayOffsetGroup = function(type) {
347 tcuTestCase.DeqpTest.call(
348 this,
349 glsVertexArrayTests.deArray.inputTypeToString(type),
350 glsVertexArrayTests.deArray.inputTypeToString(type)
352 this.makeExecutable();
353 this.m_type = type;
356 es3fVertexArrayTests.SingleVertexArrayOffsetGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
357 es3fVertexArrayTests.SingleVertexArrayOffsetGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayOffsetGroup;
360 * init
362 es3fVertexArrayTests.SingleVertexArrayOffsetGroup.prototype.init = function() {
363 var counts = [1, 256];
364 var offsets = [1, 4, 17, 32];
365 var strides = [/*0,*/ -1, 17, 32]; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
367 for (var offsetNdx = 0; offsetNdx < offsets.length; offsetNdx++) {
368 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
369 for (var strideNdx = 0; strideNdx < strides.length; strideNdx++) {
370 var packed = this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
371 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10;
372 var componentCount = packed ? 4 : 2;
373 var stride = (
374 strides[strideNdx] < 0 ?
375 glsVertexArrayTests.deArray.inputTypeSize(
376 this.m_type
377 ) * componentCount :
378 strides[strideNdx]
380 var alignment = packed ?
381 glsVertexArrayTests.deArray.inputTypeSize(this.m_type) * componentCount :
382 glsVertexArrayTests.deArray.inputTypeSize(this.m_type);
384 var aligned = ((stride % alignment) == 0) &&
385 ((offsets[offsetNdx] % alignment) == 0);
386 var name = 'offset' + offsets[offsetNdx] +
387 '_stride' + stride + '_quads' +
388 counts[countNdx];
390 /** @type {glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec} */ var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
391 this.m_type,
392 glsVertexArrayTests.deArray.OutputType.VEC2,
393 glsVertexArrayTests.deArray.Storage.BUFFER,
394 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
395 componentCount,
396 offsets[offsetNdx],
397 stride,
398 false,
399 glsVertexArrayTests.GLValue.getMinValue(this.m_type),
400 glsVertexArrayTests.GLValue.getMaxValue(this.m_type)
403 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
404 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
405 spec.drawCount = counts[countNdx];
406 spec.first = 0;
407 spec.arrays.push(arraySpec);
409 if (aligned)
410 this.addChild(
411 new glsVertexArrayTests.MultiVertexArrayTest(
412 spec, name, name
421 * @constructor
422 * @extends {tcuTestCase.DeqpTest}
424 es3fVertexArrayTests.SingleVertexArrayOffsetTests = function() {
425 tcuTestCase.DeqpTest.call(this, 'single_attribute.offset', 'Single vertex atribute offset element');
426 this.makeExecutable();
429 es3fVertexArrayTests.SingleVertexArrayOffsetTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
430 es3fVertexArrayTests.SingleVertexArrayOffsetTests.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayOffsetTests;
433 * init
435 es3fVertexArrayTests.SingleVertexArrayOffsetTests.prototype.init = function() {
436 // Test offset with different input types, component counts and storage, Usage(?)
437 var inputTypes = [
438 glsVertexArrayTests.deArray.InputType.FLOAT,
439 glsVertexArrayTests.deArray.InputType.BYTE,
440 glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
443 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
444 this.addChild(
445 new es3fVertexArrayTests.SingleVertexArrayOffsetGroup(
446 inputTypes[inputTypeNdx]
453 * @constructor
454 * @extends {tcuTestCase.DeqpTest}
455 * @param {glsVertexArrayTests.deArray.InputType} type
457 es3fVertexArrayTests.SingleVertexArrayNormalizeGroup = function(type) {
458 tcuTestCase.DeqpTest.call(
459 this,
460 glsVertexArrayTests.deArray.inputTypeToString(type),
461 glsVertexArrayTests.deArray.inputTypeToString(type)
463 this.makeExecutable();
464 this.m_type = type;
467 es3fVertexArrayTests.SingleVertexArrayNormalizeGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
468 es3fVertexArrayTests.SingleVertexArrayNormalizeGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayNormalizeGroup;
471 * init for SingleVertexArrayNormalizeGroup
473 es3fVertexArrayTests.SingleVertexArrayNormalizeGroup.prototype.init = function() {
474 var counts = [1, 256];
476 for (var componentCount = 2; componentCount < 5; componentCount++) {
477 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
478 if (
480 this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
481 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
482 ) && componentCount != 4
484 continue;
486 var name = 'components' + componentCount.toString() + '_quads' + counts[countNdx].toString();
488 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
489 this.m_type,
490 glsVertexArrayTests.deArray.OutputType.VEC4,
491 glsVertexArrayTests.deArray.Storage.BUFFER, //No USER Storage support in WebGL2
492 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
493 componentCount,
496 true,
497 glsVertexArrayTests.GLValue.getMinValue(this.m_type),
498 glsVertexArrayTests.GLValue.getMaxValue(this.m_type)
501 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
502 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
503 spec.drawCount = counts[countNdx];
504 spec.first = 0;
505 spec.arrays.push(arraySpec);
507 this.addChild(
508 new glsVertexArrayTests.MultiVertexArrayTest(
509 spec, name, name
517 * @constructor
518 * @extends {tcuTestCase.DeqpTest}
520 es3fVertexArrayTests.SingleVertexArrayNormalizeTests = function() {
521 tcuTestCase.DeqpTest.call(this, 'single_attribute.normalize', 'Single normalize vertex atribute');
522 this.makeExecutable();
525 es3fVertexArrayTests.SingleVertexArrayNormalizeTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
526 es3fVertexArrayTests.SingleVertexArrayNormalizeTests.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayNormalizeTests;
529 * init
531 es3fVertexArrayTests.SingleVertexArrayNormalizeTests.prototype.init = function() {
532 // Test normalization with different input types, component counts and storage
533 /** @type {Array<glsVertexArrayTests.deArray.InputType>} */ var inputTypes = [
534 glsVertexArrayTests.deArray.InputType.FLOAT,
535 glsVertexArrayTests.deArray.InputType.SHORT,
536 glsVertexArrayTests.deArray.InputType.BYTE,
537 glsVertexArrayTests.deArray.InputType.UNSIGNED_SHORT,
538 glsVertexArrayTests.deArray.InputType.UNSIGNED_BYTE,
539 //glsVertexArrayTests.deArray.InputType.FIXED,
540 glsVertexArrayTests.deArray.InputType.UNSIGNED_INT,
541 glsVertexArrayTests.deArray.InputType.INT,
542 glsVertexArrayTests.deArray.InputType.HALF,
543 glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10,
544 glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
547 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
548 this.addChild(
549 new es3fVertexArrayTests.SingleVertexArrayNormalizeGroup(
550 inputTypes[inputTypeNdx]
557 * @constructor
558 * @extends {tcuTestCase.DeqpTest}
559 * @param {glsVertexArrayTests.deArray.InputType} type
561 es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup = function(type) {
562 tcuTestCase.DeqpTest.call(
563 this,
564 "single_attribute.output_types." + glsVertexArrayTests.deArray.inputTypeToString(type),
565 glsVertexArrayTests.deArray.inputTypeToString(type)
567 this.makeExecutable();
568 this.m_type = type;
571 es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
572 es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup.prototype.constructor = es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup;
574 es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup.prototype.init = function() {
575 var outputTypes = [
576 glsVertexArrayTests.deArray.OutputType.VEC2,
577 glsVertexArrayTests.deArray.OutputType.VEC3,
578 glsVertexArrayTests.deArray.OutputType.VEC4,
579 glsVertexArrayTests.deArray.OutputType.IVEC2,
580 glsVertexArrayTests.deArray.OutputType.IVEC3,
581 glsVertexArrayTests.deArray.OutputType.IVEC4,
582 glsVertexArrayTests.deArray.OutputType.UVEC2,
583 glsVertexArrayTests.deArray.OutputType.UVEC3,
584 glsVertexArrayTests.deArray.OutputType.UVEC4
586 var storages = [glsVertexArrayTests.deArray.Storage.BUFFER]; //No USER storage support in WebGL2
587 var counts = [1, 256];
589 for (var outputTypeNdx = 0; outputTypeNdx < outputTypes.length; outputTypeNdx++) {
590 for (var storageNdx = 0; storageNdx < storages.length; storageNdx++) {
591 for (var componentCount = 2; componentCount < 5; componentCount++) {
592 for (var countNdx = 0; countNdx < counts.length; countNdx++) {
593 var name = 'components' + componentCount + '_' +
594 glsVertexArrayTests.deArray.outputTypeToString(
595 outputTypes[outputTypeNdx]
597 '_quads' + counts[countNdx];
599 var inputIsSignedInteger =
600 this.m_type == glsVertexArrayTests.deArray.InputType.INT ||
601 this.m_type == glsVertexArrayTests.deArray.InputType.SHORT ||
602 this.m_type == glsVertexArrayTests.deArray.InputType.BYTE;
604 var inputIsUnignedInteger =
605 this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT ||
606 this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_SHORT ||
607 this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_BYTE;
609 var outputIsSignedInteger =
610 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.IVEC2 ||
611 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.IVEC3 ||
612 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.IVEC4;
614 var outputIsUnsignedInteger =
615 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.UVEC2 ||
616 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.UVEC3 ||
617 outputTypes[outputTypeNdx] == glsVertexArrayTests.deArray.OutputType.UVEC4;
619 // If input type is float type and output type is int type skip
620 if ((this.m_type == glsVertexArrayTests.deArray.InputType.FLOAT ||
621 this.m_type == glsVertexArrayTests.deArray.InputType.HALF) &&
622 (outputTypes[outputTypeNdx] >= glsVertexArrayTests.deArray.OutputType.INT))
623 continue;
625 if ((this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
626 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10) &&
627 (outputTypes[outputTypeNdx] >= glsVertexArrayTests.deArray.OutputType.INT))
628 continue;
630 if ((this.m_type == glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10 ||
631 this.m_type == glsVertexArrayTests.deArray.InputType.INT_2_10_10_10) &&
632 componentCount != 4)
633 continue;
635 // Loading signed data as unsigned causes undefined values and vice versa
636 if (inputIsSignedInteger && outputIsUnsignedInteger)
637 continue;
638 if (inputIsUnignedInteger && outputIsSignedInteger)
639 continue;
641 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
642 this.m_type,
643 outputTypes[outputTypeNdx],
644 storages[storageNdx],
645 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
646 componentCount,
649 false,
650 glsVertexArrayTests.GLValue.getMinValue(this.m_type),
651 glsVertexArrayTests.GLValue.getMaxValue(this.m_type)
654 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
655 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
656 spec.drawCount = counts[countNdx];
657 spec.first = 0;
658 spec.arrays.push(arraySpec);
660 this.addChild(
661 new glsVertexArrayTests.MultiVertexArrayTest(
662 spec, name, name
672 * @constructor
673 * @extends {tcuTestCase.DeqpTest}
675 es3fVertexArrayTests.MultiVertexArrayCountTests = function() {
676 tcuTestCase.DeqpTest.call(this, 'multiple_attributes.attribute_count', 'Attribute counts');
677 this.makeExecutable();
680 es3fVertexArrayTests.MultiVertexArrayCountTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
681 es3fVertexArrayTests.MultiVertexArrayCountTests.prototype.constructor = es3fVertexArrayTests.MultiVertexArrayCountTests;
684 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
685 * @return {string}
687 es3fVertexArrayTests.MultiVertexArrayCountTests.prototype.getTestName = function(spec) {
688 var name = '';
689 name += spec.arrays.length;
691 return name;
694 es3fVertexArrayTests.MultiVertexArrayCountTests.prototype.init = function() {
695 // Test attribute counts
696 var arrayCounts = [2, 3, 4, 5, 6, 7, 8];
698 for (var arrayCountNdx = 0; arrayCountNdx < arrayCounts.length; arrayCountNdx++) {
699 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
701 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
702 spec.drawCount = 256;
703 spec.first = 0;
705 for (var arrayNdx = 0; arrayNdx < arrayCounts[arrayCountNdx]; arrayNdx++) {
706 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
707 glsVertexArrayTests.deArray.InputType.FLOAT,
708 glsVertexArrayTests.deArray.OutputType.VEC2,
709 glsVertexArrayTests.deArray.Storage.BUFFER, // No USER storage support in WebGL2
710 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
714 false,
715 glsVertexArrayTests.GLValue.getMinValue(glsVertexArrayTests.deArray.InputType.FLOAT),
716 glsVertexArrayTests.GLValue.getMaxValue(glsVertexArrayTests.deArray.InputType.FLOAT)
718 spec.arrays.push(arraySpec);
721 var name = this.getTestName(spec);
722 var desc = this.getTestName(spec);
724 this.addChild(
725 new glsVertexArrayTests.MultiVertexArrayTest(
726 spec, name, desc
733 * @constructor
734 * @extends {tcuTestCase.DeqpTest}
736 es3fVertexArrayTests.MultiVertexArrayStorageTests = function() {
737 tcuTestCase.DeqpTest.call(this, 'multiple_attributes.storage', 'Attribute storages');
738 this.makeExecutable();
741 es3fVertexArrayTests.MultiVertexArrayStorageTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
742 es3fVertexArrayTests.MultiVertexArrayStorageTests.prototype.constructor = es3fVertexArrayTests.MultiVertexArrayStorageTests;
745 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
746 * @return {string}
748 es3fVertexArrayTests.MultiVertexArrayStorageTests.prototype.getTestName = function(spec) {
749 var name = '';
750 name += spec.arrays.length;
752 for (var arrayNdx = 0; arrayNdx < spec.arrays.length; arrayNdx++)
753 name += '_' + glsVertexArrayTests.deArray.storageToString(spec.arrays[arrayNdx].storage);
755 return name;
759 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
760 * @param {number} depth
762 es3fVertexArrayTests.MultiVertexArrayStorageTests.prototype.addStorageCases = function(spec, depth) {
763 if (depth == 0) {
764 // Skip trivial case, used elsewhere
765 var ok = false;
766 for (var arrayNdx = 0; arrayNdx < spec.arrays.length; arrayNdx++) {
767 if (spec.arrays[arrayNdx].storage != glsVertexArrayTests.deArray.Storage.USER) {
768 ok = true;
769 break;
773 if (!ok)
774 return;
776 var name = this.getTestName(spec);
777 var desc = this.getTestName(spec);
779 this.addChild(
780 new glsVertexArrayTests.MultiVertexArrayTest(
781 spec, name, desc
784 return;
787 var storages = [
788 //glsVertexArrayTests.deArray.Storage.USER, Not supported in WebGL 2.0
789 glsVertexArrayTests.deArray.Storage.BUFFER
792 for (var storageNdx = 0; storageNdx < storages.length; storageNdx++) {
793 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
794 glsVertexArrayTests.deArray.InputType.FLOAT,
795 glsVertexArrayTests.deArray.OutputType.VEC2,
796 storages[storageNdx],
797 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
801 false,
802 glsVertexArrayTests.GLValue.getMinValue(glsVertexArrayTests.deArray.InputType.FLOAT),
803 glsVertexArrayTests.GLValue.getMaxValue(glsVertexArrayTests.deArray.InputType.FLOAT)
806 var _spec = spec;
807 _spec.arrays.push(arraySpec);
808 this.addStorageCases(_spec, depth - 1);
813 * init
815 es3fVertexArrayTests.MultiVertexArrayStorageTests.prototype.init = function() {
816 // Test different storages
817 var arrayCounts = [3];
819 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
821 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
822 spec.drawCount = 256;
823 spec.first = 0;
825 for (var arrayCountNdx = 0; arrayCountNdx < arrayCounts.length; arrayCountNdx++)
826 this.addStorageCases(spec, arrayCounts[arrayCountNdx]);
830 * @constructor
831 * @extends {tcuTestCase.DeqpTest}
833 es3fVertexArrayTests.MultiVertexArrayStrideTests = function() {
834 tcuTestCase.DeqpTest.call(this, 'multiple_attributes.stride', 'Strides');
835 this.makeExecutable();
838 es3fVertexArrayTests.MultiVertexArrayStrideTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
839 es3fVertexArrayTests.MultiVertexArrayStrideTests.prototype.constructor = es3fVertexArrayTests.MultiVertexArrayStrideTests;
842 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
843 * @return {string}
845 es3fVertexArrayTests.MultiVertexArrayStrideTests.prototype.getTestName = function(spec) {
846 var name = '';
848 name += spec.arrays.length;
850 for (var arrayNdx = 0; arrayNdx < spec.arrays.length; arrayNdx++) {
851 name += '_' +
852 glsVertexArrayTests.deArray.inputTypeToString(spec.arrays[arrayNdx].inputType) +
853 spec.arrays[arrayNdx].componentCount + '_' +
854 spec.arrays[arrayNdx].stride;
857 return name;
861 * init
863 es3fVertexArrayTests.MultiVertexArrayStrideTests.prototype.init = function() {
864 // Test different strides, with multiple arrays, input types??
865 var arrayCounts = [3];
867 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
869 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
870 spec.drawCount = 256;
871 spec.first = 0;
873 for (var arrayCountNdx = 0; arrayCountNdx < arrayCounts.length; arrayCountNdx++)
874 this.addStrideCases(spec, arrayCounts[arrayCountNdx]);
878 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
879 * @param {number} depth
881 es3fVertexArrayTests.MultiVertexArrayStrideTests.prototype.addStrideCases = function(spec, depth) {
882 if (depth == 0) {
883 var name = this.getTestName(spec);
884 var desc = this.getTestName(spec);
885 this.addChild(
886 new glsVertexArrayTests.MultiVertexArrayTest(
887 spec, name, desc
890 return;
893 var strides = [0, -1, 17, 32];
894 var inputType = glsVertexArrayTests.deArray.InputType.FLOAT;
896 for (var strideNdx = 0; strideNdx < strides.length; strideNdx++) {
897 var componentCount = 2;
898 var stride = strides[strideNdx] >= 0 ? strides[strideNdx] : componentCount * glsVertexArrayTests.deArray.inputTypeSize(glsVertexArrayTests.deArray.InputType.FLOAT);
899 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
900 inputType,
901 glsVertexArrayTests.deArray.OutputType.VEC2,
902 glsVertexArrayTests.deArray.Storage.BUFFER, //USER storage not supported in WebGL 2.0
903 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
904 componentCount,
906 stride,
907 false,
908 glsVertexArrayTests.GLValue.getMinValue(glsVertexArrayTests.deArray.InputType.FLOAT),
909 glsVertexArrayTests.GLValue.getMaxValue(glsVertexArrayTests.deArray.InputType.FLOAT)
912 /** @type {boolean} */ var aligned = (stride % glsVertexArrayTests.deArray.inputTypeSize(inputType)) == 0;
913 if (aligned) {
914 var _spec = /** @type {glsVertexArrayTests.MultiVertexArrayTest.Spec} */ (deUtil.clone(spec)); //To assign spec by value;
915 _spec.arrays.push(arraySpec);
916 this.addStrideCases(_spec, depth - 1);
922 * @constructor
923 * @extends {tcuTestCase.DeqpTest}
925 es3fVertexArrayTests.MultiVertexArrayOutputTests = function() {
926 tcuTestCase.DeqpTest.call(this, 'multiple_attributes.input_types', 'input types');
927 this.makeExecutable();
930 es3fVertexArrayTests.MultiVertexArrayOutputTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
931 es3fVertexArrayTests.MultiVertexArrayOutputTests.prototype.constructor = es3fVertexArrayTests.MultiVertexArrayOutputTests;
934 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
935 * @return {string}
937 es3fVertexArrayTests.MultiVertexArrayOutputTests.prototype.getTestName = function(spec) {
938 var name = '';
940 name += spec.arrays.length;
942 for (var arrayNdx = 0; arrayNdx < spec.arrays.length; arrayNdx++) {
943 name += '_' +
944 glsVertexArrayTests.deArray.inputTypeToString(spec.arrays[arrayNdx].inputType) +
945 spec.arrays[arrayNdx].componentCount + '_' +
946 glsVertexArrayTests.deArray.outputTypeToString(spec.arrays[arrayNdx].outputType);
949 return name;
953 * init
955 es3fVertexArrayTests.MultiVertexArrayOutputTests.prototype.init = function() {
956 // Test different input types, with multiple arrays
957 var arrayCounts = [3];
959 var spec = new glsVertexArrayTests.MultiVertexArrayTest.Spec();
961 spec.primitive = glsVertexArrayTests.deArray.Primitive.TRIANGLES;
962 spec.drawCount = 256;
963 spec.first = 0;
965 for (var arrayCountNdx = 0; arrayCountNdx < arrayCounts.length; arrayCountNdx++)
966 this.addInputTypeCases(spec, arrayCounts[arrayCountNdx]);
970 * @param {glsVertexArrayTests.MultiVertexArrayTest.Spec} spec
971 * @param {number} depth
973 es3fVertexArrayTests.MultiVertexArrayOutputTests.prototype.addInputTypeCases = function(spec, depth) {
974 if (depth == 0) {
975 var name = this.getTestName(spec);
976 var desc = this.getTestName(spec);
977 this.addChild(
978 new glsVertexArrayTests.MultiVertexArrayTest(
979 spec, name, desc
982 return;
985 var inputTypes = [
986 glsVertexArrayTests.deArray.InputType.BYTE,
987 glsVertexArrayTests.deArray.InputType.SHORT,
988 glsVertexArrayTests.deArray.InputType.UNSIGNED_BYTE,
989 glsVertexArrayTests.deArray.InputType.UNSIGNED_SHORT
992 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
993 var arraySpec = new glsVertexArrayTests.MultiVertexArrayTest.Spec.ArraySpec(
994 inputTypes[inputTypeNdx],
995 glsVertexArrayTests.deArray.OutputType.VEC2,
996 glsVertexArrayTests.deArray.Storage.BUFFER, //USER storage not supported in WebGL 2.0
997 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
1001 false,
1002 glsVertexArrayTests.GLValue.getMinValue(inputTypes[inputTypeNdx]),
1003 glsVertexArrayTests.GLValue.getMaxValue(inputTypes[inputTypeNdx])
1006 var _spec = /** @type {glsVertexArrayTests.MultiVertexArrayTest.Spec} */ (deUtil.clone(spec));
1007 _spec.arrays.push(arraySpec);
1008 this.addInputTypeCases(_spec, depth - 1);
1013 * es3fVertexArrayTests.VertexArrayTestGroup
1014 * @constructor
1015 * @extends {tcuTestCase.DeqpTest}
1017 es3fVertexArrayTests.VertexArrayTestGroup = function() {
1018 tcuTestCase.DeqpTest.call(this, 'vertex_arrays', 'Vertex array and array tests');
1019 this.makeExecutable();
1022 es3fVertexArrayTests.VertexArrayTestGroup.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
1023 es3fVertexArrayTests.VertexArrayTestGroup.prototype.constructor = es3fVertexArrayTests.VertexArrayTestGroup;
1026 * init
1028 es3fVertexArrayTests.VertexArrayTestGroup.prototype.init = function() {
1029 this.addChild(new es3fVertexArrayTests.SingleVertexArrayStrideTests());
1030 this.addChild(new es3fVertexArrayTests.SingleVertexArrayNormalizeTests());
1032 // Test output types with different input types, component counts and storage, Usage?, Precision?, float?
1033 var inputTypes = [
1034 glsVertexArrayTests.deArray.InputType.FLOAT,
1035 glsVertexArrayTests.deArray.InputType.SHORT,
1036 glsVertexArrayTests.deArray.InputType.BYTE,
1037 glsVertexArrayTests.deArray.InputType.UNSIGNED_SHORT,
1038 glsVertexArrayTests.deArray.InputType.UNSIGNED_BYTE,
1039 glsVertexArrayTests.deArray.InputType.UNSIGNED_INT,
1040 glsVertexArrayTests.deArray.InputType.INT,
1041 glsVertexArrayTests.deArray.InputType.HALF,
1042 glsVertexArrayTests.deArray.InputType.UNSIGNED_INT_2_10_10_10,
1043 glsVertexArrayTests.deArray.InputType.INT_2_10_10_10
1045 for (var inputTypeNdx = 0; inputTypeNdx < inputTypes.length; inputTypeNdx++) {
1046 this.addChild(new es3fVertexArrayTests.SingleVertexArrayOutputTypeGroup(inputTypes[inputTypeNdx]));
1049 /** @type {Array<glsVertexArrayTests.deArray.Usage>} */ var usages = [
1050 glsVertexArrayTests.deArray.Usage.STATIC_DRAW,
1051 glsVertexArrayTests.deArray.Usage.STREAM_DRAW,
1052 glsVertexArrayTests.deArray.Usage.DYNAMIC_DRAW,
1053 glsVertexArrayTests.deArray.Usage.STATIC_COPY,
1054 glsVertexArrayTests.deArray.Usage.STREAM_COPY,
1055 glsVertexArrayTests.deArray.Usage.DYNAMIC_COPY,
1056 glsVertexArrayTests.deArray.Usage.STATIC_READ,
1057 glsVertexArrayTests.deArray.Usage.STREAM_READ,
1058 glsVertexArrayTests.deArray.Usage.DYNAMIC_READ
1060 for (var usageNdx = 0; usageNdx < usages.length; usageNdx++) {
1061 this.addChild(new es3fVertexArrayTests.SingleVertexArrayUsageGroup(usages[usageNdx]));
1064 this.addChild(new es3fVertexArrayTests.SingleVertexArrayOffsetTests());
1065 this.addChild(new es3fVertexArrayTests.SingleVertexArrayFirstTests());
1067 this.addChild(new es3fVertexArrayTests.MultiVertexArrayCountTests());
1068 this.addChild(new es3fVertexArrayTests.MultiVertexArrayStorageTests());
1069 this.addChild(new es3fVertexArrayTests.MultiVertexArrayStrideTests());
1070 this.addChild(new es3fVertexArrayTests.MultiVertexArrayOutputTests());
1074 * Create and execute the test cases
1075 * @param {WebGL2RenderingContext} context
1077 es3fVertexArrayTests.run = function(context, range) {
1078 gl = context;
1079 //Set up root Test
1080 var state = tcuTestCase.runner;
1082 var test = new es3fVertexArrayTests.VertexArrayTestGroup();
1083 var testName = test.fullName();
1084 var testDescription = test.getDescription();
1085 state.testCases = test;
1086 state.testName = testName;
1088 //Set up name and description of this test series.
1089 setCurrentTestName(testName);
1090 description(testDescription);
1092 try {
1093 if (range)
1094 state.setRange(range);
1095 //Run test cases
1096 tcuTestCase.runTestCases();
1097 } catch (err) {
1098 testFailedOptions('Failed to es3fVertexArrayTests.run tests', false);
1099 tcuTestCase.runner.terminate();