| <!DOCTYPE html> |
| <html> |
| |
| <head> |
| <title> |
| Time mapAsync WRITE after a submit using the buffer |
| </title> |
| <script src="../resources/runner.js"></script> |
| <script src="./resources/webgpu-perf-utils.js"></script> |
| </head> |
| |
| <body> |
| <script> |
| (async () => { |
| const adapter = navigator.gpu && await navigator.gpu.requestAdapter(); |
| if (!adapter) { |
| return skipTest('WebGPU not supported'); |
| } |
| |
| const device = await adapter.requestDevice(); |
| const mappableBuffer = device.createBuffer({ |
| size: 4, |
| usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, |
| }); |
| const otherBuffer = device.createBuffer({ |
| size: 4, |
| usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC, |
| }); |
| |
| // Wait to make sure the device is fully ready |
| await device.queue.onSubmittedWorkDone(); |
| |
| PerfTestRunner.startMeasureValuesAsync({ |
| unit: 'ms', |
| warmUpCount: 1, |
| iterationCount: 15, |
| ...loopTestForTime(250, async () => { |
| // Enqueue some work that mapAsync must wait for |
| const enc = device.createCommandEncoder(); |
| enc.copyBufferToBuffer(mappableBuffer, 0, otherBuffer, 0, 4); |
| device.queue.submit([enc.finish()]); |
| // Map the buffer |
| await mappableBuffer.mapAsync(GPUMapMode.WRITE); |
| mappableBuffer.getMappedRange(); |
| mappableBuffer.unmap(); |
| }), |
| }); |
| })(); |
| </script> |
| </body> |
| |
| </html> |