summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/deqp/functional/gles3/es3fReadPixelTests.js
blob: 7996c9196c9202751022b68dd9daa2b3e73079b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
/*-------------------------------------------------------------------------
 * drawElements Quality Program OpenGL ES Utilities
 * ------------------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

'use strict';
goog.provide('functional.gles3.es3fReadPixelTests');
goog.require('framework.common.tcuImageCompare');
goog.require('framework.common.tcuRGBA');
goog.require('framework.common.tcuTestCase');
goog.require('framework.common.tcuTexture');
goog.require('framework.common.tcuTextureUtil');
goog.require('framework.delibs.debase.deRandom');
goog.require('framework.delibs.debase.deString');
goog.require('framework.opengl.gluShaderProgram');
goog.require('framework.opengl.gluTextureUtil');

goog.scope(function() {
    var es3fReadPixelTests = functional.gles3.es3fReadPixelTests;
    var tcuImageCompare = framework.common.tcuImageCompare;
    var tcuRGBA = framework.common.tcuRGBA;
    var tcuTestCase = framework.common.tcuTestCase;
    var tcuTexture = framework.common.tcuTexture;
    var tcuTextureUtil = framework.common.tcuTextureUtil;
    var deString = framework.delibs.debase.deString;
    var deRandom = framework.delibs.debase.deRandom;
    var gluTextureUtil = framework.opengl.gluTextureUtil;
    var gluShaderProgram = framework.opengl.gluShaderProgram;

    /**
     * @constructor
     * @extends {tcuTestCase.DeqpTest}
     * @param {string} name
     * @param {string} description
     * @param {boolean} chooseFormat
     * @param {number} alignment
     * @param {number} rowLength
     * @param {number} skipRows
     * @param {number} skipPixels
     * @param {number=} format
     * @param {number=} type
     */
    es3fReadPixelTests.ReadPixelsTest = function(name, description, chooseFormat, alignment, rowLength, skipRows, skipPixels, format, type) {
        tcuTestCase.DeqpTest.call(this, name, description);

        /** @type {number} */ this.m_seed = deString.deStringHash(name);
        /** @type {boolean} */ this.m_chooseFormat = chooseFormat;
        /** @type {number} */ this.m_alignment = alignment;
        /** @type {number} */ this.m_rowLength = rowLength;
        /** @type {number} */ this.m_skipRows = skipRows;
        /** @type {number} */ this.m_skipPixels = skipPixels;
        /** @type {number} */ this.m_format = format !== undefined ? format : gl.RGBA;
        /** @type {number} */ this.m_type = type !== undefined ? type : gl.UNSIGNED_BYTE;

        /** @const {number} */ this.m_width = 13;
        /** @const {number} */ this.m_height = 13;
    };

    es3fReadPixelTests.ReadPixelsTest.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
    es3fReadPixelTests.ReadPixelsTest.prototype.constructor = es3fReadPixelTests.ReadPixelsTest;

    /**
     * @param {tcuTexture.Texture2D} reference
     */
    es3fReadPixelTests.ReadPixelsTest.prototype.render = function(reference) {
        var refType = /** @type {tcuTexture.ChannelType} */ (reference.getFormat().type);
        /** @type {number} */ var width = reference.getWidth();
        /** @type {number} */ var height = reference.getHeight();
        /** @return {tcuTexture.PixelBufferAccess} */ var level0 = reference.getLevel(0);

        // Create program
        /** @type {string} */ var vertexSource = '#version 300 es\n' +
            'in mediump vec2 i_coord;\n' +
            'void main (void)\n' +
            '{\n' +
            '\tgl_Position = vec4(i_coord, 0.0, 1.0);\n' +
            '}\n';

        /** @type {string} */ var fragmentSource = '#version 300 es\n';

        if (refType === tcuTexture.ChannelType.SIGNED_INT32)
            fragmentSource += 'layout(location = 0) out mediump ivec4 o_color;\n';
        else if (refType === tcuTexture.ChannelType.UNSIGNED_INT32)
            fragmentSource += 'layout(location = 0) out mediump uvec4 o_color;\n';
        else
            fragmentSource += 'layout(location = 0) out mediump vec4 o_color;\n';

        fragmentSource += 'void main (void)\n' +
            '{\n';

        if (refType === tcuTexture.ChannelType.UNSIGNED_INT32)
            fragmentSource += '\to_color = uvec4(0, 0, 0, 1000);\n';
        else if (refType === tcuTexture.ChannelType.SIGNED_INT32)
            fragmentSource += '\to_color = ivec4(0, 0, 0, 1000);\n';
        else
            fragmentSource += '\to_color = vec4(0.0, 0.0, 0.0, 1.0);\n';

        fragmentSource += '}\n';

        /** @type {gluShaderProgram.ShaderProgram} */ var program = new gluShaderProgram.ShaderProgram(gl, gluShaderProgram.makeVtxFragSources(vertexSource, fragmentSource));

        assertMsgOptions(program.isOk(), 'Program failed', false, true);

        gl.useProgram(program.getProgram());

        // Render
        /** @type {Array<number>} */ var coords = [
            -0.5, -0.5,
            0.5, -0.5,
            0.5, 0.5,

            0.5, 0.5,
            -0.5, 0.5,
            -0.5, -0.5
        ];
        /** @type {number} */ var coordLoc;

        coordLoc = gl.getAttribLocation(program.getProgram(), 'i_coord');

        gl.enableVertexAttribArray(coordLoc);

        /** @type {WebGLBuffer} */ var coordsGLBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, coordsGLBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(coords), gl.STATIC_DRAW);
        gl.vertexAttribPointer(coordLoc, 2, gl.FLOAT, false, 0, 0);

        gl.drawArrays(gl.TRIANGLES, 0, 6);
        gl.disableVertexAttribArray(coordLoc);

        // Render reference

        /** @type {number} */ var coordX1 = Math.floor((-0.5 * width / 2.0) + width / 2.0);
        /** @type {number} */ var coordY1 = Math.floor((-0.5 * height / 2.0) + height / 2.0);
        /** @type {number} */ var coordX2 = Math.floor((0.5 * width / 2.0) + width / 2.0);
        /** @type {number} */ var coordY2 = Math.floor((0.5 * height / 2.0) + height / 2.0);

        for (var x = 0; x < width; x++) {
            if (x < coordX1 || x > coordX2)
                continue;

            for (var y = 0; y < height; y++) {
                if (y >= coordY1 && y <= coordY2) {
                    if (refType === tcuTexture.ChannelType.SIGNED_INT32)
                        level0.setPixelInt([0, 0, 0, 1000], x, y);
                    else if (refType === tcuTexture.ChannelType.UNSIGNED_INT32)
                        level0.setPixelInt([0, 0, 0, 1000], x, y);
                    else
                        level0.setPixel([0.0, 0.0, 0.0, 1.0], x, y);
                }
            }
        }
    };

    /**
     * @return {{format: tcuTexture.TextureFormat, pixelSize: number, align: boolean}}
     */
    es3fReadPixelTests.ReadPixelsTest.prototype.getFormatInfo = function() {
        if (this.m_chooseFormat) {
            this.m_format = /** @type {number} */ (gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT));
            this.m_type = /** @type {number} */ (gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE));
        }

        /** @type {tcuTexture.TextureFormat} */ var fmt = gluTextureUtil.mapGLTransferFormat(this.m_format, this.m_type);
        /** @type {boolean} */ var align_;
        switch (this.m_type) {
            case gl.BYTE:
            case gl.UNSIGNED_BYTE:
            case gl.SHORT:
            case gl.UNSIGNED_SHORT:
            case gl.INT:
            case gl.UNSIGNED_INT:
            case gl.FLOAT:
            case gl.HALF_FLOAT:
                align_ = true;
                break;

            case gl.UNSIGNED_SHORT_5_6_5:
            case gl.UNSIGNED_SHORT_4_4_4_4:
            case gl.UNSIGNED_SHORT_5_5_5_1:
            case gl.UNSIGNED_INT_2_10_10_10_REV:
            case gl.UNSIGNED_INT_10F_11F_11F_REV:
            case gl.UNSIGNED_INT_24_8:
            case gl.FLOAT_32_UNSIGNED_INT_24_8_REV:
            case gl.UNSIGNED_INT_5_9_9_9_REV:
                align_ = false;
                break;

            default:
                throw new Error('Unsupported format');
        }

        /** @type {number} */ var pxSize = fmt.getPixelSize();

        return {format: fmt, pixelSize: pxSize, align: align_};
    };

    /**
     * @param {tcuTexture.Texture2D} reference
     * @param {boolean} align
     * @param {number} pixelSize
     * @return {goog.TypedArray}
     */
    es3fReadPixelTests.ReadPixelsTest.prototype.clearColor = function(reference, align, pixelSize) {
        /** @type {number} */ var width = reference.getWidth();
        /** @type {number} */ var height = reference.getHeight();
        /** @return {tcuTexture.PixelBufferAccess} */ var level0 = reference.getLevel(0);

        /** @type {deRandom.Random} */ var rnd = new deRandom.Random(this.m_seed);
        /** @type {WebGLFramebuffer} */ var framebuffer;
        /** @type {WebGLRenderbuffer} */ var renderbuffer;
        /** @type {number} */ var red;
        /** @type {number} */ var green;
        /** @type {number} */ var blue;
        /** @type {number} */ var alpha;
        /** @type {Array<number>} */ var color;

        if (this.m_format === gl.RGBA_INTEGER) {
            if (this.m_type === gl.UNSIGNED_INT) {
                renderbuffer = gl.createRenderbuffer();
                gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
                gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA32UI, this.m_width, this.m_height);
            } else if (this.m_type === gl.INT) {
                renderbuffer = gl.createRenderbuffer();
                gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
                gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA32I, this.m_width, this.m_height);
            } else
                throw new Error('Type not supported');

            gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
            framebuffer = gl.createFramebuffer();
            gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer);
        } else if (this.m_format === gl.RGBA || /*this.m_format === gl.BGRA ||*/ this.m_format === gl.RGB) {
            // Empty
        } else
            throw new Error('Format not supported');

        gl.viewport(0, 0, width, height);

        // Clear color
        if (this.m_format === gl.RGBA || this.m_format === gl.RGB) {
            red = rnd.getFloat();
            green = rnd.getFloat();
            blue = rnd.getFloat();
            alpha = rnd.getFloat();

            color = [red, green, blue, alpha];
            // Clear target
            gl.clearColor(red, green, blue, alpha);
            bufferedLogToConsole('ClearColor: (' + red + ', ' + green + ', ' + blue + ')');

            gl.clearBufferfv(gl.COLOR, 0, color);

            // Clear reference
            level0.clear(color);
        } else if (this.m_format === gl.RGBA_INTEGER) {
            if (this.m_type === gl.INT) {
                red = Math.abs(rnd.getInt());
                green = Math.abs(rnd.getInt());
                blue = Math.abs(rnd.getInt());
                alpha = Math.abs(rnd.getInt());

                color = [red, green, blue, alpha];
                bufferedLogToConsole('ClearColor: (' + red + ', ' + green + ', ' + blue + ')');

                gl.clearBufferiv(gl.COLOR, 0, color);

                // Clear reference
                level0.clear([red, green, blue, alpha]);
            } else if (this.m_type === gl.UNSIGNED_INT) {
                red = Math.abs(rnd.getInt());
                green = Math.abs(rnd.getInt());
                blue = Math.abs(rnd.getInt());
                alpha = Math.abs(rnd.getInt());

                color = [red, green, blue, alpha];
                bufferedLogToConsole('ClearColor: (' + red + ', ' + green + ', ' + blue + ')');

                gl.clearBufferuiv(gl.COLOR, 0, color);

                // Clear reference
                level0.clear(color);
            } else
                throw new Error('Type not supported.');
        } else
            throw new Error('Format not supported.');

        this.render(reference);

        /** @type {number} */ var rowWidth = (this.m_rowLength === 0 ? this.m_width : this.m_rowLength) + this.m_skipPixels;
        /** @type {number} */ var rowPitch = (align ? this.m_alignment * Math.ceil(pixelSize * rowWidth / this.m_alignment) : rowWidth * pixelSize);

        var arrayType = tcuTexture.getTypedArray(reference.getFormat().type);
        /** @type {goog.TypedArray} */ var pixelData = new arrayType(rowPitch * (this.m_height + this.m_skipRows));
        gl.readPixels(0, 0, this.m_width, this.m_height, this.m_format, this.m_type, pixelData);

        if (framebuffer)
            gl.deleteFramebuffer(framebuffer);

        if (renderbuffer)
            gl.deleteRenderbuffer(renderbuffer);

        return pixelData;
    };

    /**
     * @return {tcuTestCase.IterateResult}
     */
    es3fReadPixelTests.ReadPixelsTest.prototype.iterate = function() {
        /** @type {tcuTexture.TextureFormat} */ var format = new tcuTexture.TextureFormat(tcuTexture.ChannelOrder.RGBA, tcuTexture.ChannelType.UNORM_INT8);
        /** @type {number} */ var pixelSize;
        /** @type {boolean} */ var align;

        /** @type {{format: tcuTexture.TextureFormat, pixelSize: number, align: boolean}} */ var formatInfo = this.getFormatInfo();
        format = formatInfo.format;
        align = formatInfo.align;
        pixelSize = formatInfo.pixelSize;

        bufferedLogToConsole('Format: ' + this.m_format + ', Type: ' + this.m_type);

        /** @type {tcuTexture.Texture2D} */ var reference = new tcuTexture.Texture2D(format, this.m_width, this.m_height);
        reference.allocLevel(0);
        /** @return {tcuTexture.PixelBufferAccess} */ var level0 = reference.getLevel(0);

        this.m_alignment = /** @type {number} */ (gl.getParameter(gl.PACK_ALIGNMENT));
        bufferedLogToConsole('gl.PACK_ALIGNMENT: ' + this.m_alignment);

        this.m_rowLength = /** @type {number} */ (gl.getParameter(gl.PACK_ROW_LENGTH));
        bufferedLogToConsole('gl.PACK_ROW_LENGTH: ' + this.m_rowLength);

        this.m_skipRows = /** @type {number} */ (gl.getParameter(gl.PACK_SKIP_ROWS));
        bufferedLogToConsole('gl.PACK_SKIP_ROWS: ' + this.m_skipRows);

        this.m_skipPixels = /** @type {number} */ (gl.getParameter(gl.PACK_SKIP_PIXELS));
        bufferedLogToConsole('gl.PACK_SKIP_PIXELS: ' + this.m_skipPixels);

        gl.viewport(0, 0, this.m_width, this.m_height);

        /** @type {goog.TypedArray} */ var pixelData = this.clearColor(reference, align, pixelSize);

        /** @type {number} */ var rowWidth = (this.m_rowLength === 0 ? this.m_width : this.m_rowLength);
        /** @type {number} */ var rowPitch = (align ? this.m_alignment * Math.ceil(pixelSize * rowWidth / this.m_alignment) : rowWidth * pixelSize);
        /** @type {Array<number>} */ var formatBitDepths = [];
        /** @type {number} */ var redThreshold;
        /** @type {number} */ var greenThreshold;
        /** @type {number} */ var blueThreshold;
        /** @type {number} */ var alphaThreshold;
        var redBits = /** @type {number} */ (gl.getParameter(gl.RED_BITS));
        var blueBits = /** @type {number} */ (gl.getParameter(gl.BLUE_BITS));
        var greenBits = /** @type {number} */ (gl.getParameter(gl.GREEN_BITS));
        var alphaBits = /** @type {number} */ (gl.getParameter(gl.ALPHA_BITS));
        /** @type {(tcuRGBA.RGBA|Array<number>)} */ var threshold;
        /** @type {tcuTexture.PixelBufferAccess} */ var result;
        // \note gl.RGBA_INTEGER uses always renderbuffers that are never multisampled. Otherwise default framebuffer is used.
        if (this.m_format !== gl.RGBA_INTEGER && /** @type {number} */ (gl.getParameter(gl.SAMPLES)) > 1) {
            formatBitDepths = tcuTextureUtil.getTextureFormatBitDepth(format);
            redThreshold = Math.ceil(256.0 * (2.0 / (1 << Math.min(redBits, formatBitDepths[0]))));
            greenThreshold = Math.ceil(256.0 * (2.0 / (1 << Math.min(greenBits, formatBitDepths[1]))));
            blueThreshold = Math.ceil(256.0 * (2.0 / (1 << Math.min(blueBits, formatBitDepths[2]))));
            alphaThreshold = Math.ceil(256.0 * (2.0 / (1 << Math.min(alphaBits, formatBitDepths[3]))));

            result = tcuTexture.PixelBufferAccess.newFromTextureFormat(format, this.m_width, this.m_height, 1, rowPitch, 0, pixelData.buffer);
            threshold = new tcuRGBA.RGBA([redThreshold, greenThreshold, blueThreshold, alphaThreshold]);
            if (tcuImageCompare.bilinearCompare('Result', 'Result', level0, result, threshold))
                testPassedOptions('Pass', true);
            else
                testFailedOptions('Fail', false);
        } else {
            formatBitDepths = tcuTextureUtil.getTextureFormatBitDepth(format);
            redThreshold = 2.0 / (1 << Math.min(redBits, formatBitDepths[0]));
            greenThreshold = 2.0 / (1 << Math.min(greenBits, formatBitDepths[1]));
            blueThreshold = 2.0 / (1 << Math.min(blueBits, formatBitDepths[2]));
            alphaThreshold = 2.0 / (1 << Math.min(alphaBits, formatBitDepths[3]));

            // Compare
            result = new tcuTexture.PixelBufferAccess({
                format: format,
                width: this.m_width,
                height: this.m_height,
                rowPitch: rowPitch,
                data: pixelData.buffer,
                offset: pixelSize * this.m_skipPixels + this.m_skipRows * rowPitch
            });

            threshold = [redThreshold, greenThreshold, blueThreshold, alphaThreshold];
            if (tcuImageCompare.floatThresholdCompare('Result', 'Result', level0, result, threshold))
                testPassedOptions('Pass', true);
            else
                testFailedOptions('Fail', false);
        }

        return tcuTestCase.IterateResult.STOP;
    };

    /**
    * @constructor
    * @extends {tcuTestCase.DeqpTest}
    */
    es3fReadPixelTests.ReadPixelTests = function() {
        tcuTestCase.DeqpTest.call(this, 'read_pixels', 'ReadPixel tests');
    };

    es3fReadPixelTests.ReadPixelTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
    es3fReadPixelTests.ReadPixelTests.prototype.constructor = es3fReadPixelTests.ReadPixelTests;

    es3fReadPixelTests.ReadPixelTests.prototype.init = function() {
        /** @type {tcuTestCase.DeqpTest} */ var groupAlignment = tcuTestCase.newTest('alignment', 'Read pixels pack alignment parameter tests');

        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_1', '', false, 1, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_2', '', false, 2, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_4', '', false, 4, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_8', '', false, 8, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));

        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_1', '', false, 1, 0, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_2', '', false, 2, 0, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_4', '', false, 4, 0, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_8', '', false, 8, 0, 0, 0, gl.RGBA_INTEGER, gl.INT));

        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_1', '', false, 1, 0, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_2', '', false, 2, 0, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_4', '', false, 4, 0, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_8', '', false, 8, 0, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));

        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_1', '', true, 1, 0, 0, 0));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_2', '', true, 2, 0, 0, 0));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_4', '', true, 4, 0, 0, 0));
        groupAlignment.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_8', '', true, 8, 0, 0, 0));

        this.addChild(groupAlignment);

        /** @type {tcuTestCase.DeqpTest} */ var groupRowLength = tcuTestCase.newTest('rowlength', 'Read pixels rowlength test');
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_17', '', false, 4, 17, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_19', '', false, 4, 19, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_23', '', false, 4, 23, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_29', '', false, 4, 29, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE));

        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_17', '', false, 4, 17, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_19', '', false, 4, 19, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_23', '', false, 4, 23, 0, 0, gl.RGBA_INTEGER, gl.INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_29', '', false, 4, 29, 0, 0, gl.RGBA_INTEGER, gl.INT));

        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_17', '', false, 4, 17, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_19', '', false, 4, 19, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_23', '', false, 4, 23, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_29', '', false, 4, 29, 0, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));

        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_17', '', true, 4, 17, 0, 0));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_19', '', true, 4, 19, 0, 0));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_23', '', true, 4, 23, 0, 0));
        groupRowLength.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_29', '', true, 4, 29, 0, 0));

        this.addChild(groupRowLength);

        /** @type {tcuTestCase.DeqpTest} */ var groupSkip = tcuTestCase.newTest('skip', 'Read pixels skip pixels and rows test');
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_0_3', '', false, 4, 17, 0, 3, gl.RGBA, gl.UNSIGNED_BYTE));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_3_0', '', false, 4, 17, 3, 0, gl.RGBA, gl.UNSIGNED_BYTE));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_3_3', '', false, 4, 17, 3, 3, gl.RGBA, gl.UNSIGNED_BYTE));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_ubyte_3_5', '', false, 4, 17, 3, 5, gl.RGBA, gl.UNSIGNED_BYTE));

        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_0_3', '', false, 4, 17, 0, 3, gl.RGBA_INTEGER, gl.INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_3_0', '', false, 4, 17, 3, 0, gl.RGBA_INTEGER, gl.INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_3_3', '', false, 4, 17, 3, 3, gl.RGBA_INTEGER, gl.INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_int_3_5', '', false, 4, 17, 3, 5, gl.RGBA_INTEGER, gl.INT));

        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_0_3', '', false, 4, 17, 0, 3, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_3_0', '', false, 4, 17, 3, 0, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_3_3', '', false, 4, 17, 3, 3, gl.RGBA_INTEGER, gl.UNSIGNED_INT));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('rgba_uint_3_5', '', false, 4, 17, 3, 5, gl.RGBA_INTEGER, gl.UNSIGNED_INT));

        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_0_3', '', true, 4, 17, 0, 3));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_3_0', '', true, 4, 17, 3, 0));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_3_3', '', true, 4, 17, 3, 3));
        groupSkip.addChild(new es3fReadPixelTests.ReadPixelsTest('choose_3_5', '', true, 4, 17, 3, 5));

        this.addChild(groupSkip);
    };

    /**
    * Run test
    * @param {WebGL2RenderingContext} context
    */
    es3fReadPixelTests.run = function(context) {
        gl = context;
        //Set up Test Root parameters
        var state = tcuTestCase.runner;
        state.setRoot(new es3fReadPixelTests.ReadPixelTests());

        //Set up name and description of this test series.
        setCurrentTestName(state.testCases.fullName());
        description(state.testCases.getDescription());

        try {
            //Run test cases
            tcuTestCase.runTestCases();
        }
        catch (err) {
            testFailedOptions('Failed to es3fReadPixelTests.run tests', false);
            tcuTestCase.runner.terminate();
        }
    };

});