Introducing a new way to review your PRs.

Read the announcement

visgl / luma.gl

High-performance Toolkit for WebGL-based Data Visualization

View on GitHub

30 documents · Updated Nov 20, 2026

docs / gpu-data-tables

GPU data tables

GPU data tables provide a row-aligned data layer for graph work, GPU computation, transforms, rendering, and Arrow exchange. The graph package keeps column meaning, batch identity, and GPU ownership together. The engine package maps that shared view to render and transform resources.

System role

Table purpose

The GPU table system represents application rows as typed columns that stay aligned while work moves across GPU stages. It is a GPU data view rather than a CPU data-frame API. Its main result is reusable data for later compute, transform, analysis, or render work.

Tables can carry varying columns, fixed values, and preserved record batches. They can also retain source schema details and row identity from an input adapter. A stream can therefore keep its source batch boundaries while a consumer processes batches separately or combines compatible batches.

References: modules/…/gpu-table.ts• L25-46 modules/…/gpu-table.ts• L98-120 modules/…/gpu-record-batch.ts• L16-29

Package boundary

The graph package defines the logical table contract, input schema, shader bindings, compute helper, buffer plan, and Arrow adapters. The engine package consumes that contract through render models, geometry views, and transforms. This boundary keeps data meaning separate from the operation that uses it.

The table is normally caller-owned. An engine view may prepare resources over it, but the application controls when the table and its GPU data can be released.

References: modules/…/index.ts• L13-77 modules/…/gpu-table-model.ts• L76-82 modules/…/gpu-table-geometry.ts• L24-29

Table lifecycle

Table construction

The lifecycle starts with CPU or GPU columns, record batches, or Arrow data that share a row shape. GPUTable validates the inputs, retains their batch structure, and exposes the columns and layout needed by downstream consumers. Arrow preparation can first choose a target format and a CPU or GPU conversion path.

The main stages are:

  1. Create or receive CPU or GPU columns.
  2. Validate row counts, formats, and layouts.
  3. Retain record batches and table-level constants.
  4. Prepare a consumer-specific input contract.
  5. Dispatch or draw each batch, or pack compatible batches.
  6. Release consumer resources and then the table after submitted work completes.

This diagram shows how source data becomes a table and then feeds compute, engine views, or derived GPU columns.

flowchart LR
  A[CPU or GPU columns, batches, or Arrow data] --> B[Validated GPU table]
  B --> C[Input schema and resource mapping]
  C --> D[GPU computation]
  C --> E[Engine render model]
  C --> F[Transform or geometry view]
  D --> G[Derived GPU columns]
  E --> H[Rendered rows]
  F --> I[GPU buffers or updated columns]

References: modules/…/gpu-table.ts• L120-210 modules/…/gpu-table.ts• L212-279 modules/…/gpu-record-batch.ts• L52-97

Vector transfer

Vector transfer moves columns between CPU memory and GPU memory without changing their row meaning. Upload creates owned GPU chunks while preserving lengths, offsets, and validity data. Asynchronous readback rebuilds the CPU vector with the same physical shape and nested-value metadata.

The caller releases the resulting GPU vector only after submitted work no longer uses its buffers.

References: modules/…/cpu-gpu-vector-transfer.ts• L13-80 modules/…/cpu-gpu-vector-transfer.ts• L83-110

Arrow table exchange

Arrow adapters connect columnar Arrow data to the GPU table model. They select source fields, prepare GPU-compatible formats, preserve record-batch boundaries, and retain source-row offsets. The same boundary supports whole-table preparation and incremental batch streams.

This exchange keeps source schema metadata and temporal origins with the prepared data. The caller releases each prepared table or streamed batch when its GPU work ends. The broader data interchange formats page covers the data boundary beyond GPU tables.

References: modules/…/arrow-gpu-table-conversion.ts• L21-74 modules/…/arrow-gpu-table-conversion.ts• L76-177 modules/…/arrow-gpu-table-conversion.ts• L180-245 modules/…/arrow-gpu-table-adapters.ts• L230-269

Batch alignment

Each GPURecordBatch is a physical row range. Every varying column in a batch must have the same row count. Batches in one table must use compatible fields and buffer layouts. A batch can also retain its source index and global source-row offset.

Packing is an explicit choice. It creates new buffers for compatible adjacent batches, but it does not support indexed tables, variable-length data, or metadata that cannot be preserved. Consumers that need source batch identity should keep the original batches.

References: modules/…/gpu-record-batch.ts• L100-139 modules/…/gpu-table.ts• L281-310 modules/…/gpu-table.ts• L487-618

Constant columns

A constant column stores one physical value for all logical rows. The table keeps it separate from varying GPU data, then maps it to the backend resource required by the consumer. This saves storage while preserving the difference between row data and table-wide data.

An all-constant table therefore needs an explicit row count. A consumer must also state whether a constant is valid for the input it declares.

References: modules/…/gpu-table.ts• L25-46 modules/…/gpu-table.ts• L167-209 modules/…/gpu-table.ts• L823-843

Tabular computation

WebGPU computation

GPUTableComputation exposes table columns as storage inputs to a WebGPU kernel. A single-chunk vector binds once. A multi-chunk table runs one dispatch per aligned batch and changes the bound ranges for each dispatch. Arrow compute kernels use the same compute boundary without depending on render state.

All batched inputs must have the same batch count and matching rows within each batch. Empty batches are skipped because WebGPU does not accept zero-size storage bindings.

References: modules/…/gpu-table-computation.ts• L15-35 modules/…/gpu-table-computation.ts• L57-107 modules/…/gpu-table-computation.ts• L116-157 modules/…/arrow-compute-kernel.ts• L12-30

Data-frame expressions

GPU data-frame expressions describe typed column work before a query runs. They form immutable, renderer-independent trees that can refer to columns, literals, parameters, vectors, casts, arithmetic, comparison, and boolean operations. The query layer can collect exact source-column names for schema checks without placing application names in generated shader code.

Portable expressions provide a bridge from the shared math.gl expression form to this GPU data-frame form. The bridge validates the portable tree first, then accepts only supported finite literals, unary and binary operators, fixed-width float vectors, and casts to float32 or int32. Unsupported operations fail at the boundary.

References: modules/…/gpu-expression.ts• L35-75 modules/…/gpu-expression.ts• L192-218 modules/…/portable-expression.ts• L16-46 modules/…/portable-expression.ts• L66-117

Arrow readback

Arrow readback materializes GPU analytics results only when a caller requests it. Normal readback keeps the input batch topology, validity masks, dictionary labels, and empty batches. Local row identities keep results in their source batches. Global identities create one intentionally reordered result batch.

This boundary makes row order an explicit contract. The caller must choose one selection mode and provide the metadata needed to rebuild nullable or dictionary-encoded columns.

References: modules/…/arrow-gpu-analytics-readback.ts• L26-80 modules/…/arrow-gpu-analytics-readback.ts• L82-160 modules/…/arrow-gpu-analytics-readback.ts• L185-237

WebGL transforms

TableTransform applies WebGL transform feedback to table attributes. It can use an existing table or build one from vectors. It runs once per preserved batch and restores the table-level view after each run.

The transform can allocate dense output vectors and copy selected outputs into named input vectors. That writeback path is limited to one directly bindable batch and is intended for tightly packed values with clear ownership.

References: modules/…/gpu-table-transform.ts• L17-43 modules/…/gpu-table-transform.ts• L108-175 modules/…/gpu-table-transform.ts• L332-414

Derived column flow

Computation consumes table columns and produces GPU-resident values that can become new columns or inputs to a later graph stage. The table layer preserves row and batch relationships but does not assign business meaning to the result.

This supports chained work such as filtering, transforming, analyzing, and rendering. The application still controls submission and readback within the wider GPU graph and domain systems execution boundary.

References: modules/…/gpu-table-computation.ts• L75-105 modules/…/gpu-table-transform.ts• L122-174 modules/…/index.ts• L32-64 modules/…/index.ts• L51-76

GPU resource mapping

Input contracts

An input schema maps each logical table column to the shader view that consumes it. A declaration can describe an attribute, a storage binding, or several attribute views for one physical column. It also defines the role, accepted formats, required status, and whether the value is generated internally.

The same contract serves render and compute code. Validation rejects missing required columns, unsupported formats, and constants where a varying value is required before resources are prepared.

References: modules/…/gpu-input-schema.ts• L10-57 modules/…/gpu-input-schema.ts• L65-105

Arrow shader layouts

Arrow shader layout mapping matches shader attributes to Arrow field paths before upload. It checks component count, scalar type, signedness, matrix views, and portability across the target GPU API. This gives each Arrow column a clear GPU target before table fields or shader resources are created.

References: modules/…/arrow-shader-layout.ts• L23-37 modules/…/arrow-shader-layout.ts• L48-123 modules/…/arrow-shader-layout.ts• L131-200

WGSL vector layouts

WGSL vector layouts define how packed GPU vector rows map to native WebGPU storage values. They make packed row size and aligned array stride explicit, so the same column meaning can cross from vertex-style memory into WGSL storage.

The supported contract covers packed 32-bit numeric scalar and vector formats. It reports the component type, shader value type, row size, alignment, and native array stride without changing storage.

References: modules/…/gpu-vector-wgsl-layout.ts• L8-35 modules/…/gpu-vector-wgsl-layout.ts• L38-78 modules/…/index.ts• L77-84

Shader bindings

GPUTableShaderBindings resolves one table against one fixed shader layout. It creates batch attributes and storage bindings. It also maps constants to backend resources and can reuse helper buffers when a replacement table keeps the same contract.

For storage inputs, a row multiplier lets one shader row rule support both forms. Varying columns use the current row. Constant columns use one physical row for every logical row.

References: modules/…/gpu-table-shader-bindings.ts• L36-81 modules/…/gpu-table-shader-bindings.ts• L85-135 modules/…/gpu-table-shader-bindings.ts• L214-308 modules/…/gpu-table-shader-bindings.ts• L438-470

Buffer allocation plans

GPUTableBufferPlanner turns abstract column and device descriptions into a physical allocation plan. It can keep columns separate, interleave them, group them for storage, or leave them to an external allocator. The plan also returns the names and offsets visible to shader binding code.

The plan accounts for geometry mode and device limits. Shared geometry treats table rows as instances of reusable geometry. Row geometry treats rows as generated vertex data and can use WebGPU storage groups.

References: modules/…/gpu-table-buffer-planner.ts• L7-34 modules/…/gpu-table-buffer-planner.ts• L37-49 modules/…/gpu-table-buffer-planner.ts• L180-220 modules/…/gpu-table-buffer-planner.ts• L220-363

Engine views

The engine provides three views over a table. GPUTableModel binds table resources to rendering and derives vertex or instance counts from rows. GPUTableGeometry exposes one packed table as static geometry. TableTransform exposes table columns as transform-feedback inputs and runs them by batch.

These views share one table contract but have different boundaries. A model supports preserved batch drawing. Geometry needs one static batch. A transform restores the table-level state after batch execution.

References: modules/…/gpu-table-model.ts• L25-40 modules/…/gpu-table-model.ts• L155-247 modules/…/gpu-table-geometry.ts• L10-55 modules/…/gpu-table-transform.ts• L56-74

Scene partitions

Scene partitions map preserved table batches to GPU scene records without copying record storage. Each non-empty batch becomes one partition that borrows its record buffer. Empty batches remain as empty entries so batch indices and cumulative row positions stay stable.

This view requires the WebGPU scene record layout and exact per-batch active counts. It allocates scene state per partition but does not repack table rows.

References: modules/…/gpu-scene-adapters.ts• L53-83 modules/…/gpu-scene-adapters.ts• L174-275 modules/…/gpu-scene-adapters.ts• L278-321

GPU tables are the data layer for the wider graph system. They carry source rows into graph analysis, spatial and projection work, physics preparation, and GPU compute workflows. The GPU graph workflows page describes the larger flow. GPGPU compute describes the compute context, while GPU Project describes the product-level use of GPU graph features.

The key hand-off is row alignment. A downstream system can use a column as an attribute, storage range, or derived result only while its schema, batch rows, source identity, and resource lifetime still agree.

References: modules/…/index.ts• L13-77 modules/…/gpu-record-batch.ts• L22-29 modules/…/arrow-gpu-table-conversion.ts• L212-245

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep table fields, batch fields, buffer layouts, and input-schema formats aligned when a column contract changes.
  • Keep CPU/GPU transfer counts, strides, list offsets, validity data, and ownership aligned when vector transfer changes.
  • Keep batch row counts aligned across every vector used by computation or batch drawing.
  • Keep portable expression operators and result types aligned with GPU expression nodes and query validation.
  • Keep portable expression casts and vector widths aligned with WGSL layout rules.
  • Keep constant-column handling consistent across WebGL attributes, WebGPU attributes, and WebGPU storage bindings.
  • Keep packed byte size, storage alignment, native array stride, and accepted formats aligned when WGSL vector layout support changes.
  • Keep shader names, storage offsets, device limits, and model publication aligned when the buffer planner changes.
  • Preserve source-row offsets, validity vectors, dictionary labels, and temporal origins when Arrow data is streamed or read back.
  • Keep local row-selection topology separate from global row ordering in analytics readback.
  • Keep table ownership separate from engine-view ownership, especially for geometry and transform destruction.
  • Keep scene column names, record layout, device ownership, and per-batch active counts aligned for zero-copy scene views.

Important failure modes

TriggerConsequenceGuard
Varying columns in one batch have different row countsRows no longer refer to the same recordsValidate batch row counts before construction or dispatch.
Batched computation inputs have different batch shapesA dispatch binds unrelated rows or fails validationUse matching batch counts and per-batch row counts.
A portable expression uses an unsupported operation or invalid literalExpression conversion fails before query executionUse the validated portable subset and finite scalar values.
A portable cast changes a known vector widthThe expression cannot map to a valid GPU formatPreserve vector width across numeric casts.
A constant is supplied to a required varying inputShader input semantics are invalidMark the input optional only when the consumer supports constants.
A table is sent to geometry with several batches or dynamic buffersStatic geometry cannot expose a stable vertex sourcePack the table first and use static single-batch attributes.
Storage or vertex groups exceed device limitsResource publication fails or the shader cannot bind all columnsUse the planner and inspect its limit validation.
A zero-row batch reaches a storage bindingWebGPU rejects the zero-size rangeSkip empty batches before dispatch or draw.
A table or prepared binding is destroyed while work still uses itLater GPU work reads released resourcesDestroy only after submitted work has completed.
Arrow columns change type, chunk shape, or dictionary labels between batchesConversion rejects the table or creates incompatible GPU columnsValidate source schema and batch contents before allocation.
Nullable Arrow data loses validity metadataReadback turns null rows into valid values or cannot rebuild the source typePreserve batch-aligned validity vectors and readback metadata.
Local and global selection identities are supplied togetherArrow readback has no single row-order contractChoose one selection mode and provide its complete count and index data.
A scene adapter receives non-canonical table storage or the wrong deviceZero-copy scene creation fails or exposes invalid recordsUse the required layout, storage usage, and matching WebGPU device.
A general GPU data buffer uses default index usage on WebGLThe first buffer bind can block later vertex useUse portable defaults that omit index usage on WebGL.
A requested color format is not accepted by the consumerColor preparation fails instead of using a defined fallbackDeclare accepted formats and an explicit fallback.
A WGSL layout request uses unsupported vector dataThe storage layout cannot describe the value with the required native typeConvert to a supported packed 32-bit format first.

Key files

FileWhy to read it
modules/…/gpu-table.tsDefines logical columns, batches, row counts, packing, selection, and ownership.
modules/…/gpu-record-batch.tsDefines the physical batch boundary and row-aligned GPU data contract.
modules/…/cpu-gpu-vector-transfer.tsDefines CPU/GPU vector transfer while preserving chunks and validity data.
modules/…/gpu-table-computation.tsShows batch-aware WebGPU computation dispatch.
modules/…/gpu-expression.tsDefines immutable GPU data-frame expressions and column tracking.
modules/…/portable-expression.tsShows the supported bridge from portable expressions to GPU data-frame expressions.
modules/…/gpu-input-schema.tsDefines the logical-column to shader-input contract.
modules/…/gpu-table-shader-bindings.tsShows how one table becomes backend-ready attributes and bindings.
modules/…/gpu-table-buffer-planner.tsShows how columns map to physical GPU allocation groups.
modules/…/arrow-gpu-table-conversion.tsShows planned and streaming Arrow-to-table conversion with source-row identity.
modules/…/arrow-gpu-analytics-readback.tsShows explicit GPU analytics materialization back into Arrow batches.
modules/…/gpu-table-model.tsShows table-backed rendering and batch rebinding.
modules/…/gpu-table-geometry.tsShows the static geometry view and its single-batch boundary.
modules/…/gpu-table-transform.tsShows WebGL transform-feedback execution and output writeback.