tor-browser

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

es3fInternalFormatQueryTests.js (6738B)


      1 /*-------------------------------------------------------------------------
      2 * drawElements Quality Program OpenGL ES Utilities
      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 
     21 'use strict';
     22 goog.provide('functional.gles3.es3fInternalFormatQueryTests');
     23 goog.require('framework.common.tcuTestCase');
     24 goog.require('functional.gles3.es3fApiCase');
     25 goog.require('modules.shared.glsStateQuery');
     26 
     27 goog.scope(function() {
     28 var es3fInternalFormatQueryTests = functional.gles3.es3fInternalFormatQueryTests;
     29 var tcuTestCase = framework.common.tcuTestCase;
     30 var glsStateQuery = modules.shared.glsStateQuery;
     31 var es3fApiCase = functional.gles3.es3fApiCase;
     32 
     33 var setParentClass = function(child, parent) {
     34    child.prototype = Object.create(parent.prototype);
     35    child.prototype.constructor = child;
     36 };
     37 
     38 /**
     39 * @constructor
     40 * @extends {es3fApiCase.ApiCase}
     41 * @param {string} name
     42 * @param {string} description
     43 * @param {number} internalFormat
     44 * @param {boolean} isIntegerInternalFormat
     45 */
     46 es3fInternalFormatQueryTests.SamplesCase = function(name, description, internalFormat, isIntegerInternalFormat) {
     47    es3fApiCase.ApiCase.call(this, name, description, gl);
     48    this.m_internalFormat = internalFormat;
     49    this.m_isIntegerInternalFormat = isIntegerInternalFormat;
     50 };
     51 
     52 setParentClass(es3fInternalFormatQueryTests.SamplesCase, es3fApiCase.ApiCase);
     53 
     54 es3fInternalFormatQueryTests.SamplesCase.prototype.test = function() {
     55    var samples = gl.getInternalformatParameter(gl.RENDERBUFFER, this.m_internalFormat, gl.SAMPLES);
     56 
     57    this.check(!this.m_isIntegerInternalFormat || samples.length == 0, 'integer internal format should have 0 samples, got ' + samples.length);
     58 
     59    if (samples.length == 0)
     60        return;
     61 
     62    var prevSampleCount = 0;
     63    var sampleCount = 0;
     64    for (var ndx = 0; ndx < samples.length; ++ndx, prevSampleCount = sampleCount) {
     65        sampleCount = samples[ndx];
     66 
     67        // sample count must be > 0
     68        this.check(sampleCount > 0, 'Expected sample count to be at least one; got ' + sampleCount);
     69 
     70        // samples must be ordered descending
     71        this.check(ndx == 0 || sampleCount < prevSampleCount, 'Expected sample count to be ordered in descending order; got ' + prevSampleCount + ' at index ' + (ndx - 1) + ', and ' + sampleCount + ' at index ' + ndx);
     72    }
     73 
     74    // the maximum value in SAMPLES is guaranteed to be at least the value of MAX_SAMPLES
     75    var maxSamples = /** @type {number} */ (gl.getParameter(gl.MAX_SAMPLES));
     76    var maximumFormatSampleCount = samples[0];
     77    this.check(maximumFormatSampleCount >= maxSamples, 'Expected maximum value in SAMPLES (' + maximumFormatSampleCount + ') to be at least the value of MAX_SAMPLES (' + maxSamples + ')');
     78 };
     79 
     80 /**
     81 * @constructor
     82 * @extends {tcuTestCase.DeqpTest}
     83 */
     84 es3fInternalFormatQueryTests.InternalFormatQueryTests = function() {
     85    tcuTestCase.DeqpTest.call(this, 'internal_format', 'Internal Format Query tests');
     86 };
     87 
     88 es3fInternalFormatQueryTests.InternalFormatQueryTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
     89 es3fInternalFormatQueryTests.InternalFormatQueryTests.prototype.constructor = es3fInternalFormatQueryTests.InternalFormatQueryTests;
     90 
     91 es3fInternalFormatQueryTests.InternalFormatQueryTests.prototype.init = function() {
     92    var internalFormats = [
     93        //name, format, is_integer
     94        // color renderable and unsized
     95        // \note These unsized formats seem to allowed by the spec, but they are not useful in any way. (You can't create a renderbuffer with such internalFormat)
     96        ['rgba', gl.RGBA, false],
     97        ['rgb', gl.RGB, false],
     98 
     99        // color renderable
    100        ['r8', gl.R8, false],
    101        ['rg8', gl.RG8, false],
    102        ['rgb8', gl.RGB8, false],
    103        ['rgb565', gl.RGB565, false],
    104        ['rgba4', gl.RGBA4, false],
    105        ['rgb5_a1', gl.RGB5_A1, false],
    106        ['rgba8', gl.RGBA8, false],
    107        ['rgb10_a2', gl.RGB10_A2, false],
    108        ['rgb10_a2ui', gl.RGB10_A2UI, true],
    109        ['srgb8_alpha8', gl.SRGB8_ALPHA8, false],
    110        ['r8i', gl.R8I, true],
    111        ['r8ui', gl.R8UI, true],
    112        ['r16i', gl.R16I, true],
    113        ['r16ui', gl.R16UI, true],
    114        ['r32i', gl.R32I, true],
    115        ['r32ui', gl.R32UI, true],
    116        ['rg8i', gl.RG8I, true],
    117        ['rg8ui', gl.RG8UI, true],
    118        ['rg16i', gl.RG16I, true],
    119        ['rg16ui', gl.RG16UI, true],
    120        ['rg32i', gl.RG32I, true],
    121        ['rg32ui', gl.RG32UI, true],
    122        ['rgba8i', gl.RGBA8I, true],
    123        ['rgba8ui', gl.RGBA8UI, true],
    124        ['rgba16i', gl.RGBA16I, true],
    125        ['rgba16ui', gl.RGBA16UI, true],
    126        ['rgba32i', gl.RGBA32I, true],
    127        ['rgba32ui', gl.RGBA32UI, true],
    128 
    129        // depth renderable
    130        ['depth_component16', gl.DEPTH_COMPONENT16, false],
    131        ['depth_component24', gl.DEPTH_COMPONENT24, false],
    132        ['depth_component32f', gl.DEPTH_COMPONENT32F, false],
    133        ['depth24_stencil8', gl.DEPTH24_STENCIL8, false],
    134        ['depth32f_stencil8', gl.DEPTH32F_STENCIL8, false],
    135 
    136        // stencil renderable
    137        ['stencil_index8', gl.STENCIL_INDEX8, false]
    138        // DEPTH24_STENCIL8, duplicate
    139        // DEPTH32F_STENCIL8 duplicate
    140    ];
    141 
    142    for (var ndx = 0; ndx < internalFormats.length; ++ndx) {
    143        var internalFormat = internalFormats[ndx];
    144 
    145        this.addChild(new es3fInternalFormatQueryTests.SamplesCase(internalFormat[0] + '_samples', 'SAMPLES and NUM_SAMPLE_COUNTS', internalFormat[1], internalFormat[2]));
    146    }
    147 };
    148 
    149 /**
    150 * Run test
    151 * @param {WebGL2RenderingContext} context
    152 */
    153 es3fInternalFormatQueryTests.run = function(context) {
    154    gl = context;
    155    //Set up Test Root parameters
    156    var state = tcuTestCase.runner;
    157    state.setRoot(new es3fInternalFormatQueryTests.InternalFormatQueryTests());
    158 
    159    //Set up name and description of this test series.
    160    setCurrentTestName(state.testCases.fullName());
    161    description(state.testCases.getDescription());
    162 
    163    try {
    164        //Run test cases
    165        tcuTestCase.runTestCases();
    166    }
    167    catch (err) {
    168        testFailedOptions('Failed to es3fInternalFormatQueryTests.run tests', false);
    169        tcuTestCase.runner.terminate();
    170    }
    171 };
    172 
    173 });