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.
22 goog.provide('functional.gles3.es3fInternalFormatQueryTests');
23 goog.require('framework.common.tcuTestCase');
24 goog.require('functional.gles3.es3fApiCase');
25 goog.require('modules.shared.glsStateQuery');
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;
33 var setParentClass = function(child, parent) {
34 child.prototype = Object.create(parent.prototype);
35 child.prototype.constructor = child;
40 * @extends {es3fApiCase.ApiCase}
41 * @param {string} name
42 * @param {string} description
43 * @param {number} internalFormat
44 * @param {boolean} isIntegerInternalFormat
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;
52 setParentClass(es3fInternalFormatQueryTests.SamplesCase, es3fApiCase.ApiCase);
54 es3fInternalFormatQueryTests.SamplesCase.prototype.test = function() {
55 var samples = gl.getInternalformatParameter(gl.RENDERBUFFER, this.m_internalFormat, gl.SAMPLES);
57 this.check(!this.m_isIntegerInternalFormat || samples.length == 0, 'integer internal format should have 0 samples, got ' + samples.length);
59 if (samples.length == 0)
62 var prevSampleCount = 0;
64 for (var ndx = 0; ndx < samples.length; ++ndx, prevSampleCount = sampleCount) {
65 sampleCount = samples[ndx];
67 // sample count must be > 0
68 this.check(sampleCount > 0, 'Expected sample count to be at least one; got ' + sampleCount);
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);
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 + ')');
82 * @extends {tcuTestCase.DeqpTest}
84 es3fInternalFormatQueryTests.InternalFormatQueryTests = function() {
85 tcuTestCase.DeqpTest.call(this, 'internal_format', 'Internal Format Query tests');
88 es3fInternalFormatQueryTests.InternalFormatQueryTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
89 es3fInternalFormatQueryTests.InternalFormatQueryTests.prototype.constructor = es3fInternalFormatQueryTests.InternalFormatQueryTests;
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],
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],
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],
136 // stencil renderable
137 ['stencil_index8', gl.STENCIL_INDEX8, false]
138 // DEPTH24_STENCIL8, duplicate
139 // DEPTH32F_STENCIL8 duplicate
142 for (var ndx = 0; ndx < internalFormats.length; ++ndx) {
143 var internalFormat = internalFormats[ndx];
145 this.addChild(new es3fInternalFormatQueryTests.SamplesCase(internalFormat[0] + '_samples', 'SAMPLES and NUM_SAMPLE_COUNTS', internalFormat[1], internalFormat[2]));
151 * @param {WebGL2RenderingContext} context
153 es3fInternalFormatQueryTests.run = function(context) {
155 //Set up Test Root parameters
156 var state = tcuTestCase.runner;
157 state.setRoot(new es3fInternalFormatQueryTests.InternalFormatQueryTests());
159 //Set up name and description of this test series.
160 setCurrentTestName(state.testCases.fullName());
161 description(state.testCases.getDescription());
165 tcuTestCase.runTestCases();
168 testFailedOptions('Failed to es3fInternalFormatQueryTests.run tests', false);
169 tcuTestCase.runner.terminate();