[WebGPU] Begin implementation of WebGPURenderPassEncoder and barebones WebGPURenderPa...
[WebKit-https.git] / LayoutTests / webgpu / render-passes.html
1 <!DOCTYPE html>
2 <html>
3 <script src="../resources/js-test-pre.js"></script>
4 <script src="js/basic-webgpu-functions.js"></script>
5 <script>
6 if (window.testRunner)
7     window.testRunner.dumpAsText();
8
9 let commandBuffer, texture, textureView, renderPassDescriptor, renderPassEncoder;
10
11 function setUpBasicRenderPassEncoder() {
12     commandBuffer = defaultDevice.createCommandBuffer();
13     texture = context.getNextTexture();
14     textureView = texture.createDefaultTextureView();
15
16     // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 
17     // Default a loadOp, storeOp, and clearColor in the implementation for now.
18     renderPassDescriptor = {
19         attachment : textureView
20     }
21
22     renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
23     if (renderPassEncoder)
24         testPassed("Successfully created basic WebGPURenderPassEncoder.");
25     else
26         testFailed("Could not create WebGPURenderPassEncoder!");
27 }
28
29 function checkBadRenderPassDescriptor(descriptor, testSubjectName) {
30     renderPassEncoder = commandBuffer.beginRenderPass(descriptor);
31
32     if (renderPassEncoder)
33         testFailed(`WebGPURenderPassEncoder was created with an invalid ${testSubjectName}!`);
34     else 
35         testPassed(`WebGPURenderPassEncoder with invalid ${testSubjectName} was not created.`);
36 }
37
38 function noAttachmentDescriptors() {
39     checkBadRenderPassDescriptor(null, "WebGPURenderPassDescriptor");
40     checkBadRenderPassDescriptor({}, "WebGPURenderPassDescriptor");
41 }
42
43 runWebGPUTests([setUpBasicRenderPassEncoder, noAttachmentDescriptors]);
44
45 successfullyParsed = true;
46 </script>
47 <script src="../resources/js-test-post.js"></script>
48 </html>