tor-browser

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

es3fAttribLocationTests.js (12072B)


      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 Attribute location test
     22 *//*--------------------------------------------------------------------*/
     23 'use strict';
     24 goog.provide('functional.gles3.es3fAttribLocationTests');
     25 goog.require('framework.opengl.gluShaderUtil');
     26 goog.require('modules.shared.glsAttributeLocationTests');
     27 
     28 goog.scope(function() {
     29 
     30    var es3fAttribLocationTests = functional.gles3.es3fAttribLocationTests;
     31    var glsAttributeLocationTests = modules.shared.glsAttributeLocationTests;
     32    var tcuTestCase = framework.common.tcuTestCase;
     33    var gluShaderUtil = framework.opengl.gluShaderUtil;
     34 
     35    es3fAttribLocationTests.createAttributeLocationTests = function() {
     36 
     37        /** @type {Array<glsAttributeLocationTests.AttribType>} */
     38        var types = [
     39            new glsAttributeLocationTests.AttribType('float', 1, gl.FLOAT),
     40            new glsAttributeLocationTests.AttribType('vec2', 1, gl.FLOAT_VEC2),
     41            new glsAttributeLocationTests.AttribType('vec3', 1, gl.FLOAT_VEC3),
     42            new glsAttributeLocationTests.AttribType('vec4', 1, gl.FLOAT_VEC4),
     43 
     44            new glsAttributeLocationTests.AttribType('mat2', 2, gl.FLOAT_MAT2),
     45            new glsAttributeLocationTests.AttribType('mat3', 3, gl.FLOAT_MAT3),
     46            new glsAttributeLocationTests.AttribType('mat4', 4, gl.FLOAT_MAT4),
     47 
     48            new glsAttributeLocationTests.AttribType('int', 1, gl.INT),
     49            new glsAttributeLocationTests.AttribType('ivec2', 1, gl.INT_VEC2),
     50            new glsAttributeLocationTests.AttribType('ivec3', 1, gl.INT_VEC3),
     51            new glsAttributeLocationTests.AttribType('ivec4', 1, gl.INT_VEC4),
     52 
     53            new glsAttributeLocationTests.AttribType('uint', 1, gl.UNSIGNED_INT),
     54            new glsAttributeLocationTests.AttribType('uvec2', 1, gl.UNSIGNED_INT_VEC2),
     55            new glsAttributeLocationTests.AttribType('uvec3', 1, gl.UNSIGNED_INT_VEC3),
     56            new glsAttributeLocationTests.AttribType('uvec4', 1, gl.UNSIGNED_INT_VEC4),
     57 
     58            new glsAttributeLocationTests.AttribType('mat2x2', 2, gl.FLOAT_MAT2),
     59            new glsAttributeLocationTests.AttribType('mat2x3', 2, gl.FLOAT_MAT2x3),
     60            new glsAttributeLocationTests.AttribType('mat2x4', 2, gl.FLOAT_MAT2x4),
     61 
     62            new glsAttributeLocationTests.AttribType('mat3x2', 3, gl.FLOAT_MAT3x2),
     63            new glsAttributeLocationTests.AttribType('mat3x3', 3, gl.FLOAT_MAT3),
     64            new glsAttributeLocationTests.AttribType('mat3x4', 3, gl.FLOAT_MAT3x4),
     65 
     66            new glsAttributeLocationTests.AttribType('mat4x2', 4, gl.FLOAT_MAT4x2),
     67            new glsAttributeLocationTests.AttribType('mat4x3', 4, gl.FLOAT_MAT4x3),
     68            new glsAttributeLocationTests.AttribType('mat4x4', 4, gl.FLOAT_MAT4)
     69        ];
     70 
     71        /** @type {Array<glsAttributeLocationTests.AttribType>} */
     72        var es2Types = [
     73            new glsAttributeLocationTests.AttribType('float', 1, gl.FLOAT),
     74            new glsAttributeLocationTests.AttribType('vec2', 1, gl.FLOAT_VEC2),
     75            new glsAttributeLocationTests.AttribType('vec3', 1, gl.FLOAT_VEC3),
     76            new glsAttributeLocationTests.AttribType('vec4', 1, gl.FLOAT_VEC4),
     77 
     78            new glsAttributeLocationTests.AttribType('mat2', 2, gl.FLOAT_MAT2),
     79            new glsAttributeLocationTests.AttribType('mat3', 3, gl.FLOAT_MAT3),
     80            new glsAttributeLocationTests.AttribType('mat4', 4, gl.FLOAT_MAT4)
     81        ];
     82 
     83        /** @type {tcuTestCase.DeqpTest} */
     84        var root = tcuTestCase.newTest('attribute_location', 'Attribute location tests');
     85 
     86        /** @type {number} */ var typeNdx;
     87        /** @type {glsAttributeLocationTests.AttribType} */ var type;
     88 
     89        // Basic bind attribute tests
     90        /** @type {tcuTestCase.DeqpTest} */
     91        var bindAttributeGroup = tcuTestCase.newTest('bind', 'Basic bind attribute location tests.');
     92 
     93        root.addChild(bindAttributeGroup);
     94 
     95        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
     96            type = types[typeNdx];
     97            bindAttributeGroup.addChild(new glsAttributeLocationTests.BindAttributeTest(type));
     98        }
     99 
    100        // Bind max number of attributes
    101        /** @type {tcuTestCase.DeqpTest} */
    102        var bindMaxAttributeGroup = tcuTestCase.newTest('bind_max_attributes', 'Use bind with maximum number of attributes.');
    103 
    104        root.addChild(bindMaxAttributeGroup);
    105 
    106        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    107            type = types[typeNdx];
    108            bindMaxAttributeGroup.addChild(new glsAttributeLocationTests.BindMaxAttributesTest(type));
    109        }
    110 
    111        // Test filling holes in attribute location
    112        /** @type {tcuTestCase.DeqpTest} */
    113        var holeGroup = tcuTestCase.newTest('bind_hole', 'Bind all, but one attribute and leave hole in location space for it.');
    114 
    115        root.addChild(holeGroup);
    116 
    117        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    118            type = types[typeNdx];
    119 
    120            // Bind first location, leave hole size of type and fill rest of locations
    121            holeGroup.addChild(new glsAttributeLocationTests.BindHoleAttributeTest(type));
    122        }
    123 
    124        // Test binding at different times
    125        /** @type {tcuTestCase.DeqpTest} */
    126        var bindTimeGroup = tcuTestCase.newTest('bind_time', 'Bind time tests. Test binding at different stages.');
    127 
    128        root.addChild(bindTimeGroup);
    129 
    130        bindTimeGroup.addChild(new glsAttributeLocationTests.PreAttachBindAttributeTest());
    131        bindTimeGroup.addChild(new glsAttributeLocationTests.PreLinkBindAttributeTest());
    132        bindTimeGroup.addChild(new glsAttributeLocationTests.PostLinkBindAttributeTest());
    133        bindTimeGroup.addChild(new glsAttributeLocationTests.BindRelinkAttributeTest());
    134        bindTimeGroup.addChild(new glsAttributeLocationTests.BindReattachAttributeTest());
    135 
    136        // Basic layout location attribute tests
    137        /** @type {tcuTestCase.DeqpTest} */
    138        var layoutAttributeGroup = tcuTestCase.newTest('layout', 'Basic layout location tests.');
    139 
    140        root.addChild(layoutAttributeGroup);
    141 
    142        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    143            type = types[typeNdx];
    144            layoutAttributeGroup.addChild(new glsAttributeLocationTests.LocationAttributeTest(type));
    145        }
    146 
    147        // Test max attributes with layout locations
    148        /** @type {tcuTestCase.DeqpTest} */
    149        var layoutMaxAttributeGroup = tcuTestCase.newTest('layout_max_attributes', 'Maximum attributes used with layout location qualifiers.');
    150 
    151        root.addChild(layoutMaxAttributeGroup);
    152 
    153        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    154            type = types[typeNdx];
    155            layoutMaxAttributeGroup.addChild(new glsAttributeLocationTests.LocationMaxAttributesTest(type));
    156        }
    157 
    158        // Test filling holes in attribute location
    159        holeGroup = tcuTestCase.newTest('layout_hole', 'Define layout location for all, but one attribute consuming max attribute locations.');
    160 
    161        root.addChild(holeGroup);
    162 
    163        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    164            type = types[typeNdx];
    165 
    166            // Location first location, leave hole size of type and fill rest of locations
    167            holeGroup.addChild(new glsAttributeLocationTests.LocationHoleAttributeTest(type));
    168        }
    169 
    170        // Basic mixed mixed attribute tests
    171        /** @type {tcuTestCase.DeqpTest} */
    172        var mixedAttributeGroup = tcuTestCase.newTest('mixed', 'Basic mixed location tests.');
    173 
    174        root.addChild(mixedAttributeGroup);
    175 
    176        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    177            type = types[typeNdx];
    178            mixedAttributeGroup.addChild(new glsAttributeLocationTests.MixedAttributeTest(type));
    179        }
    180 
    181        /** @type {tcuTestCase.DeqpTest} */
    182        var mixedMaxAttributeGroup = tcuTestCase.newTest('mixed_max_attributes', 'Maximum attributes used with mixed binding and layout qualifiers.');
    183 
    184        root.addChild(mixedMaxAttributeGroup);
    185 
    186        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    187            type = types[typeNdx];
    188            mixedMaxAttributeGroup.addChild(new glsAttributeLocationTests.MixedMaxAttributesTest(type));
    189        }
    190 
    191        // Test mixed binding at different times
    192        /** @type {tcuTestCase.DeqpTest} */
    193        var mixedTimeGroup = tcuTestCase.newTest('mixed_time', 'Bind time tests. Test binding at different stages.');
    194 
    195        root.addChild(mixedTimeGroup);
    196 
    197        mixedTimeGroup.addChild(new glsAttributeLocationTests.PreAttachMixedAttributeTest());
    198        mixedTimeGroup.addChild(new glsAttributeLocationTests.PreLinkMixedAttributeTest());
    199        mixedTimeGroup.addChild(new glsAttributeLocationTests.PostLinkMixedAttributeTest());
    200        mixedTimeGroup.addChild(new glsAttributeLocationTests.MixedRelinkAttributeTest());
    201        mixedTimeGroup.addChild(new glsAttributeLocationTests.MixedReattachAttributeTest());
    202 
    203        holeGroup = tcuTestCase.newTest('mixed_hole', 'Use layout location qualifiers and binding. Leave hole in location space for only free attribute.');
    204 
    205        root.addChild(holeGroup);
    206 
    207        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    208            type = types[typeNdx];
    209 
    210            holeGroup.addChild(new glsAttributeLocationTests.MixedHoleAttributeTest(type));
    211        }
    212 
    213        // Test hole in location space that moves when relinking
    214        /** @type {tcuTestCase.DeqpTest} */
    215        var relinkBindHoleGroup = tcuTestCase.newTest('bind_relink_hole', 'Test relinking with moving hole in attribute location space.');
    216 
    217        root.addChild(relinkBindHoleGroup);
    218 
    219        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    220            type = types[typeNdx];
    221 
    222            relinkBindHoleGroup.addChild(new glsAttributeLocationTests.BindRelinkHoleAttributeTest(type));
    223        }
    224 
    225        // Test hole in location space that moves when relinking
    226        /** @type {tcuTestCase.DeqpTest} */
    227        var relinkMixedHoleGroup = tcuTestCase.newTest('mixed_relink_hole', 'Test relinking with moving hole in attribute location space.');
    228 
    229        root.addChild(relinkMixedHoleGroup);
    230 
    231        for (typeNdx = 0; typeNdx < types.length; typeNdx++) {
    232            type = types[typeNdx];
    233 
    234            relinkMixedHoleGroup.addChild(new glsAttributeLocationTests.MixedRelinkHoleAttributeTest(type));
    235        }
    236 
    237        return root;
    238    };
    239 
    240    es3fAttribLocationTests.run = function(context) {
    241        gl = context;
    242        //Set up root Test
    243        var state = tcuTestCase.runner;
    244 
    245        var test = es3fAttribLocationTests.createAttributeLocationTests();
    246        var testName = test.fullName();
    247        var testDescription = test.getDescription() === undefined ? '' : test.getDescription();
    248 
    249        state.testName = testName;
    250        state.setRoot(test);
    251        //Set up name and description of this test series.
    252        setCurrentTestName(testName);
    253        description(testDescription);
    254 
    255        try {
    256            //Create test cases
    257            test.init();
    258            //Run test cases
    259            tcuTestCase.runTestCases();
    260        }
    261        catch (err) {
    262            bufferedLogToConsole('Exception: ' + err);
    263            testFailedOptions('Failed to es3fAttribLocationTests.run tests', false);
    264            tcuTestCase.runner.terminate();
    265        }
    266    };
    267 });