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