Skip to main content

GPUVectorFormat

From v9.4Experimental API

GPUVectorFormat is the canonical memory-layout string for GPUVector. GPUData also accepts an inline record of physical field formats and retains the resulting GPUDataStructFormat in its broader GPUDataFormat property.

It describes bytes in GPU memory, not the shader value written in WGSL or GLSL. Shader values are declared by ShaderLayout, for example vec4<f32>.

Types​

import type {VertexFormat} from '@luma.gl/core';

export type VertexList<Format extends VertexFormat = VertexFormat> =
`vertex-list<${Format}>`;

export type ValueList<Format extends VertexFormat = VertexFormat> =
`value-list<${Format}>`;

export type FixedSizeList<
Format extends VertexFormat = VertexFormat,
Size extends number = number
> = `fixed-size-list<${Format},${Size}>`;

export type GPUVectorFormat = VertexFormat | VertexList | ValueList | FixedSizeList;

export type GPUDataFormat = GPUVectorFormat | GPUDataStructFormat;

Fixed-width vectors reuse core VertexFormat strings:

'float32'
'float32x2'
'float32x3'
'float32x4'
'uint32'
'unorm8x4'

Variable-length vertex-aligned vectors wrap a fixed element format:

'vertex-list<float32x3>'
'vertex-list<unorm8x4>'

vertex-list<format> means each logical row owns a variable-length sequence of per-vertex element values. The format inside the angle brackets describes one flattened element. Offset buffers, row ranges, closed-path flags, text glyph maps, and similar topology metadata are adapter-owned.

Variable-length non-vertex values use value-list<format>. For example, value-list<uint8> stores flattened UTF-8 bytes with producer-owned row offsets.

Fixed-size storage values keep their logical row width in the format itself:

'fixed-size-list<float32,384>'
'fixed-size-list<float32,768>'
'fixed-size-list<float32,1536>'

fixed-size-list<float32,768> describes 768 stored Float32 values in each table row. It does not describe a vertex attribute, a WGSL vec768<f32>, or a new Arrow-owned GPU type. GPUData.length and GPUVector.length remain logical row counts; valueLength counts the flattened elements. The default row byteStride and rowByteLength are 768 * 4, while an explicit larger byteStride preserves physical row padding.

Generic list<format> remains intentionally reserved.

GPUDataStructFormat is an object rather than another format string because it contains named field formats, offsets, and row-stride metadata. It remains a physical memory description; shader value types stay separate. Struct formats currently apply to GPUData, while GPUVectorFormat remains the scalar or list format of one logical vector.

Helpers​

getGPUVectorFormatInfo(format): GPUVectorFormatInfo​

Decodes fixed scalar/vector, variable-list, or fixed-size-list storage formats.

const info = getGPUVectorFormatInfo('vertex-list<float32x3>');

info.elementFormat; // 'float32x3'
info.vertexList; // true
info.components; // 3
info.byteLength; // 12
info.primitiveType; // 'f32'

const embedding = getGPUVectorFormatInfo('fixed-size-list<float32,768>');

embedding.elementFormat; // 'float32'
embedding.fixedSizeList; // true
embedding.listSize; // 768
embedding.elementByteLength; // 4
embedding.byteLength; // 3072 bytes per logical row

getGPUVectorElementFormat(format): VertexFormat​

Returns the fixed element format. For scalar/vector formats this is the input; for variable and fixed-size lists it is the element format inside the brackets.

isVertexListGPUVectorFormat(format): boolean​

Returns true for vertex-list<...> formats.

isValueListGPUVectorFormat(format): boolean​

Returns true for variable-length non-vertex value-list<...> formats.

isFixedSizeListGPUVectorFormat(format): boolean​

Returns true for canonical fixed-size-list<format,size> formats. Sizes are positive integers; whitespace, leading zeros, missing sizes, and unsupported element formats are rejected.

isGPUVectorFormatCompatibleWithShaderType(format, shaderType): boolean​

Checks whether the memory format can feed one shader attribute type.

Examples:

GPU formatShader typeCompatibleReason
float32x3vec3<f32>yesSame component count and float primitive type.
unorm8x4vec4<f32>yesNormalized bytes become floats.
uint32x2vec2<u32>yesUnsigned integer primitive type matches.
sint32x2vec2<u32>noSignedness mismatch.
float32x3vec4<f32>noComponent count mismatch.
fixed-size-list<float32,768>vec4<f32>noFixed-size lists are storage columns, not vertex attributes.

Buffer Layouts​

Fixed formats can synthesize ordinary BufferLayout entries:

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

This yields a layout like:

[{name: 'positions', format: 'float32x3', byteStride: 12}]

If the source rows are padded, GPUVector.byteStride is preserved:

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

vertex-list<...>, value-list<...>, and fixed-size-list<...> vectors do not synthesize generic vertex-buffer layouts. Path, text, polygon, geometry, and embedding adapters must either expand compatible values into renderable fixed vectors or bind them explicitly through storage.

Arrow Mapping​

@luma.gl/arrow maps supported Arrow types into these formats:

Arrow typeGPUVector format
FixedSizeList<Float32, 3>float32x3
FixedSizeList<Uint8, 4> as normalized colorunorm8x4
FixedSizeList<Float32, 384> embeddingfixed-size-list<float32,384>
FixedSizeList<Float32, 768> embeddingfixed-size-list<float32,768>
FixedSizeList<Float32, 1536> embeddingfixed-size-list<float32,1536>
List<FixedSizeList<Float32, 3>> path coordinatesvertex-list<float32x3>
List<FixedSizeList<Uint8, 4>> vertex colorsvertex-list<unorm8x4>

Short fixed-size lists preserve their existing vertex-attribute mappings. Wide fixed-size lists become ordinary row-aligned storage columns without inventing unsupported formats such as float32x768.

Arrow data types remain adapter/readback metadata. Table core uses GPUVectorFormat.