es3fNegativeTextureApiTests.js (168950B)
1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES 3.0 Module 3 * ------------------------------------------------- 4 * 5 * Copyright 2014 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the 'License'); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an 'AS IS' BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * 19 *//*! 20 * \file 21 * \brief Negative Texture API tests. 22 *//*--------------------------------------------------------------------*/ 23 'use strict'; 24 goog.provide('functional.gles3.es3fNegativeTextureApiTests'); 25 26 goog.require('framework.common.tcuTestCase'); 27 goog.require('framework.common.tcuTexture'); 28 goog.require('functional.gles3.es3fApiCase'); 29 goog.require('framework.opengl.gluTexture'); 30 goog.require('framework.opengl.gluTextureUtil'); 31 32 goog.scope(function() { 33 34 var es3fNegativeTextureApiTests = functional.gles3.es3fNegativeTextureApiTests; 35 var tcuTexture = framework.common.tcuTexture; 36 var es3fApiCase = functional.gles3.es3fApiCase; 37 var tcuTestCase = framework.common.tcuTestCase; 38 var gluTexture = framework.opengl.gluTexture; 39 var gluTextureUtil = framework.opengl.gluTextureUtil; 40 41 function etc2Unsupported() { 42 debug("Skipping test: no support for WEBGL_compressed_texture_etc"); 43 } 44 45 46 /** 47 * @param {number} width 48 * @param {number} height 49 * @return {number} 50 */ 51 es3fNegativeTextureApiTests.etc2DataSize = function(width, height) { 52 return Math.ceil(width / 4) * Math.ceil(height / 4) * 8; 53 }; 54 55 /** 56 * @param {number} width 57 * @param {number} height 58 * @return {number} 59 */ 60 es3fNegativeTextureApiTests.etc2EacDataSize = function(width, height) { 61 return 2 * es3fNegativeTextureApiTests.etc2DataSize(width, height); 62 }; 63 64 /** 65 * @param {function(number)} func 66 */ 67 es3fNegativeTextureApiTests.forCubeFaces = function(func) { 68 var faceGLVar; 69 for (var faceIterTcu in tcuTexture.CubeFace) { 70 faceGLVar = gluTexture.cubeFaceToGLFace(tcuTexture.CubeFace[faceIterTcu]); 71 func(faceGLVar); 72 } 73 }; 74 75 /** 76 * @param {WebGL2RenderingContext} gl 77 */ 78 es3fNegativeTextureApiTests.init = function(gl) { 79 80 var haveCompressedTextureETC = gluTextureUtil.enableCompressedTextureETC(); 81 82 var testGroup = tcuTestCase.runner.testCases; 83 84 testGroup.addChild(new es3fApiCase.ApiCaseCallback('activetexture', 'Invalid gl.ActiveTexture() usage', gl, 85 function() { 86 bufferedLogToConsole('gl.INVALID_ENUM is generated if texture is not one of gl.TEXTUREi, where i ranges from 0 to (gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1).'); 87 gl.activeTexture(-1); 88 this.expectError(gl.INVALID_ENUM); 89 var numMaxTextureUnits = /** @type {number} */(gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)); 90 gl.activeTexture(gl.TEXTURE0 + numMaxTextureUnits); 91 this.expectError(gl.INVALID_ENUM); 92 93 })); 94 95 // gl.bindTexture 96 97 testGroup.addChild(new es3fApiCase.ApiCaseCallback('bindTexture', 'Invalid gl.bindTexture() usage', gl, 98 function() { 99 100 /** @type {Array<WebGLTexture>} */ var texture = []; 101 texture[0] = gl.createTexture(); 102 texture[1] = gl.createTexture(); 103 104 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the allowable values.'); 105 gl.bindTexture(0, texture[0]); 106 this.expectError(gl.INVALID_ENUM); 107 gl.bindTexture(gl.FRAMEBUFFER, texture[0]); 108 this.expectError(gl.INVALID_ENUM); 109 110 bufferedLogToConsole('gl.INVALID_OPERATION is generated if texture was previously created with a target that doesn\'t match that of target.'); 111 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 112 this.expectError(gl.NO_ERROR); 113 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[0]); 114 this.expectError(gl.INVALID_OPERATION); 115 gl.bindTexture(gl.TEXTURE_3D, texture[0]); 116 this.expectError(gl.INVALID_OPERATION); 117 gl.bindTexture(gl.TEXTURE_2D_ARRAY, texture[0]); 118 this.expectError(gl.INVALID_OPERATION); 119 120 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 121 this.expectError(gl.NO_ERROR); 122 gl.bindTexture(gl.TEXTURE_2D, texture[1]); 123 this.expectError(gl.INVALID_OPERATION); 124 gl.bindTexture(gl.TEXTURE_3D, texture[1]); 125 this.expectError(gl.INVALID_OPERATION); 126 gl.bindTexture(gl.TEXTURE_2D_ARRAY, texture[1]); 127 this.expectError(gl.INVALID_OPERATION); 128 129 gl.deleteTexture(texture[0]); 130 gl.deleteTexture(texture[1]); 131 })); 132 133 // gl.compressedTexImage2D 134 135 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_invalid_target', 'Invalid gl.compressedTexImage2D() usage', gl, 136 function() { 137 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 138 139 /** @type {Array<WebGLTexture>} */ var texture = []; 140 texture[0] = gl.createTexture(); 141 texture[1] = gl.createTexture(); 142 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 143 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 144 145 146 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 147 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(0); 148 gl.compressedTexImage2D(0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 149 this.expectError(gl.INVALID_ENUM); 150 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 151 this.expectError(gl.INVALID_ENUM); 152 153 154 gl.deleteTexture(texture[0]); 155 gl.deleteTexture(texture[1]); 156 157 158 })); 159 160 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_invalid_format', 'Invalid gl.compressedTexImage2D() usage', gl, 161 function() { 162 163 164 /** @type {Array<WebGLTexture>} */ var texture = []; 165 texture[0] = gl.createTexture(); 166 texture[1] = gl.createTexture(); 167 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 168 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 169 170 171 bufferedLogToConsole('gl.INVALID_ENUM is generated if internalformat is not a supported format returned in gl.COMPRESSED_TEXTURE_FORMATS.'); 172 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(0); 173 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, uint8); 174 this.expectError(gl.INVALID_ENUM); 175 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, uint8); 176 this.expectError(gl.INVALID_ENUM); 177 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, 0, 0, 0, uint8); 178 this.expectError(gl.INVALID_ENUM); 179 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, uint8); 180 this.expectError(gl.INVALID_ENUM); 181 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, uint8); 182 this.expectError(gl.INVALID_ENUM); 183 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, uint8); 184 this.expectError(gl.INVALID_ENUM); 185 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, uint8); 186 this.expectError(gl.INVALID_ENUM); 187 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, uint8); 188 this.expectError(gl.INVALID_ENUM); 189 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, uint8); 190 this.expectError(gl.INVALID_ENUM); 191 192 193 gl.deleteTexture(texture[0]); 194 gl.deleteTexture(texture[1]); 195 196 })); 197 198 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_neg_level', 'Invalid gl.compressedTexImage2D() usage', gl, 199 function() { 200 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 201 202 203 /** @type {Array<WebGLTexture>} */ var texture = []; 204 texture[0] = gl.createTexture(); 205 texture[1] = gl.createTexture(); 206 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 207 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 208 209 210 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 211 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(0); 212 gl.compressedTexImage2D(gl.TEXTURE_2D, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 213 this.expectError(gl.INVALID_VALUE); 214 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 215 this.expectError(gl.INVALID_VALUE); 216 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 217 this.expectError(gl.INVALID_VALUE); 218 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 219 this.expectError(gl.INVALID_VALUE); 220 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 221 this.expectError(gl.INVALID_VALUE); 222 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 223 this.expectError(gl.INVALID_VALUE); 224 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, uint8); 225 this.expectError(gl.INVALID_VALUE); 226 227 228 gl.deleteTexture(texture[0]); 229 gl.deleteTexture(texture[1]); 230 231 232 })); 233 234 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_max_level', 'Invalid gl.compressedTexImage2D() usage', gl, 235 function() { 236 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 237 238 239 /** @type {Array<WebGLTexture>} */ var texture = []; 240 texture[0] = gl.createTexture(); 241 texture[1] = gl.createTexture(); 242 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 243 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 244 245 246 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE) for a 2d texture target.'); 247 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16)); 248 249 /** @type {number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type {number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 250 gl.compressedTexImage2D(gl.TEXTURE_2D, log2MaxTextureSize, gl.COMPRESSED_RGB8_ETC2, 16, 16, 0, uint8); 251 this.expectError(gl.INVALID_VALUE); 252 253 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_TEXTURE_SIZE) for a cubemap target.'); 254 /** @type {number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type {number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 255 256 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 257 this.expectError(gl.INVALID_VALUE); 258 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 259 this.expectError(gl.INVALID_VALUE); 260 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 261 this.expectError(gl.INVALID_VALUE); 262 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 263 this.expectError(gl.INVALID_VALUE); 264 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 265 this.expectError(gl.INVALID_VALUE); 266 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, uint8); 267 this.expectError(gl.INVALID_VALUE); 268 269 270 gl.deleteTexture(texture[0]); 271 gl.deleteTexture(texture[1]); 272 273 274 })); 275 276 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_neg_width_height', 'Invalid gl.compressedTexImage2D() usage', gl, 277 function() { 278 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 279 280 281 /** @type {Array<WebGLTexture>} */ var texture = []; 282 texture[0] = gl.createTexture(); 283 texture[1] = gl.createTexture(); 284 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 285 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 286 287 288 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 289 290 bufferedLogToConsole('gl.TEXTURE_2D target'); 291 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(0); 292 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 293 this.expectError(gl.INVALID_VALUE); 294 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 295 this.expectError(gl.INVALID_VALUE); 296 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 297 this.expectError(gl.INVALID_VALUE); 298 299 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 300 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 301 this.expectError(gl.INVALID_VALUE); 302 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 303 this.expectError(gl.INVALID_VALUE); 304 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 305 this.expectError(gl.INVALID_VALUE); 306 307 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 308 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 309 this.expectError(gl.INVALID_VALUE); 310 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 311 this.expectError(gl.INVALID_VALUE); 312 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 313 this.expectError(gl.INVALID_VALUE); 314 315 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 316 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 317 this.expectError(gl.INVALID_VALUE); 318 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 319 this.expectError(gl.INVALID_VALUE); 320 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 321 this.expectError(gl.INVALID_VALUE); 322 323 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 324 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 325 this.expectError(gl.INVALID_VALUE); 326 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 327 this.expectError(gl.INVALID_VALUE); 328 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 329 this.expectError(gl.INVALID_VALUE); 330 331 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 332 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 333 this.expectError(gl.INVALID_VALUE); 334 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 335 this.expectError(gl.INVALID_VALUE); 336 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 337 this.expectError(gl.INVALID_VALUE); 338 339 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 340 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, uint8); 341 this.expectError(gl.INVALID_VALUE); 342 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, uint8); 343 this.expectError(gl.INVALID_VALUE); 344 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, uint8); 345 this.expectError(gl.INVALID_VALUE); 346 347 348 gl.deleteTexture(texture[0]); 349 gl.deleteTexture(texture[1]); 350 351 352 })); 353 354 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_max_width_height', 'Invalid gl.compressedTexImage2D() usage', gl, 355 function() { 356 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 357 358 359 /** @type {Array<WebGLTexture>} */ var texture = []; 360 texture[0] = gl.createTexture(); 361 texture[1] = gl.createTexture(); 362 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 363 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 364 365 var maxTextureSize = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_SIZE)) + 1; 366 var maxCubemapSize = /** @type {number} */ (gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)) + 1; 367 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_TEXTURE_SIZE.'); 368 369 var maxSideSize = Math.max(maxCubemapSize, maxTextureSize); 370 var scratchBuffer = new ArrayBuffer( 371 Math.max(es3fNegativeTextureApiTests.etc2EacDataSize(maxSideSize, 1), 372 es3fNegativeTextureApiTests.etc2EacDataSize(1, maxSideSize))); 373 function getUint8ArrayEtc2EacDataSize(w, h) { 374 return new Uint8Array(scratchBuffer, 0, es3fNegativeTextureApiTests.etc2EacDataSize(w, h)); 375 } 376 377 var dataTextureMaxByOne = getUint8ArrayEtc2EacDataSize(maxTextureSize, 1); 378 var dataTextureOneByMax = getUint8ArrayEtc2EacDataSize(1, maxTextureSize); 379 380 bufferedLogToConsole('gl.TEXTURE_2D target'); 381 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 1, 0, dataTextureMaxByOne); 382 this.expectError(gl.INVALID_VALUE); 383 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxTextureSize, 0, dataTextureOneByMax); 384 this.expectError(gl.INVALID_VALUE); 385 386 var dataCubemapMaxByOne = getUint8ArrayEtc2EacDataSize(maxCubemapSize, 1); 387 var dataCubemapOneByMax = getUint8ArrayEtc2EacDataSize(1, maxCubemapSize); 388 389 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 390 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 391 this.expectError(gl.INVALID_VALUE); 392 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 393 this.expectError(gl.INVALID_VALUE); 394 395 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 396 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 397 this.expectError(gl.INVALID_VALUE); 398 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 399 this.expectError(gl.INVALID_VALUE); 400 401 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 402 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 403 this.expectError(gl.INVALID_VALUE); 404 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 405 this.expectError(gl.INVALID_VALUE); 406 407 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 408 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 409 this.expectError(gl.INVALID_VALUE); 410 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 411 this.expectError(gl.INVALID_VALUE); 412 413 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 414 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 415 this.expectError(gl.INVALID_VALUE); 416 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 417 this.expectError(gl.INVALID_VALUE); 418 419 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 420 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, dataCubemapMaxByOne); 421 this.expectError(gl.INVALID_VALUE); 422 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, dataCubemapOneByMax); 423 this.expectError(gl.INVALID_VALUE); 424 425 426 gl.deleteTexture(texture[0]); 427 gl.deleteTexture(texture[1]); 428 429 430 })); 431 432 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_invalid_border', 'Invalid gl.compressedTexImage2D() usage', gl, 433 function() { 434 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 435 436 437 /** @type {Array<WebGLTexture>} */ var texture = []; 438 texture[0] = gl.createTexture(); 439 texture[1] = gl.createTexture(); 440 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 441 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 442 443 444 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(0); 445 446 bufferedLogToConsole('gl.INVALID_VALUE is generated if border is not 0.'); 447 448 bufferedLogToConsole('gl.TEXTURE_2D target'); 449 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 450 this.expectError(gl.INVALID_VALUE); 451 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 452 this.expectError(gl.INVALID_VALUE); 453 454 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 455 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 456 this.expectError(gl.INVALID_VALUE); 457 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 458 this.expectError(gl.INVALID_VALUE); 459 460 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 461 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 462 this.expectError(gl.INVALID_VALUE); 463 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 464 this.expectError(gl.INVALID_VALUE); 465 466 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 467 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 468 this.expectError(gl.INVALID_VALUE); 469 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 470 this.expectError(gl.INVALID_VALUE); 471 472 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 473 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 474 this.expectError(gl.INVALID_VALUE); 475 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 476 this.expectError(gl.INVALID_VALUE); 477 478 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 479 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 480 this.expectError(gl.INVALID_VALUE); 481 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 482 this.expectError(gl.INVALID_VALUE); 483 484 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 485 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, uint8); 486 this.expectError(gl.INVALID_VALUE); 487 gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, uint8); 488 this.expectError(gl.INVALID_VALUE); 489 490 491 gl.deleteTexture(texture[0]); 492 gl.deleteTexture(texture[1]); 493 494 495 })); 496 497 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage2d_invalid_size', 'Invalid gl.compressedTexImage2D() usage', gl, 498 function() { 499 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 500 501 502 /** @type {WebGLTexture} */ var texture; 503 texture = gl.createTexture(); 504 gl.bindTexture(gl.TEXTURE_2D, texture); 505 506 507 bufferedLogToConsole('gl.INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.'); 508 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, new Uint8Array(1)); 509 this.expectError(gl.INVALID_VALUE); 510 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, new Uint8Array(4 * 4 * 8)); 511 this.expectError(gl.INVALID_VALUE); 512 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGB8_ETC2, 16, 16, 0, new Uint8Array(4 * 4 * 16)); 513 this.expectError(gl.INVALID_VALUE); 514 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_SIGNED_R11_EAC, 16, 16, 0, new Uint8Array(4 * 4 * 16)); 515 this.expectError(gl.INVALID_VALUE); 516 517 518 gl.deleteTexture(texture); 519 520 521 })); 522 523 // gl.copyTexImage2D 524 525 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_invalid_target', 'Invalid gl.copyTexImage2D() usage', gl, 526 function() { 527 528 529 /** @type {WebGLTexture} */ var texture; 530 texture = gl.createTexture(); 531 gl.bindTexture(gl.TEXTURE_2D, texture); 532 533 534 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 535 gl.copyTexImage2D(0, 0, gl.RGB, 0, 0, 64, 64, 0); 536 this.expectError(gl.INVALID_ENUM); 537 538 539 gl.deleteTexture(texture); 540 541 542 })); 543 544 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_invalid_format', 'Invalid gl.copyTexImage2D() usage', gl, 545 function() { 546 547 548 /** @type {Array<WebGLTexture>} */ var texture = []; 549 texture[0] = gl.createTexture(); 550 texture[1] = gl.createTexture(); 551 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 552 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 553 554 555 bufferedLogToConsole('gl.INVALID_ENUM or gl.INVALID_VALUE is generated if internalformat is not an accepted format.'); 556 gl.copyTexImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0); 557 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 558 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0); 559 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 560 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0); 561 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 562 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0); 563 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 564 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0); 565 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 566 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0); 567 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 568 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0); 569 this.expectError([gl.INVALID_ENUM, gl.INVALID_VALUE]); 570 571 572 gl.deleteTexture(texture[0]); 573 gl.deleteTexture(texture[1]); 574 575 576 })); 577 578 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_inequal_width_height_cube', 'Invalid gl.copyTexImage2D() usage', gl, 579 function() { 580 581 582 /** @type {WebGLTexture} */ var texture; 583 texture = gl.createTexture(); 584 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); 585 586 587 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.'); 588 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 16, 17, 0); 589 this.expectError(gl.INVALID_VALUE); 590 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, 16, 17, 0); 591 this.expectError(gl.INVALID_VALUE); 592 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, 16, 17, 0); 593 this.expectError(gl.INVALID_VALUE); 594 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, 16, 17, 0); 595 this.expectError(gl.INVALID_VALUE); 596 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, 16, 17, 0); 597 this.expectError(gl.INVALID_VALUE); 598 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, 16, 17, 0); 599 this.expectError(gl.INVALID_VALUE); 600 601 602 gl.deleteTexture(texture); 603 604 605 })); 606 607 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_neg_level', 'Invalid gl.copyTexImage2D() usage', gl, 608 function() { 609 610 611 /** @type {Array<WebGLTexture>} */ var texture = []; 612 texture[0] = gl.createTexture(); 613 texture[1] = gl.createTexture(); 614 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 615 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 616 617 618 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 619 gl.copyTexImage2D(gl.TEXTURE_2D, -1, gl.RGB, 0, 0, 64, 64, 0); 620 this.expectError(gl.INVALID_VALUE); 621 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, -1, gl.RGB, 0, 0, 16, 16, 0); 622 this.expectError(gl.INVALID_VALUE); 623 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, -1, gl.RGB, 0, 0, 16, 16, 0); 624 this.expectError(gl.INVALID_VALUE); 625 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, -1, gl.RGB, 0, 0, 16, 16, 0); 626 this.expectError(gl.INVALID_VALUE); 627 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, -1, gl.RGB, 0, 0, 16, 16, 0); 628 this.expectError(gl.INVALID_VALUE); 629 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, gl.RGB, 0, 0, 16, 16, 0); 630 this.expectError(gl.INVALID_VALUE); 631 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, gl.RGB, 0, 0, 16, 16, 0); 632 this.expectError(gl.INVALID_VALUE); 633 634 635 gl.deleteTexture(texture[0]); 636 gl.deleteTexture(texture[1]); 637 638 })); 639 640 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_max_level', 'Invalid gl.copyTexImage2D() usage', gl, 641 function() { 642 643 /** @type {Array<WebGLTexture>} */ var texture = []; 644 texture[0] = gl.createTexture(); 645 texture[1] = gl.createTexture(); 646 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 647 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 648 649 650 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 651 /** @type {number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type {number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 652 gl.copyTexImage2D(gl.TEXTURE_2D, log2MaxTextureSize, gl.RGB, 0, 0, 64, 64, 0); 653 this.expectError(gl.INVALID_VALUE); 654 655 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_TEXTURE_SIZE).'); 656 /** @type {number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type {number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 657 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 658 this.expectError(gl.INVALID_VALUE); 659 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 660 this.expectError(gl.INVALID_VALUE); 661 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 662 this.expectError(gl.INVALID_VALUE); 663 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 664 this.expectError(gl.INVALID_VALUE); 665 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 666 this.expectError(gl.INVALID_VALUE); 667 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, gl.RGB, 0, 0, 16, 16, 0); 668 this.expectError(gl.INVALID_VALUE); 669 670 671 gl.deleteTexture(texture[0]); 672 gl.deleteTexture(texture[1]); 673 674 675 })); 676 677 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_neg_width_height', 'Invalid gl.copyTexImage2D() usage', gl, 678 function() { 679 680 681 /** @type {Array<WebGLTexture>} */ var texture = []; 682 texture[0] = gl.createTexture(); 683 texture[1] = gl.createTexture(); 684 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 685 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 686 687 688 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 689 690 bufferedLogToConsole('gl.TEXTURE_2D target'); 691 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, -1, 1, 0); 692 this.expectError(gl.INVALID_VALUE); 693 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, 1, -1, 0); 694 this.expectError(gl.INVALID_VALUE); 695 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, -1, -1, 0); 696 this.expectError(gl.INVALID_VALUE); 697 698 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 699 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, -1, 1, 0); 700 this.expectError(gl.INVALID_VALUE); 701 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 1, -1, 0); 702 this.expectError(gl.INVALID_VALUE); 703 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, -1, -1, 0); 704 this.expectError(gl.INVALID_VALUE); 705 706 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 707 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, -1, 1, 0); 708 this.expectError(gl.INVALID_VALUE); 709 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, 1, -1, 0); 710 this.expectError(gl.INVALID_VALUE); 711 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, -1, -1, 0); 712 this.expectError(gl.INVALID_VALUE); 713 714 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 715 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, -1, 1, 0); 716 this.expectError(gl.INVALID_VALUE); 717 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, 1, -1, 0); 718 this.expectError(gl.INVALID_VALUE); 719 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, -1, -1, 0); 720 this.expectError(gl.INVALID_VALUE); 721 722 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 723 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, -1, 1, 0); 724 this.expectError(gl.INVALID_VALUE); 725 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, 1, -1, 0); 726 this.expectError(gl.INVALID_VALUE); 727 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, -1, -1, 0); 728 this.expectError(gl.INVALID_VALUE); 729 730 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 731 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, -1, 1, 0); 732 this.expectError(gl.INVALID_VALUE); 733 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, 1, -1, 0); 734 this.expectError(gl.INVALID_VALUE); 735 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, -1, -1, 0); 736 this.expectError(gl.INVALID_VALUE); 737 738 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 739 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, -1, 1, 0); 740 this.expectError(gl.INVALID_VALUE); 741 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, 1, -1, 0); 742 this.expectError(gl.INVALID_VALUE); 743 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, -1, -1, 0); 744 this.expectError(gl.INVALID_VALUE); 745 746 747 gl.deleteTexture(texture[0]); 748 gl.deleteTexture(texture[1]); 749 750 })); 751 752 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_max_width_height', 'Invalid gl.copyTexImage2D() usage', gl, 753 function() { 754 755 756 /** @type {Array<WebGLTexture>} */ var texture = []; 757 texture[0] = gl.createTexture(); 758 texture[1] = gl.createTexture(); 759 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 760 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 761 762 763 var maxTextureSize = /** @type {number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)) + 1; 764 var maxCubemapSize = /** @type {number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)) + 1; 765 766 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_TEXTURE_SIZE.'); 767 768 bufferedLogToConsole('gl.TEXTURE_2D target'); 769 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, maxTextureSize, 1, 0); 770 this.expectError(gl.INVALID_VALUE); 771 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, 1, maxTextureSize, 0); 772 this.expectError(gl.INVALID_VALUE); 773 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, maxTextureSize, maxTextureSize, 0); 774 this.expectError(gl.INVALID_VALUE); 775 776 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 777 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 778 this.expectError(gl.INVALID_VALUE); 779 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 780 this.expectError(gl.INVALID_VALUE); 781 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 782 this.expectError(gl.INVALID_VALUE); 783 784 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 785 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 786 this.expectError(gl.INVALID_VALUE); 787 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 788 this.expectError(gl.INVALID_VALUE); 789 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 790 this.expectError(gl.INVALID_VALUE); 791 792 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 793 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 794 this.expectError(gl.INVALID_VALUE); 795 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 796 this.expectError(gl.INVALID_VALUE); 797 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 798 this.expectError(gl.INVALID_VALUE); 799 800 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 801 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 802 this.expectError(gl.INVALID_VALUE); 803 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 804 this.expectError(gl.INVALID_VALUE); 805 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 806 this.expectError(gl.INVALID_VALUE); 807 808 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 809 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 810 this.expectError(gl.INVALID_VALUE); 811 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 812 this.expectError(gl.INVALID_VALUE); 813 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 814 this.expectError(gl.INVALID_VALUE); 815 816 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 817 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, 1, maxCubemapSize, 0); 818 this.expectError(gl.INVALID_VALUE); 819 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, maxCubemapSize, 1, 0); 820 this.expectError(gl.INVALID_VALUE); 821 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0); 822 this.expectError(gl.INVALID_VALUE); 823 824 825 gl.deleteTexture(texture[0]); 826 gl.deleteTexture(texture[1]); 827 828 829 })); 830 831 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_invalid_border', 'Invalid gl.copyTexImage2D() usage', gl, 832 function() { 833 834 835 /** @type {Array<WebGLTexture>} */ var texture = []; 836 texture[0] = gl.createTexture(); 837 texture[1] = gl.createTexture(); 838 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 839 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 840 841 842 bufferedLogToConsole('gl.INVALID_VALUE is generated if border is not 0.'); 843 844 bufferedLogToConsole('gl.TEXTURE_2D target'); 845 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, 0, 0, -1); 846 this.expectError(gl.INVALID_VALUE); 847 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGB, 0, 0, 0, 0, 1); 848 this.expectError(gl.INVALID_VALUE); 849 850 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 851 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 0, 0, -1); 852 this.expectError(gl.INVALID_VALUE); 853 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 0, 0, 1); 854 this.expectError(gl.INVALID_VALUE); 855 856 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 857 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, 0, 0, -1); 858 this.expectError(gl.INVALID_VALUE); 859 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 0, 0, 0, 0, 1); 860 this.expectError(gl.INVALID_VALUE); 861 862 bufferedLogToConsole('gl.TEXTURE_2D target'); 863 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, 0, 0, -1); 864 this.expectError(gl.INVALID_VALUE); 865 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 0, 0, 0, 0, 1); 866 this.expectError(gl.INVALID_VALUE); 867 868 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 869 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, 0, 0, -1); 870 this.expectError(gl.INVALID_VALUE); 871 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 0, 0, 0, 0, 1); 872 this.expectError(gl.INVALID_VALUE); 873 874 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 875 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, 0, 0, -1); 876 this.expectError(gl.INVALID_VALUE); 877 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 0, 0, 0, 0, 1); 878 this.expectError(gl.INVALID_VALUE); 879 880 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 881 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, 0, 0, -1); 882 this.expectError(gl.INVALID_VALUE); 883 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 0, 0, 0, 0, 1); 884 this.expectError(gl.INVALID_VALUE); 885 886 887 gl.deleteTexture(texture[0]); 888 gl.deleteTexture(texture[1]); 889 890 891 })); 892 893 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copyteximage2d_incomplete_framebuffer', 'Invalid gl.copyTexImage2D() usage', gl, 894 function() { 895 896 897 /** @type {Array<WebGLTexture>} */ var texture = []; 898 texture[0] = gl.createTexture(); 899 texture[1] = gl.createTexture(); 900 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 901 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 902 903 904 /** @type {WebGLFramebuffer} */ var fbo; 905 fbo = gl.createFramebuffer(); 906 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); 907 gl.checkFramebufferStatus(gl.FRAMEBUFFER); 908 909 bufferedLogToConsole('gl.INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.'); 910 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 0, 0, 0, 0, 0); 911 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 912 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGBA8, 0, 0, 0, 0, 0); 913 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 914 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGBA8, 0, 0, 0, 0, 0); 915 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 916 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGBA8, 0, 0, 0, 0, 0); 917 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 918 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGBA8, 0, 0, 0, 0, 0); 919 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 920 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGBA8, 0, 0, 0, 0, 0); 921 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 922 gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGBA8, 0, 0, 0, 0, 0); 923 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 924 925 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 926 gl.deleteFramebuffer(fbo); 927 928 929 gl.deleteTexture(texture[0]); 930 gl.deleteTexture(texture[1]); 931 932 })); 933 934 // gl.copyTexSubImage2D 935 936 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_invalid_target', 'Invalid gl.copyTexSubImage2D() usage', gl, 937 function() { 938 939 /** @type {WebGLTexture} */ var texture; 940 texture = gl.createTexture(); 941 gl.bindTexture(gl.TEXTURE_2D, texture); 942 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 943 944 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 945 gl.copyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4); 946 this.expectError(gl.INVALID_ENUM); 947 948 gl.deleteTexture(texture); 949 })); 950 951 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_neg_level', 'Invalid gl.copyTexSubImage2D() usage', gl, 952 function() { 953 /** @type {Array<WebGLTexture>} */ var texture = []; 954 texture[0] = gl.createTexture(); 955 texture[1] = gl.createTexture(); 956 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 957 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 958 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 959 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 960 gl.texImage2D(faceGL, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 961 }); 962 963 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 964 gl.copyTexSubImage2D(gl.TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4); 965 this.expectError(gl.INVALID_VALUE); 966 var local = this; 967 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 968 gl.copyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4); 969 local.expectError(gl.INVALID_VALUE); 970 }); 971 972 gl.deleteTexture(texture[0]); 973 gl.deleteTexture(texture[1]); 974 })); 975 976 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_max_level', 'Invalid gl.copyTexSubImage2D() usage', gl, 977 function() { 978 /** @type{Array<WebGLTexture>} */ var texture = []; 979 texture[0] = gl.createTexture(); 980 texture[1] = gl.createTexture(); 981 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 982 gl.texImage2D (gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 983 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 984 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 985 gl.texImage2D(faceGL, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 986 }); 987 988 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE) for 2D texture targets.'); 989 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 990 gl.copyTexSubImage2D(gl.TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4); 991 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 992 993 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_SIZE) for cubemap targets.'); 994 /** @type{number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 995 var local = this; 996 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 997 gl.copyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4); 998 local.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 999 }); 1000 1001 gl.deleteTexture(texture[0]); 1002 gl.deleteTexture(texture[1]); 1003 })); 1004 1005 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_neg_offset', 'Invalid gl.copyTexSubImage2D() usage', gl, 1006 function() { 1007 /** @type{WebGLTexture} */ var texture; 1008 texture = gl.createTexture(); 1009 gl.bindTexture(gl.TEXTURE_2D, texture); 1010 gl.texImage2D (gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1011 1012 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.'); 1013 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4); 1014 this.expectError(gl.INVALID_VALUE); 1015 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4); 1016 this.expectError(gl.INVALID_VALUE); 1017 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4); 1018 this.expectError(gl.INVALID_VALUE); 1019 1020 gl.deleteTexture(texture); 1021 })); 1022 1023 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_invalid_offset', 'Invalid gl.copyTexSubImage2D() usage', gl, 1024 function() { 1025 /** @type{WebGLTexture} */ var texture; 1026 texture = gl.createTexture(); 1027 gl.bindTexture(gl.TEXTURE_2D, texture); 1028 gl.texImage2D (gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1029 1030 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.'); 1031 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4); 1032 this.expectError(gl.INVALID_VALUE); 1033 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4); 1034 this.expectError(gl.INVALID_VALUE); 1035 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4); 1036 this.expectError(gl.INVALID_VALUE); 1037 1038 gl.deleteTexture(texture); 1039 })); 1040 1041 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_neg_width_height', 'Invalid gl.copyTexSubImage2D() usage', gl, 1042 function() { 1043 /** @type{WebGLTexture} */ var texture; 1044 texture = gl.createTexture(); 1045 gl.bindTexture(gl.TEXTURE_2D, texture); 1046 gl.texImage2D (gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1047 1048 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 1049 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0); 1050 this.expectError(gl.INVALID_VALUE); 1051 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1); 1052 this.expectError(gl.INVALID_VALUE); 1053 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1); 1054 this.expectError(gl.INVALID_VALUE); 1055 1056 gl.deleteTexture(texture); 1057 })); 1058 1059 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage2d_incomplete_framebuffer', 'Invalid gl.copyTexSubImage2D() usage', gl, 1060 function() { 1061 bufferedLogToConsole('gl.INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.'); 1062 /** @type{Array<WebGLTexture>} */ var texture = []; 1063 /** @type{WebGLFramebuffer} */ var fbo; 1064 texture[0] = gl.createTexture(); 1065 texture[1] = gl.createTexture(); 1066 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1067 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1068 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1069 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1070 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1071 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1072 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1073 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1074 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1075 this.expectError(gl.NO_ERROR); 1076 1077 fbo = gl.createFramebuffer(); 1078 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); 1079 gl.checkFramebufferStatus(gl.FRAMEBUFFER); 1080 this.expectError(gl.NO_ERROR); 1081 1082 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0); 1083 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1084 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0); 1085 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1086 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0); 1087 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1088 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0); 1089 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1090 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0); 1091 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1092 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0); 1093 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1094 gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0); 1095 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 1096 1097 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 1098 gl.deleteFramebuffer(fbo); 1099 gl.deleteTexture(texture[0]); 1100 gl.deleteTexture(texture[1]); 1101 1102 })); 1103 1104 // glDeleteTextures 1105 1106 testGroup.addChild(new es3fApiCase.ApiCaseCallback('deletetextures', 'glDeleteTextures() usage', gl, 1107 function() { 1108 /** @type{WebGLTexture} */ var texture; 1109 texture = gl.createTexture(); 1110 1111 bufferedLogToConsole('gl.NO_ERROR is generated if texture is null.'); 1112 gl.deleteTexture(null); 1113 this.expectError(gl.NO_ERROR); 1114 1115 gl.bindTexture(gl.TEXTURE_2D, texture); 1116 gl.deleteTexture(null); 1117 this.expectError(gl.NO_ERROR); 1118 1119 gl.deleteTexture(texture); 1120 })); 1121 1122 // gl.generateMipmap 1123 1124 testGroup.addChild(new es3fApiCase.ApiCaseCallback('generatemipmap', 'Invalid gl.generateMipmap() usage', gl, 1125 function() { 1126 /** @type{Array<WebGLTexture>} */ var texture = []; 1127 /** @type{WebGLFramebuffer} */ var fbo; 1128 texture[0] = gl.createTexture(); 1129 texture[1] = gl.createTexture(); 1130 1131 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not gl.TEXTURE_2D or gl.TEXTURE_CUBE_MAP.'); 1132 gl.generateMipmap(0); 1133 this.expectError(gl.INVALID_ENUM); 1134 1135 bufferedLogToConsole('INVALID_OPERATION is generated if the texture bound to target is not cube complete.'); 1136 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[0]); 1137 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.REPEAT); 1138 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1139 gl.generateMipmap(gl.TEXTURE_CUBE_MAP); 1140 this.expectError(gl.INVALID_OPERATION); 1141 1142 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[0]); 1143 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 16, 16, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1144 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 16, 16, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1145 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 16, 16, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1146 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 16, 16, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1147 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 16, 16, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1148 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1149 gl.generateMipmap(gl.TEXTURE_CUBE_MAP); 1150 this.expectError(gl.INVALID_OPERATION); 1151 1152 if (haveCompressedTextureETC) { 1153 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.'); 1154 gl.bindTexture(gl.TEXTURE_2D, texture[1]); 1155 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, new Uint8Array(0)); 1156 gl.generateMipmap(gl.TEXTURE_2D); 1157 this.expectError(gl.INVALID_OPERATION); 1158 } else { 1159 etc2Unsupported(); 1160 } 1161 1162 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the level base array was not specified with an unsized internal format or a sized internal format that is both color-renderable and texture-filterable.'); 1163 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8_SNORM, 0, 0, 0, gl.RGB, gl.BYTE, null); 1164 gl.generateMipmap(gl.TEXTURE_2D); 1165 this.expectError(gl.INVALID_OPERATION); 1166 gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8I, 0, 0, 0, gl.RED_INTEGER, gl.BYTE, null); 1167 gl.generateMipmap(gl.TEXTURE_2D); 1168 this.expectError(gl.INVALID_OPERATION); 1169 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, 0, 0, 0, gl.RGBA, gl.FLOAT, null); 1170 gl.generateMipmap(gl.TEXTURE_2D); 1171 this.expectError(gl.INVALID_OPERATION); 1172 1173 gl.deleteTexture(texture[0]); 1174 gl.deleteTexture(texture[1]); 1175 })); 1176 1177 // gl.pixelStorei 1178 1179 testGroup.addChild(new es3fApiCase.ApiCaseCallback('pixelstorei', 'Invalid gl.pixelStorei() usage', gl, 1180 function() { 1181 bufferedLogToConsole('gl.INVALID_ENUM is generated if pname is not an accepted value.'); 1182 gl.pixelStorei(0,1); 1183 this.expectError(gl.INVALID_ENUM); 1184 1185 bufferedLogToConsole('gl.INVALID_VALUE is generated if a negative row length, pixel skip, or row skip value is specified, or if alignment is specified as other than 1, 2, 4, or 8.'); 1186 gl.pixelStorei(gl.PACK_ROW_LENGTH, -1); 1187 this.expectError(gl.INVALID_VALUE); 1188 gl.pixelStorei(gl.PACK_SKIP_ROWS, -1); 1189 this.expectError(gl.INVALID_VALUE); 1190 gl.pixelStorei(gl.PACK_SKIP_PIXELS, -1); 1191 this.expectError(gl.INVALID_VALUE); 1192 gl.pixelStorei(gl.UNPACK_ROW_LENGTH, -1); 1193 this.expectError(gl.INVALID_VALUE); 1194 gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, -1); 1195 this.expectError(gl.INVALID_VALUE); 1196 gl.pixelStorei(gl.UNPACK_SKIP_ROWS, -1); 1197 this.expectError(gl.INVALID_VALUE); 1198 gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, -1); 1199 this.expectError(gl.INVALID_VALUE); 1200 gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, -1); 1201 this.expectError(gl.INVALID_VALUE); 1202 gl.pixelStorei(gl.PACK_ALIGNMENT, 0); 1203 this.expectError(gl.INVALID_VALUE); 1204 gl.pixelStorei(gl.UNPACK_ALIGNMENT, 0); 1205 this.expectError(gl.INVALID_VALUE); 1206 gl.pixelStorei(gl.PACK_ALIGNMENT, 16); 1207 this.expectError(gl.INVALID_VALUE); 1208 gl.pixelStorei(gl.UNPACK_ALIGNMENT, 16); 1209 this.expectError(gl.INVALID_VALUE); 1210 1211 })); 1212 1213 // gl.texImage2D 1214 1215 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d', 'Invalid gl.texImage2D() usage', gl, 1216 function() { 1217 1218 1219 /** @type {WebGLTexture} */ var texture; 1220 texture = gl.createTexture(); 1221 gl.bindTexture(gl.TEXTURE_2D, texture); 1222 1223 1224 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 1225 gl.texImage2D(0, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1226 this.expectError(gl.INVALID_ENUM); 1227 1228 bufferedLogToConsole('gl.INVALID_ENUM is generated if type is not a type constant.'); 1229 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, 0, null); 1230 this.expectError(gl.INVALID_ENUM); 1231 1232 bufferedLogToConsole('gl.INVALID_ENUM is generated if format is not an accepted format constant.'); 1233 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, 0, gl.UNSIGNED_BYTE, null); 1234 this.expectError(gl.INVALID_ENUM); 1235 1236 bufferedLogToConsole('gl.INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants.'); 1237 gl.texImage2D(gl.TEXTURE_2D, 0, 0, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1238 this.expectError(gl.INVALID_VALUE); 1239 1240 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.'); 1241 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1242 this.expectError(gl.INVALID_OPERATION); 1243 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGB, gl.UNSIGNED_SHORT_4_4_4_4, null); 1244 this.expectError(gl.INVALID_OPERATION); 1245 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB5_A1, 1, 1, 0, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, null); 1246 this.expectError(gl.INVALID_OPERATION); 1247 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB10_A2, 1, 1, 0, gl.RGB, gl.UNSIGNED_INT_2_10_10_10_REV, null); 1248 this.expectError(gl.INVALID_OPERATION); 1249 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32UI, 1, 1, 0, gl.RGBA_INTEGER, gl.INT, null); 1250 this.expectError(gl.INVALID_OPERATION); 1251 1252 1253 gl.deleteTexture(texture); 1254 1255 1256 })); 1257 1258 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_inequal_width_height_cube', 'Invalid gl.texImage2D() usage', gl, 1259 function() { 1260 1261 /** @type {WebGLTexture} */ var texture; 1262 texture = gl.createTexture(); 1263 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); 1264 1265 bufferedLogToConsole('gl.INVALID_VALUE is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.'); 1266 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1267 this.expectError(gl.INVALID_VALUE); 1268 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1269 this.expectError(gl.INVALID_VALUE); 1270 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1271 this.expectError(gl.INVALID_VALUE); 1272 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1273 this.expectError(gl.INVALID_VALUE); 1274 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1275 this.expectError(gl.INVALID_VALUE); 1276 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 1, 2, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1277 this.expectError(gl.INVALID_VALUE); 1278 1279 1280 gl.deleteTexture(texture); 1281 1282 1283 })); 1284 1285 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_neg_level', 'Invalid gl.texImage2D() usage', gl, 1286 function() { 1287 1288 /** @type {Array<WebGLTexture>} */ var texture = []; 1289 texture[0] = gl.createTexture(); 1290 texture[1] = gl.createTexture(); 1291 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1292 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1293 1294 1295 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1296 gl.texImage2D(gl.TEXTURE_2D, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1297 this.expectError(gl.INVALID_VALUE); 1298 1299 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1300 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1301 this.expectError(gl.INVALID_VALUE); 1302 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1303 this.expectError(gl.INVALID_VALUE); 1304 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1305 this.expectError(gl.INVALID_VALUE); 1306 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1307 this.expectError(gl.INVALID_VALUE); 1308 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1309 this.expectError(gl.INVALID_VALUE); 1310 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1311 this.expectError(gl.INVALID_VALUE); 1312 1313 1314 gl.deleteTexture(texture[0]); 1315 gl.deleteTexture(texture[1]); 1316 1317 1318 })); 1319 1320 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_max_level', 'Invalid gl.texImage2D() usage', gl, 1321 function() { 1322 1323 /** @type {Array<WebGLTexture>} */ var texture = []; 1324 texture[0] = gl.createTexture(); 1325 texture[1] = gl.createTexture(); 1326 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1327 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1328 1329 1330 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 1331 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 1332 gl.texImage2D(gl.TEXTURE_2D, log2MaxTextureSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1333 this.expectError(gl.INVALID_VALUE); 1334 1335 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_TEXTURE_SIZE).'); 1336 /** @type{number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 1337 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1338 this.expectError(gl.INVALID_VALUE); 1339 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1340 this.expectError(gl.INVALID_VALUE); 1341 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1342 this.expectError(gl.INVALID_VALUE); 1343 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1344 this.expectError(gl.INVALID_VALUE); 1345 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1346 this.expectError(gl.INVALID_VALUE); 1347 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1348 this.expectError(gl.INVALID_VALUE); 1349 1350 1351 gl.deleteTexture(texture[0]); 1352 gl.deleteTexture(texture[1]); 1353 1354 })); 1355 1356 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_neg_width_height', 'Invalid gl.texImage2D() usage', gl, 1357 function() { 1358 1359 /** @type {Array<WebGLTexture>} */ var texture = []; 1360 texture[0] = gl.createTexture(); 1361 texture[1] = gl.createTexture(); 1362 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1363 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1364 1365 1366 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 1367 1368 bufferedLogToConsole('gl.TEXTURE_2D target'); 1369 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1370 this.expectError(gl.INVALID_VALUE); 1371 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1372 this.expectError(gl.INVALID_VALUE); 1373 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1374 this.expectError(gl.INVALID_VALUE); 1375 1376 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 1377 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1378 this.expectError(gl.INVALID_VALUE); 1379 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1380 this.expectError(gl.INVALID_VALUE); 1381 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1382 this.expectError(gl.INVALID_VALUE); 1383 1384 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 1385 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1386 this.expectError(gl.INVALID_VALUE); 1387 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1388 this.expectError(gl.INVALID_VALUE); 1389 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1390 this.expectError(gl.INVALID_VALUE); 1391 1392 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 1393 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1394 this.expectError(gl.INVALID_VALUE); 1395 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1396 this.expectError(gl.INVALID_VALUE); 1397 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1398 this.expectError(gl.INVALID_VALUE); 1399 1400 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 1401 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1402 this.expectError(gl.INVALID_VALUE); 1403 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1404 this.expectError(gl.INVALID_VALUE); 1405 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1406 this.expectError(gl.INVALID_VALUE); 1407 1408 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 1409 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1410 this.expectError(gl.INVALID_VALUE); 1411 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1412 this.expectError(gl.INVALID_VALUE); 1413 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1414 this.expectError(gl.INVALID_VALUE); 1415 1416 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 1417 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, -1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1418 this.expectError(gl.INVALID_VALUE); 1419 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1420 this.expectError(gl.INVALID_VALUE); 1421 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, -1, -1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1422 this.expectError(gl.INVALID_VALUE); 1423 1424 1425 gl.deleteTexture(texture[0]); 1426 gl.deleteTexture(texture[1]); 1427 1428 1429 })); 1430 1431 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_max_width_height', 'Invalid gl.texImage2D() usage', gl, 1432 function() { 1433 1434 /** @type {Array<WebGLTexture>} */ var texture = []; 1435 texture[0] = gl.createTexture(); 1436 texture[1] = gl.createTexture(); 1437 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1438 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1439 1440 1441 var maxTextureSize = /** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)) + 1; 1442 var maxCubemapSize = /** @type{number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)) + 1; 1443 1444 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_TEXTURE_SIZE.'); 1445 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, maxTextureSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1446 this.expectError(gl.INVALID_VALUE); 1447 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, maxTextureSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1448 this.expectError(gl.INVALID_VALUE); 1449 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, maxTextureSize, maxTextureSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1450 this.expectError(gl.INVALID_VALUE); 1451 1452 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is greater than gl.MAX_CUBE_MAP_TEXTURE_SIZE.'); 1453 1454 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_X target'); 1455 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1456 this.expectError(gl.INVALID_VALUE); 1457 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1458 this.expectError(gl.INVALID_VALUE); 1459 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1460 this.expectError(gl.INVALID_VALUE); 1461 1462 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Y target'); 1463 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1464 this.expectError(gl.INVALID_VALUE); 1465 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1466 this.expectError(gl.INVALID_VALUE); 1467 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1468 this.expectError(gl.INVALID_VALUE); 1469 1470 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_POSITIVE_Z target'); 1471 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1472 this.expectError(gl.INVALID_VALUE); 1473 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1474 this.expectError(gl.INVALID_VALUE); 1475 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1476 this.expectError(gl.INVALID_VALUE); 1477 1478 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_X target'); 1479 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1480 this.expectError(gl.INVALID_VALUE); 1481 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1482 this.expectError(gl.INVALID_VALUE); 1483 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1484 this.expectError(gl.INVALID_VALUE); 1485 1486 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Y target'); 1487 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1488 this.expectError(gl.INVALID_VALUE); 1489 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1490 this.expectError(gl.INVALID_VALUE); 1491 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1492 this.expectError(gl.INVALID_VALUE); 1493 1494 bufferedLogToConsole('gl.TEXTURE_CUBE_MAP_NEGATIVE_Z target'); 1495 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, maxCubemapSize, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1496 this.expectError(gl.INVALID_VALUE); 1497 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 1, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1498 this.expectError(gl.INVALID_VALUE); 1499 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, maxCubemapSize, maxCubemapSize, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1500 this.expectError(gl.INVALID_VALUE); 1501 1502 1503 gl.deleteTexture(texture[0]); 1504 gl.deleteTexture(texture[1]); 1505 1506 1507 })); 1508 1509 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage2d_invalid_border', 'Invalid gl.texImage2D() usage', gl, 1510 function() { 1511 1512 /** @type {Array<WebGLTexture>} */ var texture = []; 1513 texture[0] = gl.createTexture(); 1514 texture[1] = gl.createTexture(); 1515 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1516 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1517 1518 1519 bufferedLogToConsole('gl.INVALID_VALUE is generated if border is not 0.'); 1520 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1521 this.expectError(gl.INVALID_VALUE); 1522 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, -1, gl.RGB, gl.UNSIGNED_BYTE, null); 1523 this.expectError(gl.INVALID_VALUE); 1524 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1525 this.expectError(gl.INVALID_VALUE); 1526 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1527 this.expectError(gl.INVALID_VALUE); 1528 gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1529 this.expectError(gl.INVALID_VALUE); 1530 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1531 this.expectError(gl.INVALID_VALUE); 1532 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1533 this.expectError(gl.INVALID_VALUE); 1534 gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, 1, 1, 1, gl.RGB, gl.UNSIGNED_BYTE, null); 1535 this.expectError(gl.INVALID_VALUE); 1536 1537 1538 gl.deleteTexture(texture[0]); 1539 gl.deleteTexture(texture[1]); 1540 1541 })); 1542 1543 // gl.texSubImage2D 1544 1545 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d', 'Invalid gl.texSubImage2D() usage', gl, 1546 function() { 1547 /** @type{WebGLTexture} */ var texture; 1548 texture = gl.createTexture(); 1549 gl.bindTexture(gl.TEXTURE_2D, texture); 1550 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1551 this.expectError(gl.NO_ERROR); 1552 1553 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(64); 1554 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 1555 gl.texSubImage2D(0, 0, 0, 0, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1556 this.expectError(gl.INVALID_ENUM); 1557 1558 bufferedLogToConsole('gl.INVALID_ENUM is generated if format is not an accepted format constant.'); 1559 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 4, 4, gl.UNSIGNED_BYTE, uint8); 1560 this.expectError(gl.INVALID_ENUM); 1561 1562 bufferedLogToConsole('gl.INVALID_ENUM is generated if type is not a type constant.'); 1563 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGB, 0, uint8); 1564 this.expectError(gl.INVALID_ENUM); 1565 1566 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.'); 1567 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGBA, gl.UNSIGNED_SHORT_5_6_5, uint8); 1568 this.expectError(gl.INVALID_OPERATION); 1569 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_4_4_4_4, uint8); 1570 this.expectError(gl.INVALID_OPERATION); 1571 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, uint8); 1572 this.expectError(gl.INVALID_OPERATION); 1573 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, uint8); 1574 this.expectError(gl.INVALID_OPERATION); 1575 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGBA_INTEGER, gl.UNSIGNED_INT, uint8); 1576 this.expectError(gl.INVALID_OPERATION); 1577 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGB, gl.FLOAT, uint8); 1578 this.expectError(gl.INVALID_OPERATION); 1579 1580 gl.deleteTexture(texture); 1581 })); 1582 1583 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d_neg_level', 'Invalid gl.texSubImage2D() usage', gl, 1584 function() { 1585 /** @type{Array<WebGLTexture>} */ var texture = []; 1586 texture[0] = gl.createTexture(); 1587 texture[1] = gl.createTexture(); 1588 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1589 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1590 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1591 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1592 gl.texImage2D(faceGL, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1593 }); 1594 this.expectError(gl.NO_ERROR); 1595 1596 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 1597 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1598 gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1599 this.expectError(gl.INVALID_VALUE); 1600 1601 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1602 var local = this; 1603 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1604 gl.texSubImage2D(faceGL, -1, 0, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1605 local.expectError(gl.INVALID_VALUE); 1606 }); 1607 1608 gl.deleteTexture(texture[0]); 1609 gl.deleteTexture(texture[1]); 1610 })); 1611 1612 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d_max_level', 'Invalid gl.texSubImage2D() usage', gl, 1613 function() { 1614 /** @type{Array<WebGLTexture>} */ var texture = []; 1615 texture[0] = gl.createTexture(); 1616 texture[1] = gl.createTexture(); 1617 gl.bindTexture (gl.TEXTURE_2D, texture[0]); 1618 gl.texImage2D (gl.TEXTURE_2D, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1619 gl.bindTexture (gl.TEXTURE_CUBE_MAP, texture[1]); 1620 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1621 gl.texImage2D(faceGL, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1622 }); 1623 1624 this.expectError (gl.NO_ERROR); 1625 1626 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 1627 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 1628 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 1629 gl.texSubImage2D(gl.TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1630 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1631 1632 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_TEXTURE_SIZE).'); 1633 /** @type{number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 1634 var local = this; 1635 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1636 gl.texSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1637 local.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1638 }); 1639 1640 gl.deleteTexture(texture[0]); 1641 gl.deleteTexture(texture[1]); 1642 })); 1643 1644 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d_neg_offset', 'Invalid gl.texSubImage2D() usage', gl, 1645 function() { 1646 /** @type{WebGLTexture} */ var texture; 1647 texture = gl.createTexture(); 1648 gl.bindTexture(gl.TEXTURE_2D, texture); 1649 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 32, 32, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 1650 this.expectError(gl.NO_ERROR); 1651 1652 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 1653 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset or yoffset are negative.'); 1654 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1655 this.expectError(gl.INVALID_VALUE); 1656 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1657 this.expectError(gl.INVALID_VALUE); 1658 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, -1, 0, 0, gl.RGB, gl.UNSIGNED_BYTE, uint8); 1659 this.expectError(gl.INVALID_VALUE); 1660 1661 gl.deleteTexture(texture); 1662 })); 1663 1664 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d_invalid_offset', 'Invalid gl.texSubImage2D() usage', gl, 1665 function() { 1666 /** @type{WebGLTexture} */ var texture; 1667 texture = gl.createTexture(); 1668 gl.bindTexture(gl.TEXTURE_2D, texture); 1669 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1670 this.expectError(gl.NO_ERROR); 1671 1672 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(64); 1673 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.'); 1674 gl.texSubImage2D(gl.TEXTURE_2D, 0, 30, 0, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1675 this.expectError(gl.INVALID_VALUE); 1676 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 30, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1677 this.expectError(gl.INVALID_VALUE); 1678 gl.texSubImage2D(gl.TEXTURE_2D, 0, 30, 30, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1679 this.expectError(gl.INVALID_VALUE); 1680 1681 gl.deleteTexture(texture); 1682 })); 1683 1684 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage2d_neg_width_height', 'Invalid gl.texSubImage2D() usage', gl, 1685 function() { 1686 /** @type{WebGLTexture} */ var texture; 1687 texture = gl.createTexture(); 1688 gl.bindTexture(gl.TEXTURE_2D, texture); 1689 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1690 this.expectError(gl.NO_ERROR); 1691 1692 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 1693 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 1694 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1695 this.expectError(gl.INVALID_VALUE); 1696 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1697 this.expectError(gl.INVALID_VALUE); 1698 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, -1, -1, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 1699 this.expectError(gl.INVALID_VALUE); 1700 1701 gl.deleteTexture(texture); 1702 })); 1703 1704 // gl.texParameteri 1705 1706 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texparameteri', 'Invalid gl.texParameteri() usage', gl, 1707 function() { 1708 bufferedLogToConsole('gl.INVALID_ENUM is generated if target or pname is not one of the accepted defined values.'); 1709 gl.texParameteri(0, gl.TEXTURE_MIN_FILTER, gl.LINEAR); 1710 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1711 gl.texParameteri(gl.TEXTURE_2D, 0, gl.LINEAR); 1712 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1713 gl.texParameteri(0, 0, gl.LINEAR); 1714 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1715 1716 bufferedLogToConsole('gl.INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.'); 1717 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, 0); 1718 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1719 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.REPEAT); 1720 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1721 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, 0); 1722 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1723 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.NEAREST); 1724 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1725 1726 /** @type{WebGLTexture} */ var texture; 1727 texture = gl.createTexture(); 1728 gl.bindTexture(gl.TEXTURE_2D, texture); 1729 1730 bufferedLogToConsole('gl.INVALID_ENUM is generated if target or pname is not one of the accepted defined values.'); 1731 gl.texParameteri(0, gl.TEXTURE_MIN_FILTER, gl.LINEAR); 1732 this.expectError(gl.INVALID_ENUM); 1733 gl.texParameteri(gl.TEXTURE_2D, 0, gl.LINEAR); 1734 this.expectError(gl.INVALID_ENUM); 1735 gl.texParameteri(0, 0, gl.LINEAR); 1736 this.expectError(gl.INVALID_ENUM); 1737 1738 bufferedLogToConsole('gl.INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.'); 1739 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, 0); 1740 this.expectError(gl.INVALID_ENUM); 1741 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.REPEAT); 1742 this.expectError(gl.INVALID_ENUM); 1743 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, 0); 1744 this.expectError(gl.INVALID_ENUM); 1745 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.NEAREST); 1746 this.expectError(gl.INVALID_ENUM); 1747 1748 gl.deleteTexture(texture); 1749 })); 1750 1751 // gl.texParameterf 1752 1753 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texparameterf', 'Invalid gl.texParameterf() usage', gl, 1754 function() { 1755 bufferedLogToConsole('gl.INVALID_ENUM is generated if target or pname is not one of the accepted defined values.'); 1756 gl.texParameterf(0, gl.TEXTURE_MIN_FILTER, gl.LINEAR); 1757 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1758 gl.texParameterf(gl.TEXTURE_2D, 0, gl.LINEAR); 1759 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1760 gl.texParameterf(0, 0, gl.LINEAR); 1761 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1762 1763 bufferedLogToConsole('gl.INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.'); 1764 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, 0); 1765 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1766 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.REPEAT); 1767 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1768 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, 0); 1769 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1770 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.NEAREST); 1771 this.expectError([gl.INVALID_ENUM, gl.INVALID_OPERATION]); 1772 1773 /** @type{ WebGLTexture} */ var texture; 1774 texture = gl.createTexture(); 1775 gl.bindTexture(gl.TEXTURE_2D, texture); 1776 1777 bufferedLogToConsole('gl.INVALID_ENUM is generated if target or pname is not one of the accepted defined values.'); 1778 gl.texParameterf(0, gl.TEXTURE_MIN_FILTER, gl.LINEAR); 1779 this.expectError(gl.INVALID_ENUM); 1780 gl.texParameterf(gl.TEXTURE_2D, 0, gl.LINEAR); 1781 this.expectError(gl.INVALID_ENUM); 1782 gl.texParameterf(0, 0, gl.LINEAR); 1783 this.expectError(gl.INVALID_ENUM); 1784 1785 bufferedLogToConsole('gl.INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.'); 1786 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, 0); 1787 this.expectError(gl.INVALID_ENUM); 1788 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.REPEAT); 1789 this.expectError(gl.INVALID_ENUM); 1790 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, 0); 1791 this.expectError(gl.INVALID_ENUM); 1792 gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.NEAREST); 1793 this.expectError(gl.INVALID_ENUM); 1794 1795 gl.deleteTexture(texture); 1796 })); 1797 1798 // gl.compressedTexSubImage2D 1799 1800 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1801 function() { 1802 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1803 1804 /** @type{WebGLTexture} */ var texture; 1805 texture = gl.createTexture(); 1806 gl.bindTexture (gl.TEXTURE_2D, texture); 1807 1808 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 1809 gl.compressedTexSubImage2D(0, 0, 0, 0, 0, 0, gl.COMPRESSED_RGB8_ETC2, new Uint8Array(0)); 1810 this.expectError(gl.INVALID_ENUM); 1811 1812 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 1813 this.expectError (gl.NO_ERROR); 1814 1815 bufferedLogToConsole('gl.INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.'); 1816 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.COMPRESSED_RGB8_ETC2, new Uint8Array(0)); 1817 this.expectError(gl.INVALID_OPERATION); 1818 1819 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if width is not a multiple of four, and width + xoffset is not equal to the width of the texture level.'); 1820 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 4, 0, 10, 4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(10, 4))); 1821 this.expectError(gl.INVALID_OPERATION); 1822 1823 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if height is not a multiple of four, and height + yoffset is not equal to the height of the texture level.'); 1824 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 4, 4, 10, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 10))); 1825 this.expectError(gl.INVALID_OPERATION); 1826 1827 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.'); 1828 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 1, 4, 4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 1829 this.expectError(gl.INVALID_OPERATION); 1830 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 1, 0, 4, 4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 1831 this.expectError(gl.INVALID_OPERATION); 1832 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 1, 1, 4, 4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 1833 this.expectError(gl.INVALID_OPERATION); 1834 1835 gl.deleteTexture(texture); 1836 })); 1837 1838 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_neg_level', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1839 function() { 1840 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1841 1842 /** @type{Array<WebGLTexture>} */ var texture = []; 1843 texture[0] = gl.createTexture(); 1844 texture[1] = gl.createTexture(); 1845 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1846 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 1847 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1848 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1849 gl.compressedTexImage2D(faceGL, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 1850 }); 1851 1852 this.expectError(gl.NO_ERROR); 1853 1854 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1855 gl.compressedTexSubImage2D(gl.TEXTURE_2D, -1, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1856 this.expectError(gl.INVALID_VALUE); 1857 1858 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 1859 var local = this; 1860 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1861 gl.compressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1862 local.expectError(gl.INVALID_VALUE); 1863 }); 1864 1865 gl.deleteTexture(texture[0]); 1866 gl.deleteTexture(texture[1]); 1867 })); 1868 1869 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_max_level', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1870 function() { 1871 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1872 1873 /** @type{Array<WebGLTexture>} */ var texture = []; 1874 texture[0] = gl.createTexture(); 1875 texture[1] = gl.createTexture(); 1876 gl.bindTexture(gl.TEXTURE_2D, texture[0]); 1877 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 1878 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture[1]); 1879 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1880 gl.compressedTexImage2D(faceGL, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 1881 }); 1882 1883 this.expectError(gl.NO_ERROR); 1884 1885 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 1886 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 1887 gl.compressedTexSubImage2D(gl.TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1888 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1889 1890 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_CUBE_MAP_TEXTURE_SIZE).'); 1891 /** @type{number} */ var log2MaxCubemapSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)))) + 1; 1892 var local = this; 1893 es3fNegativeTextureApiTests.forCubeFaces(function(faceGL) { 1894 gl.compressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1895 local.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1896 }); 1897 1898 gl.deleteTexture(texture[0]); 1899 gl.deleteTexture(texture[1]); 1900 })); 1901 1902 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_neg_offset', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1903 function() { 1904 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1905 1906 /** @type{ WebGLTexture} */ var texture; 1907 texture = gl.createTexture(); 1908 gl.bindTexture(gl.TEXTURE_2D, texture); 1909 gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(8, 8))); 1910 1911 // \note Both gl.INVALID_VALUE and gl.INVALID_OPERATION are valid here since implementation may 1912 // first check if offsets are valid for certain format and only after that check that they 1913 // are not negative. 1914 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if xoffset or yoffset are negative.'); 1915 1916 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, -4, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1917 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1918 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, -4, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1919 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1920 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, -4, -4, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1921 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1922 1923 gl.deleteTexture(texture); 1924 })); 1925 1926 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_invalid_offset', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1927 function() { 1928 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1929 1930 /** @type{WebGLTexture} */ var texture; 1931 texture = gl.createTexture(); 1932 gl.bindTexture (gl.TEXTURE_2D, texture); 1933 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 1934 this.expectError (gl.NO_ERROR); 1935 1936 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.'); 1937 1938 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 12, 0, 8, 4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(8, 4))); 1939 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1940 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 12, 4, 8, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 8))); 1941 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1942 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 12, 12, 8, 8, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(8, 8))); 1943 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1944 1945 gl.deleteTexture(texture); 1946 })); 1947 1948 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_neg_width_height', 'Invalid gl.compressedTexSubImage2D() usage', gl, 1949 function() { 1950 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1951 1952 /** @type{WebGLTexture} */ var texture; 1953 texture = gl.createTexture(); 1954 gl.bindTexture (gl.TEXTURE_2D, texture); 1955 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 1956 this.expectError (gl.NO_ERROR); 1957 1958 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if width or height is less than 0.'); 1959 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, -4, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1960 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1961 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, -4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1962 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1963 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, -4, -4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 1964 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 1965 1966 gl.deleteTexture(texture); 1967 })); 1968 1969 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage2d_invalid_size', 'Invalid gl.compressedTexImage2D() usage', gl, 1970 function() { 1971 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 1972 1973 /** @type{WebGLTexture} */ var texture; 1974 texture = gl.createTexture(); 1975 gl.bindTexture (gl.TEXTURE_2D, texture); 1976 gl.compressedTexImage2D (gl.TEXTURE_2D, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 1977 this.expectError (gl.NO_ERROR); 1978 1979 bufferedLogToConsole('gl.INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.'); 1980 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(1)); 1981 this.expectError(gl.INVALID_VALUE); 1982 1983 gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 16, 16, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(4*4*16-1)); 1984 this.expectError(gl.INVALID_VALUE); 1985 1986 gl.deleteTexture(texture); 1987 })); 1988 1989 // gl.texImage3D 1990 1991 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d', 'Invalid gl.texImage3D() usage', gl, 1992 function() { 1993 /** @type{Array<WebGLTexture>} */ var texture = []; 1994 texture[0] = gl.createTexture(); 1995 texture[1] = gl.createTexture(); 1996 gl.bindTexture (gl.TEXTURE_2D, texture[0]); 1997 gl.bindTexture (gl.TEXTURE_3D, texture[1]); 1998 1999 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 2000 gl.texImage3D(0, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2001 this.expectError(gl.INVALID_ENUM); 2002 gl.texImage3D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2003 this.expectError(gl.INVALID_ENUM); 2004 2005 bufferedLogToConsole('gl.INVALID_ENUM is generated if type is not a type constant.'); 2006 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, 0, null); 2007 this.expectError(gl.INVALID_ENUM); 2008 2009 bufferedLogToConsole('gl.INVALID_ENUM is generated if format is not an accepted format constant.'); 2010 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, 0, gl.UNSIGNED_BYTE, null); 2011 this.expectError(gl.INVALID_ENUM); 2012 2013 bufferedLogToConsole('gl.INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants.'); 2014 gl.texImage3D(gl.TEXTURE_3D, 0, 0, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2015 this.expectError(gl.INVALID_VALUE); 2016 2017 bufferedLogToConsole('gl.INVALID_OPERATION is generated if target is gl.TEXTURE_3D and format is gl.DEPTH_COMPONENT, or gl.DEPTH_STENCIL.'); 2018 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_BYTE, null); 2019 this.expectError(gl.INVALID_OPERATION); 2020 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_BYTE, null); 2021 this.expectError(gl.INVALID_OPERATION); 2022 2023 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.'); 2024 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2025 this.expectError(gl.INVALID_OPERATION); 2026 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_SHORT_4_4_4_4, null); 2027 this.expectError(gl.INVALID_OPERATION); 2028 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB5_A1, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, null); 2029 this.expectError(gl.INVALID_OPERATION); 2030 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB10_A2, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_INT_2_10_10_10_REV, null); 2031 this.expectError(gl.INVALID_OPERATION); 2032 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA32UI, 1, 1, 1, 0, gl.RGBA_INTEGER, gl.INT, null); 2033 this.expectError(gl.INVALID_OPERATION); 2034 2035 gl.deleteTexture(texture[0]); 2036 gl.deleteTexture(texture[1]); 2037 })); 2038 2039 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d_neg_level', 'Invalid gl.texImage3D() usage', gl, 2040 function() { 2041 // NOTE: this method hangs the browser if the textures are binded. 2042 /** @type{Array<WebGLTexture>} */ var texture = []; 2043 texture[0] = gl.createTexture(); 2044 texture[1] = gl.createTexture(); 2045 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2046 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2047 2048 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 2049 gl.texImage3D(gl.TEXTURE_3D, -1, gl.RGB, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 2050 this.expectError(gl.INVALID_VALUE); 2051 gl.texImage3D(gl.TEXTURE_2D_ARRAY, -1, gl.RGB, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 2052 this.expectError(gl.INVALID_VALUE); 2053 2054 gl.deleteTexture(texture[0]); 2055 gl.deleteTexture(texture[1]); 2056 2057 })); 2058 2059 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d_max_level', 'Invalid gl.texImage3D() usage', gl, 2060 function() { 2061 2062 /** @type{Array<WebGLTexture>} */ var texture = []; 2063 texture[0] = gl.createTexture(); 2064 texture[1] = gl.createTexture(); 2065 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2066 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2067 2068 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_3D_TEXTURE_SIZE).'); 2069 /** @type{number} */ var log2Max3DTextureSize = Math.floor(Math.log2(/** @type{number} */ (gl.getParameter(gl.MAX_3D_TEXTURE_SIZE)))) + 1; 2070 gl.texImage3D(gl.TEXTURE_3D, log2Max3DTextureSize, gl.RGB, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 2071 this.expectError(gl.INVALID_VALUE); 2072 2073 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 2074 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */ (gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 2075 gl.texImage3D(gl.TEXTURE_2D_ARRAY, log2MaxTextureSize, gl.RGB, 1, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); 2076 this.expectError(gl.INVALID_VALUE); 2077 2078 gl.deleteTexture(texture[0]); 2079 gl.deleteTexture(texture[1]); 2080 2081 })); 2082 2083 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d_neg_width_height_depth', 'Invalid gl.texImage3D() usage', gl, 2084 function() { 2085 2086 /** @type{Array<WebGLTexture>} */ var texture = []; 2087 texture[0] = gl.createTexture(); 2088 texture[1] = gl.createTexture(); 2089 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2090 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2091 2092 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height is less than 0.'); 2093 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, -1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2094 this.expectError(gl.INVALID_VALUE); 2095 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, -1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2096 this.expectError(gl.INVALID_VALUE); 2097 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2098 this.expectError(gl.INVALID_VALUE); 2099 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, -1, -1, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2100 this.expectError(gl.INVALID_VALUE); 2101 2102 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, -1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2103 this.expectError(gl.INVALID_VALUE); 2104 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 1, -1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2105 this.expectError(gl.INVALID_VALUE); 2106 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 1, 1, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2107 this.expectError(gl.INVALID_VALUE); 2108 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, -1, -1, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2109 this.expectError(gl.INVALID_VALUE); 2110 2111 gl.deleteTexture(texture[0]); 2112 gl.deleteTexture(texture[1]); 2113 })); 2114 2115 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d_max_width_height_depth', 'Invalid gl.texImage3D() usage', gl, 2116 function() { 2117 2118 /** @type{Array<WebGLTexture>} */ var texture = []; 2119 texture[0] = gl.createTexture(); 2120 texture[1] = gl.createTexture(); 2121 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2122 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2123 2124 var max3DTextureSize = /** @type{number} */ (gl.getParameter(gl.MAX_3D_TEXTURE_SIZE)) + 1; 2125 var maxTextureSize = /** @type{number} */ (gl.getParameter(gl.MAX_TEXTURE_SIZE)) + 1; 2126 2127 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth is greater than gl.MAX_3D_TEXTURE_SIZE.'); 2128 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, max3DTextureSize, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2129 this.expectError(gl.INVALID_VALUE); 2130 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, max3DTextureSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2131 this.expectError(gl.INVALID_VALUE); 2132 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, max3DTextureSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2133 this.expectError(gl.INVALID_VALUE); 2134 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2135 this.expectError(gl.INVALID_VALUE); 2136 2137 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth is greater than gl.MAX_TEXTURE_SIZE.'); 2138 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, maxTextureSize, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2139 this.expectError(gl.INVALID_VALUE); 2140 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 1, maxTextureSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2141 this.expectError(gl.INVALID_VALUE); 2142 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 1, 1, maxTextureSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2143 this.expectError(gl.INVALID_VALUE); 2144 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, maxTextureSize, maxTextureSize, maxTextureSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2145 this.expectError(gl.INVALID_VALUE); 2146 2147 gl.deleteTexture(texture[0]); 2148 gl.deleteTexture(texture[1]); 2149 })); 2150 2151 testGroup.addChild(new es3fApiCase.ApiCaseCallback('teximage3d_invalid_border', 'Invalid gl.texImage3D() usage', gl, 2152 function() { 2153 /** @type{Array<WebGLTexture>} */ var texture = []; 2154 texture[0] = gl.createTexture(); 2155 texture[1] = gl.createTexture(); 2156 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2157 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2158 2159 bufferedLogToConsole('gl.INVALID_VALUE is generated if border is not 0 or 1.'); 2160 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB, 1, 1, 1, -1, gl.RGB, gl.UNSIGNED_BYTE, null); 2161 this.expectError(gl.INVALID_VALUE); 2162 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB, 1, 1, 1, 2, gl.RGB, gl.UNSIGNED_BYTE, null); 2163 this.expectError(gl.INVALID_VALUE); 2164 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGB, 1, 1, 1, -1, gl.RGB, gl.UNSIGNED_BYTE, null); 2165 this.expectError(gl.INVALID_VALUE); 2166 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGB, 1, 1, 1, 2, gl.RGB, gl.UNSIGNED_BYTE, null); 2167 this.expectError(gl.INVALID_VALUE); 2168 2169 gl.deleteTexture(texture[0]); 2170 gl.deleteTexture(texture[1]); 2171 })); 2172 2173 // gl.texSubImage3D 2174 2175 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d', 'Invalid gl.texSubImage3D() usage', gl, 2176 function() { 2177 /** @type{WebGLTexture} */ var texture; 2178 texture = gl.createTexture(); 2179 gl.bindTexture (gl.TEXTURE_3D, texture); 2180 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2181 this.expectError (gl.NO_ERROR); 2182 2183 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(256); 2184 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 2185 gl.texSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2186 this.expectError(gl.INVALID_ENUM); 2187 gl.texSubImage3D(gl.TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2188 this.expectError(gl.INVALID_ENUM); 2189 2190 bufferedLogToConsole('gl.INVALID_ENUM is generated if format is not an accepted format constant.'); 2191 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, gl.UNSIGNED_BYTE, uint8); 2192 this.expectError(gl.INVALID_ENUM); 2193 2194 bufferedLogToConsole('gl.INVALID_ENUM is generated if type is not a type constant.'); 2195 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGB, 0, uint8); 2196 this.expectError(gl.INVALID_ENUM); 2197 2198 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.'); 2199 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_4_4_4_4, uint8); 2200 this.expectError(gl.INVALID_OPERATION); 2201 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, uint8); 2202 this.expectError(gl.INVALID_OPERATION); 2203 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGB, gl.UNSIGNED_SHORT_5_5_5_1, uint8); 2204 this.expectError(gl.INVALID_OPERATION); 2205 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGBA_INTEGER, gl.UNSIGNED_INT, uint8); 2206 this.expectError(gl.INVALID_OPERATION); 2207 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, gl.RGB, gl.FLOAT, uint8); 2208 this.expectError(gl.INVALID_OPERATION); 2209 2210 gl.deleteTexture(texture); 2211 })); 2212 2213 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d_neg_level', 'Invalid gl.texSubImage3D() usage', gl, 2214 function() { 2215 /** @type{Array<WebGLTexture>} */ var texture = []; 2216 texture[0] = gl.createTexture(); 2217 texture[1] = gl.createTexture(); 2218 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2219 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2220 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2221 gl.texImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2222 this.expectError (gl.NO_ERROR); 2223 2224 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 2225 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 2226 gl.texSubImage3D(gl.TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2227 this.expectError(gl.INVALID_VALUE); 2228 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2229 this.expectError(gl.INVALID_VALUE); 2230 2231 gl.deleteTexture(texture[0]); 2232 gl.deleteTexture(texture[1]); 2233 })); 2234 2235 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d_max_level', 'Invalid gl.texSubImage3D() usage', gl, 2236 function() { 2237 /** @type{Array<WebGLTexture>} */ var texture = []; 2238 texture[0] = gl.createTexture(); 2239 texture[1] = gl.createTexture(); 2240 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2241 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2242 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2243 gl.texImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2244 this.expectError (gl.NO_ERROR); 2245 2246 /** @type{number} */ var log2Max3DTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_3D_TEXTURE_SIZE)))) + 1; 2247 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 2248 2249 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 2250 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_3D_TEXTURE_SIZE).'); 2251 gl.texSubImage3D(gl.TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2252 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2253 2254 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 2255 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2256 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2257 2258 gl.deleteTexture(texture[0]); 2259 gl.deleteTexture(texture[1]); 2260 })); 2261 2262 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d_neg_offset', 'Invalid gl.texSubImage3D() usage', gl, 2263 function() { 2264 /** @type{Array<WebGLTexture>} */ var texture = []; 2265 texture[0] = gl.createTexture(); 2266 texture[1] = gl.createTexture(); 2267 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2268 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2269 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2270 gl.texImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2271 this.expectError (gl.NO_ERROR); 2272 2273 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 2274 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.'); 2275 gl.texSubImage3D(gl.TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2276 this.expectError(gl.INVALID_VALUE); 2277 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2278 this.expectError(gl.INVALID_VALUE); 2279 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2280 this.expectError(gl.INVALID_VALUE); 2281 gl.texSubImage3D(gl.TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2282 this.expectError(gl.INVALID_VALUE); 2283 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2284 this.expectError(gl.INVALID_VALUE); 2285 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2286 this.expectError(gl.INVALID_VALUE); 2287 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2288 this.expectError(gl.INVALID_VALUE); 2289 gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2290 this.expectError(gl.INVALID_VALUE); 2291 2292 gl.deleteTexture(texture[0]); 2293 gl.deleteTexture(texture[1]); 2294 })); 2295 2296 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d_invalid_offset', 'Invalid gl.texSubImage3D() usage', gl, 2297 function() { 2298 /** @type{WebGLTexture} */ var texture; 2299 texture = gl.createTexture(); 2300 gl.bindTexture (gl.TEXTURE_3D, texture); 2301 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2302 this.expectError (gl.NO_ERROR); 2303 2304 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(256); 2305 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset + width > texture_width.'); 2306 gl.texSubImage3D(gl.TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2307 this.expectError(gl.INVALID_VALUE); 2308 2309 bufferedLogToConsole('gl.INVALID_VALUE is generated if yoffset + height > texture_height.'); 2310 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2311 this.expectError(gl.INVALID_VALUE); 2312 2313 bufferedLogToConsole('gl.INVALID_VALUE is generated if zoffset + depth > texture_depth.'); 2314 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2315 this.expectError(gl.INVALID_VALUE); 2316 2317 gl.deleteTexture(texture); 2318 })); 2319 2320 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texsubimage3d_neg_width_height', 'Invalid gl.texSubImage3D() usage', gl, 2321 function() { 2322 /** @type{WebGLTexture} */ var texture; 2323 texture = gl.createTexture(); 2324 gl.bindTexture (gl.TEXTURE_3D, texture); 2325 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2326 2327 /** @type {ArrayBufferView} */ var uint8 = new Uint8Array(4); 2328 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth is less than 0.'); 2329 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2330 this.expectError(gl.INVALID_VALUE); 2331 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2332 this.expectError(gl.INVALID_VALUE); 2333 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2334 this.expectError(gl.INVALID_VALUE); 2335 gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, gl.RGBA, gl.UNSIGNED_BYTE, uint8); 2336 this.expectError(gl.INVALID_VALUE); 2337 2338 gl.deleteTexture(texture); 2339 2340 })); 2341 2342 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d', 'Invalid gl.copyTexSubImage3D() usage', gl, 2343 function() { 2344 /** @type{WebGLTexture} */ var texture; 2345 texture = gl.createTexture(); 2346 gl.bindTexture (gl.TEXTURE_3D, texture); 2347 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2348 2349 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 2350 gl.copyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 0); 2351 this.expectError(gl.INVALID_ENUM); 2352 2353 gl.deleteTexture(texture); 2354 })); 2355 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_neg_level', 'Invalid gl.copyTexSubImage3D() usage', gl, 2356 function() { 2357 /** @type{Array<WebGLTexture>} */ var texture = []; 2358 texture[0] = gl.createTexture(); 2359 texture[1] = gl.createTexture(); 2360 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2361 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2362 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2363 gl.texImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2364 this.expectError (gl.NO_ERROR); 2365 2366 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 2367 gl.copyTexSubImage3D(gl.TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 0); 2368 this.expectError(gl.INVALID_VALUE); 2369 gl.copyTexSubImage3D(gl.TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 0); 2370 this.expectError(gl.INVALID_VALUE); 2371 2372 gl.deleteTexture(texture[0]); 2373 gl.deleteTexture(texture[1]); 2374 })); 2375 2376 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_max_level', 'Invalid gl.copyTexSubImage3D() usage', gl, 2377 function() { 2378 /** @type{number} */ var log2Max3DTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_3D_TEXTURE_SIZE)))) + 1; 2379 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 2380 2381 /** @type{Array<WebGLTexture>} */ var texture = []; 2382 texture[0] = gl.createTexture(); 2383 texture[1] = gl.createTexture(); 2384 gl.bindTexture (gl.TEXTURE_3D, texture[0]); 2385 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2386 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2387 gl.texImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2388 this.expectError (gl.NO_ERROR); 2389 2390 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_3D_TEXTURE_SIZE).'); 2391 gl.copyTexSubImage3D(gl.TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 0); 2392 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2393 2394 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 2395 gl.copyTexSubImage3D(gl.TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 0); 2396 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2397 2398 gl.deleteTexture(texture[0]); 2399 gl.deleteTexture(texture[1]); 2400 })); 2401 2402 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_neg_offset', 'Invalid gl.copyTexSubImage3D() usage', gl, 2403 function() { 2404 /** @type{ WebGLTexture} */ var texture; 2405 texture = gl.createTexture(); 2406 gl.bindTexture (gl.TEXTURE_3D, texture); 2407 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2408 2409 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.'); 2410 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, -1, 0, 0, 0, 0, 4, 4); 2411 this.expectError(gl.INVALID_VALUE); 2412 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4); 2413 this.expectError(gl.INVALID_VALUE); 2414 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4); 2415 this.expectError(gl.INVALID_VALUE); 2416 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4); 2417 this.expectError(gl.INVALID_VALUE); 2418 2419 gl.deleteTexture(texture); 2420 })); 2421 2422 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_invalid_offset', 'Invalid gl.copyTexSubImage3D() usage', gl, 2423 function() { 2424 /** @type{WebGLTexture} */ var texture; 2425 texture = gl.createTexture(); 2426 gl.bindTexture (gl.TEXTURE_3D, texture); 2427 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2428 2429 bufferedLogToConsole('gl.INVALID_VALUE is generated if xoffset + width > texture_width.'); 2430 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4); 2431 this.expectError(gl.INVALID_VALUE); 2432 2433 bufferedLogToConsole('gl.INVALID_VALUE is generated if yoffset + height > texture_height.'); 2434 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4); 2435 this.expectError(gl.INVALID_VALUE); 2436 2437 bufferedLogToConsole('gl.INVALID_VALUE is generated if zoffset + 1 > texture_depth.'); 2438 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4); 2439 this.expectError(gl.INVALID_VALUE); 2440 2441 gl.deleteTexture(texture); 2442 })); 2443 2444 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_neg_width_height', 'Invalid gl.copyTexSubImage3D() usage', gl, 2445 function() { 2446 /** @type{ WebGLTexture} */ var texture; 2447 texture = gl.createTexture(); 2448 gl.bindTexture (gl.TEXTURE_3D, texture); 2449 gl.texImage3D (gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2450 2451 bufferedLogToConsole('gl.INVALID_VALUE is generated if width < 0.'); 2452 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4); 2453 this.expectError(gl.INVALID_VALUE); 2454 2455 bufferedLogToConsole('gl.INVALID_VALUE is generated if height < 0.'); 2456 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4); 2457 this.expectError(gl.INVALID_VALUE); 2458 2459 gl.deleteTexture(texture); 2460 })); 2461 2462 testGroup.addChild(new es3fApiCase.ApiCaseCallback('copytexsubimage3d_incomplete_framebuffer', 'Invalid gl.copyTexSubImage3D() usage', gl, 2463 function() { 2464 bufferedLogToConsole('gl.INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.'); 2465 /** @type{Array<WebGLTexture>} */ var texture = []; 2466 /** @type{WebGLFramebuffer} */ var fbo; 2467 texture[0] = gl.createTexture(); 2468 texture[1] = gl.createTexture(); 2469 gl.bindTexture(gl.TEXTURE_3D, texture[0]); 2470 gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2471 gl.bindTexture(gl.TEXTURE_2D_ARRAY, texture[1]); 2472 gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA, 4, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 2473 this.expectError(gl.NO_ERROR); 2474 2475 fbo = gl.createFramebuffer(); 2476 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fbo); 2477 gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER); 2478 this.expectError(gl.NO_ERROR); 2479 2480 gl.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4); 2481 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 2482 gl.copyTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4); 2483 this.expectError(gl.INVALID_FRAMEBUFFER_OPERATION); 2484 2485 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 2486 gl.deleteFramebuffer(fbo); 2487 gl.deleteTexture(texture[0]); 2488 gl.deleteTexture(texture[1]); 2489 })); 2490 2491 // gl.compressedTexImage3D 2492 2493 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d', 'Invalid gl.compressedTexImage3D() usage', gl, 2494 function() { 2495 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2496 2497 /** @type{Array<WebGLTexture>} */ var texture = []; 2498 2499 // We have to create and bind textures to each target for the test because default textures are not supported by WebGL. 2500 texture[0] = gl.createTexture(); 2501 texture[1] = gl.createTexture(); 2502 gl.bindTexture (gl.TEXTURE_CUBE_MAP, texture[0]); 2503 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture[1]); 2504 2505 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 2506 gl.compressedTexImage3D(0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, new Uint8Array(0)); 2507 this.expectError(gl.INVALID_ENUM); 2508 gl.compressedTexImage3D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, new Uint8Array(0)); 2509 this.expectError(gl.INVALID_ENUM); 2510 2511 bufferedLogToConsole('gl.INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.'); 2512 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, new Uint8Array(0)); 2513 this.expectError(gl.INVALID_ENUM); 2514 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.RGBA8, 0, 0, 0, 0, new Uint8Array(0)); 2515 this.expectError(gl.INVALID_ENUM); 2516 2517 gl.deleteTexture(texture[0]); 2518 gl.deleteTexture(texture[1]); 2519 })); 2520 2521 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_neg_level', 'Invalid gl.compressedTexImage3D() usage', gl, 2522 function() { 2523 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2524 2525 /** @type{ WebGLTexture} */ var texture; 2526 texture = gl.createTexture(); 2527 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2528 2529 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 2530 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, -1, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, new Uint8Array(0)); 2531 this.expectError(gl.INVALID_VALUE); 2532 2533 gl.deleteTexture(texture); 2534 })); 2535 2536 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_max_level', 'Invalid gl.compressedTexImage3D() usage', gl, 2537 function() { 2538 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2539 2540 /** @type{ WebGLTexture} */ var texture; 2541 texture = gl.createTexture(); 2542 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2543 2544 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 2545 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 2546 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, log2MaxTextureSize, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, new Uint8Array(0)); 2547 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2548 2549 gl.deleteTexture(texture); 2550 2551 })); 2552 2553 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_neg_width_height_depth', 'Invalid gl.compressedTexImage3D() usage', gl, 2554 function() { 2555 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2556 2557 /** @type{ WebGLTexture} */ var texture; 2558 texture = gl.createTexture(); 2559 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2560 2561 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth is less than 0.'); 2562 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, new Uint8Array(0)); 2563 this.expectError(gl.INVALID_VALUE); 2564 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, new Uint8Array(0)); 2565 this.expectError(gl.INVALID_VALUE); 2566 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, new Uint8Array(0)); 2567 this.expectError(gl.INVALID_VALUE); 2568 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, new Uint8Array(0)); 2569 this.expectError(gl.INVALID_VALUE); 2570 2571 gl.deleteTexture(texture); 2572 2573 })); 2574 2575 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_max_width_height_depth', 'Invalid gl.compressedTexImage3D() usage', gl, 2576 function() { 2577 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2578 2579 /** @type{ WebGLTexture} */ var texture; 2580 texture = gl.createTexture(); 2581 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2582 2583 var maxTextureSize = /** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)) + 1; 2584 2585 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth is greater than gl.MAX_TEXTURE_SIZE.'); 2586 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, new Uint8Array(0)); 2587 this.expectError(gl.INVALID_VALUE); 2588 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, new Uint8Array(0)); 2589 this.expectError(gl.INVALID_VALUE); 2590 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureSize, 0, new Uint8Array(0)); 2591 this.expectError(gl.INVALID_VALUE); 2592 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureSize, 0, new Uint8Array(0)); 2593 this.expectError(gl.INVALID_VALUE); 2594 2595 gl.deleteTexture(texture); 2596 2597 })); 2598 2599 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_invalid_border', 'Invalid gl.compressedTexImage3D() usage', gl, 2600 function() { 2601 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2602 2603 /** @type{ WebGLTexture} */ var texture; 2604 texture = gl.createTexture(); 2605 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2606 2607 bufferedLogToConsole('gl.INVALID_VALUE is generated if border is not 0.'); 2608 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, new Uint8Array(0)); 2609 this.expectError(gl.INVALID_VALUE); 2610 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, new Uint8Array(0)); 2611 this.expectError(gl.INVALID_VALUE); 2612 2613 gl.deleteTexture(texture); 2614 2615 })); 2616 2617 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedteximage3d_invalid_size', 'Invalid gl.compressedTexImage3D() usage', gl, 2618 function() { 2619 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2620 2621 /** @type{ WebGLTexture} */ var texture; 2622 texture = gl.createTexture(); 2623 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2624 2625 bufferedLogToConsole('gl.INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.'); 2626 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, new Uint8Array(1)); 2627 this.expectError(gl.INVALID_VALUE); 2628 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(4*4*8)); 2629 this.expectError(gl.INVALID_VALUE); 2630 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, new Uint8Array(4*4*16)); 2631 this.expectError(gl.INVALID_VALUE); 2632 gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, new Uint8Array(4*4*16)); 2633 this.expectError(gl.INVALID_VALUE); 2634 2635 gl.deleteTexture(texture); 2636 2637 })); 2638 2639 // gl.compressedTexSubImage3D 2640 2641 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2642 function() { 2643 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2644 2645 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is invalid.'); 2646 /** @type{WebGLTexture} */ var texture; 2647 texture = gl.createTexture(); 2648 gl.compressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2649 this.expectError(gl.INVALID_ENUM); 2650 2651 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2652 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 2653 this.expectError (gl.NO_ERROR); 2654 2655 bufferedLogToConsole('gl.INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.'); 2656 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, gl.COMPRESSED_RGB8_ETC2, new Uint8Array(0)); 2657 this.expectError(gl.INVALID_OPERATION); 2658 2659 bufferedLogToConsole('gl.INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not gl.TEXTURE_2D_ARRAY.'); 2660 gl.compressedTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(18, 18))); 2661 this.expectError(gl.INVALID_OPERATION); 2662 2663 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if width is not a multiple of four, and width + xoffset is not equal to the width of the texture level.'); 2664 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(10, 4))); 2665 this.expectError(gl.INVALID_OPERATION); 2666 2667 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if height is not a multiple of four, and height + yoffset is not equal to the height of the texture level.'); 2668 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 10))); 2669 this.expectError(gl.INVALID_OPERATION); 2670 2671 bufferedLogToConsole('For ETC2/EAC images gl.INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.'); 2672 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 2673 this.expectError(gl.INVALID_OPERATION); 2674 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 2675 this.expectError(gl.INVALID_OPERATION); 2676 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 2677 this.expectError(gl.INVALID_OPERATION); 2678 2679 gl.deleteTexture(texture); 2680 })); 2681 2682 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_neg_level', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2683 function() { 2684 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2685 2686 /** @type{WebGLTexture} */ var texture; 2687 texture = gl.createTexture(); 2688 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2689 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 2690 this.expectError (gl.NO_ERROR); 2691 2692 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is less than 0.'); 2693 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2694 this.expectError(gl.INVALID_VALUE); 2695 2696 gl.deleteTexture(texture); 2697 })); 2698 2699 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_max_level', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2700 function() { 2701 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2702 2703 /** @type{WebGLTexture} */ var texture; 2704 texture = gl.createTexture(); 2705 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2706 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 2707 this.expectError (gl.NO_ERROR); 2708 2709 bufferedLogToConsole('gl.INVALID_VALUE is generated if level is greater than log_2(gl.MAX_TEXTURE_SIZE).'); 2710 /** @type{number} */ var log2MaxTextureSize = Math.floor(Math.log2(/** @type{number} */(gl.getParameter(gl.MAX_TEXTURE_SIZE)))) + 1; 2711 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2712 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2713 2714 gl.deleteTexture(texture); 2715 })); 2716 2717 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_neg_offset', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2718 function() { 2719 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2720 2721 /** @type{WebGLTexture} */ var texture; 2722 texture = gl.createTexture(); 2723 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2724 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 2725 this.expectError (gl.NO_ERROR); 2726 2727 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.'); 2728 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2729 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2730 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2731 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2732 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2733 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2734 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2735 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2736 2737 gl.deleteTexture(texture); 2738 })); 2739 2740 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_invalid_offset', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2741 function() { 2742 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2743 2744 /** @type{WebGLTexture} */ var texture; 2745 texture = gl.createTexture(); 2746 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2747 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 2748 this.expectError (gl.NO_ERROR); 2749 2750 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.'); 2751 2752 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(8, 4))); 2753 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2754 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 8))); 2755 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2756 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(4, 4))); 2757 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2758 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(8, 8))); 2759 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2760 2761 gl.deleteTexture(texture); 2762 })); 2763 2764 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_neg_width_height_depth', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2765 function() { 2766 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2767 2768 /** @type{WebGLTexture} */ var texture; 2769 texture = gl.createTexture(); 2770 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2771 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(es3fNegativeTextureApiTests.etc2EacDataSize(16, 16))); 2772 this.expectError (gl.NO_ERROR); 2773 2774 bufferedLogToConsole('gl.INVALID_VALUE or gl.INVALID_OPERATION is generated if width, height or depth are negative.'); 2775 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2776 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2777 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2778 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2779 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2780 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2781 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2782 this.expectError([gl.INVALID_VALUE, gl.INVALID_OPERATION]); 2783 2784 gl.deleteTexture(texture); 2785 })); 2786 2787 testGroup.addChild(new es3fApiCase.ApiCaseCallback('compressedtexsubimage3d_invalid_size', 'Invalid gl.compressedTexSubImage3D() usage', gl, 2788 function() { 2789 if (!haveCompressedTextureETC) { etc2Unsupported(); return; } 2790 2791 /** @type{WebGLTexture} */ var texture; 2792 texture = gl.createTexture(); 2793 gl.bindTexture (gl.TEXTURE_2D_ARRAY, texture); 2794 gl.compressedTexImage3D (gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, new Uint8Array(4*4*16)); 2795 this.expectError (gl.NO_ERROR); 2796 2797 bufferedLogToConsole('gl.INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.'); 2798 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(0)); 2799 this.expectError(gl.INVALID_VALUE); 2800 2801 gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, new Uint8Array(4*4*16-1)); 2802 this.expectError(gl.INVALID_VALUE); 2803 2804 gl.deleteTexture(texture); 2805 })); 2806 2807 // gl.texStorage2D 2808 2809 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage2d', 'Invalid gl.texStorage2D() usage', gl, 2810 function() { 2811 /** @type{WebGLTexture} */ var texture; 2812 texture = gl.createTexture(); 2813 gl.bindTexture (gl.TEXTURE_2D, texture); 2814 2815 bufferedLogToConsole('gl.INVALID_ENUM or gl.INVALID_VALUE is generated if internalformat is not a valid sized internal format.'); 2816 gl.texStorage2D (gl.TEXTURE_2D, 1, 0, 16, 16); 2817 this.expectError ([gl.INVALID_ENUM, gl.INVALID_VALUE]); 2818 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA_INTEGER, 16, 16); 2819 this.expectError ([gl.INVALID_ENUM, gl.INVALID_VALUE]); 2820 2821 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted target enumerants.'); 2822 gl.texStorage2D (0, 1, gl.RGBA8, 16, 16); 2823 this.expectError (gl.INVALID_ENUM); 2824 gl.texStorage2D (gl.TEXTURE_3D, 1, gl.RGBA8, 16, 16); 2825 this.expectError (gl.INVALID_ENUM); 2826 gl.texStorage2D (gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, 16, 16); 2827 this.expectError (gl.INVALID_ENUM); 2828 2829 bufferedLogToConsole('gl.INVALID_VALUE is generated if width or height are less than 1.'); 2830 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 0, 16); 2831 this.expectError (gl.INVALID_VALUE); 2832 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 16, 0); 2833 this.expectError (gl.INVALID_VALUE); 2834 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 0, 0); 2835 this.expectError (gl.INVALID_VALUE); 2836 2837 gl.deleteTexture(texture); 2838 })); 2839 2840 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage2d_invalid_binding', 'Invalid gl.texStorage2D() usage', gl, 2841 function() { 2842 gl.bindTexture (gl.TEXTURE_2D, null); 2843 2844 bufferedLogToConsole('gl.INVALID_OPERATION is generated if there is no texture object curently bound to target.'); 2845 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 16, 16); 2846 this.expectError (gl.INVALID_OPERATION); 2847 2848 /** @type{WebGLTexture} */ var texture; 2849 texture = gl.createTexture(); 2850 gl.bindTexture (gl.TEXTURE_2D, texture); 2851 2852 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the texture object currently bound to target already has gl.TEXTURE_IMMUTABLE_FORMAT set to true.'); 2853 /** @type{number} */ var immutable; 2854 immutable = /** @type{number} */(gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_IMMUTABLE_FORMAT)); 2855 bufferedLogToConsole('// gl.TEXTURE_IMMUTABLE_FORMAT = ' + ((immutable != 0) ? 'true' : 'false')); 2856 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 16, 16); 2857 this.expectError (gl.NO_ERROR); 2858 immutable = /** @type{number} */(gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_IMMUTABLE_FORMAT)); 2859 bufferedLogToConsole('// gl.TEXTURE_IMMUTABLE_FORMAT = ' + ((immutable != 0) ? 'true' : 'false')); 2860 gl.texStorage2D (gl.TEXTURE_2D, 1, gl.RGBA8, 16, 16); 2861 this.expectError (gl.INVALID_OPERATION); 2862 2863 gl.deleteTexture(texture); 2864 })); 2865 2866 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage2d_invalid_levels', 'Invalid gl.texStorage2D() usage', gl, 2867 function() { 2868 /** @type{WebGLTexture} */ var texture; 2869 texture = gl.createTexture(); 2870 gl.bindTexture (gl.TEXTURE_2D, texture); 2871 2872 bufferedLogToConsole('gl.INVALID_VALUE is generated if levels is less than 1.'); 2873 gl.texStorage2D (gl.TEXTURE_2D, 0, gl.RGBA8, 16, 16); 2874 this.expectError (gl.INVALID_VALUE); 2875 gl.texStorage2D (gl.TEXTURE_2D, 0, gl.RGBA8, 0, 0); 2876 this.expectError (gl.INVALID_VALUE); 2877 2878 bufferedLogToConsole('gl.INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1'); 2879 /** @type{number} */ var log2MaxSize = Math.floor(Math.log2(Math.max(16, 4))) + 1 + 1; 2880 gl.texStorage2D (gl.TEXTURE_2D, log2MaxSize, gl.RGBA8, 16, 4); 2881 this.expectError (gl.INVALID_OPERATION); 2882 gl.texStorage2D (gl.TEXTURE_2D, log2MaxSize, gl.RGBA8, 4, 16); 2883 this.expectError (gl.INVALID_OPERATION); 2884 gl.texStorage2D (gl.TEXTURE_2D, log2MaxSize, gl.RGBA8, 16, 16); 2885 this.expectError (gl.INVALID_OPERATION); 2886 2887 gl.deleteTexture(texture); 2888 })); 2889 2890 // gl.texStorage3D 2891 2892 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage3d', 'Invalid gl.texStorage3D() usage', gl, 2893 function() { 2894 /** @type{WebGLTexture} */ var texture; 2895 texture = gl.createTexture(); 2896 gl.bindTexture (gl.TEXTURE_3D, texture); 2897 2898 bufferedLogToConsole('gl.INVALID_ENUM or gl.INVALID_VALUE is generated if internalformat is not a valid sized internal format.'); 2899 gl.texStorage3D (gl.TEXTURE_3D, 1, 0, 4, 4, 4); 2900 this.expectError ([gl.INVALID_ENUM, gl.INVALID_VALUE]); 2901 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA_INTEGER, 4, 4, 4); 2902 this.expectError ([gl.INVALID_ENUM, gl.INVALID_VALUE]); 2903 2904 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted target enumerants.'); 2905 gl.texStorage3D (0, 1, gl.RGBA8, 4, 4, 4); 2906 this.expectError (gl.INVALID_ENUM); 2907 gl.texStorage3D (gl.TEXTURE_CUBE_MAP, 1, gl.RGBA8, 4, 4, 4); 2908 this.expectError (gl.INVALID_ENUM); 2909 gl.texStorage3D (gl.TEXTURE_2D, 1, gl.RGBA8, 4, 4, 4); 2910 this.expectError (gl.INVALID_ENUM); 2911 2912 bufferedLogToConsole('gl.INVALID_VALUE is generated if width, height or depth are less than 1.'); 2913 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 0, 4, 4); 2914 this.expectError (gl.INVALID_VALUE); 2915 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 4, 0, 4); 2916 this.expectError (gl.INVALID_VALUE); 2917 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 4, 4, 0); 2918 this.expectError (gl.INVALID_VALUE); 2919 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 0, 0, 0); 2920 this.expectError (gl.INVALID_VALUE); 2921 2922 gl.deleteTexture(texture); 2923 })); 2924 2925 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage3d_invalid_binding', 'Invalid gl.texStorage3D() usage', gl, 2926 function() { 2927 gl.bindTexture (gl.TEXTURE_3D, null); 2928 2929 bufferedLogToConsole('gl.INVALID_OPERATION is generated if there is no texture object curently bound to target.'); 2930 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 4, 4, 4); 2931 this.expectError (gl.INVALID_OPERATION); 2932 2933 /** @type{WebGLTexture} */ var texture; 2934 texture = gl.createTexture(); 2935 gl.bindTexture (gl.TEXTURE_3D, texture); 2936 2937 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the texture object currently bound to target already has gl.TEXTURE_IMMUTABLE_FORMAT set to true.'); 2938 /** @type{number} */ var immutable; 2939 immutable = /** @type{number} */(gl.getTexParameter(gl.TEXTURE_3D, gl.TEXTURE_IMMUTABLE_FORMAT)); 2940 bufferedLogToConsole('// gl.TEXTURE_IMMUTABLE_FORMAT = ' + ((immutable != 0) ? 'true' : 'false')); 2941 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 4, 4, 4); 2942 this.expectError (gl.NO_ERROR); 2943 immutable = /** @type{number} */(gl.getTexParameter(gl.TEXTURE_3D, gl.TEXTURE_IMMUTABLE_FORMAT)); 2944 bufferedLogToConsole('// gl.TEXTURE_IMMUTABLE_FORMAT = ' + ((immutable != 0) ? 'true' : 'false')); 2945 gl.texStorage3D (gl.TEXTURE_3D, 1, gl.RGBA8, 4, 4, 4); 2946 this.expectError (gl.INVALID_OPERATION); 2947 2948 gl.deleteTexture(texture); 2949 })); 2950 2951 // NOTE: the test doesn't cause glError using the parameters defined in the original test of C code 2952 testGroup.addChild(new es3fApiCase.ApiCaseCallback('texstorage3d_invalid_levels', 'Invalid gl.texStorage3D() usage', gl, 2953 function() { 2954 /** @type{WebGLTexture} */ var texture; 2955 texture = gl.createTexture(); 2956 gl.bindTexture (gl.TEXTURE_3D, texture); 2957 2958 bufferedLogToConsole('gl.INVALID_VALUE is generated if levels is less than 1.'); 2959 gl.texStorage3D (gl.TEXTURE_3D, 0, gl.RGBA8, 4, 4, 4); 2960 this.expectError (gl.INVALID_VALUE); 2961 gl.texStorage3D (gl.TEXTURE_3D, 0, gl.RGBA8, 0, 0, 0); 2962 this.expectError (gl.INVALID_VALUE); 2963 2964 bufferedLogToConsole('gl.INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1'); 2965 /** @type{number} */ var log2MaxSize = Math.floor(Math.log2(8)) + 1 + 1; 2966 gl.texStorage3D (gl.TEXTURE_3D, log2MaxSize, gl.RGBA8, 8, 2, 2); 2967 this.expectError (gl.INVALID_OPERATION); 2968 gl.texStorage3D (gl.TEXTURE_3D, log2MaxSize, gl.RGBA8, 2, 8, 2); 2969 this.expectError (gl.INVALID_OPERATION); 2970 gl.texStorage3D (gl.TEXTURE_3D, log2MaxSize, gl.RGBA8, 2, 2, 8); 2971 this.expectError (gl.INVALID_OPERATION); 2972 gl.texStorage3D (gl.TEXTURE_3D, log2MaxSize, gl.RGBA8, 8, 8, 8); 2973 this.expectError (gl.INVALID_OPERATION); 2974 2975 gl.deleteTexture(texture); 2976 })); 2977 }; 2978 2979 /** 2980 * @param {WebGL2RenderingContext} gl 2981 */ 2982 es3fNegativeTextureApiTests.run = function(gl) { 2983 var testName = 'negativeTextureApi'; 2984 var testDescription = 'Negative Texture API tests'; 2985 var state = tcuTestCase.runner; 2986 2987 state.testName = testName; 2988 state.testCases = tcuTestCase.newTest(testName, testDescription, null); 2989 2990 //Set up name and description of this test series. 2991 setCurrentTestName(testName); 2992 description(testDescription); 2993 try { 2994 es3fNegativeTextureApiTests.init(gl); 2995 tcuTestCase.runner.runCallback(tcuTestCase.runTestCases); 2996 } catch (err) { 2997 bufferedLogToConsole(err); 2998 tcuTestCase.runner.terminate(); 2999 } 3000 }; 3001 3002 });