0becd337673fc2c976f2adf5e4718df881ac8e05
[WebKit-https.git] / LayoutTests / webgpu / textures-textureviews.html
1 <!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
2 <meta charset=utf-8>
3 <title>Basic GPUTexture Tests.</title>
4 <body>
5 <canvas width="400" height="400"></canvas>
6 <script src="js/webgpu-functions.js"></script>
7 <script src="../resources/testharness.js"></script>
8 <script src="../resources/testharnessreport.js"></script>
9 <script>
10 const canvas = document.querySelector("canvas");    
11 let device, context;
12
13 let texSize = {
14     width: canvas.width,
15     height: canvas.height,
16     depth: 1
17 };
18
19 let texDescriptor = {
20     size: texSize,
21     format: "depth32float-stencil8",
22     usage: GPUTextureUsage.OUTPUT_ATTACHMENT
23 };
24
25 promise_test(async () => {
26     device = await getBasicDevice();
27     swapChain = createBasicSwapChain(canvas, device);
28
29     const texture = swapChain.getCurrentTexture();
30     assert_true(texture instanceof GPUTexture, "Successfully acquired next texture.");
31
32     const textureView = texture.createDefaultView();
33     assert_true(textureView instanceof GPUTextureView, "Successfully created texture view from next texture.");
34 }, "Create texture view from swap chain.");
35
36 promise_test(async () => {
37     const depthTexture = device.createTexture(texDescriptor);
38     assert_true(depthTexture instanceof GPUTexture, "Successfully created depth texture.");
39 }, "Create basic depth texture from device.");
40
41 promise_test(async () => {
42     texDescriptor.sampleCount = 4;
43     texDescriptor.format = "rgba8unorm";
44     texDescriptor.usage = GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_SRC
45
46     const multisampledTexture = device.createTexture(texDescriptor);
47     assert_true(multisampledTexture instanceof GPUTexture, "Successfully created multisampled texture.");
48 }, "Create basic 4x multisampled texture.");
49
50 promise_test(async () => {
51     texDescriptor.size.depth = 3;
52     texDescriptor.sampleCount = 1;
53     texDescriptor.dimension = "3d";
54
55     const texture3d = device.createTexture(texDescriptor);
56     assert_true(texture3d instanceof GPUTexture, "Successfully created basic 3D texture.");
57 }, "Create basic 3D texture from device.");
58
59 // FIXME: Add tests for 1D textures, textureArrays, and GPUTextureViews.
60 </script>
61 </body>
62 </html>