tor-browser

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

readpixels-16gb-wasm-memory.html (1862B)


      1 <!--
      2 Copyright (c) 2023 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 <!DOCTYPE html>
      7 <html>
      8 <head>
      9 <meta charset="utf-8">
     10 <title>gl.readPixels() test to Wasm Memory 16GB in size.</title>
     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 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
     17 <div id="description"></div>
     18 <div id="console"></div>
     19 <script>
     20 "use strict";
     21 description(document.title);
     22 debug("");
     23 debug("Tests that gl.readPixels() can be called on WebAssembly Memory of 16GB in size.");
     24 debug("");
     25 let wtu = WebGLTestUtils;
     26 let gl = wtu.create3DContext("canvas", undefined, 2);
     27 
     28 const PAGE = 65536;
     29 const SIZE = 16*1024*1024*1024;
     30 let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE/PAGE }).buffer);
     31 
     32 // Clear the canvas to a specific color
     33 const expectedColor = [42, 84, 128, 255];
     34 gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0);
     35 gl.clear(gl.COLOR_BUFFER_BIT);
     36 
     37 // Test that gl.readPixels() can be called with a high offset to Memory
     38 const offset = SIZE - 4;
     39 view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading
     40 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
     41 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     42 let obtainedColor = view.subarray(offset, offset+4);
     43 shouldBe('obtainedColor[0]', 'expectedColor[0]');
     44 shouldBe('obtainedColor[1]', 'expectedColor[1]');
     45 shouldBe('obtainedColor[2]', 'expectedColor[2]');
     46 shouldBe('obtainedColor[3]', 'expectedColor[3]');
     47 var successfullyParsed = true;
     48 </script>
     49 <script src="../../js/js-test-post.js"></script>
     50 </body>
     51 </html>