Skip to main content

BufferTransform

BufferTransform is the engine wrapper for WebGL transform-feedback workflows. It internally builds a GPUVectorModel plus a TransformFeedback object and uses them to run buffer-to-buffer transforms.

BufferTransform is only supported on WebGL devices.

Usage​

import {BufferTransform} from '@luma.gl/engine/api';

const transform = new BufferTransform(device, {
vs: VERTEX_SHADER,
outputs: ['outValue'],
attributes: {
inValue: sourceBuffer
}
});

transform.run({
outputBuffers: {
outValue: targetBuffer
}
});

GPU vector inputs and outputs​

inputVectors and outputVectors can be supplied at construction or to run(). Inputs map to buffer-layout names; outputs map to shader varying names:

const transform = new BufferTransform(device, {
vs: VERTEX_SHADER,
bufferLayout: [{name: 'inValue', format: 'float32'}],
outputs: ['outValue'],
inputVectors: {inValue: sourceVector},
outputVectors: {outValue: targetVector}
});
transform.run();

The transform borrows the vectors, preserves chunk byte offsets, and infers vertex count from input row count. Direct vector bindings require at most one chunk per vector; no packing occurs. Output vectors must match the shader outputs and use separate, tightly packed transform-feedback streams. For multi-chunk table workloads, use TableTransform.dispatchBatches(). Buffer-valued options are also supported. Vector bindings take precedence when both forms are supplied for the same input or output.

Types​

BufferTransformProps​

export type BufferTransformProps = Omit<GPUVectorModelProps, 'fs'> & {
fs?: GPUVectorModelProps['fs'];
inputVectors?: GPUVectorModelInputs;
outputVectors?: GPUVectorModelInputs;
outputs?: string[];
feedbackBuffers?: Record<string, Buffer | BufferRange>;
};

feedbackBuffers is deprecated in favor of run({outputBuffers}).

Properties​

device​

Owning device.

model​

Internal model used to run the transform-feedback draw.

transformFeedback​

Internal transform-feedback object.

Methods​

BufferTransform.isSupported(device: Device): boolean​

Returns true when the device is WebGL-backed.

constructor(device: Device, props?: BufferTransformProps)​

Creates the internal model and transform-feedback objects. Throws on unsupported devices.

destroy(): void​

Destroys the internal model.

delete(): void​

Deprecated alias for destroy().

run(options?): void​

Runs one transform-feedback pass.

run(options?: RenderPassProps & {
inputBuffers?: Record<string, Buffer>;
outputBuffers?: Record<string, Buffer>;
}): void

getBuffer(varyingName: string): Buffer | BufferRange | null​

Deprecated accessor for one named transform-feedback output.

readAsync(varyingName: string): Promise<Uint8Array>​

Deprecated helper for reading back one named output.

Remarks​

  • BufferTransform defaults the fragment shader to a passthrough implementation because transform feedback typically only needs vertex output.
  • Prefer run({inputBuffers, outputBuffers}) for explicit buffer management.