Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / webgpu / mochitest / test_submit_render_empty.worker.js
blob334230c3c1296bc065b7ad880fa4bcb7eac5d32d
1 self.addEventListener("message", async function (event) {
2   try {
3     const adapter = await navigator.gpu.requestAdapter();
4     const device = await adapter.requestDevice();
6     const swapChainFormat = "rgba8unorm";
7     const bundleEncoder = device.createRenderBundleEncoder({
8       colorFormats: [swapChainFormat],
9     });
10     const bundle = bundleEncoder.finish({});
12     const texture = device.createTexture({
13       size: { width: 100, height: 100, depth: 1 },
14       format: swapChainFormat,
15       usage: GPUTextureUsage.RENDER_ATTACHMENT,
16     });
17     const view = texture.createView();
19     const encoder = device.createCommandEncoder();
20     const pass = encoder.beginRenderPass({
21       colorAttachments: [
22         {
23           view,
24           clearValue: { r: 0, g: 0, b: 0, a: 0 },
25           loadOp: "clear",
26           storeOp: "store",
27         },
28       ],
29     });
30     pass.executeBundles([bundle]);
31     pass.end();
32     const command_buffer = encoder.finish();
34     device.queue.submit([command_buffer]);
35     self.postMessage([
36       {
37         value: command_buffer !== undefined,
38         message: "command_buffer !== undefined",
39       },
40     ]);
41   } catch (e) {
42     self.postMessage([
43       {
44         value: false,
45         message: "Unhandled exception " + e,
46       },
47     ]);
48   }
49 });