1 self.addEventListener("message", async function (event) {
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],
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,
17 const view = texture.createView();
19 const encoder = device.createCommandEncoder();
20 const pass = encoder.beginRenderPass({
24 clearValue: { r: 0, g: 0, b: 0, a: 0 },
30 pass.executeBundles([bundle]);
32 const command_buffer = encoder.finish();
34 device.queue.submit([command_buffer]);
37 value: command_buffer !== undefined,
38 message: "command_buffer !== undefined",
45 message: "Unhandled exception " + e,