Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolerate throws in wasm/* tests, add 2gb-in-4gb variants. #3665

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions sdk/tests/conformance2/wasm/00_test_list.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
--min-version 2.0.1 readpixels-16gb-wasm-memory.html
--min-version 2.0.1 readpixels-4gb-wasm-memory.html
--min-version 2.0.1 teximage2d-16gb-wasm-memory.html
--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-2gb-in-4gb-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 bufferdata-16gb-wasm-memory.html
--min-version 2.0.1 buffersubdata-2gb-in-4gb-wasm-memory.html
--min-version 2.0.1 buffersubdata-4gb-wasm-memory.html
--min-version 2.0.1 buffersubdata-16gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-2gb-in-4gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-4gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-16gb-wasm-memory.html
--min-version 2.0.1 getbuffersubdata-4gb-wasm-memory.html
--min-version 2.0.1 readpixels-2gb-in-4gb-wasm-memory.html
--min-version 2.0.1 readpixels-4gb-wasm-memory.html
--min-version 2.0.1 readpixels-16gb-wasm-memory.html
--min-version 2.0.1 teximage2d-2gb-in-4gb-wasm-memory.html
--min-version 2.0.1 teximage2d-4gb-wasm-memory.html
--min-version 2.0.1 teximage2d-16gb-wasm-memory.html
--min-version 2.0.1 texsubimage2d-2gb-in-4gb-wasm-memory.html
--min-version 2.0.1 texsubimage2d-4gb-wasm-memory.html
--min-version 2.0.1 texsubimage2d-16gb-wasm-memory.html
44 changes: 28 additions & 16 deletions sdk/tests/conformance2/wasm/bufferdata-16gb-wasm-memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,42 @@
<script>
"use strict";
description(document.title);
debug("Tests that bufferData can be called on WebAssembly Memory of 16GB in size.");
debug("Tests that bufferData can be called on the end of a 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 view;
try {
view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer);
} catch (e) {
testPassed(`Allocating ${SIZE} threw: ${e}`);
return;
}

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 expectedData = new Uint8Array([1, 2, 3, 4]);
const length = expectedData.length;
const offset = SIZE - length;
view.set(expectedData, offset);

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}]`);
}
let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
try {
gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length);
} catch (e) {
testFailed(`bufferData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
Expand Down
64 changes: 64 additions & 0 deletions sdk/tests/conformance2/wasm/bufferdata-2gb-in-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
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 the end of a ~2GB view into ~4GB of WebAssembly Memory.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

const PAGE = 65536;
const HEAP_SIZE = 4 * 1024 * 1024 * 1024 - PAGE;
const VIEW_SIZE = 2 * 1024 * 1024 * 1024 - PAGE;
(() => {
let view;
try {
view = new Uint8Array(new WebAssembly.Memory({ initial: HEAP_SIZE / PAGE }).buffer, 0, VIEW_SIZE);
} catch (e) {
testPassed(`Allocating ${HEAP_SIZE} threw: ${e}`);
return;
}

let expectedData = new Uint8Array([1, 2, 3, 4]);
const length = expectedData.length;
const offset = view.length - length;
view.set(expectedData, offset);

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
try {
gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length);
} catch (e) {
testFailed(`bufferData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>
44 changes: 28 additions & 16 deletions sdk/tests/conformance2/wasm/bufferdata-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,42 @@
<script>
"use strict";
description(document.title);
debug("Tests that bufferData can be called on WebAssembly Memory of 4GB in size.");
debug("Tests that bufferData can be called on the end of a WebAssembly Memory of nearly 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 view;
try {
view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer);
} catch (e) {
testPassed(`Allocating ${SIZE} threw: ${e}`);
return;
}

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 expectedData = new Uint8Array([1, 2, 3, 4]);
const length = expectedData.length;
const offset = SIZE - length;
view.set(expectedData, offset);

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}]`);
}
let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
try {
gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length);
} catch (e) {
testFailed(`bufferData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
Expand Down
46 changes: 29 additions & 17 deletions sdk/tests/conformance2/wasm/buffersubdata-16gb-wasm-memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,43 @@
<script>
"use strict";
description(document.title);
debug("Tests that bufferSubData can be called on WebAssembly Memory of 16GB in size.");
debug("Tests that bufferSubData can be called on the end of a 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 view;
try {
view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer);
} catch (e) {
testPassed(`Allocating ${SIZE} threw: ${e}`);
return;
}

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 expectedData = new Uint8Array([1, 2]);
const length = expectedData.length;
let srcOffset = SIZE - length;
view.set(expectedData, srcOffset);
const dstByteOffset = 4;

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
for (let i = 0; i < length; i++) {
shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
}
let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
try {
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
} catch (e) {
testFailed(`bufferSubData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--
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 the end of a ~2GB view into ~4GB of WebAssembly Memory.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

const PAGE = 65536;
const HEAP_SIZE = 4 * 1024 * 1024 * 1024 - PAGE;
const VIEW_SIZE = 2 * 1024 * 1024 * 1024 - PAGE;
(() => {
let view;
try {
view = new Uint8Array(new WebAssembly.Memory({ initial: HEAP_SIZE / PAGE }).buffer, 0, VIEW_SIZE);
} catch (e) {
testPassed(`Allocating ${HEAP_SIZE} threw: ${e}`);
return;
}

let expectedData = new Uint8Array([1, 2]);
const length = expectedData.length;
let srcOffset = view.length - 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);
try {
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
} catch (e) {
testFailed(`bufferSubData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>
46 changes: 29 additions & 17 deletions sdk/tests/conformance2/wasm/buffersubdata-4gb-wasm-memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,43 @@
<script>
"use strict";
description(document.title);
debug("Tests that bufferSubData can be called on WebAssembly Memory of 4GB in size.");
debug("Tests that bufferSubData can be called on the end of a WebAssembly Memory of nearly 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 view;
try {
view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer);
} catch (e) {
testPassed(`Allocating ${SIZE} threw: ${e}`);
return;
}

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 expectedData = new Uint8Array([1, 2]);
const length = expectedData.length;
let srcOffset = SIZE - length;
view.set(expectedData, srcOffset);
const dstByteOffset = 4;

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
for (let i = 0; i < length; i++) {
shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
}
let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
try {
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
} catch (e) {
testFailed(`bufferSubData from ${view.length} byte view threw: ${e}`);
return;
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
expectArray(actualData, expectedData);
})();

var successfullyParsed = true;
</script>
Expand Down
Loading
Loading