mapAsync method

JSPromise<JSAny?> mapAsync(
  1. GPUMapModeFlags mode, [
  2. GPUSize64 offset,
  3. GPUSize64 size
])

The mapAsync() method of the GPUBuffer interface maps the specified range of the GPUBuffer. It returns a Promise that resolves when the GPUBuffer's content is ready to be accessed. While the GPUBuffer is mapped it cannot be used in any GPU commands.

Once the buffer is successfully mapped (which can be checked via GPUBuffer.mapState), calls to GPUBuffer.getMappedRange will return an ArrayBuffer containing the GPUBuffer's current values, to be read and updated by JavaScript as required.

When you have finished working with the GPUBuffer values, call GPUBuffer.unmap to unmap it, making it accessible to the GPU again.

Implementation

external JSPromise<JSAny?> mapAsync(
  GPUMapModeFlags mode, [
  GPUSize64 offset,
  GPUSize64 size,
]);