| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../../resources/js-test.js"></script> | |
| 4 <script src="resources/webgl-test.js"></script> | |
| 5 <script src="resources/webgl-test-utils.js"></script> | |
| 6 </head> | |
| 7 <body> | |
| 8 <div id="description"></div> | |
| 9 <div id="console"></div> | |
| 10 | |
| 11 <script> | |
| 12 if (window.internals) | |
| 13 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
| 14 | |
| 15 var wtu = WebGLTestUtils; | |
| 16 var gl = null; | |
| 17 var tex = null; | |
| 18 var error = 0; | |
| 19 | |
| 20 function enumToString(value) { | |
| 21 return wtu.glEnumToString(gl, value); | |
| 22 } | |
| 23 | |
| 24 function testTexImage2D(testCase) | |
| 25 { | |
| 26 var level = 0; | |
| 27 var width = 16; | |
| 28 var height = 16; | |
| 29 var msg = "" + | |
| 30 " internalFormat: " + enumToString(testCase.internalFormat) + | |
| 31 " target: " + enumToString(testCase.target) + | |
| 32 " format: " + enumToString(testCase.format) + | |
| 33 " type: " + enumToString(testCase.type) + | |
| 34 " border: " + testCase.border; | |
| 35 | |
| 36 gl.texImage2D(testCase.target, level, testCase.internalFormat, width, height
, testCase.border, testCase.format, testCase.type, null); | |
| 37 error = testCase.expectedError; | |
| 38 glErrorShouldBe(gl, error, msg); | |
| 39 } | |
| 40 | |
| 41 function testTexSubImage2D(testCase) | |
| 42 { | |
| 43 var level = 0; | |
| 44 var xoffset = 0; | |
| 45 var yoffset = 0; | |
| 46 var width = 16; | |
| 47 var height = 16; | |
| 48 var msg = ""+ | |
| 49 " format: " + enumToString(testCase.format) + | |
| 50 " type: " + enumToString(testCase.type); | |
| 51 var array = new Uint8Array(width * height * 4); | |
| 52 gl.texSubImage2D(testCase.target, level, xoffset, yoffset, width, height, te
stCase.format, testCase.type, array); | |
| 53 error = testCase.expectedError; | |
| 54 glErrorShouldBe(gl, error, msg); | |
| 55 } | |
| 56 | |
| 57 function testTexParameter(testCase) | |
| 58 { | |
| 59 var msg = "paramName: " + enumToString(testCase.pname); | |
| 60 error = testCase.expectedError; | |
| 61 gl.texParameteri(testCase.target, testCase.pname, testCase.param); | |
| 62 glErrorShouldBe(gl, error, msg); | |
| 63 gl.texParameterf(testCase.target, testCase.pname, testCase.param); | |
| 64 glErrorShouldBe(gl, error, msg); | |
| 65 } | |
| 66 | |
| 67 function testGetTexParameter(testCase) | |
| 68 { | |
| 69 var msg = "paramName: " + enumToString(testCase.pname); | |
| 70 error = testCase.expectedError; | |
| 71 gl.getTexParameter(testCase.target, testCase.pname); | |
| 72 glErrorShouldBe(gl, error, msg); | |
| 73 } | |
| 74 | |
| 75 function testCopyTexImage2D(testCase) | |
| 76 { | |
| 77 var level = 0; | |
| 78 var x = 0; | |
| 79 var y = 0; | |
| 80 var width = 16; | |
| 81 var height = 16; | |
| 82 | |
| 83 var msg = "" + | |
| 84 " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) + | |
| 85 " internalFormat: " + enumToString(testCase.internalFormat) + | |
| 86 " target: " + enumToString(testCase.target) + | |
| 87 " border: " + testCase.border; | |
| 88 | |
| 89 gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, h
eight); | |
| 90 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 91 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLE
TE"); | |
| 92 | |
| 93 gl.copyTexImage2D(testCase.target, level, testCase.internalFormat, x, y, wid
th, height, testCase.border); | |
| 94 error = testCase.expectedError; | |
| 95 glErrorShouldBe(gl, error, msg); | |
| 96 } | |
| 97 | |
| 98 function testCopyTexSubImage2D(testCase) | |
| 99 { | |
| 100 var level = 0; | |
| 101 var x = 0; | |
| 102 var y = 0; | |
| 103 var width = 16; | |
| 104 var height = 16; | |
| 105 var xoffset = 0; | |
| 106 var yoffset = 0; | |
| 107 var border = 0; | |
| 108 var type = gl.UNSIGNED_BYTE; | |
| 109 var msg = "" + | |
| 110 " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) + | |
| 111 " internalFormat: " + enumToString(testCase.internalFormat) + | |
| 112 " target: " + enumToString(testCase.target); | |
| 113 | |
| 114 gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, h
eight); | |
| 115 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 116 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLE
TE"); | |
| 117 | |
| 118 gl.texImage2D(testCase.target, level, testCase.internalFormat, xoffset + wid
th, yoffset + height, border, testCase.internalFormat, type, null); | |
| 119 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 120 | |
| 121 gl.copyTexSubImage2D(testCase.target, level, xoffset, yoffset, x, y, width,
height); | |
| 122 error = testCase.expectedError; | |
| 123 glErrorShouldBe(gl, error, msg); | |
| 124 } | |
| 125 | |
| 126 function testCopyFromInternalFBO(testCase) | |
| 127 { | |
| 128 var target = gl.TEXTURE_2D; | |
| 129 var level = 0; | |
| 130 var x = 0; | |
| 131 var y = 0; | |
| 132 var width = 16; | |
| 133 var height = 16; | |
| 134 var xoffset = 0; | |
| 135 var yoffset = 0; | |
| 136 var border = 0; | |
| 137 var type = gl.UNSIGNED_BYTE; | |
| 138 var msg = "" + | |
| 139 " colorBufferFormat: " + enumToString(testCase.contextAlpha ? gl.RGBA : gl
.RGB) + | |
| 140 " internalFormat: " + enumToString(testCase.internalFormat); | |
| 141 | |
| 142 if (testCase.contextAlpha) | |
| 143 gl = create3DContext(null, { alpha: true }); | |
| 144 else | |
| 145 gl = create3DContext(null, { alpha: false }); | |
| 146 shouldBeNonNull("gl"); | |
| 147 shouldBeNonNull("tex = gl.createTexture()"); | |
| 148 gl.bindTexture(target, tex); | |
| 149 if (testCase.subImage) { | |
| 150 gl.texImage2D(target, level, testCase.internalFormat, xoffset + width, y
offset + height, border, testCase.internalFormat, type, null); | |
| 151 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 152 gl.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, heigh
t); | |
| 153 } else { | |
| 154 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 155 gl.copyTexImage2D(target, level, testCase.internalFormat, x, y, width, h
eight, border); | |
| 156 } | |
| 157 error = testCase.expectedError; | |
| 158 glErrorShouldBe(gl, error, msg); | |
| 159 } | |
| 160 | |
| 161 description("Validate tex functions input parameters"); | |
| 162 | |
| 163 shouldBeNonNull("gl = create3DContext()"); | |
| 164 shouldBeNonNull("tex = gl.createTexture()"); | |
| 165 gl.bindTexture(gl.TEXTURE_2D, tex); | |
| 166 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 167 | |
| 168 debug(""); | |
| 169 debug("Checking TexImage2D: a set of inputs that are valid in GL but invalid in
GLES2"); | |
| 170 | |
| 171 var testCases = | |
| 172 [ {target: 0x8064, // GL_PROXY_TEXTURE_2D | |
| 173 internalFormat: gl.RGBA, | |
| 174 border: 0, | |
| 175 format: gl.RGBA, | |
| 176 type: gl.UNSIGNED_BYTE, | |
| 177 expectedError: gl.INVALID_ENUM}, | |
| 178 {target: gl.TEXTURE_2D, | |
| 179 internalFormat: 0x1903, // GL_RED | |
| 180 border: 0, | |
| 181 format: 0x1903, // GL_RED | |
| 182 type: gl.UNSIGNED_BYTE, | |
| 183 expectedError: [gl.INVALID_ENUM, gl.INVALID_VALUE] }, | |
| 184 {target: gl.TEXTURE_2D, | |
| 185 internalFormat: gl.RGBA, | |
| 186 border: 1, | |
| 187 format: gl.RGBA, | |
| 188 type: gl.UNSIGNED_BYTE, | |
| 189 expectedError: gl.INVALID_VALUE}, | |
| 190 {target: gl.TEXTURE_2D, | |
| 191 internalFormat: gl.RGBA, | |
| 192 border: 0, | |
| 193 format: gl.RGB, | |
| 194 type: gl.UNSIGNED_BYTE, | |
| 195 expectedError: gl.INVALID_OPERATION}, | |
| 196 {target: gl.TEXTURE_2D, | |
| 197 internalFormat: gl.RGBA, | |
| 198 border: 0, | |
| 199 format: gl.RGBA, | |
| 200 type: gl.BYTE, | |
| 201 expectedError: gl.INVALID_ENUM}, | |
| 202 {target: gl.TEXTURE_2D, | |
| 203 internalFormat: gl.RGBA, | |
| 204 border: 0, | |
| 205 format: gl.RGBA, | |
| 206 type: gl.UNSIGNED_BYTE, | |
| 207 expectedError: gl.NO_ERROR} ]; | |
| 208 | |
| 209 for (var ii = 0; ii < testCases.length; ++ii) | |
| 210 testTexImage2D(testCases[ii]); | |
| 211 | |
| 212 debug(""); | |
| 213 debug("Checking TexSubImage2D: a set of inputs that are valid in GL but invalid
in GLES2"); | |
| 214 | |
| 215 testCases = | |
| 216 [ {target: gl.TEXTURE_2D, | |
| 217 format: 0x1903, // GL_RED | |
| 218 type: gl.UNSIGNED_BYTE, | |
| 219 expectedError: gl.INVALID_ENUM}, | |
| 220 {target: gl.TEXTURE_2D, | |
| 221 format: gl.RGBA, | |
| 222 type: gl.BYTE, | |
| 223 expectedError: gl.INVALID_ENUM}, | |
| 224 {target: gl.TEXTURE_2D, | |
| 225 format: gl.RGBA, | |
| 226 type: gl.UNSIGNED_BYTE, | |
| 227 expectedError: gl.NO_ERROR} ]; | |
| 228 | |
| 229 for (var ii = 0; ii < testCases.length; ++ii) | |
| 230 testTexSubImage2D(testCases[ii]); | |
| 231 | |
| 232 debug(""); | |
| 233 debug("Checking TexParameter: a set of inputs that are valid in GL but invalid i
n GLES2"); | |
| 234 | |
| 235 testCases = | |
| 236 [ {target: 0x0DE0, // GL_TEXTURE_1D | |
| 237 pname: gl.TEXTURE_WRAP_T, | |
| 238 param: gl.REPEAT, | |
| 239 expectedError: gl.INVALID_ENUM}, | |
| 240 {target: gl.TEXTURE_2D, | |
| 241 pname: 0x813A, // GL_TEXTURE_MIN_LOD | |
| 242 param: 0, | |
| 243 expectedError: gl.INVALID_ENUM}, | |
| 244 {target: gl.TEXTURE_2D, | |
| 245 pname: gl.TEXTURE_WRAP_T, | |
| 246 param: 0x2900, // GL_CLAMP | |
| 247 expectedError: gl.INVALID_ENUM}, | |
| 248 {target: gl.TEXTURE_2D, | |
| 249 pname: gl.TEXTURE_WRAP_T, | |
| 250 param: gl.REPEAT, | |
| 251 expectedError: gl.NO_ERROR} ]; | |
| 252 | |
| 253 for (var ii = 0; ii < testCases.length; ++ii) | |
| 254 testTexParameter(testCases[ii]); | |
| 255 | |
| 256 debug(""); | |
| 257 debug("Checking GetTexParameter: a set of inputs that are valid in GL but invali
d in GLES2"); | |
| 258 | |
| 259 testCases = | |
| 260 [ {target: 0x0DE0, // GL_TEXTURE_1D | |
| 261 pname: gl.TEXTURE_WRAP_T, | |
| 262 expectedError: gl.INVALID_ENUM}, | |
| 263 {target: gl.TEXTURE_2D, | |
| 264 pname: 0x813A, // GL_TEXTURE_MIN_LOD | |
| 265 expectedError: gl.INVALID_ENUM}, | |
| 266 {target: gl.TEXTURE_2D, | |
| 267 pname: gl.TEXTURE_WRAP_T, | |
| 268 expectedError: gl.NO_ERROR} ]; | |
| 269 | |
| 270 for (var ii = 0; ii < testCases.length; ++ii) | |
| 271 testGetTexParameter(testCases[ii]); | |
| 272 | |
| 273 debug(""); | |
| 274 debug("Checking CopyTexImage2D: a set of inputs that are valid in GL but invalid
in GLES2"); | |
| 275 | |
| 276 var colorBuffer = null; | |
| 277 var fbo = null; | |
| 278 | |
| 279 shouldBeNonNull("fbo = gl.createFramebuffer()"); | |
| 280 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); | |
| 281 shouldBeNonNull("colorBuffer = gl.createRenderbuffer()"); | |
| 282 gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer); | |
| 283 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER
, colorBuffer); | |
| 284 glErrorShouldBe(gl, gl.NO_ERROR); | |
| 285 | |
| 286 testCases = | |
| 287 [ {target: gl.TEXTURE_2D, | |
| 288 colorBufferFormat: gl.RGB565, | |
| 289 internalFormat: 0x8054, // GL_RGB16 | |
| 290 border: 0, | |
| 291 expectedError: gl.INVALID_ENUM}, | |
| 292 {target: gl.TEXTURE_2D, | |
| 293 colorBufferFormat: gl.RGB565, | |
| 294 internalFormat: gl.RGBA, | |
| 295 border: 1, | |
| 296 expectedError: gl.INVALID_VALUE}, | |
| 297 {target: gl.TEXTURE_2D, | |
| 298 colorBufferFormat: gl.RGB565, | |
| 299 internalFormat: gl.RGBA, | |
| 300 border: 0, | |
| 301 expectedError: gl.INVALID_OPERATION}, | |
| 302 {target: gl.TEXTURE_2D, | |
| 303 colorBufferFormat: gl.RGB565, | |
| 304 internalFormat: gl.RGB, | |
| 305 border: 0, | |
| 306 expectedError: gl.NO_ERROR} ]; | |
| 307 | |
| 308 for (var ii = 0; ii < testCases.length; ++ii) | |
| 309 testCopyTexImage2D(testCases[ii]); | |
| 310 | |
| 311 debug(""); | |
| 312 debug("Checking CopyTexSubImage2D: a set of inputs that are valid in GL but inva
lid in GLES2"); | |
| 313 | |
| 314 testCases = | |
| 315 [ {target: gl.TEXTURE_2D, | |
| 316 colorBufferFormat: gl.RGB5_A1, | |
| 317 internalFormat: gl.RGBA, | |
| 318 expectedError: gl.NO_ERROR}, | |
| 319 {target: gl.TEXTURE_2D, | |
| 320 colorBufferFormat: gl.RGB565, | |
| 321 internalFormat: gl.RGBA, | |
| 322 expectedError: gl.INVALID_OPERATION} ]; | |
| 323 | |
| 324 for (var ii = 0; ii < testCases.length; ++ii) | |
| 325 testCopyTexSubImage2D(testCases[ii]); | |
| 326 | |
| 327 debug(""); | |
| 328 debug("Checking CopyTex{Sub}Image2D: copy from WebGL internal framebuffer"); | |
| 329 | |
| 330 testCases = | |
| 331 [ {contextAlpha: true, | |
| 332 internalFormat: gl.RGBA, | |
| 333 subImage: false, | |
| 334 expectedError: gl.NO_ERROR}, | |
| 335 {contextAlpha: false, | |
| 336 internalFormat: gl.RGBA, | |
| 337 subImage: false, | |
| 338 expectedError: gl.INVALID_OPERATION}, | |
| 339 {contextAlpha: true, | |
| 340 internalFormat: gl.RGBA, | |
| 341 subImage: true, | |
| 342 expectedError: gl.NO_ERROR}, | |
| 343 {contextAlpha: false, | |
| 344 internalFormat: gl.RGBA, | |
| 345 subImage: true, | |
| 346 expectedError: gl.INVALID_OPERATION} ]; | |
| 347 | |
| 348 for (var ii = 0; ii < testCases.length; ++ii) | |
| 349 testCopyFromInternalFBO(testCases[ii]); | |
| 350 </script> | |
| 351 | |
| 352 </body> | |
| 353 </html> | |
| OLD | NEW |