es3fTextureFormatTests.js (53073B)
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 'use strict'; 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'); 34 35 goog.scope(function() { 36 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; 50 51 /** @type {WebGL2RenderingContext} */ var gl; 52 53 var DE_ASSERT = function(x) { 54 if (!x) 55 throw new Error('Assert failed'); 56 }; 57 58 es3fTextureFormatTests.version = '300 es'; 59 60 es3fTextureFormatTests.testDescription = function() { 61 var test = tcuTestCase.runner.currentTest; 62 return test.description; 63 }; 64 65 es3fTextureFormatTests.setParentClass = function(child, parent) { 66 child.prototype = Object.create(parent.prototype); 67 child.prototype.constructor = child; 68 }; 69 70 /** 71 * @constructor 72 * @extends {tcuTestCase.DeqpTest} 73 */ 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); 81 }; 82 83 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture2DFormatCase, tcuTestCase.DeqpTest); 84 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); 88 /* TODO : Port 89 90 std::ostringstream fmtName; 91 92 if (m_dataType) 93 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType); 94 else 95 fmtName << glu::getPixelFormatStr(m_format); 96 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; 100 */ 101 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. 105 106 // Fill level 0. 107 this.m_texture.getRefTexture().allocLevel(0); 108 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax); 109 }; 110 111 es3fTextureFormatTests.Texture2DFormatCase.prototype.deinit = function() { 112 /* TODO: Implement */ 113 }; 114 115 es3fTextureFormatTests.Texture2DFormatCase.prototype.iterate = function() { 116 /* TODO: Implement */ 117 118 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 119 120 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 121 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 122 /* TODO: Implement 123 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 124 */ 125 var threshold = [3, 3, 3, 3]; 126 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D); 127 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; 133 134 renderParams.flags.log_programs = true; 135 renderParams.flags.log_uniforms = true; 136 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; 142 143 var texCoord = glsTextureTestUtil.computeQuadTexCoord2D([0, 0], [1, 1]); 144 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; 151 152 // Setup base viewport. 153 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 154 155 // Upload texture data to GL. 156 this.m_texture.upload(); 157 158 // Bind to unit 0. 159 gl.activeTexture(gl.TEXTURE0); 160 gl.bindTexture(gl.TEXTURE_2D, this.m_texture.getGLTexture()); 161 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); 167 168 // // Draw. 169 this.m_renderer.renderQuad(0, texCoord, renderParams); 170 renderedFrame.readViewport(gl, viewport); 171 172 // // Compute reference. 173 glsTextureTestUtil.sampleTexture2D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 174 this.m_texture.getRefTexture(), texCoord, renderParams); 175 176 // Compare and log. 177 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold); 178 179 assertMsgOptions(isOk, es3fTextureFormatTests.testDescription(), true, false); 180 return tcuTestCase.IterateResult.STOP; 181 }; 182 183 /** 184 * @constructor 185 * @extends {tcuTestCase.DeqpTest} 186 */ 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); 195 }; 196 197 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.TextureCubeFormatCase, tcuTestCase.DeqpTest); 198 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); 202 /* TODO : Port 203 204 std::ostringstream fmtName; 205 206 if (m_dataType) 207 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType); 208 else 209 fmtName << glu::getPixelFormatStr(m_format); 210 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; 214 */ 215 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. 219 220 // Fill level 0. 221 for (var face in tcuTexture.CubeFace) { 222 var gMin = null; 223 var gMax = null; 224 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; 232 default: 233 DE_ASSERT(false); 234 } 235 236 this.m_texture.getRefTexture().allocLevel(tcuTexture.CubeFace[face], 0); 237 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevelFace(0, tcuTexture.CubeFace[face]), gMin, gMax); 238 } 239 240 this.m_texture.upload(); 241 this.m_curFace = 0; 242 this.m_isOk = true; 243 }; 244 245 es3fTextureFormatTests.TextureCubeFormatCase.prototype.testFace = function(face) { 246 /* TODO: Implement */ 247 248 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 249 250 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 251 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 252 /* TODO: Implement 253 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 254 */ 255 var threshold = [3, 3, 3, 3]; 256 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_CUBE); 257 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; 263 264 renderParams.flags.log_programs = true; 265 renderParams.flags.log_uniforms = true; 266 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; 272 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; 277 } 278 279 var texCoord = glsTextureTestUtil.computeQuadTexCoordCube(face); 280 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; 287 288 // Setup base viewport. 289 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 290 291 // Bind to unit 0. 292 gl.activeTexture(gl.TEXTURE0); 293 gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.m_texture.getGLTexture()); 294 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); 300 301 // // Draw. 302 this.m_renderer.renderQuad(0, texCoord, renderParams); 303 renderedFrame.readViewport(gl, viewport); 304 305 // // Compute reference. 306 glsTextureTestUtil.sampleTextureCube(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 307 this.m_texture.getRefTexture(), texCoord, renderParams); 308 309 // Compare and log. 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 315 skipPixels = [ 316 [this.m_width - 1, this.m_height - 1] 317 ]; 318 } 319 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold, skipPixels); 320 321 assertMsgOptions(isOk, 'Face: ' + this.m_curFace + ' ' + es3fTextureFormatTests.testDescription(), true, false); 322 return isOk; 323 }; 324 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)) 329 this.m_isOk = false; 330 331 this.m_curFace += 1; 332 333 if (this.m_curFace < Object.keys(tcuTexture.CubeFace).length) 334 return tcuTestCase.IterateResult.CONTINUE; 335 else 336 return tcuTestCase.IterateResult.STOP; 337 }; 338 339 /** 340 * @constructor 341 * @extends {tcuTestCase.DeqpTest} 342 */ 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); 351 }; 352 353 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture2DArrayFormatCase, tcuTestCase.DeqpTest); 354 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); 358 /* TODO : Port 359 360 std::ostringstream fmtName; 361 362 if (m_dataType) 363 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType); 364 else 365 fmtName << glu::getPixelFormatStr(m_format); 366 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; 370 */ 371 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. 375 376 this.m_texture.getRefTexture().allocLevel(0); 377 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax); 378 379 this.m_curLayer = 0; 380 this.m_isOk = true; 381 }; 382 383 es3fTextureFormatTests.Texture2DArrayFormatCase.prototype.testLayer = function(layerNdx) { 384 /* TODO: Implement */ 385 386 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 387 388 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 389 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 390 /* TODO: Implement 391 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 392 */ 393 var threshold = [3, 3, 3, 3]; 394 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D_ARRAY); 395 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; 401 402 renderParams.flags.log_programs = true; 403 renderParams.flags.log_uniforms = true; 404 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; 410 411 var texCoord = glsTextureTestUtil.computeQuadTexCoord2DArray(layerNdx, [0, 0], [1, 1]); 412 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; 419 420 // Setup base viewport. 421 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 422 423 this.m_texture.upload(); 424 425 // Bind to unit 0. 426 gl.activeTexture(gl.TEXTURE0); 427 gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.m_texture.getGLTexture()); 428 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); 434 435 // // Draw. 436 this.m_renderer.renderQuad(0, texCoord, renderParams); 437 renderedFrame.readViewport(gl, viewport); 438 439 // // Compute reference. 440 glsTextureTestUtil.sampleTexture2DArray(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 441 this.m_texture.getRefTexture().getView(), texCoord, renderParams); 442 443 // Compare and log. 444 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold); 445 446 assertMsgOptions(isOk, 'Layer: ' + this.m_curLayer + ' ' + es3fTextureFormatTests.testDescription(), true, false); 447 return isOk; 448 }; 449 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)) 454 this.m_isOk = false; 455 456 this.m_curLayer += 1; 457 458 if (this.m_curLayer == this.m_numLayers) 459 return tcuTestCase.IterateResult.STOP; 460 else 461 return tcuTestCase.IterateResult.CONTINUE; 462 }; 463 464 /** 465 * @constructor 466 * @extends {tcuTestCase.DeqpTest} 467 */ 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); 476 }; 477 478 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Texture3DFormatCase, tcuTestCase.DeqpTest); 479 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); 483 /* TODO : Port 484 485 std::ostringstream fmtName; 486 487 if (m_dataType) 488 fmtName << glu::getPixelFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType); 489 else 490 fmtName << glu::getPixelFormatStr(m_format); 491 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; 495 */ 496 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. 500 501 this.m_texture.getRefTexture().allocLevel(0); 502 tcuTextureUtil.fillWithComponentGradients(this.m_texture.getRefTexture().getLevel(0), spec.valueMin, spec.valueMax); 503 504 this.m_curSlice = 0; 505 this.m_isOk = true; 506 }; 507 508 es3fTextureFormatTests.Texture3DFormatCase.prototype.testSlice = function(sliceNdx) { 509 /* TODO: Implement */ 510 511 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 512 513 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 514 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 515 /* TODO: Implement 516 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 517 */ 518 var threshold = [3, 3, 3, 3]; 519 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_3D); 520 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; 527 528 renderParams.flags.log_programs = true; 529 renderParams.flags.log_uniforms = true; 530 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; 536 537 var texCoord = glsTextureTestUtil.computeQuadTexCoord3D([0, 0, r], [1, 1, r], [0, 1, 2]); 538 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; 545 546 // Setup base viewport. 547 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 548 549 this.m_texture.upload(); 550 551 // Bind to unit 0. 552 gl.activeTexture(gl.TEXTURE0); 553 gl.bindTexture(gl.TEXTURE_3D, this.m_texture.getGLTexture()); 554 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); 560 561 // // Draw. 562 this.m_renderer.renderQuad(0, texCoord, renderParams); 563 renderedFrame.readViewport(gl, viewport); 564 565 // // Compute reference. 566 glsTextureTestUtil.sampleTexture3D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 567 this.m_texture.getRefTexture(), texCoord, renderParams); 568 569 // Compare and log. 570 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold); 571 572 assertMsgOptions(isOk, 'Slice: ' + this.m_curSlice + ' ' + es3fTextureFormatTests.testDescription(), true, false); 573 return isOk; 574 }; 575 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)) 580 this.m_isOk = false; 581 582 this.m_curSlice += 1; 583 584 if (this.m_curSlice >= this.m_depth) 585 return tcuTestCase.IterateResult.STOP; 586 else 587 return tcuTestCase.IterateResult.CONTINUE; 588 }; 589 590 /** 591 * @constructor 592 * @extends {tcuTestCase.DeqpTest} 593 */ 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); 601 }; 602 603 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.Compressed2DFormatCase, tcuTestCase.DeqpTest); 604 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); 610 } 611 this.m_texture = gluTexture.compressed2DFromInternalFormat(gl, this.m_format, this.m_width, this.m_height, compressed); 612 }; 613 614 es3fTextureFormatTests.Compressed2DFormatCase.prototype.deinit = function() { 615 /* TODO: Implement */ 616 }; 617 618 es3fTextureFormatTests.Compressed2DFormatCase.prototype.iterate = function() { 619 /* TODO: Implement */ 620 621 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 622 623 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 624 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 625 /* TODO: Implement 626 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 627 */ 628 var threshold = [3, 3, 3, 3]; 629 var renderParams = new glsTextureTestUtil.ReferenceParams(glsTextureTestUtil.textureType.TEXTURETYPE_2D); 630 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; 636 637 renderParams.flags.log_programs = true; 638 renderParams.flags.log_uniforms = true; 639 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; 645 646 var texCoord = glsTextureTestUtil.computeQuadTexCoord2D([0, 0], [1, 1]); 647 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; 654 655 // Setup base viewport. 656 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 657 658 // Bind to unit 0. 659 gl.activeTexture(gl.TEXTURE0); 660 gl.bindTexture(gl.TEXTURE_2D, this.m_texture.getGLTexture()); 661 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); 667 668 // // Draw. 669 this.m_renderer.renderQuad(0, texCoord, renderParams); 670 renderedFrame.readViewport(gl, viewport); 671 672 // // Compute reference. 673 glsTextureTestUtil.sampleTexture2D(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 674 this.m_texture.getRefTexture(), texCoord, renderParams); 675 676 // Compare and log. 677 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold); 678 679 assertMsgOptions(isOk, es3fTextureFormatTests.testDescription(), true, false); 680 return tcuTestCase.IterateResult.STOP; 681 }; 682 683 /** 684 * @constructor 685 * @extends {tcuTestCase.DeqpTest} 686 */ 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); 694 this.m_curFace = 0; 695 this.m_isOk = true; 696 DE_ASSERT(this.m_width == this.m_height); 697 }; 698 699 es3fTextureFormatTests.setParentClass(es3fTextureFormatTests.CompressedCubeFormatCase, tcuTestCase.DeqpTest); 700 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); 706 } 707 this.m_texture = gluTexture.compressedCubeFromInternalFormat(gl, this.m_format, this.m_width, compressed); 708 }; 709 710 es3fTextureFormatTests.CompressedCubeFormatCase.prototype.testFace = function(face) { 711 /* TODO: Implement */ 712 713 var viewport = new glsTextureTestUtil.RandomViewport(document.getElementById('canvas'), this.m_width, this.m_height/*, deStringHash(getName())*/); 714 715 /* tcu::Surface */ var renderedFrame = new tcuSurface.Surface(viewport.width, viewport.height); 716 /* tcu::Surface */ var referenceFrame = new tcuSurface.Surface(viewport.width, viewport.height); 717 /* TODO: Implement 718 // tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 719 */ 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); 723 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; 728 729 renderParams.flags.log_programs = true; 730 renderParams.flags.log_uniforms = true; 731 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); 735 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; 740 } 741 742 var texCoord = glsTextureTestUtil.computeQuadTexCoordCube(face); 743 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; 750 751 // Setup base viewport. 752 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 753 754 // Bind to unit 0. 755 gl.activeTexture(gl.TEXTURE0); 756 gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.m_texture.getGLTexture()); 757 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); 763 764 // // Draw. 765 this.m_renderer.renderQuad(0, texCoord, renderParams); 766 renderedFrame.readViewport(gl, viewport); 767 768 // // Compute reference. 769 glsTextureTestUtil.sampleTextureCube(new glsTextureTestUtil.SurfaceAccess(referenceFrame, undefined /*m_renderCtx.getRenderTarget().getPixelFormat()*/), 770 this.m_texture.getRefTexture(), texCoord, renderParams); 771 772 // Compare and log. 773 var isOk = glsTextureTestUtil.compareImages(referenceFrame, renderedFrame, threshold); 774 775 assertMsgOptions(isOk, 'Face: ' + this.m_curFace + ' ' + es3fTextureFormatTests.testDescription(), true, false); 776 return isOk; 777 }; 778 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)) 783 this.m_isOk = false; 784 785 this.m_curFace += 1; 786 787 if (this.m_curFace < Object.keys(tcuTexture.CubeFace).length) 788 return tcuTestCase.IterateResult.CONTINUE; 789 else 790 return tcuTestCase.IterateResult.STOP; 791 }; 792 793 es3fTextureFormatTests.genTestCases = function() { 794 var state = tcuTestCase.runner; 795 state.setRoot(tcuTestCase.newTest('texture_format', 'Top level')); 796 797 var texFormats = [ 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] 806 ]; 807 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); 814 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', 823 format: format, 824 dataType: dataType, 825 width: 128, 826 height: 128 827 })); 828 unsized2DGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({ 829 name: nameBase + '_2d_npot', 830 description: descriptionBase + ' gl.TEXTURE_2D', 831 format: format, 832 dataType: dataType, 833 width: 63, 834 height: 112 835 })); 836 unsized2DGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 837 name: nameBase + '_cube_pot', 838 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 839 format: format, 840 dataType: dataType, 841 width: 64, 842 height: 64 843 })); 844 unsized2DGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 845 name: nameBase + '_cube_npot', 846 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 847 format: format, 848 dataType: dataType, 849 width: 57, 850 height: 57 851 })); 852 unsized2DArrayGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 853 name: nameBase + '_2d_array_pot', 854 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 855 format: format, 856 dataType: dataType, 857 width: 64, 858 height: 64, 859 numLayers: 8 860 })); 861 unsized2DArrayGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 862 name: nameBase + '_2d_array_npot', 863 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 864 format: format, 865 dataType: dataType, 866 width: 63, 867 height: 57, 868 numLayers: 7 869 })); 870 unsized3DGroup.addChild(new es3fTextureFormatTests.Texture3DFormatCase({ 871 name: nameBase + '_3d_pot', 872 description: descriptionBase + ' gl.TEXTURE_3D', 873 format: format, 874 dataType: dataType, 875 width: 8, 876 height: 32, 877 depth: 16 878 })); 879 unsized3DGroup.addChild(new es3fTextureFormatTests.Texture3DFormatCase({ 880 name: nameBase + '_3d_npot', 881 description: descriptionBase + ' gl.TEXTURE_3D', 882 format: format, 883 dataType: dataType, 884 width: 11, 885 height: 31, 886 depth: 7 887 })); 888 }); 889 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], 897 ['rgba8', gl.RGBA8], 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], 903 ['rgba4', gl.RGBA4], 904 ['rgb5_a1', gl.RGB5_A1], 905 ['rgba8_snorm', gl.RGBA8_SNORM], 906 ['rgb8', gl.RGB8], 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], 916 ['rgb8i', gl.RGB8I], 917 ['rgb8ui', gl.RGB8UI], 918 ['srgb8', gl.SRGB8], 919 ['rgb9_e5', gl.RGB9_E5], 920 ['rg32f', gl.RG32F], 921 ['rg32i', gl.RG32I], 922 ['rg32ui', gl.RG32UI], 923 ['rg16f', gl.RG16F], 924 ['rg16i', gl.RG16I], 925 ['rg16ui', gl.RG16UI], 926 ['rg8', gl.RG8], 927 ['rg8i', gl.RG8I], 928 ['rg8ui', gl.RG8UI], 929 ['rg8_snorm', gl.RG8_SNORM], 930 ['r32f', gl.R32F], 931 ['r32i', gl.R32I], 932 ['r32ui', gl.R32UI], 933 ['r16f', gl.R16F], 934 ['r16i', gl.R16I], 935 ['r16ui', gl.R16UI], 936 ['r8', gl.R8], 937 ['r8i', gl.R8I], 938 ['r8ui', gl.R8UI], 939 ['r8_snorm', gl.R8_SNORM] 940 ]; 941 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]); 947 } 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]); 952 } 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]); 957 } 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]); 962 } 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]); 967 } 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]); 972 } 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]); 977 } 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]); 982 } 983 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, 992 width: 128, 993 height: 128 994 })); 995 sizedColor2DNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DFormatCase({ 996 name: nameBase + '_npot', 997 description: descriptionBase + ' gl.TEXTURE_2D', 998 format: internalFormat, 999 width: 63, 1000 height: 112 1001 })); 1002 sizedColorCubePOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 1003 name: nameBase + '_pot', 1004 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 1005 format: internalFormat, 1006 width: 64, 1007 height: 64 1008 })); 1009 sizedColorCubeNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 1010 name: nameBase + '_npot', 1011 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 1012 format: internalFormat, 1013 width: 57, 1014 height: 57 1015 })); 1016 sizedColor2DArrayPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 1017 name: nameBase + '_pot', 1018 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 1019 format: internalFormat, 1020 width: 64, 1021 height: 64, 1022 numLayers: 8 1023 1024 })); 1025 sizedColor2DArrayNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 1026 name: nameBase + '_npot', 1027 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 1028 format: internalFormat, 1029 width: 63, 1030 height: 57, 1031 numLayers: 7 1032 })); 1033 sizedColor3DPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture3DFormatCase({ 1034 name: nameBase + '_pot', 1035 description: descriptionBase + ' gl.TEXTURE_3D', 1036 format: internalFormat, 1037 width: 8, 1038 height: 32, 1039 depth: 16 1040 })); 1041 sizedColor3DNPOTGroup[ii % splitSizedColorTests].addChild(new es3fTextureFormatTests.Texture3DFormatCase({ 1042 name: nameBase + '_npot', 1043 description: descriptionBase + ' gl.TEXTURE_3D', 1044 format: internalFormat, 1045 width: 11, 1046 height: 31, 1047 depth: 7 1048 })); 1049 } 1050 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] 1059 ]; 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, 1070 width: 128, 1071 height: 128 1072 })); 1073 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DFormatCase({ 1074 name: nameBase + '_npot', 1075 description: descriptionBase + ' gl.TEXTURE_2D', 1076 format: internalFormat, 1077 width: 63, 1078 height: 112 1079 })); 1080 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 1081 name: nameBase + '_pot', 1082 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 1083 format: internalFormat, 1084 width: 64, 1085 height: 64 1086 })); 1087 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.TextureCubeFormatCase({ 1088 name: nameBase + '_npot', 1089 description: descriptionBase + ' gl.TEXTURE_CUBE_MAP', 1090 format: internalFormat, 1091 width: 57, 1092 height: 57 1093 })); 1094 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 1095 name: nameBase + '_pot', 1096 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 1097 format: internalFormat, 1098 width: 64, 1099 height: 64, 1100 numLayers: 8 1101 })); 1102 sizedDepthStencilGroup.addChild(new es3fTextureFormatTests.Texture2DArrayFormatCase({ 1103 name: nameBase + '_npot', 1104 description: descriptionBase + ' gl.TEXTURE_2D_ARRAY', 1105 format: internalFormat, 1106 width: 63, 1107 height: 57, 1108 numLayers: 7 1109 })); 1110 }); 1111 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); 1116 var etc2Formats = [ 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] 1127 ]; 1128 if (!gluTextureUtil.enableCompressedTextureETC()) { 1129 debug('Skipping ETC2/EAC texture format tests: no support for WEBGL_compressed_texture_etc'); 1130 etc2Formats = []; 1131 } 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', 1139 format: format, 1140 width: 128, 1141 height: 64 1142 })); 1143 compressedCubeGroup.addChild(new es3fTextureFormatTests.CompressedCubeFormatCase({ 1144 name: nameBase + '_cube_pot', 1145 description: descriptionBase + ', gl.TEXTURE_CUBE_MAP', 1146 format: format, 1147 width: 64, 1148 height: 64 1149 })); 1150 compressed2DGroup.addChild(new es3fTextureFormatTests.Compressed2DFormatCase({ 1151 name: nameBase + '_2d_pot', 1152 description: descriptionBase + ', gl.TEXTURE_2D', 1153 format: format, 1154 width: 128, 1155 height: 64 1156 })); 1157 compressedCubeGroup.addChild(new es3fTextureFormatTests.CompressedCubeFormatCase({ 1158 name: nameBase + '_cube_npot', 1159 description: descriptionBase + ', gl.TEXTURE_CUBE_MAP', 1160 format: format, 1161 width: 51, 1162 height: 51 1163 })); 1164 }); 1165 }; 1166 1167 /** 1168 * Create and execute the test cases 1169 */ 1170 es3fTextureFormatTests.run = function(context, range) { 1171 gl = context; 1172 var state = tcuTestCase.runner; 1173 try { 1174 es3fTextureFormatTests.genTestCases(); 1175 if (range) 1176 state.setRange(range); 1177 state.runCallback(tcuTestCase.runTestCases); 1178 } catch (err) { 1179 bufferedLogToConsole(err); 1180 state.terminate(); 1181 } 1182 1183 }; 1184 1185 });