Skip to main content

Abstract Class: Buffer

Defined in: modules/core/src/adapter/resources/buffer.ts:29

Abstract GPU buffer

Extends​

Constructors​

Constructor​

new Buffer(device, props): Buffer

Defined in: modules/core/src/adapter/resources/buffer.ts:60

Parameters​

device​

Device

props​

BufferProps

Returns​

Buffer

Overrides​

Resource.constructor

Properties​

byteLength​

abstract byteLength: number

Defined in: modules/core/src/adapter/resources/buffer.ts:56

Length of buffer in bytes


debugData​

debugData: ArrayBuffer

Defined in: modules/core/src/adapter/resources/buffer.ts:125

A partial CPU-side copy of the data in this buffer, for debugging purposes


destroyed​

destroyed: boolean = false

Defined in: modules/core/src/adapter/resources/resource.ts:131

Whether this resource has been destroyed

Inherited from​

Resource.destroyed


device​

abstract readonly device: Device

Defined in: modules/core/src/adapter/resources/resource.ts:124

The device that this resource is associated with

Inherited from​

Resource.device


handle​

abstract readonly handle: unknown

Defined in: modules/core/src/adapter/resources/resource.ts:126

The handle for the underlying resource, e.g. WebGL object or WebGPU handle

Inherited from​

Resource.handle


id​

id: string

Defined in: modules/core/src/adapter/resources/resource.ts:118

props.id, for debugging.

Inherited from​

Resource.id


indexType?​

readonly optional indexType?: "uint8" | "uint16" | "uint32"

Defined in: modules/core/src/adapter/resources/buffer.ts:54

For index buffers, whether indices are 8, 16 or 32 bit. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility


props​

readonly props: Required<Props>

Defined in: modules/core/src/adapter/resources/resource.ts:120

The props that this resource was created with

Inherited from​

Resource.props


updateTimestamp​

updateTimestamp: number

Defined in: modules/core/src/adapter/resources/buffer.ts:58

"Time" of last update, can be used to check if redraw is needed


usage​

readonly usage: number

Defined in: modules/core/src/adapter/resources/buffer.ts:52

The usage with which this buffer was created


userData​

readonly userData: Record<string, unknown> = {}

Defined in: modules/core/src/adapter/resources/resource.ts:122

User data object, reserved for the application

Inherited from​

Resource.userData


COPY_DST​

static COPY_DST: number = 0x0008

Defined in: modules/core/src/adapter/resources/buffer.ts:45


COPY_SRC​

static COPY_SRC: number = 0x0004

Defined in: modules/core/src/adapter/resources/buffer.ts:44


DEBUG_DATA_MAX_LENGTH​

static DEBUG_DATA_MAX_LENGTH: number = 32

Defined in: modules/core/src/adapter/resources/buffer.ts:122

Max amount of debug data saved. Two vec4's


defaultProps​

static defaultProps: Required<BufferProps>

Defined in: modules/core/src/adapter/resources/buffer.ts:159

Default properties for resource

Overrides​

Resource.defaultProps


INDEX​

static INDEX: number = 0x0010

Defined in: modules/core/src/adapter/resources/buffer.ts:31

Index buffer


INDIRECT​

static INDIRECT: number = 0x0100

Defined in: modules/core/src/adapter/resources/buffer.ts:38


MAP_READ​

static MAP_READ: number = 0x01

Defined in: modules/core/src/adapter/resources/buffer.ts:42


MAP_WRITE​

static MAP_WRITE: number = 0x02

Defined in: modules/core/src/adapter/resources/buffer.ts:43


QUERY_RESOLVE​

static QUERY_RESOLVE: number = 0x0200

Defined in: modules/core/src/adapter/resources/buffer.ts:39


STORAGE​

static STORAGE: number = 0x0080

Defined in: modules/core/src/adapter/resources/buffer.ts:37

Storage buffer


UNIFORM​

static UNIFORM: number = 0x0040

Defined in: modules/core/src/adapter/resources/buffer.ts:35

Uniform buffer


VERTEX​

static VERTEX: number = 0x0020

Defined in: modules/core/src/adapter/resources/buffer.ts:33

Vertex buffer

Accessors​

[toStringTag]​

Get Signature​

get [toStringTag](): string

Defined in: modules/core/src/adapter/resources/buffer.ts:47

Returns​

string

Overrides​

Resource.[toStringTag]


isHandleBorrowed​

Get Signature​

get isHandleBorrowed(): boolean

Defined in: modules/core/src/adapter/resources/resource.ts:147

Whether luma.gl may only reference the opaque externally owned resource handle.

Returns​

boolean

Inherited from​

Resource.isHandleBorrowed


ownsHandle​

Get Signature​

get ownsHandle(): boolean

Defined in: modules/core/src/adapter/resources/resource.ts:140

Whether luma.gl created and owns the underlying resource handle.

Returns​

boolean

Inherited from​

Resource.ownsHandle

Methods​

attachResource()​

attachResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:200

Attaches a resource. Attached resources are auto destroyed when this resource is destroyed Called automatically when sub resources are auto created but can be called by application

Parameters​

resource​

Resource<ResourceProps>

Returns​

void

Inherited from​

Resource.attachResource


clone()​

clone(props): Buffer

Defined in: modules/core/src/adapter/resources/buffer.ts:90

Create a copy of this Buffer with new byteLength, with same props but of the specified size.

Parameters​

props​
byteLength​

number

Returns​

Buffer

Note​

Does not copy contents of the cloned Buffer.


delete()​

delete(): this

Defined in: modules/core/src/adapter/resources/resource.ts:181

Returns​

this

Deprecated​

Use destroy()

Inherited from​

Resource.delete


destroy()​

destroy(): void

Defined in: modules/core/src/adapter/resources/resource.ts:173

destroy can be called on any resource to release it before it is garbage collected.

Returns​

void

Inherited from​

Resource.destroy


destroyAttachedResource()​

destroyAttachedResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:214

Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.

Parameters​

resource​

Resource<ResourceProps>

Returns​

void

Inherited from​

Resource.destroyAttachedResource


destroyAttachedResources()​

destroyAttachedResources(): void

Defined in: modules/core/src/adapter/resources/resource.ts:221

Destroy all owned resources. Make sure the resources are no longer needed before calling.

Returns​

void

Inherited from​

Resource.destroyAttachedResources


detachResource()​

detachResource(resource): void

Defined in: modules/core/src/adapter/resources/resource.ts:207

Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.

Parameters​

resource​

Resource<ResourceProps>

Returns​

void

Inherited from​

Resource.detachResource


getProps()​

getProps(): object

Defined in: modules/core/src/adapter/resources/resource.ts:190

Combines a map of user props and default props, only including props from defaultProps

Returns​

object

returns a map of overridden default props

Inherited from​

Resource.getProps


mapAndReadAsync()​

abstract mapAndReadAsync<T>(onMapped, byteOffset?, byteLength?): Promise<T>

Defined in: modules/core/src/adapter/resources/buffer.ts:110

Maps buffer data to CPU memory. Mapped memory is only accessible in the callback

Type Parameters​

T​

T

Parameters​

onMapped​

BufferMapCallback<T>

byteOffset?​

number

byteLength?​

number

Returns​

Promise<T>


mapAndWriteAsync()​

abstract mapAndWriteAsync(onMapped, byteOffset?, byteLength?): Promise<void>

Defined in: modules/core/src/adapter/resources/buffer.ts:100

Parameters​

onMapped​

BufferMapCallback<void | Promise<void>>

byteOffset?​

number

byteLength?​

number

Returns​

Promise<void>


readAsync()​

abstract readAsync(byteOffset?, byteLength?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: modules/core/src/adapter/resources/buffer.ts:107

Reads data asynchronously, returns a copy of the buffer data

Parameters​

byteOffset?​

number

byteLength?​

number

Returns​

Promise<Uint8Array<ArrayBufferLike>>


readSyncWebGL()​

abstract readSyncWebGL(byteOffset?, byteLength?): Uint8Array

Defined in: modules/core/src/adapter/resources/buffer.ts:117

Read data synchronously.

Parameters​

byteOffset?​

number

byteLength?​

number

Returns​

Uint8Array

Note​

WebGL2 only


toJSON()​

toJSON(): string

Defined in: modules/core/src/adapter/resources/resource.ts:113

Compact serialization for assertion diffs and structured debug logs.

Returns​

string

Inherited from​

Resource.toJSON


toString()​

toString(): string

Defined in: modules/core/src/adapter/resources/resource.ts:108

Returns​

string

Inherited from​

Resource.toString


write()​

abstract write(data, byteOffset?): void

Defined in: modules/core/src/adapter/resources/buffer.ts:95

Write data to buffer

Parameters​

data​

ArrayBufferLike | ArrayBufferView<ArrayBufferLike>

byteOffset?​

number

Returns​

void