Web Inspector: REGRESSION (r238602): Elements: deleting the last child of a collapsed...
[WebKit-https.git] / LayoutTests / webgpu / vertex-buffer-triangle-strip.html
index 667a0a5..5c4d0eb 100644 (file)
@@ -7,6 +7,9 @@
 <canvas width="400" height="400"></canvas>
 <script src="js/webgpu-functions.js"></script>
 <script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
 const shaderCode = `
 #include <metal_stdlib>
     
@@ -40,43 +43,41 @@ fragment float4 fragment_main(VertexOut v [[stage_in]])
 
 function createVertexBuffer(device) {
     const bufferSize = 4 * 5 * 4;
-    const buffer = device.createBuffer({ size: bufferSize, usage: WebGPUBufferUsage.MAP_WRITE });
-    
-    let floatArray = new Float32Array(buffer.mapping);
-
-    const vertices = [
+    const buffer = device.createBuffer({ size: bufferSize, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.TRANSFER_DST });
+    const vertexArrayBuffer0 = new Float32Array([
         // float4 xyzw, float g
         -1, 1, 0, 1, 1,
-        -1, -1, 0, 1, 1,
+        -1, -1, 0, 1, 1
+    ]).buffer;
+    const vertexArrayBuffer1 = new Float32Array([
         1, 1, 0, 1, 1,
         1, -1, 0, 1, 1
-    ];
+    ]).buffer;
 
-    for (let i = 0; i < vertices.length; ++i) {
-        floatArray[i] = vertices[i];
-    }
+    buffer.setSubData(0, vertexArrayBuffer0);
+    buffer.setSubData(4 * 5 * 2, vertexArrayBuffer1);
 
     return buffer;
 }
 
 function createInputStateDescriptor() {
     return {
-        indexFormat: WebGPUIndexFormat.UINT32,
+        indexFormat: "uint32",
         attributes: [{
             shaderLocation: 0,
             inputSlot: 0,
             offset: 0,
-            format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32
+            format: "float4"
         }, {
             shaderLocation: 1,
             inputSlot: 0,
             offset: 4 * 4,
-            format: WebGPUVertexFormat.FLOAT_R32
+            format: "float"
         }],
         inputs: [{
             inputSlot: 0,
             stride: 4 * 5,
-            stepMode: WebGPUInputStepMode.VERTEX
+            stepMode: "vertex"
         }]
     }
 }
@@ -84,19 +85,21 @@ function createInputStateDescriptor() {
 async function test() {
     const device = await getBasicDevice();
     const canvas = document.querySelector("canvas");
-    const context = createBasicContext(canvas, device);
+    const swapChain = createBasicSwapChain(canvas, device);
     // FIXME: Replace with non-MSL shaders.
     const shaderModule = device.createShaderModule({ code: shaderCode });
     const vertexBuffer = createVertexBuffer(device);
     const inputStateDescriptor = createInputStateDescriptor();
-    const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor);
-    const commandBuffer = device.createCommandBuffer();
-    const passEncoder = beginBasicRenderPass(context, commandBuffer);
-    const endCommandBuffer = encodeBasicCommands(passEncoder, pipeline, vertexBuffer);
+    const pipeline = createBasicPipeline(shaderModule, device, null, null, inputStateDescriptor);
+    const commandEncoder = device.createCommandEncoder();
+    const passEncoder = beginBasicRenderPass(swapChain, commandEncoder);
+    encodeBasicCommands(passEncoder, pipeline, vertexBuffer);
     const queue = device.getQueue();
+    queue.submit([commandEncoder.finish()]);
+    vertexBuffer.destroy();
 
-    queue.submit([endCommandBuffer]);
-    context.present();
+    if (window.testRunner)
+        testRunner.notifyDone();
 }
 
 test();