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.
21 goog.provide('functional.gles3.es3fTextureFormatTests');
22 goog.require('framework.common.tcuCompressedTexture');
23 goog.require('framework.common.tcuSurface');
24 goog.require('framework.common.tcuTestCase');
25 goog.require('framework.common.tcuTexture');
26 goog.require('framework.common.tcuTextureUtil');
27 goog.require('framework.delibs.debase.deMath');
28 goog.require('framework.delibs.debase.deRandom');
29 goog.require('framework.opengl.gluShaderUtil');
30 goog.require('framework.opengl.gluStrUtil');
31 goog.require('framework.opengl.gluTexture');
32 goog.require('framework.opengl.gluTextureUtil');
33 goog.require('modules.shared.glsTextureTestUtil');
35 goog.scope(function() {
37 var es3fTextureFormatTests = functional.gles3.es3fTextureFormatTests;
38 var gluShaderUtil = framework.opengl.gluShaderUtil;
39 var deRandom = framework.delibs.debase.deRandom;
40 var tcuTestCase = framework.common.tcuTestCase;
41 var tcuSurface = framework.common.tcuSurface;
42 var gluTexture = framework.opengl.gluTexture;
43 var gluTextureUtil = framework.opengl.gluTextureUtil;
44 var tcuTexture = framework.common.tcuTexture;
45 var glsTextureTestUtil = modules.shared.glsTextureTestUtil;
46 var tcuTextureUtil = framework.common.tcuTextureUtil;
47 var gluStrUtil = framework.opengl.gluStrUtil;
48 var deMath = framework.delibs.debase.deMath;
49 var tcuCompressedTexture = framework.common.tcuCompressedTexture;
51 /** @type {WebGL2RenderingContext} */ var gl;
53 var DE_ASSERT = function(x) {
55 throw new Error('Assert failed');
58 es3fTextureFormatTests.version = '300 es';
60 es3fTextureFormatTests.testDescription = function() {
61 var test = tcuTestCase.runner.currentTest;
62 return test.description;
65 es3fTextureFormatTests.setParentClass = function(child, parent) {
66 child.prototype = Object.create(parent.prototype);
67 child.prototype.constructor = child;
72 * @extends {tcuTestCase.DeqpTest}
74 es3fTextureFormatTests.Texture2DFormatCase = function(descriptor) {
75 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
76 this.m_format = descriptor.format;
77 this.m_dataType = descriptor.dataType;
78 this.m_width = descriptor.width;
79 this.m_height = descriptor.height;
80 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
83 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture2DFormatCase, tcuTestCase.DeqpTest);
85 es3fTextureFormatTests.Texture2DFormatCase.prototype.init = function() {
86 /*tcu::TextureFormat*/ var fmt = this.m_dataType ? gluTextureUtil.mapGLTransferFormat(this.m_format, this.m_dataType) : gluTextureUtil.mapGLInternalFormat(this.m_format);
87 /*tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(fmt);
90 std::ostringstream fmtName;
93 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
95 fmtName << glu::getPixelFormatStr(m_format);
97 log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
98 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
99 << TestLog::EndMessage;
102 this.m_texture = this.m_dataType ?
103 gluTexture.texture2DFromFormat(gl, this.m_format, this.m_dataType, this.m_width, this.m_height) : // Implicit internal format.
104 gluTexture.texture2DFromInternalFormat(gl, this.m_format, this.m_width, this.m_height); // Explicit internal format.
107 this.m_texture.getRefTexture().allocLevel(0);
108 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
111 es3fTextureFormatTests.Texture2DFormatCase.prototype.deinit = function() {
112 /* TODO: Implement */
115 es3fTextureFormatTests.Texture2DFormatCase.prototype.iterate = function() {
116 /* TODO: Implement */
118 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
120 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
121 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
123 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
125 var threshold = [3, 3, 3, 3];
126 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D);
128 /* tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(this.m_texture.getRefTexture().getFormat());
129 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
130 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
131 /** @const */ var minFilter = gl.NEAREST;
132 /** @const */ var magFilter = gl.NEAREST;
134 renderParams.flags.log_programs = true;
135 renderParams.flags.log_uniforms = true;
137 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
138 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
139 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
140 renderParams.colorScale = spec.lookupScale;
141 renderParams.colorBias = spec.lookupBias;
143 var texCoord = glsTextureTestUtil.computeQuadTexCoord2D([0, 0], [1, 1]);
145 // log << TestLog::Message << "Texture parameters:"
146 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
147 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
148 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
149 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
150 // << TestLog::EndMessage;
152 // Setup base viewport.
153 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
155 // Upload texture data to GL.
156 this.m_texture.upload();
159 gl.activeTexture(gl.TEXTURE0);
160 gl.bindTexture(gl.TEXTURE_2D, this.m_texture.getGLTexture());
162 // Setup nearest neighbor filtering and clamp-to-edge.
163 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
164 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
165 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
166 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
169 this.m_renderer.renderQuad(0, texCoord, renderParams);
170 renderedFrame.readViewport(gl, viewport);
172 // // Compute reference.
173 glsTextureTestUtil.sampleTexture2D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
174 this.m_texture.getRefTexture(), texCoord, renderParams);
177 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold);
179 assertMsgOptions(isOk, es3fTextureFormatTests.testDescription(), true, false);
180 return tcuTestCase.IterateResult.STOP;
185 * @extends {tcuTestCase.DeqpTest}
187 es3fTextureFormatTests.TextureCubeFormatCase = function(descriptor) {
188 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
189 this.m_format = descriptor.format;
190 this.m_dataType = descriptor.dataType;
191 this.m_width = descriptor.width;
192 this.m_height = descriptor.height;
193 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
194 DE_ASSERT(this.m_width == this.m_height);
197 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.TextureCubeFormatCase, tcuTestCase.DeqpTest);
199 es3fTextureFormatTests.TextureCubeFormatCase.prototype.init = function() {
200 /*tcu::TextureFormat*/ var fmt = this.m_dataType ? gluTextureUtil.mapGLTransferFormat(this.m_format, this.m_dataType) : gluTextureUtil.mapGLInternalFormat(this.m_format);
201 /*tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(fmt);
204 std::ostringstream fmtName;
207 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
209 fmtName << glu::getPixelFormatStr(m_format);
211 log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
212 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
213 << TestLog::EndMessage;
216 this.m_texture = this.m_dataType ?
217 gluTexture.cubeFromFormat(gl, this.m_format, this.m_dataType, this.m_width) : // Implicit internal format.
218 gluTexture.cubeFromInternalFormat(gl, this.m_format, this.m_width); // Explicit internal format.
221 for (var face in tcuTexture.CubeFace) {
225 switch (tcuTexture.CubeFace[face]) {
226 case 0: gMin = deMath.swizzle(spec.valueMin, [0, 1, 2, 3]); gMax = deMath.swizzle(spec.valueMax, [0, 1, 2, 3]); break;
227 case 1: gMin = deMath.swizzle(spec.valueMin, [2, 1, 0, 3]); gMax = deMath.swizzle(spec.valueMax, [2, 1, 0, 3]); break;
228 case 2: gMin = deMath.swizzle(spec.valueMin, [1, 2, 0, 3]); gMax = deMath.swizzle(spec.valueMax, [1, 2, 0, 3]); break;
229 case 3: gMin = deMath.swizzle(spec.valueMax, [0, 1, 2, 3]); gMax = deMath.swizzle(spec.valueMin, [0, 1, 2, 3]); break;
230 case 4: gMin = deMath.swizzle(spec.valueMax, [2, 1, 0, 3]); gMax = deMath.swizzle(spec.valueMin, [2, 1, 0, 3]); break;
231 case 5: gMin = deMath.swizzle(spec.valueMax, [1, 2, 0, 3]); gMax = deMath.swizzle(spec.valueMin, [1, 2, 0, 3]); break;
236 this.m_texture.getRefTexture().allocLevel(tcuTexture.CubeFace[face], 0);
237 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevelFace(0, tcuTexture.CubeFace[face]), gMin, gMax);
240 this.m_texture.upload();
245 es3fTextureFormatTests.TextureCubeFormatCase.prototype.testFace = function(face) {
246 /* TODO: Implement */
248 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
250 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
251 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
253 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
255 var threshold = [3, 3, 3, 3];
256 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_CUBE);
258 /* tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(this.m_texture.getRefTexture().getFormat());
259 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
260 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
261 /** @const */ var minFilter = gl.NEAREST;
262 /** @const */ var magFilter = gl.NEAREST;
264 renderParams.flags.log_programs = true;
265 renderParams.flags.log_uniforms = true;
267 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
268 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
269 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
270 renderParams.colorScale = spec.lookupScale;
271 renderParams.colorBias = spec.lookupBias;
273 // Log render info on first face.
274 if (face === tcuTexture.CubeFace.CUBEFACE_NEGATIVE_X) {
275 renderParams.flags.log_programs = true;
276 renderParams.flags.log_uniforms = true;
279 var texCoord = glsTextureTestUtil.computeQuadTexCoordCube(face);
281 // log << TestLog::Message << "Texture parameters:"
282 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
283 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
284 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
285 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
286 // << TestLog::EndMessage;
288 // Setup base viewport.
289 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
292 gl.activeTexture(gl.TEXTURE0);
293 gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.m_texture.getGLTexture());
295 // Setup nearest neighbor filtering and clamp-to-edge.
296 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, wrapS);
297 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, wrapT);
298 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, minFilter);
299 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, magFilter);
302 this.m_renderer.renderQuad(0, texCoord, renderParams);
303 renderedFrame.readViewport(gl, viewport);
305 // // Compute reference.
306 glsTextureTestUtil.sampleTextureCube(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
307 this.m_texture.getRefTexture(), texCoord, renderParams);
310 var skipPixels = null;
311 if (renderParams.samplerType == glsTextureTestUtil.samplerType.SAMPLERTYPE_INT ||
312 renderParams.samplerType == glsTextureTestUtil.samplerType.SAMPLERTYPE_UINT) {
313 // Skip top right pixel due to Mac Intel driver bug.
314 // https://github.com/KhronosGroup/WebGL/issues/1819
316 [this.m_width - 1, this.m_height - 1]
319 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold, skipPixels);
321 assertMsgOptions(isOk, 'Face: ' + this.m_curFace + ' ' + es3fTextureFormatTests.testDescription(), true, false);
325 es3fTextureFormatTests.TextureCubeFormatCase.prototype.iterate = function() {
326 debug('Testing face ' + this.m_curFace);
327 // Execute test for all faces.
328 if (!this.testFace(this.m_curFace))
333 if (this.m_curFace < Object.keys(tcuTexture.CubeFace).length)
334 return tcuTestCase.IterateResult.CONTINUE;
336 return tcuTestCase.IterateResult.STOP;
341 * @extends {tcuTestCase.DeqpTest}
343 es3fTextureFormatTests.Texture2DArrayFormatCase = function(descriptor) {
344 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
345 this.m_format = descriptor.format;
346 this.m_dataType = descriptor.dataType;
347 this.m_width = descriptor.width;
348 this.m_height = descriptor.height;
349 this.m_numLayers = descriptor.numLayers;
350 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
353 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture2DArrayFormatCase, tcuTestCase.DeqpTest);
355 es3fTextureFormatTests.Texture2DArrayFormatCase.prototype.init = function() {
356 /*tcu::TextureFormat*/ var fmt = this.m_dataType ? gluTextureUtil.mapGLTransferFormat(this.m_format, this.m_dataType) : gluTextureUtil.mapGLInternalFormat(this.m_format);
357 /*tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(fmt);
360 std::ostringstream fmtName;
363 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
365 fmtName << glu::getPixelFormatStr(m_format);
367 log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
368 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
369 << TestLog::EndMessage;
372 this.m_texture = this.m_dataType ?
373 gluTexture.texture2DArrayFromFormat(gl, this.m_format, this.m_dataType, this.m_width, this.m_height, this.m_numLayers) : // Implicit internal format.
374 gluTexture.texture2DArrayFromInternalFormat(gl, this.m_format, this.m_width, this.m_height, this.m_numLayers); // Explicit internal format.
376 this.m_texture.getRefTexture().allocLevel(0);
377 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
383 es3fTextureFormatTests.Texture2DArrayFormatCase.prototype.testLayer = function(layerNdx) {
384 /* TODO: Implement */
386 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
388 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
389 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
391 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
393 var threshold = [3, 3, 3, 3];
394 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D_ARRAY);
396 /* tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(this.m_texture.getRefTexture().getFormat());
397 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
398 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
399 /** @const */ var minFilter = gl.NEAREST;
400 /** @const */ var magFilter = gl.NEAREST;
402 renderParams.flags.log_programs = true;
403 renderParams.flags.log_uniforms = true;
405 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
406 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
407 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
408 renderParams.colorScale = spec.lookupScale;
409 renderParams.colorBias = spec.lookupBias;
411 var texCoord = glsTextureTestUtil.computeQuadTexCoord2DArray(layerNdx, [0, 0], [1, 1]);
413 // log << TestLog::Message << "Texture parameters:"
414 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
415 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
416 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
417 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
418 // << TestLog::EndMessage;
420 // Setup base viewport.
421 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
423 this.m_texture.upload();
426 gl.activeTexture(gl.TEXTURE0);
427 gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.m_texture.getGLTexture());
429 // Setup nearest neighbor filtering and clamp-to-edge.
430 gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_WRAP_S, wrapS);
431 gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_WRAP_T, wrapT);
432 gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, minFilter);
433 gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, magFilter);
436 this.m_renderer.renderQuad(0, texCoord, renderParams);
437 renderedFrame.readViewport(gl, viewport);
439 // // Compute reference.
440 glsTextureTestUtil.sampleTexture2DArray(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
441 this.m_texture.getRefTexture().getView(), texCoord, renderParams);
444 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold);
446 assertMsgOptions(isOk, 'Layer: ' + this.m_curLayer + ' ' + es3fTextureFormatTests.testDescription(), true, false);
450 es3fTextureFormatTests.Texture2DArrayFormatCase.prototype.iterate = function() {
451 debug('Testing layer ' + this.m_curLayer);
452 // Execute test for all layers.
453 if (!this.testLayer(this.m_curLayer))
456 this.m_curLayer += 1;
458 if (this.m_curLayer == this.m_numLayers)
459 return tcuTestCase.IterateResult.STOP;
461 return tcuTestCase.IterateResult.CONTINUE;
466 * @extends {tcuTestCase.DeqpTest}
468 es3fTextureFormatTests.Texture3DFormatCase = function(descriptor) {
469 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
470 this.m_format = descriptor.format;
471 this.m_dataType = descriptor.dataType;
472 this.m_width = descriptor.width;
473 this.m_height = descriptor.height;
474 this.m_depth = descriptor.depth;
475 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
478 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture3DFormatCase, tcuTestCase.DeqpTest);
480 es3fTextureFormatTests.Texture3DFormatCase.prototype.init = function() {
481 /*tcu::TextureFormat*/ var fmt = this.m_dataType ? gluTextureUtil.mapGLTransferFormat(this.m_format, this.m_dataType) : gluTextureUtil.mapGLInternalFormat(this.m_format);
482 /*tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(fmt);
485 std::ostringstream fmtName;
488 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
490 fmtName << glu::getPixelFormatStr(m_format);
492 log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
493 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
494 << TestLog::EndMessage;
497 this.m_texture = this.m_dataType ?
498 gluTexture.texture3DFromFormat(gl, this.m_format, this.m_dataType, this.m_width, this.m_height, this.m_depth) : // Implicit internal format.
499 gluTexture.texture3DFromInternalFormat(gl, this.m_format, this.m_width, this.m_height, this.m_depth); // Explicit internal format.
501 this.m_texture.getRefTexture().allocLevel(0);
502 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
508 es3fTextureFormatTests.Texture3DFormatCase.prototype.testSlice = function(sliceNdx) {
509 /* TODO: Implement */
511 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
513 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
514 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
516 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
518 var threshold = [3, 3, 3, 3];
519 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_3D);
521 /* tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(this.m_texture.getRefTexture().getFormat());
522 var r = (sliceNdx + 0.5) / this.m_depth;
523 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
524 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
525 /** @const */ var minFilter = gl.NEAREST;
526 /** @const */ var magFilter = gl.NEAREST;
528 renderParams.flags.log_programs = true;
529 renderParams.flags.log_uniforms = true;
531 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
532 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
533 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
534 renderParams.colorScale = spec.lookupScale;
535 renderParams.colorBias = spec.lookupBias;
537 var texCoord = glsTextureTestUtil.computeQuadTexCoord3D([0, 0, r], [1, 1, r], [0, 1, 2]);
539 // log << TestLog::Message << "Texture parameters:"
540 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
541 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
542 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
543 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
544 // << TestLog::EndMessage;
546 // Setup base viewport.
547 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
549 this.m_texture.upload();
552 gl.activeTexture(gl.TEXTURE0);
553 gl.bindTexture(gl.TEXTURE_3D, this.m_texture.getGLTexture());
555 // Setup nearest neighbor filtering and clamp-to-edge.
556 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_S, wrapS);
557 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_T, wrapT);
558 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, minFilter);
559 gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, magFilter);
562 this.m_renderer.renderQuad(0, texCoord, renderParams);
563 renderedFrame.readViewport(gl, viewport);
565 // // Compute reference.
566 glsTextureTestUtil.sampleTexture3D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
567 this.m_texture.getRefTexture(), texCoord, renderParams);
570 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold);
572 assertMsgOptions(isOk, 'Slice: ' + this.m_curSlice + ' ' + es3fTextureFormatTests.testDescription(), true, false);
576 es3fTextureFormatTests.Texture3DFormatCase.prototype.iterate = function() {
577 debug('Testing slice ' + this.m_curSlice);
578 // Execute test for all layers.
579 if (!this.testSlice(this.m_curSlice))
582 this.m_curSlice += 1;
584 if (this.m_curSlice >= this.m_depth)
585 return tcuTestCase.IterateResult.STOP;
587 return tcuTestCase.IterateResult.CONTINUE;
592 * @extends {tcuTestCase.DeqpTest}
594 es3fTextureFormatTests.Compressed2DFormatCase = function(descriptor) {
595 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
596 this.m_format = descriptor.format;
597 this.m_dataType = descriptor.dataType;
598 this.m_width = descriptor.width;
599 this.m_height = descriptor.height;
600 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
603 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Compressed2DFormatCase, tcuTestCase.DeqpTest);
605 es3fTextureFormatTests.Compressed2DFormatCase.prototype.init = function() {
606 var compressed = new tcuCompressedTexture.CompressedTexture(this.m_format, this.m_width, this.m_height);
607 var rand = new deRandom.Random(0);
608 for (var i = 0; i < compressed.m_data.length; i++) {
609 compressed.m_data[i] = rand.getInt(0, 255);
611 this.m_texture = gluTexture.compressed2DFromInternalFormat(gl, this.m_format, this.m_width, this.m_height, compressed);
614 es3fTextureFormatTests.Compressed2DFormatCase.prototype.deinit = function() {
615 /* TODO: Implement */
618 es3fTextureFormatTests.Compressed2DFormatCase.prototype.iterate = function() {
619 /* TODO: Implement */
621 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
623 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
624 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
626 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
628 var threshold = [3, 3, 3, 3];
629 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D);
631 /* tcu::TextureFormatInfo*/ var spec = tcuTextureUtil.getTextureFormatInfo(this.m_texture.getRefTexture().getFormat());
632 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
633 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
634 /** @const */ var minFilter = gl.NEAREST;
635 /** @const */ var magFilter = gl.NEAREST;
637 renderParams.flags.log_programs = true;
638 renderParams.flags.log_uniforms = true;
640 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
641 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
642 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
643 renderParams.colorScale = spec.lookupScale;
644 renderParams.colorBias = spec.lookupBias;
646 var texCoord = glsTextureTestUtil.computeQuadTexCoord2D([0, 0], [1, 1]);
648 // log << TestLog::Message << "Texture parameters:"
649 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
650 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
651 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
652 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
653 // << TestLog::EndMessage;
655 // Setup base viewport.
656 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
659 gl.activeTexture(gl.TEXTURE0);
660 gl.bindTexture(gl.TEXTURE_2D, this.m_texture.getGLTexture());
662 // Setup nearest neighbor filtering and clamp-to-edge.
663 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
664 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
665 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
666 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
669 this.m_renderer.renderQuad(0, texCoord, renderParams);
670 renderedFrame.readViewport(gl, viewport);
672 // // Compute reference.
673 glsTextureTestUtil.sampleTexture2D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
674 this.m_texture.getRefTexture(), texCoord, renderParams);
677 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold);
679 assertMsgOptions(isOk, es3fTextureFormatTests.testDescription(), true, false);
680 return tcuTestCase.IterateResult.STOP;
685 * @extends {tcuTestCase.DeqpTest}
687 es3fTextureFormatTests.CompressedCubeFormatCase = function(descriptor) {
688 tcuTestCase.DeqpTest.call(this, descriptor.name, descriptor.description);
689 this.m_format = descriptor.format;
690 this.m_dataType = descriptor.dataType;
691 this.m_width = descriptor.width;
692 this.m_height = descriptor.height;
693 this.m_renderer = new glsTextureTestUtil.TextureRenderer(es3fTextureFormatTests.version, gluShaderUtil.precision.PRECISION_HIGHP);
696 DE_ASSERT(this.m_width == this.m_height);
699 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.CompressedCubeFormatCase, tcuTestCase.DeqpTest);
701 es3fTextureFormatTests.CompressedCubeFormatCase.prototype.init = function() {
702 var compressed = new tcuCompressedTexture.CompressedTexture(this.m_format, this.m_width, this.m_height);
703 var rand = new deRandom.Random(0);
704 for (var i = 0; i < compressed.m_data.length; i++) {
705 compressed.m_data[i] = rand.getInt(0, 255);
707 this.m_texture = gluTexture.compressedCubeFromInternalFormat(gl, this.m_format, this.m_width, compressed);
710 es3fTextureFormatTests.CompressedCubeFormatCase.prototype.testFace = function(face) {
711 /* TODO: Implement */
713 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/);
715 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height);
716 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height);
718 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
720 // Threshold high enough to cover numerical errors in software decoders on Windows and Mac. Threshold is 17 in native dEQP.
721 var threshold = [6, 6, 6, 6];
722 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_CUBE);
724 /** @const */ var wrapS = gl.CLAMP_TO_EDGE;
725 /** @const */ var wrapT = gl.CLAMP_TO_EDGE;
726 /** @const */ var minFilter = gl.NEAREST;
727 /** @const */ var magFilter = gl.NEAREST;
729 renderParams.flags.log_programs = true;
730 renderParams.flags.log_uniforms = true;
732 renderParams.samplerType = glsTextureTestUtil.getSamplerType(this.m_texture.getRefTexture().getFormat());
733 renderParams.sampler = new tcuTexture.Sampler(tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE, tcuTexture.WrapMode.CLAMP_TO_EDGE,
734 tcuTexture.FilterMode.NEAREST, tcuTexture.FilterMode.NEAREST);
736 // Log render info on first face.
737 if (face === tcuTexture.CubeFace.CUBEFACE_NEGATIVE_X) {
738 renderParams.flags.log_programs = true;
739 renderParams.flags.log_uniforms = true;
742 var texCoord = glsTextureTestUtil.computeQuadTexCoordCube(face);
744 // log << TestLog::Message << "Texture parameters:"
745 // << "\n WRAP_S = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_S, wrapS)
746 // << "\n WRAP_T = " << glu::getTextureParameterValueStr(gl.TEXTURE_WRAP_T, wrapT)
747 // << "\n MIN_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MIN_FILTER, minFilter)
748 // << "\n MAG_FILTER = " << glu::getTextureParameterValueStr(gl.TEXTURE_MAG_FILTER, magFilter)
749 // << TestLog::EndMessage;
751 // Setup base viewport.
752 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
755 gl.activeTexture(gl.TEXTURE0);
756 gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.m_texture.getGLTexture());
758 // Setup nearest neighbor filtering and clamp-to-edge.
759 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, wrapS);
760 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, wrapT);
761 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, minFilter);
762 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, magFilter);
765 this.m_renderer.renderQuad(0, texCoord, renderParams);
766 renderedFrame.readViewport(gl, viewport);
768 // // Compute reference.
769 glsTextureTestUtil.sampleTextureCube(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/),
770 this.m_texture.getRefTexture(), texCoord, renderParams);
773 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold);
775 assertMsgOptions(isOk, 'Face: ' + this.m_curFace + ' ' + es3fTextureFormatTests.testDescription(), true, false);
779 es3fTextureFormatTests.CompressedCubeFormatCase.prototype.iterate = function() {
780 debug('Testing face ' + this.m_curFace);
781 // Execute test for all faces.
782 if (!this.testFace(this.m_curFace))
787 if (this.m_curFace < Object.keys(tcuTexture.CubeFace).length)
788 return tcuTestCase.IterateResult.CONTINUE;
790 return tcuTestCase.IterateResult.STOP;
793 es3fTextureFormatTests.genTestCases = function() {
794 var state = tcuTestCase.runner;
795 state.setRoot(tcuTestCase.newTest('texture_format', 'Top level'));
798 ['alpha', gl.ALPHA, gl.UNSIGNED_BYTE],
799 ['luminance', gl.LUMINANCE, gl.UNSIGNED_BYTE],
800 ['luminance_alpha', gl.LUMINANCE_ALPHA, gl.UNSIGNED_BYTE],
801 ['rgb_unsigned_short_5_6_5', gl.RGB, gl.UNSIGNED_SHORT_5_6_5],
802 ['rgb_unsigned_byte', gl.RGB, gl.UNSIGNED_BYTE],
803 ['rgba_unsigned_short_4_4_4_4', gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4],
804 ['rgba_unsigned_short_5_5_5_1', gl.RGBA, gl.UNSIGNED_SHORT_5_5_5_1],
805 ['rgba_unsigned_byte', gl.RGBA, gl.UNSIGNED_BYTE]
808 var unsized2DGroup = tcuTestCase.newTest('unsized', 'Unsized formats (2D, Cubemap)');
809 state.testCases.addChild(unsized2DGroup);
810 var unsized2DArrayGroup = tcuTestCase.newTest('unsized', 'Unsized formats (2D Array)');
811 state.testCases.addChild(unsized2DArrayGroup);
812 var unsized3DGroup = tcuTestCase.newTest('unsized', 'Unsized formats (3D)');
813 state.testCases.addChild(unsized3DGroup);
815 texFormats.forEach(function(elem) {
816 var format = elem[1];
817 var dataType = elem[2];
818 var nameBase = elem[0];
819 var descriptionBase = gluStrUtil.getPixelFormatName(format) + ', ' + gluStrUtil.getTypeName(dataType);
820 unsized2DGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({
821 name: nameBase + '_2d_pot',
822 description: descriptionBase + ' gl.TEXTURE_2D',
828 unsized2DGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({
829 name: nameBase + '_2d_npot',
830 description: descriptionBase + ' gl.TEXTURE_2D',
836 unsized2DGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
837 name: nameBase + '_cube_pot',
838 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
844 unsized2DGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
845 name: nameBase + '_cube_npot',
846 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
852 unsized2DArrayGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
853 name: nameBase + '_2d_array_pot',
854 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
861 unsized2DArrayGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
862 name: nameBase + '_2d_array_npot',
863 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
870 unsized3DGroup.addChild(new es3fTextureFormatTests.Texture3DFormatCase({
871 name: nameBase + '_3d_pot',
872 description: descriptionBase + ' gl.TEXTURE_3D',
879 unsized3DGroup.addChild(new es3fTextureFormatTests.Texture3DFormatCase({
880 name: nameBase + '_3d_npot',
881 description: descriptionBase + ' gl.TEXTURE_3D',
890 var sizedColorFormats = [
891 ['rgba32f', gl.RGBA32F],
892 ['rgba32i', gl.RGBA32I],
893 ['rgba32ui', gl.RGBA32UI],
894 ['rgba16f', gl.RGBA16F],
895 ['rgba16i', gl.RGBA16I],
896 ['rgba16ui', gl.RGBA16UI],
898 ['rgba8i', gl.RGBA8I],
899 ['rgba8ui', gl.RGBA8UI],
900 ['srgb8_alpha8', gl.SRGB8_ALPHA8],
901 ['rgb10_a2', gl.RGB10_A2],
902 ['rgb10_a2ui', gl.RGB10_A2UI],
904 ['rgb5_a1', gl.RGB5_A1],
905 ['rgba8_snorm', gl.RGBA8_SNORM],
907 ['rgb565', gl.RGB565],
908 ['r11f_g11f_b10f', gl.R11F_G11F_B10F],
909 ['rgb32f', gl.RGB32F],
910 ['rgb32i', gl.RGB32I],
911 ['rgb32ui', gl.RGB32UI],
912 ['rgb16f', gl.RGB16F],
913 ['rgb16i', gl.RGB16I],
914 ['rgb16ui', gl.RGB16UI],
915 ['rgb8_snorm', gl.RGB8_SNORM],
917 ['rgb8ui', gl.RGB8UI],
919 ['rgb9_e5', gl.RGB9_E5],
922 ['rg32ui', gl.RG32UI],
925 ['rg16ui', gl.RG16UI],
929 ['rg8_snorm', gl.RG8_SNORM],
939 ['r8_snorm', gl.R8_SNORM]
942 var splitSizedColorTests = 4;
943 var sizedColor2DPOTGroup = [];
944 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
945 sizedColor2DPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (2D POT)'));
946 state.testCases.addChild(sizedColor2DPOTGroup[ii]);
948 var sizedColor2DNPOTGroup = [];
949 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
950 sizedColor2DNPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (2D NPOT)'));
951 state.testCases.addChild(sizedColor2DNPOTGroup[ii]);
953 var sizedColorCubePOTGroup = [];
954 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
955 sizedColorCubePOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (Cubemap POT)'));
956 state.testCases.addChild(sizedColorCubePOTGroup[ii]);
958 var sizedColorCubeNPOTGroup = [];
959 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
960 sizedColorCubeNPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (Cubemap NPOT)'));
961 state.testCases.addChild(sizedColorCubeNPOTGroup[ii]);
963 var sizedColor2DArrayPOTGroup = [];
964 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
965 sizedColor2DArrayPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (2D Array POT)'));
966 state.testCases.addChild(sizedColor2DArrayPOTGroup[ii]);
968 var sizedColor2DArrayNPOTGroup = [];
969 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
970 sizedColor2DArrayNPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (2D Array NPOT)'));
971 state.testCases.addChild(sizedColor2DArrayNPOTGroup[ii]);
973 var sizedColor3DPOTGroup = [];
974 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
975 sizedColor3DPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (3D POT)'));
976 state.testCases.addChild(sizedColor3DPOTGroup[ii]);
978 var sizedColor3DNPOTGroup = [];
979 for (var ii = 0; ii < splitSizedColorTests; ++ii) {
980 sizedColor3DNPOTGroup.push(tcuTestCase.newTest('sized', 'Sized formats (3D NPOT)'));
981 state.testCases.addChild(sizedColor3DNPOTGroup[ii]);
984 for (var ii = 0; ii < sizedColorFormats.length; ++ii) {
985 var internalFormat = sizedColorFormats[ii][1];
986 var nameBase = sizedColorFormats[ii][0];
987 var descriptionBase = gluStrUtil.getPixelFormatName(internalFormat);
988 sizedColor2DPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DFormatCase({
989 name: nameBase + '_pot',
990 description: descriptionBase + ' gl.TEXTURE_2D',
991 format: internalFormat,
995 sizedColor2DNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DFormatCase({
996 name: nameBase + '_npot',
997 description: descriptionBase + ' gl.TEXTURE_2D',
998 format: internalFormat,
1002 sizedColorCubePOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
1003 name: nameBase + '_pot',
1004 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
1005 format: internalFormat,
1009 sizedColorCubeNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
1010 name: nameBase + '_npot',
1011 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
1012 format: internalFormat,
1016 sizedColor2DArrayPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
1017 name: nameBase + '_pot',
1018 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
1019 format: internalFormat,
1025 sizedColor2DArrayNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
1026 name: nameBase + '_npot',
1027 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
1028 format: internalFormat,
1033 sizedColor3DPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture3DFormatCase({
1034 name: nameBase + '_pot',
1035 description: descriptionBase + ' gl.TEXTURE_3D',
1036 format: internalFormat,
1041 sizedColor3DNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture3DFormatCase({
1042 name: nameBase + '_npot',
1043 description: descriptionBase + ' gl.TEXTURE_3D',
1044 format: internalFormat,
1051 var sizedDepthStencilFormats = [
1052 // Depth and stencil formats
1053 ['depth_component32f', gl.DEPTH_COMPONENT32F],
1054 ['depth_component24', gl.DEPTH_COMPONENT24],
1055 ['depth_component16', gl.DEPTH_COMPONENT16],
1056 // The following format is restricted in WebGL2.
1057 // ['depth32f_stencil8', gl.DEPTH32F_STENCIL8],
1058 ['depth24_stencil8', gl.DEPTH24_STENCIL8]
1060 var sizedDepthStencilGroup = tcuTestCase.newTest('sized', 'Sized formats (Depth Stencil)');
1061 state.testCases.addChild(sizedDepthStencilGroup);
1062 sizedDepthStencilFormats.forEach(function(elem) {
1063 var internalFormat = elem[1];
1064 var nameBase = elem[0];
1065 var descriptionBase = gluStrUtil.getPixelFormatName(internalFormat);
1066 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({
1067 name: nameBase + '_pot',
1068 description: descriptionBase + ' gl.TEXTURE_2D',
1069 format: internalFormat,
1073 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({
1074 name: nameBase + '_npot',
1075 description: descriptionBase + ' gl.TEXTURE_2D',
1076 format: internalFormat,
1080 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
1081 name: nameBase + '_pot',
1082 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
1083 format: internalFormat,
1087 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({
1088 name: nameBase + '_npot',
1089 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP',
1090 format: internalFormat,
1094 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
1095 name: nameBase + '_pot',
1096 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
1097 format: internalFormat,
1102 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({
1103 name: nameBase + '_npot',
1104 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY',
1105 format: internalFormat,
1112 var compressed2DGroup = tcuTestCase.newTest('compressed', 'Compressed formats (2D)');
1113 state.testCases.addChild(compressed2DGroup);
1114 var compressedCubeGroup = tcuTestCase.newTest('compressed', 'Compressed formats (Cubemap)');
1115 state.testCases.addChild(compressedCubeGroup);
1117 ['gl.COMPRESSED_R11_EAC', 'eac_r11', tcuCompressedTexture.Format.EAC_R11],
1118 ['gl.COMPRESSED_SIGNED_R11_EAC', 'eac_signed_r11', tcuCompressedTexture.Format.EAC_SIGNED_R11],
1119 ['gl.COMPRESSED_RG11_EAC', 'eac_rg11', tcuCompressedTexture.Format.EAC_RG11],
1120 ['gl.COMPRESSED_SIGNED_RG11_EAC', 'eac_signed_rg11', tcuCompressedTexture.Format.EAC_SIGNED_RG11],
1121 ['gl.COMPRESSED_RGB8_ETC2', 'etc2_rgb8', tcuCompressedTexture.Format.ETC2_RGB8],
1122 ['gl.COMPRESSED_SRGB8_ETC2', 'etc2_srgb8', tcuCompressedTexture.Format.ETC2_SRGB8],
1123 ['gl.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2', 'etc2_rgb8_punchthrough_alpha1', tcuCompressedTexture.Format.ETC2_RGB8_PUNCHTHROUGH_ALPHA1],
1124 ['gl.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2', 'etc2_srgb8_punchthrough_alpha1', tcuCompressedTexture.Format.ETC2_SRGB8_PUNCHTHROUGH_ALPHA1],
1125 ['gl.COMPRESSED_RGBA8_ETC2_EAC', 'etc2_eac_rgba8', tcuCompressedTexture.Format.ETC2_EAC_RGBA8],
1126 ['gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC', 'etc2_eac_srgb8_alpha8', tcuCompressedTexture.Format.ETC2_EAC_SRGB8_ALPHA8]
1128 if (!gluTextureUtil.enableCompressedTextureETC()) {
1129 debug('Skipping ETC2/EAC texture format tests: no support for WEBGL_compressed_texture_etc');
1132 etc2Formats.forEach(function(elem) {
1133 var nameBase = elem[1];
1134 var descriptionBase = elem[0];
1135 var format = elem[2];
1136 compressed2DGroup.addChild(new es3fTextureFormatTests.Compressed2DFormatCase({
1137 name: nameBase + '_2d_pot',
1138 description: descriptionBase + ', gl.TEXTURE_2D',
1143 compressedCubeGroup.addChild(new es3fTextureFormatTests.CompressedCubeFormatCase({
1144 name: nameBase + '_cube_pot',
1145 description: descriptionBase + ', gl.TEXTURE_CUBE_MAP',
1150 compressed2DGroup.addChild(new es3fTextureFormatTests.Compressed2DFormatCase({
1151 name: nameBase + '_2d_pot',
1152 description: descriptionBase + ', gl.TEXTURE_2D',
1157 compressedCubeGroup.addChild(new es3fTextureFormatTests.CompressedCubeFormatCase({
1158 name: nameBase + '_cube_npot',
1159 description: descriptionBase + ', gl.TEXTURE_CUBE_MAP',
1168 * Create and execute the test cases
1170 es3fTextureFormatTests.run = function(context, range) {
1172 var state = tcuTestCase.runner;
1174 es3fTextureFormatTests.genTestCases();
1176 state.setRange(range);
1177 state.runCallback(tcuTestCase.runTestCases);
1179 bufferedLogToConsole(err);