getbuffersubdata-4gb-wasm-memory.html (1524B)
1 <!-- 2 Copyright (c) 2024 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>getBufferSubData test to Wasm Memory 4GB 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("Tests that getBufferSubData can be called on WebAssembly Memory of 4GB in size."); 23 debug(""); 24 let wtu = WebGLTestUtils; 25 let gl = wtu.create3DContext("canvas", undefined, 2); 26 27 const PAGE = 65536; 28 const SIZE = 4 * 1024 * 1024 * 1024 - PAGE; 29 let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer); 30 let expectedData = new Uint8Array([1, 2, 3, 4]); 31 32 let buf = gl.createBuffer(); 33 gl.bindBuffer(gl.ARRAY_BUFFER, buf); 34 gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW); 35 36 const length = expectedData.length; 37 const offset = SIZE - length; 38 gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length); 39 wtu.glErrorShouldBe(gl, gl.NO_ERROR); 40 for (let i = 0; i < length; i++) { 41 shouldBe(`view[${i + offset}]`, `expectedData[${i}]`); 42 } 43 44 var successfullyParsed = true; 45 </script> 46 <script src="../../js/js-test-post.js"></script> 47 </body> 48 </html>