Web Inspector: REGRESSION (r238602): Elements: deleting the last child of a collapsed...
[WebKit-https.git] / LayoutTests / webgpu / color-write-mask-triangle-strip.html
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>WebGPU Hello Triangles</title>
4 <meta name="assert" content="WebGPU correctly renders a green canvas.">
5 <link rel="match" href="color-write-mask-triangle-strip-expected.html">
6 <p>Pass if square canvas below is completely green.</p>
7 <canvas width="400" height="400"></canvas>
8 <script src="js/webgpu-functions.js"></script>
9 <script>
10 if (window.testRunner)
11     testRunner.waitUntilDone();
12
13 const shaderCode = `
14 #include <metal_stdlib>
15     
16 using namespace metal;
17
18 struct Vertex
19 {
20     float4 position [[position]];
21 };
22
23 vertex Vertex vertex_main(uint vid [[vertex_id]])
24 {
25     Vertex v;
26     switch (vid) {
27     case 0:
28         v.position = float4(-1, 1, 0, 1);
29         break;
30     case 1:
31         v.position = float4(-1, -1, 0, 1);
32         break;
33     case 2:
34         v.position = float4(1, 1, 0, 1);
35         break;
36     default:
37         v.position = float4(1, -1, 0, 1);
38     }
39     return v;
40 }
41
42 fragment float4 fragment_main()
43 {
44     return float4(1, 1, 1, 1);
45 }
46 `
47
48 async function test() {
49     const device = await getBasicDevice();
50     const canvas = document.querySelector("canvas");
51     const swapChain = createBasicSwapChain(canvas, device);
52     const shaderModule = device.createShaderModule({ code: shaderCode });
53     const colorStates = [{
54         format: "bgra8unorm",
55         alphaBlend: {
56             srcFactor: "one",
57             dstFactor: "zero",
58             operation: "add"
59         },
60         colorBlend: {
61             srcFactor: "one",
62             dstFactor: "zero",
63             operation: "add"
64         },
65         writeMask: GPUColorWriteBits.GREEN | GPUColorWriteBits.ALPHA
66     }];
67     const pipeline = createBasicPipeline(shaderModule, device, colorStates);
68     const commandEncoder = device.createCommandEncoder();
69     const colorAttachment = {
70         attachment: swapChain.getCurrentTexture().createDefaultView(),
71         loadOp: "clear",
72         storeOp: "store",
73         clearColor: { r: 0, g: 0, b: 0, a: 0 }
74     };
75     const passEncoder = commandEncoder.beginRenderPass({ colorAttachments: [colorAttachment] });
76     encodeBasicCommands(passEncoder, pipeline);
77     const queue = device.getQueue();
78
79     queue.submit([commandEncoder.finish()]);
80
81     requestAnimationFrame(() => { 
82         if (window.testRunner)
83             testRunner.notifyDone();
84     });
85 }
86
87 test();
88 </script>