summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/wasm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/00_test_list.txt12
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-16gb-wasm-memory.html51
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-4gb-wasm-memory.html51
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-16gb-wasm-memory.html52
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-4gb-wasm-memory.html52
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html48
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html48
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-16gb-wasm-memory.html51
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-4gb-wasm-memory.html50
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-16gb-wasm-memory.html85
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-4gb-wasm-memory.html85
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html86
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html86
13 files changed, 757 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/00_test_list.txt
new file mode 100644
index 0000000000..d188fc30a6
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/00_test_list.txt
@@ -0,0 +1,12 @@
+--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-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 \ No newline at end of file
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-16gb-wasm-memory.html
new file mode 100644
index 0000000000..0dd21bf64f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-16gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-4gb-wasm-memory.html
new file mode 100644
index 0000000000..2296c3a5ea
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/bufferdata-4gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-16gb-wasm-memory.html
new file mode 100644
index 0000000000..08d6d1df50
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-16gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-4gb-wasm-memory.html
new file mode 100644
index 0000000000..2834a6901b
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-4gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html
new file mode 100644
index 0000000000..8390957b02
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-16gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html
new file mode 100644
index 0000000000..09a336b753
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/getbuffersubdata-4gb-wasm-memory.html
@@ -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>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-16gb-wasm-memory.html
new file mode 100644
index 0000000000..af74678dda
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-16gb-wasm-memory.html
@@ -0,0 +1,51 @@
+<!--
+Copyright (c) 2023 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>gl.readPixels() 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("");
+debug("Tests that gl.readPixels() 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);
+
+// Clear the canvas to a specific color
+const expectedColor = [42, 84, 128, 255];
+gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0);
+gl.clear(gl.COLOR_BUFFER_BIT);
+
+// Test that gl.readPixels() can be called with a high offset to Memory
+const offset = SIZE - 4;
+view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading
+gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+let obtainedColor = view.subarray(offset, offset+4);
+shouldBe('obtainedColor[0]', 'expectedColor[0]');
+shouldBe('obtainedColor[1]', 'expectedColor[1]');
+shouldBe('obtainedColor[2]', 'expectedColor[2]');
+shouldBe('obtainedColor[3]', 'expectedColor[3]');
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-4gb-wasm-memory.html
new file mode 100644
index 0000000000..f97a3ccba0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/readpixels-4gb-wasm-memory.html
@@ -0,0 +1,50 @@
+<!--
+Copyright (c) 2023 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>gl.readPixels() 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 gl.readPixels() 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; // when uint32_t size is max, we can only reach one page short of full 4GB
+let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer);
+
+// Clear the canvas to a specific color
+const expectedColor = [42, 84, 128, 255];
+gl.clearColor(expectedColor[0]/255.0, expectedColor[1]/255.0, expectedColor[2]/255.0, expectedColor[3]/255.0);
+gl.clear(gl.COLOR_BUFFER_BIT);
+
+// Test that gl.readPixels() can be called with a high offset to Memory
+const offset = SIZE - 4;
+view.set([0,0,0,0], offset); // For good measure, clear data at offset before reading
+gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+let obtainedColor = view.subarray(offset, offset+4);
+shouldBe('obtainedColor[0]', 'expectedColor[0]');
+shouldBe('obtainedColor[1]', 'expectedColor[1]');
+shouldBe('obtainedColor[2]', 'expectedColor[2]');
+shouldBe('obtainedColor[3]', 'expectedColor[3]');
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-16gb-wasm-memory.html
new file mode 100644
index 0000000000..8ce5111953
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-16gb-wasm-memory.html
@@ -0,0 +1,85 @@
+<!--
+Copyright (c) 2023 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>gl.texImage2D() 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 gl.texImage2D() can be called on WebAssembly Memory 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);
+
+function compileShader(type, src) {
+ let shader = gl.createShader(type);
+ gl.shaderSource(shader, src);
+ gl.compileShader(shader);
+ let log = gl.getShaderInfoLog(shader);
+ if (log) debug(log);
+ return shader;
+}
+
+function createProgram(vs, fs) {
+ let program = gl.createProgram();
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.bindAttribLocation(program, 0, 'pos');
+ gl.linkProgram(program);
+ gl.useProgram(program);
+ return program;
+}
+
+let program = createProgram(
+ compileShader(gl.VERTEX_SHADER, `
+ varying vec2 uv;
+ attribute vec2 pos;
+ void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`),
+ compileShader(gl.FRAGMENT_SHADER, `
+ precision lowp float;
+ uniform sampler2D tex;
+ varying vec2 uv;
+ void main() { gl_FragColor = texture2D(tex,uv); }`));
+
+gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW);
+gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0);
+gl.enableVertexAttribArray(0);
+
+let texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+
+// Test uploading an image
+const expectedColor = [42, 84, 128, 255];
+const offset = SIZE - 4;
+view.set(expectedColor, offset);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// Test rendering with that image
+gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+// Verify that we rendered what we expected
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color");
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-4gb-wasm-memory.html
new file mode 100644
index 0000000000..5d6897347d
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/teximage2d-4gb-wasm-memory.html
@@ -0,0 +1,85 @@
+<!--
+Copyright (c) 2023 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>gl.texImage2D() 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 gl.texImage2D() can be called on WebAssembly Memory 4GB in size.");
+debug("");
+let wtu = WebGLTestUtils;
+let gl = wtu.create3DContext("canvas", undefined, 2);
+
+const PAGE = 65536;
+const SIZE = 4*1024*1024*1024 - PAGE; // when uint32_t size is max, we can only reach one page short of full 4GB
+let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer);
+
+function compileShader(type, src) {
+ let shader = gl.createShader(type);
+ gl.shaderSource(shader, src);
+ gl.compileShader(shader);
+ let log = gl.getShaderInfoLog(shader);
+ if (log) debug(log);
+ return shader;
+}
+
+function createProgram(vs, fs) {
+ let program = gl.createProgram();
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.bindAttribLocation(program, 0, 'pos');
+ gl.linkProgram(program);
+ gl.useProgram(program);
+ return program;
+}
+
+let program = createProgram(
+ compileShader(gl.VERTEX_SHADER, `
+ varying vec2 uv;
+ attribute vec2 pos;
+ void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`),
+ compileShader(gl.FRAGMENT_SHADER, `
+ precision lowp float;
+ uniform sampler2D tex;
+ varying vec2 uv;
+ void main() { gl_FragColor = texture2D(tex,uv); }`));
+
+gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW);
+gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0);
+gl.enableVertexAttribArray(0);
+
+let texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+
+// Test uploading an image
+const expectedColor = [42, 84, 128, 255];
+const offset = SIZE - 4;
+view.set(expectedColor, offset);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// Test rendering with that image
+gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+// Verify that we rendered what we expected
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texImage2D produced expected color");
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html
new file mode 100644
index 0000000000..328d42ec49
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-16gb-wasm-memory.html
@@ -0,0 +1,86 @@
+<!--
+Copyright (c) 2023 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>gl.texSubImage2D() 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 gl.texSubImage2D() can be called on WebAssembly Memory 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);
+
+function compileShader(type, src) {
+ let shader = gl.createShader(type);
+ gl.shaderSource(shader, src);
+ gl.compileShader(shader);
+ let log = gl.getShaderInfoLog(shader);
+ if (log) debug(log);
+ return shader;
+}
+
+function createProgram(vs, fs) {
+ let program = gl.createProgram();
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.bindAttribLocation(program, 0, 'pos');
+ gl.linkProgram(program);
+ gl.useProgram(program);
+ return program;
+}
+
+let program = createProgram(
+ compileShader(gl.VERTEX_SHADER, `
+ varying vec2 uv;
+ attribute vec2 pos;
+ void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`),
+ compileShader(gl.FRAGMENT_SHADER, `
+ precision lowp float;
+ uniform sampler2D tex;
+ varying vec2 uv;
+ void main() { gl_FragColor = texture2D(tex,uv); }`));
+
+gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW);
+gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0);
+gl.enableVertexAttribArray(0);
+
+let texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+
+// Test uploading an image
+const expectedColor = [42, 84, 128, 255];
+const offset = SIZE - 4;
+view.set(expectedColor, offset);
+gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1);
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// Test rendering with that image
+gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+// Verify that we rendered what we expected
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color");
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html
new file mode 100644
index 0000000000..d7756629a0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/wasm/texsubimage2d-4gb-wasm-memory.html
@@ -0,0 +1,86 @@
+<!--
+Copyright (c) 2023 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>gl.texSubImage2D() 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 gl.texSubImage2D() can be called on WebAssembly Memory 4GB in size.");
+debug("");
+let wtu = WebGLTestUtils;
+let gl = wtu.create3DContext("canvas", undefined, 2);
+
+const PAGE = 65536;
+const SIZE = 4*1024*1024*1024 - PAGE; // when uint32_t size is max, we can only reach one page short of full 4GB
+let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE/PAGE }).buffer);
+
+function compileShader(type, src) {
+ let shader = gl.createShader(type);
+ gl.shaderSource(shader, src);
+ gl.compileShader(shader);
+ let log = gl.getShaderInfoLog(shader);
+ if (log) debug(log);
+ return shader;
+}
+
+function createProgram(vs, fs) {
+ let program = gl.createProgram();
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.bindAttribLocation(program, 0, 'pos');
+ gl.linkProgram(program);
+ gl.useProgram(program);
+ return program;
+}
+
+let program = createProgram(
+ compileShader(gl.VERTEX_SHADER, `
+ varying vec2 uv;
+ attribute vec2 pos;
+ void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`),
+ compileShader(gl.FRAGMENT_SHADER, `
+ precision lowp float;
+ uniform sampler2D tex;
+ varying vec2 uv;
+ void main() { gl_FragColor = texture2D(tex,uv); }`));
+
+gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), gl.STATIC_DRAW);
+gl.vertexAttribPointer(0, 2, gl.FLOAT, gl.FALSE, 0, 0);
+gl.enableVertexAttribArray(0);
+
+let texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+
+// Test uploading an image
+const expectedColor = [42, 84, 128, 255];
+const offset = SIZE - 4;
+view.set(expectedColor, offset);
+gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, 1, 1);
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, view, offset);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// Test rendering with that image
+gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+// Verify that we rendered what we expected
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, expectedColor, "texSubImage2D produced expected color");
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>