From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- dom/webgpu/mochitest/mochitest-no-pref.toml | 10 + dom/webgpu/mochitest/mochitest.toml | 116 +++++++++ dom/webgpu/mochitest/test_basic_canvas.worker.html | 18 ++ dom/webgpu/mochitest/test_basic_canvas.worker.js | 32 +++ dom/webgpu/mochitest/test_buffer_mapping.html | 73 ++++++ .../test_buffer_mapping_invalid_device.html | 60 +++++ .../mochitest/test_command_buffer_creation.html | 29 +++ dom/webgpu/mochitest/test_context_configure.html | 48 ++++ dom/webgpu/mochitest/test_device_creation.html | 29 +++ dom/webgpu/mochitest/test_device_lost.html | 73 ++++++ dom/webgpu/mochitest/test_disabled.html | 17 ++ .../mochitest/test_double_encoder_finish.html | 36 +++ dom/webgpu/mochitest/test_enabled.html | 17 ++ dom/webgpu/mochitest/test_error_scope.html | 43 ++++ dom/webgpu/mochitest/test_insecure_context.html | 22 ++ .../test_navigator_gpu_not_replaceable.html | 32 +++ .../test_queue_copyExternalImageToTexture.html | 261 +++++++++++++++++++++ dom/webgpu/mochitest/test_queue_write.html | 50 ++++ .../mochitest/test_queue_write_invalid_device.html | 44 ++++ .../mochitest/test_submit_compute_empty.html | 32 +++ dom/webgpu/mochitest/test_submit_render_empty.html | 57 +++++ .../mochitest/test_submit_render_empty.worker.html | 14 ++ .../mochitest/test_submit_render_empty.worker.js | 49 ++++ dom/webgpu/mochitest/worker_wrapper.js | 33 +++ 24 files changed, 1195 insertions(+) create mode 100644 dom/webgpu/mochitest/mochitest-no-pref.toml create mode 100644 dom/webgpu/mochitest/mochitest.toml create mode 100644 dom/webgpu/mochitest/test_basic_canvas.worker.html create mode 100644 dom/webgpu/mochitest/test_basic_canvas.worker.js create mode 100644 dom/webgpu/mochitest/test_buffer_mapping.html create mode 100644 dom/webgpu/mochitest/test_buffer_mapping_invalid_device.html create mode 100644 dom/webgpu/mochitest/test_command_buffer_creation.html create mode 100644 dom/webgpu/mochitest/test_context_configure.html create mode 100644 dom/webgpu/mochitest/test_device_creation.html create mode 100644 dom/webgpu/mochitest/test_device_lost.html create mode 100644 dom/webgpu/mochitest/test_disabled.html create mode 100644 dom/webgpu/mochitest/test_double_encoder_finish.html create mode 100644 dom/webgpu/mochitest/test_enabled.html create mode 100644 dom/webgpu/mochitest/test_error_scope.html create mode 100644 dom/webgpu/mochitest/test_insecure_context.html create mode 100644 dom/webgpu/mochitest/test_navigator_gpu_not_replaceable.html create mode 100644 dom/webgpu/mochitest/test_queue_copyExternalImageToTexture.html create mode 100644 dom/webgpu/mochitest/test_queue_write.html create mode 100644 dom/webgpu/mochitest/test_queue_write_invalid_device.html create mode 100644 dom/webgpu/mochitest/test_submit_compute_empty.html create mode 100644 dom/webgpu/mochitest/test_submit_render_empty.html create mode 100644 dom/webgpu/mochitest/test_submit_render_empty.worker.html create mode 100644 dom/webgpu/mochitest/test_submit_render_empty.worker.js create mode 100644 dom/webgpu/mochitest/worker_wrapper.js (limited to 'dom/webgpu/mochitest') diff --git a/dom/webgpu/mochitest/mochitest-no-pref.toml b/dom/webgpu/mochitest/mochitest-no-pref.toml new file mode 100644 index 0000000000..511b840c0b --- /dev/null +++ b/dom/webgpu/mochitest/mochitest-no-pref.toml @@ -0,0 +1,10 @@ +[DEFAULT] +subsuite = "webgpu" +run-if = ["release_or_beta"] + +# Even if the pref were enabled, WebGPU is only available in secure contexts. +# +# See spec WebIDL, like this: https://www.w3.org/TR/webgpu/#navigatorgpu +scheme = "https" + +["test_disabled.html"] diff --git a/dom/webgpu/mochitest/mochitest.toml b/dom/webgpu/mochitest/mochitest.toml new file mode 100644 index 0000000000..f32d7a9a86 --- /dev/null +++ b/dom/webgpu/mochitest/mochitest.toml @@ -0,0 +1,116 @@ +[DEFAULT] +subsuite = "webgpu" +run-if = ["!release_or_beta"] +prefs = [ + "dom.webgpu.enabled=true", + "dom.webgpu.workers.enabled=true", + "gfx.offscreencanvas.enabled=true", +] +support-files = [ + "worker_wrapper.js", + "test_basic_canvas.worker.js", + "test_submit_render_empty.worker.js", +] + +# WebGPU is only available in secure contexts. +# +# See spec WebIDL, like this: https://www.w3.org/TR/webgpu/#navigatorgpu +scheme = "https" + +["test_basic_canvas.worker.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_buffer_mapping.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_buffer_mapping_invalid_device.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_command_buffer_creation.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_context_configure.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_device_creation.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_device_lost.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_double_encoder_finish.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_enabled.html"] + +["test_error_scope.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_insecure_context.html"] +# This test checks that WebGPU is not available in insecure contexts. +scheme = "http" + +["test_navigator_gpu_not_replaceable.html"] + +["test_queue_copyExternalImageToTexture.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_queue_write.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_queue_write_invalid_device.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_submit_compute_empty.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_submit_render_empty.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] + +["test_submit_render_empty.worker.html"] +fail-if = [ + "os == 'linux' && os_version == '18.04'", + "os == 'mac'", +] diff --git a/dom/webgpu/mochitest/test_basic_canvas.worker.html b/dom/webgpu/mochitest/test_basic_canvas.worker.html new file mode 100644 index 0000000000..a23ee9fc70 --- /dev/null +++ b/dom/webgpu/mochitest/test_basic_canvas.worker.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_basic_canvas.worker.js b/dom/webgpu/mochitest/test_basic_canvas.worker.js new file mode 100644 index 0000000000..cec6d6f210 --- /dev/null +++ b/dom/webgpu/mochitest/test_basic_canvas.worker.js @@ -0,0 +1,32 @@ +self.addEventListener("message", async function (event) { + try { + const offscreen = event.data.offscreen; + const context = offscreen.getContext("webgpu"); + + const swapChainFormat = navigator.gpu.getPreferredCanvasFormat(); + const adapter = await navigator.gpu.requestAdapter(); + const device = await adapter.requestDevice(); + + context.configure({ + device, + format: swapChainFormat, + size: { width: 100, height: 100, depth: 1 }, + }); + + const texture = context.getCurrentTexture(); + + self.postMessage([ + { + value: texture !== undefined, + message: "texture !== undefined", + }, + ]); + } catch (e) { + self.postMessage([ + { + value: false, + message: "Unhandled exception " + e, + }, + ]); + } +}); diff --git a/dom/webgpu/mochitest/test_buffer_mapping.html b/dom/webgpu/mochitest/test_buffer_mapping.html new file mode 100644 index 0000000000..01dfbf893e --- /dev/null +++ b/dom/webgpu/mochitest/test_buffer_mapping.html @@ -0,0 +1,73 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_buffer_mapping_invalid_device.html b/dom/webgpu/mochitest/test_buffer_mapping_invalid_device.html new file mode 100644 index 0000000000..6b7e7fafad --- /dev/null +++ b/dom/webgpu/mochitest/test_buffer_mapping_invalid_device.html @@ -0,0 +1,60 @@ + + + + + + + + + + + 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..a92c038afd --- /dev/null +++ b/dom/webgpu/mochitest/test_command_buffer_creation.html @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_context_configure.html b/dom/webgpu/mochitest/test_context_configure.html new file mode 100644 index 0000000000..7ca96d0afe --- /dev/null +++ b/dom/webgpu/mochitest/test_context_configure.html @@ -0,0 +1,48 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_device_creation.html b/dom/webgpu/mochitest/test_device_creation.html new file mode 100644 index 0000000000..678359c323 --- /dev/null +++ b/dom/webgpu/mochitest/test_device_creation.html @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_device_lost.html b/dom/webgpu/mochitest/test_device_lost.html new file mode 100644 index 0000000000..bc6614f0ef --- /dev/null +++ b/dom/webgpu/mochitest/test_device_lost.html @@ -0,0 +1,73 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_disabled.html b/dom/webgpu/mochitest/test_disabled.html new file mode 100644 index 0000000000..12eb01e465 --- /dev/null +++ b/dom/webgpu/mochitest/test_disabled.html @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_double_encoder_finish.html b/dom/webgpu/mochitest/test_double_encoder_finish.html new file mode 100644 index 0000000000..24c91c3165 --- /dev/null +++ b/dom/webgpu/mochitest/test_double_encoder_finish.html @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_enabled.html b/dom/webgpu/mochitest/test_enabled.html new file mode 100644 index 0000000000..318788bf1e --- /dev/null +++ b/dom/webgpu/mochitest/test_enabled.html @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_error_scope.html b/dom/webgpu/mochitest/test_error_scope.html new file mode 100644 index 0000000000..f89b4b6e78 --- /dev/null +++ b/dom/webgpu/mochitest/test_error_scope.html @@ -0,0 +1,43 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_insecure_context.html b/dom/webgpu/mochitest/test_insecure_context.html new file mode 100644 index 0000000000..dcc4a313b9 --- /dev/null +++ b/dom/webgpu/mochitest/test_insecure_context.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_navigator_gpu_not_replaceable.html b/dom/webgpu/mochitest/test_navigator_gpu_not_replaceable.html new file mode 100644 index 0000000000..6b6b7b9715 --- /dev/null +++ b/dom/webgpu/mochitest/test_navigator_gpu_not_replaceable.html @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_queue_copyExternalImageToTexture.html b/dom/webgpu/mochitest/test_queue_copyExternalImageToTexture.html new file mode 100644 index 0000000000..279b4a52b4 --- /dev/null +++ b/dom/webgpu/mochitest/test_queue_copyExternalImageToTexture.html @@ -0,0 +1,261 @@ + + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_queue_write.html b/dom/webgpu/mochitest/test_queue_write.html new file mode 100644 index 0000000000..585c1617cd --- /dev/null +++ b/dom/webgpu/mochitest/test_queue_write.html @@ -0,0 +1,50 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_queue_write_invalid_device.html b/dom/webgpu/mochitest/test_queue_write_invalid_device.html new file mode 100644 index 0000000000..09180dee7f --- /dev/null +++ b/dom/webgpu/mochitest/test_queue_write_invalid_device.html @@ -0,0 +1,44 @@ + + + + + + + + + + + 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..82cb9473c5 --- /dev/null +++ b/dom/webgpu/mochitest/test_submit_compute_empty.html @@ -0,0 +1,32 @@ + + + + + + + + + + + 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..bac0d1ede7 --- /dev/null +++ b/dom/webgpu/mochitest/test_submit_render_empty.html @@ -0,0 +1,57 @@ + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_submit_render_empty.worker.html b/dom/webgpu/mochitest/test_submit_render_empty.worker.html new file mode 100644 index 0000000000..8db3168be0 --- /dev/null +++ b/dom/webgpu/mochitest/test_submit_render_empty.worker.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/dom/webgpu/mochitest/test_submit_render_empty.worker.js b/dom/webgpu/mochitest/test_submit_render_empty.worker.js new file mode 100644 index 0000000000..334230c3c1 --- /dev/null +++ b/dom/webgpu/mochitest/test_submit_render_empty.worker.js @@ -0,0 +1,49 @@ +self.addEventListener("message", async function (event) { + try { + const adapter = await navigator.gpu.requestAdapter(); + const device = await adapter.requestDevice(); + + const swapChainFormat = "rgba8unorm"; + const bundleEncoder = device.createRenderBundleEncoder({ + colorFormats: [swapChainFormat], + }); + const bundle = bundleEncoder.finish({}); + + const texture = device.createTexture({ + size: { width: 100, height: 100, depth: 1 }, + format: swapChainFormat, + usage: GPUTextureUsage.RENDER_ATTACHMENT, + }); + const view = texture.createView(); + + const encoder = device.createCommandEncoder(); + const pass = encoder.beginRenderPass({ + colorAttachments: [ + { + view, + clearValue: { r: 0, g: 0, b: 0, a: 0 }, + loadOp: "clear", + storeOp: "store", + }, + ], + }); + pass.executeBundles([bundle]); + pass.end(); + const command_buffer = encoder.finish(); + + device.queue.submit([command_buffer]); + self.postMessage([ + { + value: command_buffer !== undefined, + message: "command_buffer !== undefined", + }, + ]); + } catch (e) { + self.postMessage([ + { + value: false, + message: "Unhandled exception " + e, + }, + ]); + } +}); diff --git a/dom/webgpu/mochitest/worker_wrapper.js b/dom/webgpu/mochitest/worker_wrapper.js new file mode 100644 index 0000000000..6f6de9002d --- /dev/null +++ b/dom/webgpu/mochitest/worker_wrapper.js @@ -0,0 +1,33 @@ +ok( + SpecialPowers.getBoolPref("dom.webgpu.enabled"), + "WebGPU pref should be enabled." +); +ok( + SpecialPowers.getBoolPref("gfx.offscreencanvas.enabled"), + "OffscreenCanvas pref should be enabled." +); +SimpleTest.waitForExplicitFinish(); + +const workerWrapperFunc = async function (worker_path, data, transfer) { + const worker = new Worker(worker_path); + + const results = new Promise((resolve, reject) => { + worker.addEventListener("message", event => { + resolve(event.data); + }); + }); + + worker.postMessage(data, transfer); + for (const result of await results) { + ok(result.value, result.message); + } +}; + +async function runWorkerTest(worker_path, data, transfer) { + try { + await workerWrapperFunc(worker_path, data, transfer); + } catch (e) { + ok(false, "Unhandled exception " + e); + } + SimpleTest.finish(); +} -- cgit v1.2.3