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.
10 <title>bufferData 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>
16 <canvas id=
"canvas" width=
"2" height=
"2" style=
"width: 40px; height: 40px;"></canvas>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
21 description(document
.title
);
22 debug("Tests that bufferData can be called on WebAssembly Memory of 16GB in size.");
24 let wtu
= WebGLTestUtils
;
25 let gl
= wtu
.create3DContext("canvas", undefined, 2);
28 const SIZE
= 16 * 1024 * 1024 * 1024;
29 let view
= new Uint8Array(new WebAssembly
.Memory({ index
: 'i64', initial
: SIZE
/ PAGE
}).buffer
);
30 let expectedData
= new Uint8Array([1, 2, 3, 4]);
31 const length
= expectedData
.length
;
32 const offset
= SIZE
- length
;
33 view
.set(expectedData
, offset
);
35 let buf
= gl
.createBuffer();
36 gl
.bindBuffer(gl
.ARRAY_BUFFER
, buf
);
37 gl
.bufferData(gl
.ARRAY_BUFFER
, view
, gl
.STATIC_DRAW
, offset
, length
);
38 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
40 let actualData
= new Uint8Array(length
);
41 gl
.getBufferSubData(gl
.ARRAY_BUFFER
, 0, actualData
);
42 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
43 for (let i
= 0; i
< length
; i
++) {
44 shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
47 var successfullyParsed
= true;
49 <script src=
"../../js/js-test-post.js"></script>