---
title: "GPUBuffer | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

# Interface GPUBuffer

The **`GPUBuffer`** interface of the WebGPU API represents a block of memory that can be used to store raw data to use in GPU operations. Available only in secure contexts.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer)

interface GPUBuffer {  
    [label](#label): string;  
    [mapState](#mapstate): [GPUBufferMapState](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.GPUBufferMapState/);  
    [size](#size): number;  
    [usage](#usage): number;  
    [destroy](#destroy-1)(): void;  
    [getMappedRange](#getmappedrange-1)(offset?: number, size?: number): ArrayBuffer;  
    [mapAsync](#mapasync-1)(mode: number, offset?: number, size?: number): Promise<void\>;  
    [unmap](#unmap-1)(): void;  
}

#### Hierarchy ([View Summary](https://docs.maptiler.com/sdk-js/api-reference/hierarchy/#Externals.GPUBuffer))

-   [GPUObjectBase](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.GPUObjectBase/)
    -   GPUBuffer

##### Index

### Properties[](#properties)

[label](#label) [mapState](#mapstate) [size](#size) [usage](#usage)

### Methods[](#methods)

[destroy](#destroy) [getMappedRange](#getmappedrange) [mapAsync](#mapasync) [unmap](#unmap)

## Properties[](#properties-1)

### label[](#label)

label: string

[MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBindGroup/label)

Inherited from [GPUObjectBase](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.GPUObjectBase/).[label](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.GPUObjectBase/#label)

### `Readonly`mapState[](#mapstate)

mapState: [GPUBufferMapState](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.GPUBufferMapState/)

The **`mapState`** read-only property of the GPUBuffer interface represents the mapped state of the GPUBuffer.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/mapState)

### `Readonly`size[](#size)

size: number

The **`size`** read-only property of the GPUBuffer interface represents the length of the GPUBuffer's memory allocation, in bytes.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/size)

### `Readonly`usage[](#usage)

usage: number

The **`usage`** read-only property of the GPUBuffer interface contains the bitwise flags representing the allowed usages of the GPUBuffer.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/usage)

## Methods[](#methods-1)

### destroy[](#destroy)

-   destroy(): void[](#destroy-1)
    
    The **`destroy()`** method of the GPUBuffer interface destroys the GPUBuffer.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/destroy)
    
    #### Returns void
    

### getMappedRange[](#getmappedrange)

-   getMappedRange(offset?: number, size?: number): ArrayBuffer[](#getmappedrange-1)
    
    The **`getMappedRange()`** method of the GPUBuffer interface returns an ArrayBuffer containing the mapped contents of the GPUBuffer in the specified range.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/getMappedRange)
    
    #### Parameters
    
    -   `Optional`offset: number
    -   `Optional`size: number
    
    #### Returns ArrayBuffer
    

### mapAsync[](#mapasync)

-   mapAsync(mode: number, offset?: number, size?: number): Promise<void\>[](#mapasync-1)
    
    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.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/mapAsync)
    
    #### Parameters
    
    -   mode: number
    -   `Optional`offset: number
    -   `Optional`size: number
    
    #### Returns Promise<void\>
    

### unmap[](#unmap)

-   unmap(): void[](#unmap-1)
    
    The **`unmap()`** method of the GPUBuffer interface unmaps the mapped range of the GPUBuffer, making its contents available for use by the GPU again after it has previously been mapped with GPUBuffer.mapAsync() (the GPU cannot access a mapped GPUBuffer).
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBuffer/unmap)
    
    #### Returns void
