summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-16gb-wasm-memory.html
blob: 0dd21bf64fb4ca1abcbe159f93820c3914242793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!--
Copyright (c) 2024 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>bufferData test to Wasm Memory 16GB in size.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description(document.title);
debug("Tests that bufferData can be called on WebAssembly Memory of 16GB in size.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

const PAGE = 65536;
const SIZE = 16 * 1024 * 1024 * 1024;
let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer);
let expectedData = new Uint8Array([1, 2, 3, 4]);
const length = expectedData.length;
const offset = SIZE - length;
view.set(expectedData, offset);

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
for (let i = 0; i < length; i++) {
  shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
}

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>