tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

es3fRasterizerDiscardTests.js (27488B)


      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 Rasterizer discard tests.
     22 *//*--------------------------------------------------------------------*/
     23 
     24 goog.provide('functional.gles3.es3fRasterizerDiscardTests');
     25 goog.require('framework.common.tcuLogImage');
     26 goog.require('framework.common.tcuSurface');
     27 goog.require('framework.common.tcuTestCase');
     28 goog.require('framework.delibs.debase.deRandom');
     29 goog.require('framework.delibs.debase.deString');
     30 goog.require('framework.opengl.gluDrawUtil');
     31 goog.require('framework.opengl.gluShaderProgram');
     32 
     33 goog.scope(function() {
     34 var es3fRasterizerDiscardTests = functional.gles3.es3fRasterizerDiscardTests;
     35 var deString = framework.delibs.debase.deString;
     36 var tcuTestCase = framework.common.tcuTestCase;
     37 var deRandom = framework.delibs.debase.deRandom;
     38 var gluShaderProgram = framework.opengl.gluShaderProgram;
     39 var tcuSurface = framework.common.tcuSurface;
     40 var gluDrawUtil = framework.opengl.gluDrawUtil;
     41 var tcuLogImage = framework.common.tcuLogImage;
     42 
     43 /** @const */ var NUM_CASE_ITERATIONS = 1;
     44 /** @const */ var FAIL_COLOR_RED = [1, 0, 0.0, 1];
     45 /** @const */ var PASS_COLOR_BLUE = [0, 0, 0.5, 1];
     46 /** @const */ var BLACK_COLOR = [0, 0, 0.0, 1];
     47 /** @const */ var FAIL_DEPTH = 0;
     48 /** @const */ var FAIL_STENCIL = 1;
     49 /** @const */ var UNIT_SQUARE = [
     50     1, 1, 0.05, 1,
     51     1, -1, 0.05, 1,
     52    -1, 1, 0.05, 1,
     53    -1, -1, 0.05, 1
     54 ];
     55 
     56 /** @type {WebGL2RenderingContext} */ var gl;
     57 
     58 /**
     59 * @enum
     60 */
     61 es3fRasterizerDiscardTests.CaseType = {
     62    WRITE_DEPTH: 0,
     63    WRITE_STENCIL: 1,
     64    CLEAR_COLOR: 2,
     65    CLEAR_DEPTH: 3,
     66    CLEAR_STENCIL: 4
     67 };
     68 
     69 /**
     70 * @enum {{useFBO: boolean, useScissor: boolean}}
     71 */
     72 es3fRasterizerDiscardTests.CaseOptions = {
     73    FBO: {useFBO: true, useScissor: false},
     74    SCISSOR: {useFBO: false, useScissor: true}
     75 };
     76 
     77 /**
     78 * @constructor
     79 * @extends {tcuTestCase.DeqpTest}
     80 * @param {string} name
     81 * @param {string} description
     82 * @param {number} numPrimitives
     83 * @param {es3fRasterizerDiscardTests.CaseType} caseType
     84 * @param {?es3fRasterizerDiscardTests.CaseOptions} caseOptions
     85 * @param {gluDrawUtil.primitiveType=} drawMode
     86 */
     87 es3fRasterizerDiscardTests.RasterizerDiscardCase = function(name, description, numPrimitives, caseType, caseOptions, drawMode) {
     88    tcuTestCase.DeqpTest.call(this, name, description);
     89    this.m_numPrimitives = numPrimitives;
     90    this.m_caseType = caseType;
     91    this.m_caseOptions = caseOptions || {useFBO: false, useScissor: false};
     92    this.m_drawMode = drawMode || gluDrawUtil.primitiveType.TRIANGLES;
     93    this.m_program = null;
     94    this.m_fbo = null;
     95    this.m_colorBuf = null;
     96    this.m_depthStencilBuf = null;
     97    this.m_iterNdx = 0;
     98    this.m_rnd = new deRandom.Random(deString.deStringHash(name));
     99 };
    100 
    101 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
    102 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.constructor = es3fRasterizerDiscardTests.RasterizerDiscardCase;
    103 
    104 /**
    105 * @param {number} numPrimitives
    106 * @param {deRandom.Random} rnd
    107 * @param {gluDrawUtil.primitiveType} drawMode
    108 * @return {Array<number>}
    109 */
    110 es3fRasterizerDiscardTests.generateVertices = function(numPrimitives, rnd, drawMode) {
    111    var dst = [];
    112    var numVertices;
    113 
    114    switch (drawMode) {
    115        case gl.POINTS: numVertices = numPrimitives; break;
    116        case gl.LINES: numVertices = 2 * numPrimitives; break;
    117        case gl.LINE_STRIP: numVertices = numPrimitives + 1; break;
    118        case gl.LINE_LOOP: numVertices = numPrimitives + 2; break;
    119        case gl.TRIANGLES: numVertices = 3 * numPrimitives; break;
    120        case gl.TRIANGLE_STRIP: numVertices = numPrimitives + 2; break;
    121        case gl.TRIANGLE_FAN: numVertices = numPrimitives + 2; break;
    122        default:
    123            throw new Error('Invalid drawMode: ' + drawMode);
    124    }
    125 
    126    for (var i = 0; i < numVertices; i++) {
    127        dst[i * 4] = rnd.getFloat(-1.0, 1.0); // x
    128        dst[i * 4 + 1] = rnd.getFloat(-1.0, 1.0); // y
    129        dst[i * 4 + 2] = rnd.getFloat(0.1, 0.9); // z
    130        dst[i * 4 + 3] = 1.0; // w
    131    }
    132 
    133    return dst;
    134 };
    135 
    136 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.setupFramebufferObject = function() {
    137    var width = gl.drawingBufferWidth;
    138    var height = gl.drawingBufferHeight;
    139 
    140    // Create framebuffer object
    141 
    142    this.m_fbo = gl.createFramebuffer();
    143    this.m_colorBuf = gl.createTexture();
    144    this.m_depthStencilBuf = gl.createRenderbuffer();
    145 
    146    // Create color texture
    147 
    148    gl.bindTexture(gl.TEXTURE_2D, this.m_colorBuf);
    149    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    150    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    151    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    152    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    153    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
    154 
    155    // Create depth and stencil buffers
    156 
    157    gl.bindRenderbuffer(gl.RENDERBUFFER, this.m_depthStencilBuf);
    158    gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, width, height);
    159 
    160    // Attach texture and buffers to FBO
    161 
    162    gl.bindFramebuffer(gl.FRAMEBUFFER, this.m_fbo);
    163    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.m_colorBuf, 0);
    164    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.m_depthStencilBuf);
    165    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.m_depthStencilBuf);
    166 
    167    var fboStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
    168 
    169    if (fboStatus == gl.FRAMEBUFFER_UNSUPPORTED)
    170        throw new Error('Framebuffer unsupported');
    171    else if (fboStatus != gl.FRAMEBUFFER_COMPLETE)
    172        throw new Error('Failed to create framebuffer object: ' + deString.enumToString(gl, fboStatus));
    173 };
    174 
    175 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.deleteFramebufferObject = function() {
    176    gl.deleteTexture(this.m_colorBuf);
    177    gl.deleteRenderbuffer(this.m_depthStencilBuf);
    178    gl.deleteFramebuffer(this.m_fbo);
    179 };
    180 
    181 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.init = function() {
    182    var vertShaderSource =
    183                '#version 300 es\n' +
    184                'layout(location = 0) in mediump vec4 a_position;\n' +
    185                '\n' +
    186                'void main (void)\n' +
    187                '{\n' +
    188                ' gl_Position = a_position;\n' +
    189                '}\n';
    190 
    191    var fragShaderSource =
    192                '#version 300 es\n' +
    193                'layout(location = 0) out mediump vec4 dEQP_FragColor;\n' +
    194                'uniform mediump vec4 u_color;\n' +
    195                '\n' +
    196                'void main (void)\n' +
    197                '{\n' +
    198                ' mediump float depth_gradient = gl_FragCoord.z;\n' +
    199                ' mediump float bias = 0.1;\n' +
    200                ' dEQP_FragColor = vec4(u_color.xyz * (depth_gradient + bias), 1.0);\n' +
    201                '}\n';
    202 
    203    this.m_program = new gluShaderProgram.ShaderProgram(gl, gluShaderProgram.makeVtxFragSources(vertShaderSource, fragShaderSource));
    204 
    205    if (!this.m_program.isOk()) {
    206        bufferedLogToConsole(this.m_program);
    207        testFailedOptions('Failed to compile shader program', true);
    208    }
    209 };
    210 
    211 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.deinit = function() {
    212    this.deleteFramebufferObject();
    213    this.m_program = null;
    214 };
    215 
    216 es3fRasterizerDiscardTests.RasterizerDiscardCase.prototype.iterate = function() {
    217    var program = this.m_program.getProgram();
    218    var colorUnif = gl.getUniformLocation(program, 'u_color');
    219    var failColorFound = false;
    220    var passColorFound = false;
    221    var vertices;
    222 
    223    bufferedLogToConsole('Case iteration ' + (this.m_iterNdx + 1) + ' / ' + NUM_CASE_ITERATIONS);
    224 
    225    // Create and bind FBO if needed
    226 
    227    if (this.m_caseOptions.useFBO) {
    228        this.setupFramebufferObject();
    229    }
    230 
    231    if (this.m_caseOptions.useScissor) {
    232        gl.enable(gl.SCISSOR_TEST);
    233        gl.scissor(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
    234        bufferedLogToConsole('Scissor test enabled: glScissor(0, 0, ' + gl.drawingBufferWidth + ', ' + gl.drawingBufferHeight + ')');
    235    }
    236 
    237    gl.useProgram(this.m_program.getProgram());
    238 
    239    gl.enable(gl.DEPTH_TEST);
    240    gl.depthRange(0, 1);
    241    gl.depthFunc(gl.LEQUAL);
    242 
    243    gl.enable(gl.STENCIL_TEST);
    244    gl.stencilFunc(gl.NOTEQUAL, 1, 0xFF);
    245    gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP);
    246 
    247    gl.clearColor(PASS_COLOR_BLUE[0], PASS_COLOR_BLUE[1], PASS_COLOR_BLUE[2], PASS_COLOR_BLUE[3]);
    248    gl.clearDepth(1);
    249    gl.clearStencil(0);
    250    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
    251 
    252    // Generate vertices
    253    vertices = es3fRasterizerDiscardTests.generateVertices(this.m_numPrimitives, this.m_rnd, this.m_drawMode);
    254    var posLoc = gl.getAttribLocation(program, 'a_position');
    255    var vertexArrays = [];
    256    vertexArrays.push(new gluDrawUtil.VertexArrayBinding(gl.FLOAT, posLoc, 4, vertices.length / 4, vertices));
    257    // Clear color to black for depth and stencil clear cases
    258 
    259    if (this.m_caseType == es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH || this.m_caseType == es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL) {
    260        gl.clearColor(BLACK_COLOR[0], BLACK_COLOR[1], BLACK_COLOR[2], BLACK_COLOR[3]);
    261        gl.clear(gl.COLOR_BUFFER_BIT);
    262    }
    263 
    264    // Set fail values for color, depth and stencil
    265 
    266    gl.uniform4fv(colorUnif, FAIL_COLOR_RED);
    267    gl.clearColor(FAIL_COLOR_RED[0], FAIL_COLOR_RED[1], FAIL_COLOR_RED[2], FAIL_COLOR_RED[3]);
    268    gl.clearDepth(FAIL_DEPTH);
    269    gl.clearStencil(FAIL_STENCIL);
    270 
    271    // Enable rasterizer discard
    272 
    273    gl.enable(gl.RASTERIZER_DISCARD);
    274    bufferedLogToConsole('Rasterizer discard enabled');
    275 
    276    // Do to-be-discarded primitive draws and buffer clears
    277 
    278    switch (this.m_caseType) {
    279        case es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH:
    280            gluDrawUtil.draw(gl, program, vertexArrays, new gluDrawUtil.PrimitiveList(this.m_drawMode, vertices.length / 4));
    281            break;
    282        case es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL:
    283            gluDrawUtil.draw(gl, program, vertexArrays, new gluDrawUtil.PrimitiveList(this.m_drawMode, vertices.length / 4));
    284            break;
    285        case es3fRasterizerDiscardTests.CaseType.CLEAR_COLOR:
    286            if (this.m_caseOptions.useFBO)
    287                gl.clearBufferfv(gl.COLOR, 0, FAIL_COLOR_RED);
    288            else
    289                gl.clear(gl.COLOR_BUFFER_BIT);
    290            break;
    291        case es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH:
    292            if (this.m_caseOptions.useFBO)
    293                gl.clearBufferfv(gl.DEPTH, 0, [FAIL_DEPTH]);
    294            else
    295                gl.clear(gl.DEPTH_BUFFER_BIT);
    296            break;
    297        case es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL:
    298            if (this.m_caseOptions.useFBO)
    299                gl.clearBufferiv(gl.STENCIL, 0, [FAIL_STENCIL]);
    300            else
    301                gl.clear(gl.STENCIL_BUFFER_BIT);
    302            break;
    303        default:
    304            throw new Error('Invalid case type ' + this.m_caseType);
    305    }
    306 
    307    // Disable rasterizer discard
    308 
    309    gl.disable(gl.RASTERIZER_DISCARD);
    310    bufferedLogToConsole('Rasterizer discard disabled');
    311 
    312    if (this.m_caseType == es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL) {
    313        if (this.m_caseOptions.useFBO || gl.getContextAttributes().stencil) {
    314            // Draw a full-screen square that colors all pixels red if they have stencil value 1.
    315            var square = [new gluDrawUtil.VertexArrayBinding(gl.FLOAT, posLoc, 4, UNIT_SQUARE.length / 4, UNIT_SQUARE)];
    316 
    317            gl.stencilFunc(gl.EQUAL, 1, 0xFF);
    318            gluDrawUtil.draw(gl, program, square,
    319             new gluDrawUtil.PrimitiveList(gluDrawUtil.primitiveType.TRIANGLE_STRIP, UNIT_SQUARE.length / 4));
    320        }
    321        // \note If no stencil buffers are present and test is rendering to default framebuffer, test will always pass.
    322    } else if (this.m_caseType == es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH || this.m_caseType == es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL) {
    323        // Draw pass-indicating primitives for depth and stencil clear cases
    324 
    325        gl.uniform4fv(colorUnif, PASS_COLOR_BLUE);
    326        gluDrawUtil.draw(gl, program, vertexArrays, new gluDrawUtil.PrimitiveList(this.m_drawMode, vertices.length / 4));
    327    }
    328 
    329    gl.finish();
    330    gl.disable(gl.STENCIL_TEST);
    331    gl.disable(gl.DEPTH_TEST);
    332    gl.disable(gl.SCISSOR_TEST);
    333 
    334    // Read and check pixel data
    335 
    336    var pixels = new tcuSurface.Surface();
    337    pixels.readViewport(gl);
    338 
    339    var width = pixels.getWidth();
    340    var height = pixels.getHeight();
    341 
    342    for (var y = 0; y < height; y++) {
    343        for (var x = 0; x < width; x++) {
    344            var pixel = pixels.getPixel(x, y);
    345            if (pixel[2] != 0)
    346                passColorFound = true;
    347 
    348            if (pixel[0] != 0) {
    349                failColorFound = true;
    350                break;
    351            }
    352        }
    353        if (failColorFound) break;
    354    }
    355 
    356    // Delete FBO if created
    357 
    358    if (this.m_caseOptions.useFBO)
    359        this.deleteFramebufferObject();
    360 
    361    // Evaluate test result
    362 
    363    var testOk = passColorFound && !failColorFound;
    364 
    365    if (!testOk) {
    366        tcuLogImage.logImage('Result image', '', pixels.getAccess());
    367        testFailed('Primitive or buffer clear was not discarded.');
    368        return tcuTestCase.IterateResult.STOP;
    369    }
    370    bufferedLogToConsole('Primitive or buffer clear was discarded correctly.');
    371 
    372    if (++this.m_iterNdx < NUM_CASE_ITERATIONS)
    373        return tcuTestCase.IterateResult.CONTINUE;
    374 
    375    testPassed();
    376    return tcuTestCase.IterateResult.STOP;
    377 };
    378 
    379 es3fRasterizerDiscardTests.init = function() {
    380    var state = tcuTestCase.runner;
    381    var testGroup = state.testCases;
    382 
    383    var basic = tcuTestCase.newTest('basic', 'Rasterizer discard test for default framebuffer');
    384    var scissor = tcuTestCase.newTest('scissor', 'Rasterizer discard test for default framebuffer with scissor test enabled');
    385    var fbo = tcuTestCase.newTest('fbo', 'Rasterizer discard test for framebuffer object');
    386 
    387    testGroup.addChild(basic);
    388    testGroup.addChild(scissor);
    389    testGroup.addChild(fbo);
    390 
    391    // Default framebuffer cases
    392 
    393    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.POINTS));
    394    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.LINES));
    395    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.LINE_STRIP));
    396    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.LINE_LOOP));
    397    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.TRIANGLES));
    398    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    399    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, null, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    400 
    401    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.POINTS));
    402    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.LINES));
    403    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.LINE_STRIP));
    404    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.LINE_LOOP));
    405    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.TRIANGLES));
    406    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    407    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, null, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    408 
    409    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_color', 'clear_color', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_COLOR, null));
    410    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_depth', 'clear_depth', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH, null));
    411    basic.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_stencil', 'clear_stencil', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL, null));
    412 
    413    // Default framebuffer cases with scissor test enabled
    414 
    415    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.POINTS));
    416    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINES));
    417    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINE_STRIP));
    418    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINE_LOOP));
    419    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLES));
    420    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    421    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    422 
    423    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.POINTS));
    424    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINES));
    425    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINE_STRIP));
    426    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.LINE_LOOP));
    427    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLES));
    428    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    429    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    430 
    431    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_color', 'clear_color', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_COLOR, es3fRasterizerDiscardTests.CaseOptions.SCISSOR));
    432    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_depth', 'clear_depth', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH, es3fRasterizerDiscardTests.CaseOptions.SCISSOR));
    433    scissor.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_stencil', 'clear_stencil', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL, es3fRasterizerDiscardTests.CaseOptions.SCISSOR));
    434 
    435    // FBO cases
    436 
    437    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.POINTS));
    438    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINES));
    439    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINE_STRIP));
    440    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINE_LOOP));
    441    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLES));
    442    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    443    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_depth_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    444 
    445    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_points', 'points', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.POINTS));
    446    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_lines', 'lines', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINES));
    447    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_strip', 'line_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINE_STRIP));
    448    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_line_loop', 'line_loop', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.LINE_LOOP));
    449    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangles', 'triangles', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLES));
    450    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_strip', 'triangle_strip', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLE_STRIP));
    451    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('write_stencil_triangle_fan', 'triangle_fan', 4, es3fRasterizerDiscardTests.CaseType.WRITE_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO, gluDrawUtil.primitiveType.TRIANGLE_FAN));
    452 
    453    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_color', 'clear_color', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_COLOR, es3fRasterizerDiscardTests.CaseOptions.FBO));
    454    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_depth', 'clear_depth', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_DEPTH, es3fRasterizerDiscardTests.CaseOptions.FBO));
    455    fbo.addChild(new es3fRasterizerDiscardTests.RasterizerDiscardCase('clear_stencil', 'clear_stencil', 4, es3fRasterizerDiscardTests.CaseType.CLEAR_STENCIL, es3fRasterizerDiscardTests.CaseOptions.FBO));
    456 };
    457 
    458 /**
    459 * Create and execute the test cases
    460 */
    461 es3fRasterizerDiscardTests.run = function(context) {
    462    gl = context;
    463    //Set up Test Root parameters
    464    var testName = 'rasterizer_discard';
    465    var testDescription = 'Rasterizer Discard Tests';
    466    var state = tcuTestCase.runner;
    467 
    468    state.testName = testName;
    469    state.testCases = tcuTestCase.newTest(testName, testDescription, null);
    470 
    471    //Set up name and description of this test series.
    472    setCurrentTestName(testName);
    473    description(testDescription);
    474 
    475    try {
    476        es3fRasterizerDiscardTests.init();
    477        tcuTestCase.runTestCases();
    478    } catch (err) {
    479        testFailedOptions('Failed to run tests', false);
    480        bufferedLogToConsole(err);
    481        tcuTestCase.runner.terminate();
    482    }
    483 };
    484 
    485 });