REGRESSION: ( r246394 ) webgpu/whlsl-buffer-fragment.html and webgpu/whlsl-buffer...
[WebKit-https.git] / LayoutTests / webgpu / render-command-encoding.html
1 <!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
2 <meta charset=utf-8>
3 <title>Get the GPUDevice and ask for the GPUQueue</title>
4 <body>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="js/webgpu-functions.js"></script>
8 <script>
9 const shaders = `
10 #include <metal_stdlib>
11     
12 using namespace metal;
13
14 struct Vertex
15 {
16     float4 position [[position]];
17 };
18
19 vertex Vertex vertex_main()
20 {
21     return Vertex { float4(0, 0, 0, 1) };
22 }
23
24 fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
25 {
26     return vertexIn.position;
27 }
28 `
29
30 promise_test(() => {
31     return getBasicDevice().then(function(device) {
32         const canvas = document.createElement("canvas");
33         const swapChain = createBasicSwapChain(canvas, device);
34         const shaderModule = device.createShaderModule({ code: shaders });
35         const pipeline = createBasicPipeline(shaderModule, device);
36
37         const commandEncoder = device.createCommandEncoder();
38         assert_true(commandEncoder instanceof GPUCommandEncoder, "createCommandEncoder returned a GPUCommandEncoder");
39
40         const encoder = beginBasicRenderPass(swapChain, commandEncoder);
41         assert_true(encoder instanceof GPURenderPassEncoder, "beginRenderPass() returned a GPURenderPassEncoder");
42
43         encoder.setPipeline(pipeline);
44         encoder.endPass();
45     }, function() {
46     });
47 }, "GPURenderPassEncoder created and successfully ended");
48
49 </script>
50 </body>