tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

index-validation-large-buffer.html (1891B)


      1 <!--
      2 Copyright (c) 2019 The Khronos Group Inc.
      3 Use of this source code is governed by an MIT-style license that can be
      4 found in the LICENSE.txt file.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     12 <script src="../../js/js-test-pre.js"></script>
     13 <script src="../../js/webgl-test-utils.js"></script>
     14 </head>
     15 <body>
     16 <div id="description"></div>
     17 <div id="console"></div>
     18 
     19 <script>
     20 "use strict";
     21 description('Tests that index validation for drawElements works with large attribute buffers');
     22 
     23 var wtu = WebGLTestUtils;
     24 var context = wtu.create3DContext();
     25 var program = wtu.loadStandardProgram(context);
     26 
     27 context.useProgram(program);
     28 
     29 // Create a small index buffer.
     30 var indexObject = context.createBuffer();
     31 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
     32 var indexArray = new Uint16Array([0, 1, 2]);
     33 context.bufferData(context.ELEMENT_ARRAY_BUFFER, indexArray, context.STATIC_DRAW);
     34 
     35 // Create a large attribute buffer.
     36 var vertexObject = context.createBuffer();
     37 context.enableVertexAttribArray(0);
     38 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
     39 context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536), context.STATIC_DRAW);
     40 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
     41 
     42 debug("Test large attribute buffer")
     43 wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
     44 
     45 // Enlarge the attribute buffer slightly.
     46 debug("Test even larger attribute buffer")
     47 context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536 + 3), context.STATIC_DRAW);
     48 wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
     49 
     50 debug("")
     51 var successfullyParsed = true;
     52 </script>
     53 
     54 <script src="../../js/js-test-post.js"></script>
     55 </body>
     56 </html>