GPGPU programming
GPU data processing in luma.gl ranges from portable lazy vector operations to explicitly scheduled WebGPU command graphs. Start with the highest-level API that expresses the workflow cleanly.
Outcome and prerequisites​
This guide helps you choose between the stable @luma.gl/graph/gpu-simple-graph evaluators, its experimental
subpaths, Engine compute helpers, and experimental GPU tables. It assumes familiarity with
buffers and typed arrays; the
Core GPU guide introduces those concepts.
Mental model​
| Need | Start with |
|---|---|
| Portable lazy vector expressions on CPU, WebGL 2, or WebGPU | GPU Evaluations with GPUVectorEvaluator |
| Primitive GPU chunks, vectors, and memory formats | @luma.gl/graph/gpu-data |
| Batch-preserving GPU tables and schemas | @luma.gl/graph/gpu-tables |
| One explicit buffer or texture computation | Engine compute helpers |
| Several dependent WebGPU operations, indirect work, or transient reuse | GPU Core |
For a reusable graph with named runtime inputs, begin with
Getting started with graphs. GPUGraph executes
on WebGPU; GPUSimpleGraph shares its expression subset on WebGL and WebGPU. The evaluator
workflow below is a separate lazy API with evaluator-owned outputs.
Complete workflow​
import {GPUDataEvaluator, add, cleanEvaluate} from '@luma.gl/graph/gpu-simple-graph';
const values = GPUDataEvaluator.fromArray(new Float32Array([1, 2, 3]), {size: 1});
const adjusted = add(values, GPUDataEvaluator.fromConstant(0.5));
const result = await cleanEvaluate(device, adjusted);
Operations stay lazy until evaluation. cleanEvaluate() retains the requested output and releases
intermediate evaluator results.
Decisions and tradeoffs​
- Prefer GPGPU evaluators when portability and expression composition matter most.
- Prefer
@luma.gl/graph/gpu-corewhen WebGPU-only scheduling, GPU-written work counts, or multi-pass resource planning matter more than backend portability. - Preserve source chunks in GPU vectors and tables instead of silently repacking streaming data.
- Avoid readback between operations unless the CPU actually needs the result.
Common mistakes​
- Evaluating every intermediate expression separately instead of evaluating the final expression.
- Treating GPU memory layout and shader value types as the same contract.
- Choosing a command graph for a single simple operation that has no scheduling problem to solve.