tor-browser

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

delete-buffer.html (2669B)


      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 <title>WebGL buffer deletion behavior test.</title>
     12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     13 <script src="../../js/js-test-pre.js"></script>
     14 <script src="../../js/webgl-test-utils.js"></script>
     15 </head>
     16 <body>
     17 <div id="description"></div>
     18 <div id="console"></div>
     19 <script>
     20 "use strict";
     21 description("Test buffer deletion behavior.");
     22 // This is a regression test for https://crbug.com/822976
     23 
     24 var wtu = WebGLTestUtils;
     25 
     26 var gl = wtu.create3DContext(undefined, undefined, 2);
     27 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
     28 
     29 function runTexImageTest(gl) {
     30  debug("");
     31  var buffer = gl.createBuffer();
     32  gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, buffer);
     33  gl.bufferData(gl.PIXEL_UNPACK_BUFFER, 4, gl.DYNAMIC_DRAW);
     34  gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer);
     35  gl.deleteBuffer(buffer);
     36  // Indexed uniform buffer bindings should not prevent a buffer from being
     37  // deleted. Therefore, PIXEL_UNPACK_BUFFER binding should also be 0.
     38  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no error");
     39 
     40  var tex = gl.createTexture();
     41  gl.bindTexture(gl.TEXTURE_2D, tex);
     42  var data = new Uint8Array(1024);
     43  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 16, 16, 0,
     44                gl.RGBA, gl.UNSIGNED_BYTE, data);
     45  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texImage2D should succeed");
     46 
     47  // Clean up bindings just in case an implementation gets it wrong.
     48  gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null);
     49  gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, null);
     50 }
     51 
     52 function runReadPixelsTest(gl) {
     53  debug("");
     54  var buffer = gl.createBuffer();
     55  gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buffer);
     56  gl.bufferData(gl.PIXEL_PACK_BUFFER, 4, gl.DYNAMIC_DRAW);
     57  gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer);
     58  gl.deleteBuffer(buffer);
     59  // Indexed transform feedback buffer bindings should not prevent a buffer
     60  // from being deleted. Therefore, PIXEL_PACK_BUFFER binding should also be 0.
     61  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no error");
     62 
     63  var buffer = new Uint8Array(1024);
     64  gl.readPixels(0, 0, 16, 16, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
     65  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels should succeed");
     66 
     67  // Clean up bindings just in case an implementation gets it wrong.
     68  gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
     69  gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, null);
     70 }
     71 
     72 runTexImageTest(gl);
     73 runReadPixelsTest(gl);
     74 
     75 debug("");
     76 var successfullyParsed = true;
     77 </script>
     78 <script src="../../js/js-test-post.js"></script>
     79 </body>
     80 </html>