Add a runtime-disabled dialog element skeleton
[WebKit-https.git] / LayoutTests / webgpu / propertyresolver / ander-lvalue.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../js/webgpu-functions.js"></script>
5 </head>
6 <body>
7 <canvas id="canvas" width="400" height="400"></canvas>
8 <script>
9 const shaderSource = `
10 vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position {
11     return position;
12 }
13
14 struct Foo {
15     float x;
16 }
17
18 thread float* operator&.y(thread Foo* f) {
19     return &f->x;
20 }
21
22 struct Bar {
23     Foo z;
24 }
25
26 thread Foo* operator&.w(thread Bar* b) {
27     return &b->z;
28 }
29
30 fragment float4 fragmentShader() : SV_Target 0 {
31     Bar b;
32     b.w.y = 1.0;
33     return float4(b.w.y, b.w.y, b.w.y, 1.0);
34 }
35 `;
36
37 const canvas = document.getElementById("canvas");
38
39 async function start(device) {
40     const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true});
41     const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
42     const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
43     const primitiveTopology = "triangle-strip";
44     const rasterizationState = {frontFace: "cw", cullMode: "none"};
45     const alphaBlend = {};
46     const colorBlend = {};
47     const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
48     const depthStencilState = null;
49     
50     const attribute0 = {shaderLocation: 0, format: "float4"};
51     const input0 = {stride: 16, attributeSet: [attribute0]};
52     const inputs = [input0];
53     const vertexInput = {vertexBuffers: inputs};
54
55     const pipelineLayoutDescriptor = {bindGroupLayouts: []};
56     const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
57
58     const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
59     const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
60
61     const vertexBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
62     const vertexBuffer = device.createBuffer(vertexBufferDescriptor);
63     const vertexBufferArrayBuffer = await vertexBuffer.mapWriteAsync();
64     const vertexBufferFloat32Array = new Float32Array(vertexBufferArrayBuffer);
65     vertexBufferFloat32Array[0] = -0.5;
66     vertexBufferFloat32Array[1] = -0.5;
67     vertexBufferFloat32Array[2] = 1.0;
68     vertexBufferFloat32Array[3] = 1;
69     vertexBufferFloat32Array[4] = -0.5;
70     vertexBufferFloat32Array[5] = 0.5;
71     vertexBufferFloat32Array[6] = 1.0;
72     vertexBufferFloat32Array[7] = 1;
73     vertexBufferFloat32Array[8] = 0.5;
74     vertexBufferFloat32Array[9] = -0.5;
75     vertexBufferFloat32Array[10] = 1.0;
76     vertexBufferFloat32Array[11] = 1;
77     vertexBufferFloat32Array[12] = 0.5;
78     vertexBufferFloat32Array[13] = 0.5;
79     vertexBufferFloat32Array[14] = 1.0;
80     vertexBufferFloat32Array[15] = 1;
81     vertexBuffer.unmap();
82
83     const context = canvas.getContext("gpu");
84     const swapChainDescriptor = {device, format: "bgra8unorm"};
85     const swapChain = context.configureSwapChain(swapChainDescriptor);
86     const outputTexture = swapChain.getCurrentTexture();
87     const outputTextureView = outputTexture.createDefaultView();
88
89     const commandEncoder = device.createCommandEncoder(); // {}
90     const red = {r: 0, g: 0, b: 1, a: 1};
91     const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor: red}];
92     const depthStencilAttachment = null;
93     const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
94     const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
95     renderPassEncoder.setPipeline(renderPipeline);
96     renderPassEncoder.setVertexBuffers(0, [vertexBuffer], [0]);
97     renderPassEncoder.draw(4, 1, 0, 0);
98     renderPassEncoder.endPass();
99     const commandBuffer = commandEncoder.finish();
100     device.getQueue().submit([commandBuffer]);
101 }
102 if (window.testRunner)
103     testRunner.waitUntilDone();
104 getBasicDevice().then(function(device) {
105     start(device).then(function() {
106         if (window.testRunner)
107             testRunner.notifyDone();
108     }, function() {
109         if (window.testRunner)
110             testRunner.notifyDone();
111     });
112 }, function() {
113     drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
114     if (window.testRunner)
115         testRunner.notifyDone();
116 });
117 </script>
118 </body>
119 </html>