Skip to main content

GPUVector

From: v10Status: Work-In-Progress

GPUVector represents one logical typed table column over one or more GPUData chunks. It does not own a buffer directly; every concrete buffer lives on a GPUData object in GPUVector.data[].

Usage

import {GPUVector} from '@luma.gl/tables';

const gpuVector = new GPUVector({
type: 'buffer',
name: 'positions',
buffer,
format: 'float32x3',
length,
byteStride: 12
});

gpuVector.data[0].buffer; // the bindable storage

When the input starts as Apache Arrow, prefer makeGPUVectorFromArrow() from @luma.gl/arrow.

Constructor Modes

GPUVector uses a discriminated constructor prop union.

ModeKey propsUse when
{type: 'buffer'}name, buffer, format, lengthWrap one existing typed GPU buffer as one GPUData chunk.
{type: 'interleaved'}name, buffer, byteStride, attributesWrap one existing interleaved row buffer as one GPUData chunk plus a BufferLayout.
{type: 'data'}name, format, data[]Expose existing GPUData chunks as one logical column.
{type: 'appendable'}name, device, format, byteStrideCreate an initially empty logical vector that adapter code can append to with new GPUData chunks.

Properties

PropertyTypeMeaning
namestringStable vector/table column name.
formatGPUVectorFormat | undefinedCanonical memory-layout descriptor for uploaded bytes.
typeunknownDeprecated adapter-owned logical metadata.
dataTypeunknownDeprecated adapter-owned logical metadata.
lengthnumberAggregate logical row count.
valueLengthnumberAggregate fixed-row or flattened vertex-list element count.
stridenumberNumber of scalar values represented by one fixed row or flattened element.
byteOffsetnumberCompatibility metadata for the first row when this vector has one chunk.
byteStridenumberBytes between adjacent fixed rows or flattened elements.
rowByteLengthnumberBytes occupied by one fixed row or flattened element payload.
bufferLayoutBufferLayout | undefinedInterleaved buffer layout, when this vector describes multiple attribute views.
dataGPUData[]Ordered chunks that define the logical column. Each chunk has its own buffer.
ownsBufferbooleanWhether destroying this vector releases retained GPU storage.
capacityRowsnumber | undefinedCurrent logical rows for appendable vectors.
appendedByteLengthnumberAdapter-reported bytes occupied by appended chunks.

Methods

addData(data): this

Adds an existing GPUData chunk to this logical vector. The chunk must have the same format, byteStride, and rowByteLength.

appendDataChunk(data, appendedByteLength): this

Adds one adapter-created GPUData chunk to an appendable logical vector.

resetLastBatch(): this

Clears appendable logical rows and destroys appended GPUData buffers.

transferBufferOwnership(target): void

Transfers same-buffer ownership between two single-chunk vector views. This is a migration helper for adapters that create short-lived views.

destroy(): void

Destroys owned GPUData chunks and retained detached vectors. Borrowed storage is left alive.

Notes

Use data[] for binding, copying, batching, and ownership. A single-buffer consumer should explicitly require vector.data.length === 1 and then bind vector.data[0].buffer.

For vertex-list<...> vectors, length remains the source row count and valueLength is the flattened element count. byteStride and rowByteLength describe one flattened element, not one source row. Offsets and other variable-length metadata are adapter-owned.