GPU Project projection system
GPU Project is a graph-module WebGPU system for moving two-dimensional coordinate transformation work from a CPU projection provider to GPU-resident data. It reads coordinate-reference definitions, plans a bounded transformation, generates a reusable GPU program, and can apply that program to graph data or tabular batches. The graph surface also provides a layer-facing coordinate pipeline and CPU geometry helpers for GeoArrow data. The public graph surface exposes a CPU projection operation for executor-managed fallback work. See the parent page, GPU graph systems, for the wider graph context. Related workflow pages include GPU graph workflows and GPU geospatial workflows. The system also connects to other GPU graph areas described by GPU physics, GPU simple graph, GPU data tables, and experimental GPU workflows.
System role
The system separates projection semantics from projection execution. A CPU-side provider or CRS (coordinate reference system) definition states what the transformation means. GPU Project turns that meaning into either native operations or a local approximation that WebGPU can evaluate without native GPU binary64 arithmetic. The provider remains responsible for projection definitions, datum support, and grid behavior.
The main flow connects planning to several forms of execution:
flowchart LR
A[CRS definition or provider] --> B[CRS and pipeline planning]
B --> C[Projection program]
C --> D[WGSL shader and parameters]
D --> E[Command graph execution]
E --> F[GPU vectors or projected tables]
B --> G[CPU table transform]
G --> F
The system is intended for bounded coordinate regions with many rows that can stay on the GPU. A direct CPU transform is still the better fit when data is small, unbounded, or needed by JavaScript immediately.
Coordinate-reference inputs
CRS definitions and pipelines
The CRS planner accepts explicit two-dimensional CRS definitions or a parsed PROJ pipeline. A CRS definition describes source and destination frames; a pipeline describes an ordered set of coordinate operations. The planner uses this information to preserve axis meaning, units, datum identity, and valid operation domains rather than treating CRS labels as a transformation by themselves. CRS metadata alone does not perform a transformation. The optional CRS entry point uses math.gl geospatial APIs and can accept compatible PROJJSON objects. References: modules/…/crs.ts• L50-67, modules/…/projection-pipeline.ts• L28-58, modules/…/README.md• L71-84, modules/…/README.md• L270-300
Pipeline planning first lowers supported axis, unit, affine, and selected projection operations into a static program. Native routes cover supported two-dimensional axis and unit changes, affine changes, and selected projection families such as Web Mercator and Transverse Mercator. If native lowering cannot represent the requested pipeline, an explicitly supplied CPU provider may serve as the oracle for a bounded adaptive plan. Unsupported definitions return structured reasons by default, or raise ProjectionPlanningError when the caller selects throwing behavior. References: modules/…/crs.ts• L69-113, modules/…/projection-planning.ts• L21-40, modules/…/projection-planning.ts• L193-220, modules/…/README.md• L279-313
The planners return a ready or unsupported result. A ready result includes the program, compiled form, execution strategy, and any fallback reasons. Adaptive routes need finite source bounds and a sampled tolerance; native routes can avoid those bounds. Geographic units, mixed projected units, unsupported axis semantics, non-2D definitions, and extra provider output remain outside the supported contract. References: modules/…/README.md• L279-313
Provider-backed preparation
Provider-backed planning is the boundary for projection libraries and custom transforms. planProjection accepts an already prepared two-dimensional provider and samples it over caller-owned source bounds. A provider can expose project and inverse operations or be a standalone projection function. CRS preparation can also retain the CPU transform and its CRS metadata for later CPU reference work or table processing. No native formula silently replaces a caller's provider, and explicitly lossy transforms are declined. References: modules/…/projection-planning.ts• L83-163, modules/…/projection-engine.ts• L18-35, modules/…/README.md• L103-116
Preparation is explicit about loading. Synchronous preparation does not load deferred algorithms; asynchronous preparation is the loading boundary. The resulting GPU plan is a snapshot, so changes to the provider or its CRS settings require a new preparation step. References: modules/…/projection-engine.ts• L37-70, modules/…/projection-engine.ts• L77-92
Projection planning
Adaptive projection plans
An adaptive projection plan is a set of local polynomial patches that approximate a CPU provider over a finite source rectangle. The planner samples the provider, fits each local region, and subdivides regions that do not meet the requested sampled tolerance. Each patch carries its source domain and the information needed to evaluate the same local transform on the GPU. References: modules/…/projection-plan.ts• L61-126, modules/…/types.ts• L33-61, modules/…/README.md• L137-142
The plan records the source bounds, destination origin, precision mode, polynomial degree, patch count, and sampled error. local-f32 produces origin-relative Float32 output. double-single preserves more significand precision and produces absolute high/low pairs. These are execution contracts, not claims of IEEE binary64 behavior or formal global error bounds. Compilation is bounded by the selected subdivision limit and fails when it cannot meet the requested sampled budget. References: modules/…/types.ts• L63-86, modules/…/projection-plan.ts• L142-161, modules/…/README.md• L118-142
Projection programs
A projection program is an ordered two-dimensional transformation. It can combine axis changes, unit conversion, affine changes, explicit analytic stages, longitude normalization, and adaptive stages. The order matters because each stage receives the previous stage's coordinates and domain. The compiled program specializes this sequence into straight-line shader calls rather than interpreting operations per row. Compilation describes the program and its parameters; it does not allocate GPU resources. References: modules/…/projection-program.ts• L43-62, modules/…/projection-program.ts• L180-249, modules/…/README.md• L191-197
Programs support a separate inverse description for adaptive stages. Inversion reverses the operation order, but it does not assume that a forward approximation is also an inverse. Callers must provide an independently bounded inverse plan when they need one. Longitude wrapping discards turn information, so it is a one-way normalization step and cannot be inverted automatically. References: modules/…/projection-program.ts• L148-177, modules/…/projection-planning.ts• L75-81, modules/…/README.md• L258-268, modules/…/README.md• L333-338
Domains and discontinuities
Validity is part of the projection contract. Non-finite rows, coordinates outside a plan, unsupported formula domains, rejected seams, and unresolved partition gaps become invalid rows rather than plausible coordinates. Applications must split or partition data at discontinuities such as antimeridians, singularities, incompatible zones, or disconnected visible regions. References: modules/…/projection-partition.ts• L44-49, modules/…/projection-program.ts• L180-249, modules/…/README.md• L468-479
compileProjectionPartition lets an application describe separate source branches and conservative interior regions. It keeps gaps invalid and can provide segments split at accepted patch boundaries. It does not unwrap longitudes, densify curved edges, or rebuild polygon topology. References: modules/…/projection-partition.ts• L16-42, modules/…/projection-partition.ts• L187-220
Shader and program generation
Compiled GPU programs
CompiledProjection turns a program into a static shader source and packed parameter data. The generated shader is a callable transformation rather than a complete compute pass, so the same compiled projection can feed a materialized compute stage or an existing render or analysis shader. References: modules/…/projection-program.ts• L64-100, modules/…/projection-program.ts• L141-146, modules/…/README.md• L344-360
The caller selects a namespace and parameter offset when embedding the callable. The caller also binds the packed parameters and supplies the required shader modules and defines. This allows several projections to share a consumer shader while keeping shader structure separate from changing numeric parameters. References: modules/…/projection-program.ts• L94-129, modules/…/README.md• L344-360
Program updates and metadata
Compiled metadata describes the input encoding, stage arithmetic, output frame, validity behavior, domains, and inversion support. A compatible update changes numeric parameters without changing the generated shader layout. Changes to operation order, input format, precision, or other structural choices require a new compiled program and may require graph rebuilding. References: modules/…/projection-program.ts• L75-92, modules/…/projection-program.ts• L132-138, modules/…/projection-metadata.ts• L1-80, modules/…/README.md• L367-373
The program metadata reports whether its error is none, a sampled estimate, or unknown. A sampled estimate belongs to the fitted stage and does not include input, formula, or output rounding. When several adaptive stages are composed, the system does not claim a global error bound; later stages can magnify earlier error. References: modules/…/README.md• L270-277
GPU execution
Command-graph execution
GPU Project exposes two execution shapes. GPUProjection applies one adaptive plan directly to source positions. GPUProjectionProgram materializes any compiled multi-stage program. Both add work to a caller-owned WebGPU command graph and leave submission, synchronization, and downstream use to the caller. GPUProjection keeps the packed plan in storage data, so an update with the same patch and layout contract can change plan values without rebuilding the surrounding graph. References: modules/…/gpu-projection.ts• L75-86, modules/…/gpu-projection.ts• L162-198, modules/…/gpu-projection.ts• L200-245, modules/…/gpu-projection-program.ts• L38-45, modules/…/README.md• L57-69
Execution preserves the source vector's row and chunk layout. Each non-empty chunk gets a matching compute pass, while empty chunks remain part of the data model. Input and output views must have matching rows, and optional validity columns carry one value per row. A projection can be registered once on a graph, and its source, output, auxiliary views, and plan storage must belong to that graph. References: modules/…/gpu-projection.ts• L108-155, modules/…/gpu-projection.ts• L200-245, modules/…/gpu-projection-program.ts• L84-123, modules/…/README.md• L175-189
Precision and validity
Raw binary64 source coordinates can enter as packed uint32x4 values. The evaluator first works in a local coordinate frame so that large global origins do not erase small differences during Float32 conversion. Local Float32 output remains relative to a destination origin; double-single output uses absolute high/low pairs. Projection programs use double-single arithmetic for most stages, while explicit Web Mercator and Transverse Mercator/UTM native operations can opt into Float32 formula arithmetic. The reported output format does not restore precision lost inside a Float32 formula. References: modules/…/gpu-projection.ts• L43-73, modules/…/projection-shader.ts• L101-124, modules/…/README.md• L118-135, modules/…/README.md• L231-245, modules/…/README.md• L315-331
Precise projection programs need a hardware WebGPU adapter in practice. Software adapters can exceed practical shader compilation budgets, while CPU compiler checks cover hosts without hardware WebGPU. This separates the ability to describe a program from the ability to run its numerical shader. References: modules/…/README.md• L247-250
Invalid input or a failed domain check writes zero output. An optional validity column distinguishes that result from a valid coordinate whose numeric value is also zero. Upstream validity can short-circuit a program before it evaluates its stages. References: modules/…/projection-shader.ts• L30-52, modules/…/projection-program.ts• L423-437, modules/…/README.md• L362-365
Graph-facing coordinate workflows
Coordinate projection graph
CoordinateProjectionGraph provides a reusable point-coordinate pipeline for graph and layer callers. It accepts a CPU or GPU vector with a declared two- or three-component format, applies the configured CPU projection operation through the graph runtime, and returns independently owned projected positions. The pipeline selects the full GPU graph on WebGPU devices and a simple graph path on other devices. References: modules/…/coordinate-projection-graph.ts• L15-43
The graph preserves source row and chunk boundaries, so downstream layers can match projected positions to their input rows. The caller owns each returned result and must release it after downstream work finishes. Projection loading remains outside this wrapper, which keeps provider setup separate from graph execution. References: modules/…/coordinate-projection-graph.ts• L25-27, modules/…/coordinate-projection-graph.ts• L46-58
GeoArrow coordinate exchange
The GeoArrow bridge maps CPU coordinate vectors to the native GeoArrow forms used by geometry workflows. It preserves chunk structure and row validity, and it can encode points, single-level coordinate lists, or one-ring polygon rows. The reverse path maps supported interleaved point, line, and multipoint columns back to CPU vectors; nested polygons remain in GeoArrow form because one CPU vector cannot express their extra nesting. References: modules/…/cpu-geoarrow.ts• L15-35, modules/…/cpu-geoarrow.ts• L54-85, modules/…/cpu-geoarrow.ts• L87-134
The bridge accepts two-, three-, and four-component coordinate dimensions when the source format matches the declared dimension. It uses the source storage when the coordinate stride is already packed and creates packed values when the source has padding. This makes GeoArrow the common boundary between vector data and geometry operations without changing row-level validity. References: modules/…/cpu-geoarrow.ts• L27-64, modules/…/cpu-geoarrow.ts• L93-132
CPU geometry pipelines
The CPU geometry helpers provide a reference path for coordinate projection and polygon tessellation. CPU projection first normalizes supported vectors through the GeoArrow boundary, then applies the provider to contiguous valid runs while retaining the source vector's chunk and row topology. Polygon tessellation converts GeoArrow polygon data into positions, triangle indices, and source-row indices so rendered mesh elements can still map back to source features. References: modules/…/cpu-geometry-pipelines.ts• L16-76, modules/…/cpu-geometry-pipelines.ts• L78-87
The native GeoArrow tessellation path supports holes, multipolygons, and mixed polygon columns. Its output keeps per-row offsets and validity across chunks, while row indices preserve feature identity after tessellation. References: modules/…/cpu-geometry-pipelines.ts• L89-158
Patch routing
Patch lookup
Adaptive execution must associate each source row with a patch. The default path searches the plan's patches. Applications that already know the assignment can provide a row-aligned patch-ID column and avoid that search. Invalid or out-of-range IDs produce invalid rows. References: modules/…/projection-plan.ts• L129-161, modules/…/gpu-projection.ts• L131-155, modules/…/gpu-projection.ts• L200-240, modules/…/README.md• L144-173
Patch lookup accepts shared seam endpoints after Float32 normalization, but this tolerance does not enlarge the compiled exterior bounds. Packed plans keep those bounds with the patch records so a plan replacement cannot separate domain checks from the coefficients they protect. References: modules/…/README.md• L164-186
Routing index
An optional routing index adds a broad phase before the final patch-domain check. It can reduce lookup work for plans with many patches, but it does not change patch coefficients or validity. The indexed and scan paths must be compared on the target device and workload rather than selected from synthetic assumptions. References: modules/…/projection-routing.ts• L8-25, modules/…/projection-routing-benchmark.ts• L56-89
Tabular transformation
CPU batch transformation
ProjectionTableTransform applies a prepared CRS transformation to dense batches while preserving row order, batch identity, and metadata. The CPU path uses the retained provider as its reference, writes absolute Float64 positions, and emits an explicit validity array. It processes batches lazily, so already yielded batches remain available if a later batch fails. References: modules/…/projection-table-transform.ts• L12-38, modules/…/projection-table-transform.ts• L41-125
Masked, non-finite, and out-of-domain rows become zero-valued invalid rows. A provider exception or non-finite result inside the accepted domain is different: it aborts the current batch with ProjectionTableError and includes the row and source information. References: modules/…/projection-table-transform.ts• L63-119
GPU table transformation
The GPU table path creates a derived table with only projected positions and validity. It borrows source batches and allocates output resources, while registration and submission remain explicit. The table adapter requires dense packed binary64 coordinate columns and an explicit validity column when source rows can be null. References: modules/…/gpu-projection-table.ts• L14-31, modules/…/gpu-projection-table.ts• L45-73
The derived table keeps the source batch topology and provenance but does not copy unrelated application columns. Consumers join those attributes by batch and row position or by source metadata. Outputs are usable only after the caller submits the graph, and cleanup releases derived resources without destroying source data. References: modules/…/gpu-projection-table.ts• L95-163
Program benchmarking
Program comparisons
The program benchmark compares caller-selected GPU programs against one independent CPU oracle. It tests inline use against materialized reuse with the same raw binary64 inputs, output format, destination frame, validity expectations, and consumer work. Every path must pass accuracy and validity checks before warmup and after measurement. References: modules/…/projection-program-benchmark.ts• L40-145, modules/…/projection-program-benchmark.ts• L199-284, modules/…/README.md• L426-445
Timing reports
The report separates planning, shader and graph preparation, first use, synchronized execution, and optional GPU timestamp data. A materialized path projects once and shares its result across consumers. An inline path repeats the projection for each consumer. Timestamp instrumentation measures GPU work but can prevent compute-pass coalescing, so instrumented and uninstrumented results are separate observations rather than production guarantees. References: modules/…/projection-program-benchmark.ts• L287-581, modules/…/README.md• L402-440
Accuracy boundaries
GPU Project reports sampled fitting error. It does not prove a global error bound for a complete composed program, and final input, formula, and output rounding add separate error. Applications should validate representative data against the CPU provider and choose bounds that stay inside a smooth, continuous domain. Projection definitions, datum behavior, and grid availability remain the provider's responsibility. References: modules/…/projection-plan.ts• L61-69, modules/…/projection-metadata.ts• L1-80, modules/…/README.md• L468-479
Change checklist
When these files or sections are changed, remember to consider these:
- Keep CRS parser support, native lowering, fallback reasons, and the
ready/unsupportedcontract aligned. - Keep plan precision, input format, output format, destination-origin handling, and shader metadata consistent.
- When changing operation topology or adaptive domains, check inverse planning and compiled-program compatibility.
- Preserve row and chunk alignment across positions, patch IDs, input validity, output positions, and output validity.
- Keep owned and caller-owned packed plan storage aligned with update rules, graph ownership, and resource lifetime.
- Keep table adapters aligned with dense packed storage rules and explicit null-to-validity conversion.
- Keep
CPUProjectionOperationinput formats aligned with its declared graph vector output and provider projection dimension. - Keep
CoordinateProjectionGraphgraph selection, vector format checks, result ownership, and provider-loading boundaries aligned. - Keep GeoArrow encodings, coordinate dimensions, offsets, validity, and CPU vector formats aligned across conversion helpers.
- Keep projected geometry row offsets, source-row indices, and polygon validity aligned after tessellation.
- Requalify scan versus indexed routing and inline versus materialized execution when the workload or device contract changes.
- Keep benchmark oracle validity, error budgets, consumer counts, and timing modes comparable before using a result for a choice.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An adaptive CRS plan has no source bounds | Planning returns bounds-required | Supply a finite source domain or use a native plan |
| A definition is 3D, compound, dynamic, or otherwise outside the supported 2D contract | Planning returns structured unsupported reasons | Handle the result or opt into throwing policy |
A CPU projection operation receives a vector with a format different from its declared float32x2 or float32x3 format | The operation rejects the input before projection | Match the graph vector format to the operation's declared dimension |
| A coordinate graph receives a vector with the wrong format or with null or nested-offset data | The graph run is rejected before projection | Normalize the input to the declared dense coordinate shape and handle null filtering before this point |
| A GeoArrow column uses unsupported nesting, coordinate layout, or primitive storage | CPU vector conversion is rejected | Use interleaved supported point, line, or multipoint columns, or keep nested polygons as GeoArrow |
| Local Float32 output is combined with a large global origin in Float32 | Recovered local precision is lost | Keep the destination origin in a higher-precision or camera-relative path |
| A row is outside the plan or has an invalid patch ID | The row receives zero output and validity 0 | Partition data or provide correct patch assignments |
| A native formula receives coordinates outside its supported domain | The row becomes invalid rather than producing a usable coordinate | Keep the stage inside its declared domain and validate the complete program |
| A plan update changes patch count, precision, routing layout, or domain layout | The existing projection rejects the update | Build a new projection for structural changes and use updates only for compatible plan values |
A caller-owned plan buffer lacks a usable default buffer or COPY_DST usage | A plan update cannot write the new packed values | Create the buffer for updates or let GPUProjection own its plan storage |
| A projection is registered on the wrong graph, registered twice, or used after destruction | Graph registration or later use fails | Keep all views on the target graph and treat projection registration and destruction as one-way lifecycle steps |
| Longitude wrapping is used where inverse turn information is required | The forward result cannot be inverted automatically, and seam rows can be invalid | Treat wrapping as a one-way normalization step and split data at the seam |
| A table uses indexed rows, non-packed coordinates, or a null bitmap without a validity column | GPU table construction is rejected | Adapt the source into dense packed columns with explicit validity |
| A CPU provider fails inside a valid table domain | The current batch is not published | Catch ProjectionTableError and handle its row and source context |
| Polygon tessellation drops row offsets or source-row indices | Mesh output cannot map back to source features | Preserve per-row offsets and carry the returned source-row vector with positions and indices |
| Benchmark variants use different error budgets or mix timestamp modes | The comparison can describe unlike accuracy or timing conditions | Check the report's budget and timing fields before comparing paths |
Key files
| File | Why to read it |
|---|---|
| modules/…/index.ts | Public projection planning, execution, routing, table, metadata, and CPU-operation exports |
| modules/…/README.md | High-level purpose, provider boundary, precision model, CRS planning choices, and benchmark scope |
| modules/…/README.md | High-level purpose, precision model, and supported usage choices |
| modules/…/crs.ts | CRS and PROJ pipeline planning entry points and fallback behavior |
| modules/…/projection-planning.ts | Provider planning results, inverse fitting, and failure policy |
| modules/…/projection-plan.ts | Adaptive plan model and CPU reference evaluation |
| modules/…/projection-program.ts | Ordered program model, shader generation, parameters, and compatibility |
| modules/…/projection-shader.ts | Shared adaptive patch selection, domain checks, precision handling, and validity output |
| modules/…/gpu-projection.ts | Direct adaptive-plan execution, packed plan updates, graph registration, and resource lifetime |
| modules/…/gpu-projection-program.ts | Materialized execution for compiled multi-stage programs |
| modules/…/projection-program-benchmark.ts | Accuracy-checked inline and materialized program comparisons |
| modules/…/projection-routing.ts | Optional patch-routing index |
| modules/…/projection-table-transform.ts | Batch-preserving CPU and GPU table boundary |
| modules/…/gpu-projection-table.ts | Derived GPU table layout, ownership, and registration |
| modules/…/cpu-projection-operation.ts | Executor-managed CPU forward projection for packed graph vectors |
| modules/…/coordinate-projection-graph.ts | Reusable layer-facing coordinate projection graph and result ownership |
| modules/…/cpu-geoarrow.ts | CPU vector and GeoArrow coordinate conversion boundary |
| modules/…/cpu-geometry-pipelines.ts | CPU coordinate projection and polygon tessellation workflows |
| modules/…/geoarrow.ts | Public GeoArrow and CPU geometry helper exports |
| modules/…/graph.ts | Public coordinate projection graph export |