Skip to content

Commit

Permalink
Add tests for bufferData, bufferSubData and getBufferSubData from WAS…
Browse files Browse the repository at this point in the history
…M Memories of 4GB and 16GB in size. (#3630)

Related to crbug.com/325090165 .
  • Loading branch information
perryuwang authored Mar 7, 2024
1 parent 5c61c39 commit e2ac29b
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdk/tests/conformance2/wasm/00_test_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
--min-version 2.0.1 teximage2d-4gb-wasm-memory.html
--min-version 2.0.1 texsubimage2d-16gb-wasm-memory.html
--min-version 2.0.1 texsubimage2d-4gb-wasm-memory.html
--min-version 2.0.1 bufferdata-16gb-wasm-memory.html
--min-version 2.0.1 bufferdata-4gb-wasm-memory.html
--min-version 2.0.1 buffersubdata-16gb-wasm-memory.html
--min-version 2.0.1 buffersubdata-4gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-16gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-4gb-wasm-memory.html
51 changes: 51 additions & 0 deletions sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,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>
51 changes: 51 additions & 0 deletions sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 4GB 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 4GB in size.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

const PAGE = 65536;
const SIZE = 4 * 1024 * 1024 * 1024 - PAGE;
let view = new Uint8Array(new WebAssembly.Memory({ 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>
52 changes: 52 additions & 0 deletions sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
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>bufferSubData 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 bufferSubData 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]);
const length = expectedData.length;
let srcOffset = SIZE - length;
view.set(expectedData, srcOffset);
const dstByteOffset = 4;

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
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>
52 changes: 52 additions & 0 deletions sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
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>bufferSubData test to Wasm Memory 4GB 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 bufferSubData can be called on WebAssembly Memory of 4GB in size.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

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

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
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>
48 changes: 48 additions & 0 deletions sdk/tests/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
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>getBufferSubData 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 getBufferSubData 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]);

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW);

const length = expectedData.length;
const offset = SIZE - length;
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
for (let i = 0; i < length; i++) {
shouldBe(`view[${i + offset}]`, `expectedData[${i}]`);
}

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>
48 changes: 48 additions & 0 deletions sdk/tests/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
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>getBufferSubData test to Wasm Memory 4GB 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 getBufferSubData can be called on WebAssembly Memory of 4GB in size.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

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

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, expectedData, gl.STATIC_DRAW);

const length = expectedData.length;
const offset = SIZE - length;
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view, offset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
for (let i = 0; i < length; i++) {
shouldBe(`view[${i + offset}]`, `expectedData[${i}]`);
}

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

0 comments on commit e2ac29b

Please sign in to comment.