OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <title>WebGL OES_element_index_uint Conformance Tests</title> |
| 33 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 34 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s
cript> |
| 35 <script src="../../resources/js-test-pre.js"></script> |
| 36 <script src="../resources/webgl-test.js"></script> |
| 37 <script src="../resources/webgl-test-utils.js"></script> |
| 38 |
| 39 <script id="vs" type="x-shader/x-vertex"> |
| 40 attribute vec4 vPosition; |
| 41 attribute vec4 vColor; |
| 42 varying vec4 color; |
| 43 void main() { |
| 44 gl_Position = vPosition; |
| 45 color = vColor; |
| 46 } |
| 47 </script> |
| 48 <script id="fs" type="x-shader/x-fragment"> |
| 49 precision mediump float; |
| 50 varying vec4 color; |
| 51 void main() { |
| 52 gl_FragColor = color; |
| 53 } |
| 54 </script> |
| 55 |
| 56 </head> |
| 57 <body> |
| 58 <div id="description"></div> |
| 59 <div id="console"></div> |
| 60 <script> |
| 61 "use strict"; |
| 62 description("This test verifies the functionality of the OES_element_index_uint
extension, if it is available."); |
| 63 |
| 64 debug(""); |
| 65 |
| 66 var wtu = WebGLTestUtils; |
| 67 var gl = null; |
| 68 var ext = null; |
| 69 var canvas = null; |
| 70 |
| 71 // Test both STATIC_DRAW and DYNAMIC_DRAW as a regression test |
| 72 // for a bug in ANGLE which has since been fixed. |
| 73 for (var ii = 0; ii < 2; ++ii) { |
| 74 canvas = document.createElement("canvas"); |
| 75 canvas.width = 50; |
| 76 canvas.height = 50; |
| 77 |
| 78 gl = wtu.create3DContext(canvas); |
| 79 |
| 80 if (!gl) { |
| 81 testFailed("WebGL context does not exist"); |
| 82 } else { |
| 83 testPassed("WebGL context exists"); |
| 84 |
| 85 var drawType = (ii == 0) ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW; |
| 86 debug("Testing " + ((ii == 0) ? "STATIC_DRAW" : "DYNAMIC_DRAW")); |
| 87 |
| 88 |
| 89 // Query the extension and store globally so shouldBe can access it |
| 90 ext = gl.getExtension("OES_element_index_uint"); |
| 91 if (!ext) { |
| 92 testPassed("No OES_element_index_uint support -- this is legal"); |
| 93 |
| 94 runSupportedTest(false); |
| 95 } else { |
| 96 testPassed("Successfully enabled OES_element_index_uint extension"); |
| 97 |
| 98 runSupportedTest(true); |
| 99 |
| 100 runDrawTests(drawType); |
| 101 |
| 102 // These tests are tweaked duplicates of the buffers/index-validatio
n* tests |
| 103 // using unsigned int indices to ensure that behavior remains consis
tent |
| 104 runIndexValidationTests(drawType); |
| 105 runCopiesIndicesTests(drawType); |
| 106 runResizedBufferTests(drawType); |
| 107 runVerifiesTooManyIndicesTests(drawType); |
| 108 runCrashWithBufferSubDataTests(drawType); |
| 109 |
| 110 glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); |
| 111 } |
| 112 } |
| 113 } |
| 114 |
| 115 function runSupportedTest(extensionEnabled) { |
| 116 var supported = gl.getSupportedExtensions(); |
| 117 if (supported.indexOf("OES_element_index_uint") >= 0) { |
| 118 if (extensionEnabled) { |
| 119 testPassed("OES_element_index_uint listed as supported and getExtens
ion succeeded"); |
| 120 } else { |
| 121 testFailed("OES_element_index_uint listed as supported but getExtens
ion failed"); |
| 122 } |
| 123 } else { |
| 124 if (extensionEnabled) { |
| 125 testFailed("OES_element_index_uint not listed as supported but getEx
tension succeeded"); |
| 126 } else { |
| 127 testPassed("OES_element_index_uint not listed as supported and getEx
tension failed -- this is legal"); |
| 128 } |
| 129 } |
| 130 } |
| 131 |
| 132 function runDrawTests(drawType) { |
| 133 debug("Test that draws with unsigned integer indices produce the expected re
sults"); |
| 134 |
| 135 canvas.width = 50; canvas.height = 50; |
| 136 gl.viewport(0, 0, canvas.width, canvas.height); |
| 137 |
| 138 var program = wtu.setupNoTexCoordTextureProgram(gl); |
| 139 |
| 140 function setupDraw(s) { |
| 141 // Create a vertex buffer that cannot be fully indexed via shorts |
| 142 var quadArrayLen = 65537 * 3; |
| 143 var quadArray = new Float32Array(quadArrayLen); |
| 144 |
| 145 // Leave all but the last 4 values zero-ed out |
| 146 var idx = quadArrayLen - 12; |
| 147 |
| 148 // Initialized the last 4 values to a quad |
| 149 quadArray[idx++] = 1.0 * s; |
| 150 quadArray[idx++] = 1.0 * s; |
| 151 quadArray[idx++] = 0.0; |
| 152 |
| 153 quadArray[idx++] = -1.0 * s; |
| 154 quadArray[idx++] = 1.0 * s; |
| 155 quadArray[idx++] = 0.0; |
| 156 |
| 157 quadArray[idx++] = -1.0 * s; |
| 158 quadArray[idx++] = -1.0 * s; |
| 159 quadArray[idx++] = 0.0; |
| 160 |
| 161 quadArray[idx++] = 1.0 * s; |
| 162 quadArray[idx++] = -1.0 * s; |
| 163 quadArray[idx++] = 0.0; |
| 164 |
| 165 var vertexObject = gl.createBuffer(); |
| 166 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
| 167 gl.bufferData(gl.ARRAY_BUFFER, quadArray, drawType); |
| 168 |
| 169 // Create an unsigned int index buffer that indexes the last 4 vertices |
| 170 var baseIndex = (quadArrayLen / 3) - 4; |
| 171 |
| 172 var indexObject = gl.createBuffer(); |
| 173 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject); |
| 174 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ |
| 175 baseIndex + 0, |
| 176 baseIndex + 1, |
| 177 baseIndex + 2, |
| 178 baseIndex + 2, |
| 179 baseIndex + 3, |
| 180 baseIndex + 0]), drawType); |
| 181 |
| 182 var opt_positionLocation = 0; |
| 183 gl.enableVertexAttribArray(opt_positionLocation); |
| 184 gl.vertexAttribPointer(opt_positionLocation, 3, gl.FLOAT, false, 0, 0); |
| 185 }; |
| 186 function readLocation(x, y) { |
| 187 var pixels = new Uint8Array(1 * 1 * 4); |
| 188 gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels); |
| 189 return pixels; |
| 190 }; |
| 191 function testPixel(blackList, whiteList) { |
| 192 function testList(list, expected) { |
| 193 for (var n = 0; n < list.length; n++) { |
| 194 var l = list[n]; |
| 195 var x = -Math.floor(l * canvas.width / 2) + canvas.width / 2; |
| 196 var y = -Math.floor(l * canvas.height / 2) + canvas.height / 2; |
| 197 var source = readLocation(x, y); |
| 198 if (Math.abs(source[0] - expected) > 2) { |
| 199 return false; |
| 200 } |
| 201 } |
| 202 return true; |
| 203 } |
| 204 return testList(blackList, 0) && testList(whiteList, 255); |
| 205 }; |
| 206 function verifyDraw(drawNumber, s) { |
| 207 gl.clearColor(1.0, 1.0, 1.0, 1.0); |
| 208 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
| 209 gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_INT, 0); |
| 210 |
| 211 var blackList = []; |
| 212 var whiteList = []; |
| 213 var points = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]; |
| 214 for (var n = 0; n < points.length; n++) { |
| 215 if (points[n] <= s) { |
| 216 blackList.push(points[n]); |
| 217 } else { |
| 218 whiteList.push(points[n]); |
| 219 } |
| 220 } |
| 221 if (testPixel(blackList, whiteList)) { |
| 222 testPassed("Draw " + drawNumber + " passed pixel test"); |
| 223 } else { |
| 224 testFailed("Draw " + drawNumber + " failed pixel test"); |
| 225 } |
| 226 }; |
| 227 |
| 228 setupDraw(0.5); |
| 229 verifyDraw(0, 0.5); |
| 230 } |
| 231 |
| 232 function runIndexValidationTests(drawType) { |
| 233 description("Tests that index validation verifies the correct number of indi
ces"); |
| 234 |
| 235 function sizeInBytes(type) { |
| 236 switch (type) { |
| 237 case gl.BYTE: |
| 238 case gl.UNSIGNED_BYTE: |
| 239 return 1; |
| 240 case gl.SHORT: |
| 241 case gl.UNSIGNED_SHORT: |
| 242 return 2; |
| 243 case gl.INT: |
| 244 case gl.UNSIGNED_INT: |
| 245 case gl.FLOAT: |
| 246 return 4; |
| 247 default: |
| 248 throw "unknown type"; |
| 249 } |
| 250 } |
| 251 |
| 252 var program = wtu.loadStandardProgram(gl); |
| 253 |
| 254 // 3 vertices => 1 triangle, interleaved data |
| 255 var dataComplete = new Float32Array([0, 0, 0, 1, |
| 256 0, 0, 1, |
| 257 1, 0, 0, 1, |
| 258 0, 0, 1, |
| 259 1, 1, 1, 1, |
| 260 0, 0, 1]); |
| 261 var dataIncomplete = new Float32Array([0, 0, 0, 1, |
| 262 0, 0, 1, |
| 263 1, 0, 0, 1, |
| 264 0, 0, 1, |
| 265 1, 1, 1, 1]); |
| 266 var indices = new Uint32Array([0, 1, 2]); |
| 267 |
| 268 debug("Testing with valid indices"); |
| 269 |
| 270 var bufferComplete = gl.createBuffer(); |
| 271 gl.bindBuffer(gl.ARRAY_BUFFER, bufferComplete); |
| 272 gl.bufferData(gl.ARRAY_BUFFER, dataComplete, drawType); |
| 273 var elements = gl.createBuffer(); |
| 274 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements); |
| 275 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType); |
| 276 gl.useProgram(program); |
| 277 var vertexLoc = gl.getAttribLocation(program, "a_vertex"); |
| 278 var normalLoc = gl.getAttribLocation(program, "a_normal"); |
| 279 gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLO
AT), 0); |
| 280 gl.enableVertexAttribArray(vertexLoc); |
| 281 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLO
AT), 4 * sizeInBytes(gl.FLOAT)); |
| 282 gl.enableVertexAttribArray(normalLoc); |
| 283 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLE
TE'); |
| 284 glErrorShouldBe(gl, gl.NO_ERROR); |
| 285 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 286 glErrorShouldBe(gl, gl.NO_ERROR); |
| 287 |
| 288 debug("Testing with out-of-range indices"); |
| 289 |
| 290 var bufferIncomplete = gl.createBuffer(); |
| 291 gl.bindBuffer(gl.ARRAY_BUFFER, bufferIncomplete); |
| 292 gl.bufferData(gl.ARRAY_BUFFER, dataIncomplete, drawType); |
| 293 gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLO
AT), 0); |
| 294 gl.enableVertexAttribArray(vertexLoc); |
| 295 gl.disableVertexAttribArray(normalLoc); |
| 296 debug("Enable vertices, valid"); |
| 297 glErrorShouldBe(gl, gl.NO_ERROR); |
| 298 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 299 glErrorShouldBe(gl, gl.NO_ERROR); |
| 300 debug("Enable normals, out-of-range"); |
| 301 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLO
AT), 4 * sizeInBytes(gl.FLOAT)); |
| 302 gl.enableVertexAttribArray(normalLoc); |
| 303 glErrorShouldBe(gl, gl.NO_ERROR); |
| 304 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 305 glErrorShouldBe(gl, gl.INVALID_OPERATION); |
| 306 |
| 307 debug("Test with enabled attribute that does not belong to current program")
; |
| 308 |
| 309 gl.disableVertexAttribArray(normalLoc); |
| 310 var extraLoc = Math.max(vertexLoc, normalLoc) + 1; |
| 311 gl.enableVertexAttribArray(extraLoc); |
| 312 debug("Enable an extra attribute with null"); |
| 313 glErrorShouldBe(gl, gl.NO_ERROR); |
| 314 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 315 glErrorShouldBe(gl, gl.INVALID_OPERATION); |
| 316 debug("Enable an extra attribute with insufficient data buffer"); |
| 317 gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOA
T), 4 * sizeInBytes(gl.FLOAT)); |
| 318 glErrorShouldBe(gl, gl.NO_ERROR); |
| 319 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 320 debug("Pass large negative index to vertexAttribPointer"); |
| 321 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLO
AT), -2000000000 * sizeInBytes(gl.FLOAT)); |
| 322 glErrorShouldBe(gl, gl.INVALID_VALUE); |
| 323 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)'); |
| 324 } |
| 325 |
| 326 function runCopiesIndicesTests(drawType) { |
| 327 debug("Test that client data is always copied during bufferData and bufferSu
bData calls"); |
| 328 |
| 329 var program = wtu.loadStandardProgram(gl); |
| 330 |
| 331 gl.useProgram(program); |
| 332 var vertexObject = gl.createBuffer(); |
| 333 gl.enableVertexAttribArray(0); |
| 334 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
| 335 // 4 vertices -> 2 triangles |
| 336 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0
]), drawType); |
| 337 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); |
| 338 |
| 339 var indexObject = gl.createBuffer(); |
| 340 |
| 341 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject); |
| 342 var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]); |
| 343 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType); |
| 344 shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4
, gl.UNSIGNED_INT, 4)"); |
| 345 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 0)"); |
| 346 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 8)"); |
| 347 indices[0] = 2; |
| 348 indices[5] = 1; |
| 349 shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4
, gl.UNSIGNED_INT, 4)"); |
| 350 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 0)"); |
| 351 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 8)"); |
| 352 } |
| 353 |
| 354 function runResizedBufferTests(drawType) { |
| 355 debug("Test that updating the size of a vertex buffer is properly noticed by
the WebGL implementation."); |
| 356 |
| 357 var program = wtu.setupProgram(gl, ["vs", "fs"], ["vPosition", "vColor"]); |
| 358 glErrorShouldBe(gl, gl.NO_ERROR, "after initialization"); |
| 359 |
| 360 var vertexObject = gl.createBuffer(); |
| 361 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
| 362 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array( |
| 363 [-1,1,0, 1,1,0, -1,-1,0, |
| 364 -1,-1,0, 1,1,0, 1,-1,0]), drawType); |
| 365 gl.enableVertexAttribArray(0); |
| 366 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); |
| 367 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup"); |
| 368 |
| 369 var texCoordObject = gl.createBuffer(); |
| 370 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject); |
| 371 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array( |
| 372 [0,0, 1,0, 0,1, |
| 373 0,1, 1,0, 1,1]), drawType); |
| 374 gl.enableVertexAttribArray(1); |
| 375 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0); |
| 376 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup"); |
| 377 |
| 378 // Now resize these buffers because we want to change what we're drawing. |
| 379 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
| 380 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ |
| 381 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0, |
| 382 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), drawType); |
| 383 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition"); |
| 384 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject); |
| 385 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([ |
| 386 255, 0, 0, 255, |
| 387 255, 0, 0, 255, |
| 388 255, 0, 0, 255, |
| 389 255, 0, 0, 255, |
| 390 0, 255, 0, 255, |
| 391 0, 255, 0, 255, |
| 392 0, 255, 0, 255, |
| 393 0, 255, 0, 255]), drawType); |
| 394 gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0); |
| 395 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinit
ion"); |
| 396 |
| 397 var numQuads = 2; |
| 398 var indices = new Uint32Array(numQuads * 6); |
| 399 for (var ii = 0; ii < numQuads; ++ii) { |
| 400 var offset = ii * 6; |
| 401 var quad = (ii == (numQuads - 1)) ? 4 : 0; |
| 402 indices[offset + 0] = quad + 0; |
| 403 indices[offset + 1] = quad + 1; |
| 404 indices[offset + 2] = quad + 2; |
| 405 indices[offset + 3] = quad + 2; |
| 406 indices[offset + 4] = quad + 1; |
| 407 indices[offset + 5] = quad + 3; |
| 408 } |
| 409 var indexObject = gl.createBuffer(); |
| 410 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject); |
| 411 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType); |
| 412 glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices"); |
| 413 gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_INT, 0); |
| 414 glErrorShouldBe(gl, gl.NO_ERROR, "after drawing"); |
| 415 } |
| 416 |
| 417 function runVerifiesTooManyIndicesTests(drawType) { |
| 418 description("Tests that index validation for drawElements does not examine t
oo many indices"); |
| 419 |
| 420 var program = wtu.loadStandardProgram(gl); |
| 421 |
| 422 gl.useProgram(program); |
| 423 var vertexObject = gl.createBuffer(); |
| 424 gl.enableVertexAttribArray(0); |
| 425 gl.disableVertexAttribArray(1); |
| 426 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
| 427 // 4 vertices -> 2 triangles |
| 428 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0
]), drawType); |
| 429 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); |
| 430 |
| 431 var indexObject = gl.createBuffer(); |
| 432 |
| 433 debug("Test out of range indices") |
| 434 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject); |
| 435 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3,
10000 ]), drawType); |
| 436 shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4
, gl.UNSIGNED_INT, 4)"); |
| 437 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 0)"); |
| 438 shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE
_STRIP, 4, gl.UNSIGNED_INT, 8)"); |
| 439 } |
| 440 |
| 441 function runCrashWithBufferSubDataTests(drawType) { |
| 442 debug('Verifies that the index validation code which is within bufferSubData
does not crash.') |
| 443 |
| 444 var elementBuffer = gl.createBuffer(); |
| 445 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer); |
| 446 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 256, drawType); |
| 447 var data = new Uint32Array(127); |
| 448 gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 64, data); |
| 449 glErrorShouldBe(gl, gl.INVALID_VALUE, "after attempting to update a buffer o
utside of the allocated bounds"); |
| 450 testPassed("bufferSubData, when buffer object was initialized with null, did
not crash"); |
| 451 } |
| 452 |
| 453 debug(""); |
| 454 var successfullyParsed = true; |
| 455 </script> |
| 456 <script src="../../resources/js-test-post.js"></script> |
| 457 |
| 458 </body> |
| 459 </html> |
OLD | NEW |