summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/mochitest
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/mochitest')
-rw-r--r--dom/webgpu/mochitest/mochitest-no-pref.ini4
-rw-r--r--dom/webgpu/mochitest/mochitest.ini13
-rw-r--r--dom/webgpu/mochitest/test_buffer_mapping.html39
-rw-r--r--dom/webgpu/mochitest/test_command_buffer_creation.html26
-rw-r--r--dom/webgpu/mochitest/test_device_creation.html24
-rw-r--r--dom/webgpu/mochitest/test_disabled.html16
-rw-r--r--dom/webgpu/mochitest/test_enabled.html16
-rw-r--r--dom/webgpu/mochitest/test_queue_write.html31
-rw-r--r--dom/webgpu/mochitest/test_submit_compute_empty.html29
-rw-r--r--dom/webgpu/mochitest/test_submit_render_empty.html43
10 files changed, 241 insertions, 0 deletions
diff --git a/dom/webgpu/mochitest/mochitest-no-pref.ini b/dom/webgpu/mochitest/mochitest-no-pref.ini
new file mode 100644
index 0000000000..c1e2681367
--- /dev/null
+++ b/dom/webgpu/mochitest/mochitest-no-pref.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+subsuite = webgpu
+
+[test_disabled.html]
diff --git a/dom/webgpu/mochitest/mochitest.ini b/dom/webgpu/mochitest/mochitest.ini
new file mode 100644
index 0000000000..0a039426bd
--- /dev/null
+++ b/dom/webgpu/mochitest/mochitest.ini
@@ -0,0 +1,13 @@
+[DEFAULT]
+subsuite = webgpu
+run-if = nightly_build && webrender
+prefs =
+ dom.webgpu.enabled=true
+
+[test_enabled.html]
+[test_device_creation.html]
+[test_buffer_mapping.html]
+[test_command_buffer_creation.html]
+[test_submit_compute_empty.html]
+[test_submit_render_empty.html]
+[test_queue_write.html]
diff --git a/dom/webgpu/mochitest/test_buffer_mapping.html b/dom/webgpu/mochitest/test_buffer_mapping.html
new file mode 100644
index 0000000000..78e22470ee
--- /dev/null
+++ b/dom/webgpu/mochitest/test_buffer_mapping.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+
+ const bufferRead = device.createBuffer({ size:4, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
+ const bufferWrite = device.createBuffer({ size:4, usage: GPUBufferUsage.COPY_SRC, mappedAtCreation: true });
+ (new Float32Array(bufferWrite.getMappedRange())).set([1.0]);
+ bufferWrite.unmap();
+
+ const encoder = device.createCommandEncoder();
+ encoder.copyBufferToBuffer(bufferWrite, 0, bufferRead, 0, 4);
+ device.defaultQueue.submit([encoder.finish()]);
+
+ await bufferRead.mapAsync(GPUMapMode.READ);
+ const data = bufferRead.getMappedRange();
+ const value = (new Float32Array(data))[0];
+ bufferRead.unmap();
+
+ ok(value == 1.0, 'value == 1.0');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_command_buffer_creation.html b/dom/webgpu/mochitest/test_command_buffer_creation.html
new file mode 100644
index 0000000000..31339824d5
--- /dev/null
+++ b/dom/webgpu/mochitest/test_command_buffer_creation.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+ const encoder = device.createCommandEncoder();
+ const command_buffer = encoder.finish();
+ ok(command_buffer !== undefined, 'command_buffer !== undefined');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_device_creation.html b/dom/webgpu/mochitest/test_device_creation.html
new file mode 100644
index 0000000000..33f91b0811
--- /dev/null
+++ b/dom/webgpu/mochitest/test_device_creation.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+ ok(device !== undefined, 'device !== undefined');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_disabled.html b/dom/webgpu/mochitest/test_disabled.html
new file mode 100644
index 0000000000..e96b8d7ecf
--- /dev/null
+++ b/dom/webgpu/mochitest/test_disabled.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(!SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be disabled.');
+ok(navigator.gpu === undefined, 'navigator.gpu === undefined');
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_enabled.html b/dom/webgpu/mochitest/test_enabled.html
new file mode 100644
index 0000000000..3f4af2177b
--- /dev/null
+++ b/dom/webgpu/mochitest/test_enabled.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+ok(navigator.gpu !== undefined, 'navigator.gpu !== undefined');
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_queue_write.html b/dom/webgpu/mochitest/test_queue_write.html
new file mode 100644
index 0000000000..527cdf580f
--- /dev/null
+++ b/dom/webgpu/mochitest/test_queue_write.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+ const buffer = device.createBuffer({size:16, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC | GPUBufferUsage.VERTEX});
+ const arrayBuf = new ArrayBuffer(16);
+ (new Int32Array(arrayBuf)).fill(5)
+ device.defaultQueue.writeBuffer(buffer, 0, arrayBuf, 0);
+ const texture = device.createTexture({size: [2,2,1], dimension: "2d", format: "rgba8unorm", usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC });
+ device.defaultQueue.writeTexture({ texture }, arrayBuf, { bytesPerRow:8 }, [2,2,1]);
+ // this isn't a process check, we need to read back the contents and verify the writes happened
+ ok(device !== undefined, '');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_submit_compute_empty.html b/dom/webgpu/mochitest/test_submit_compute_empty.html
new file mode 100644
index 0000000000..bded945528
--- /dev/null
+++ b/dom/webgpu/mochitest/test_submit_compute_empty.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+ const encoder = device.createCommandEncoder();
+ const pass = encoder.beginComputePass();
+ pass.endPass();
+ const command_buffer = encoder.finish();
+ device.defaultQueue.submit([command_buffer]);
+ ok(command_buffer !== undefined, 'command_buffer !== undefined');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>
diff --git a/dom/webgpu/mochitest/test_submit_render_empty.html b/dom/webgpu/mochitest/test_submit_render_empty.html
new file mode 100644
index 0000000000..946afd8a88
--- /dev/null
+++ b/dom/webgpu/mochitest/test_submit_render_empty.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset='utf-8'>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<script>
+
+ok(SpecialPowers.getBoolPref('dom.webgpu.enabled'), 'Pref should be enabled.');
+
+const func = async function() {
+ const adapter = await navigator.gpu.requestAdapter();
+ const device = await adapter.requestDevice();
+
+ const texture = device.createTexture({
+ size: { width: 100, height: 100, depth: 1 },
+ format: "rgba8unorm",
+ usage: GPUTextureUsage.OUTPUT_ATTACHMENT,
+ });
+ const view = texture.createView();
+
+ const encoder = device.createCommandEncoder();
+ const pass = encoder.beginRenderPass({
+ colorAttachments: [{
+ attachment: view,
+ loadValue: { r: 0, g: 0, b: 0, a: 0 },
+ storeOp: "store",
+ }],
+ });
+ pass.endPass();
+ const command_buffer = encoder.finish();
+ device.defaultQueue.submit([command_buffer]);
+ ok(command_buffer !== undefined, 'command_buffer !== undefined');
+};
+
+SimpleTest.waitForExplicitFinish();
+func().finally(() => SimpleTest.finish());
+
+</script>
+</body>
+</html>