@luma.gl/graph 10.0.0-alpha.10 → 10.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow/cpu/arrow-coordinate-projection.cjs +30 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.d.ts +5 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.js +9 -0
- package/dist/arrow/cpu/arrow-coordinate-projection.js.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.cjs +31 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts +2 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.js +5 -0
- package/dist/arrow/cpu/arrow-cpu-pipelines.js.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.cjs +99 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts +9 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts.map +1 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.js +100 -0
- package/dist/arrow/cpu/arrow-cpu-vector-adapters.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +10 -371
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +9 -28
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +5 -381
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +11 -11
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +2 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -1
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +3 -3
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -1
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +2 -2
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +1 -1
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -1
- package/dist/arrow/index.cjs +17 -2
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +3 -0
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +3 -0
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/internal.cjs.map +2 -2
- package/dist/dist.dev.js +533 -108
- package/dist/dist.min.js +70 -70
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/simulation/index.cjs.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.cjs +32 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts +4 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.js +39 -1
- package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph.cjs +19 -7
- package/dist/gpu-core/gpu-command-graph.d.ts +11 -4
- package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph.js +24 -7
- package/dist/gpu-core/gpu-command-graph.js.map +1 -1
- package/dist/gpu-core/gpu-cpu-execution.cjs +279 -0
- package/dist/gpu-core/gpu-cpu-execution.d.ts +22 -0
- package/dist/gpu-core/gpu-cpu-execution.d.ts.map +1 -0
- package/dist/gpu-core/gpu-cpu-execution.js +294 -0
- package/dist/gpu-core/gpu-cpu-execution.js.map +1 -0
- package/dist/gpu-core/gpu-cpu-operation.cjs +54 -0
- package/dist/gpu-core/gpu-cpu-operation.d.ts +40 -0
- package/dist/gpu-core/gpu-cpu-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-cpu-operation.js +35 -0
- package/dist/gpu-core/gpu-cpu-operation.js.map +1 -0
- package/dist/gpu-core/gpu-expression-operation.cjs +2 -2
- package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
- package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-operation.js +1 -1
- package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.cjs +1 -1
- package/dist/gpu-core/gpu-expression-plan.d.ts +3 -2
- package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.js +2 -1
- package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
- package/dist/gpu-core/gpu-graph.d.ts +2 -2
- package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-operation.d.ts +4 -4
- package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-operation.js.map +1 -1
- package/dist/gpu-core/gpu-render-operation.cjs +39 -0
- package/dist/gpu-core/gpu-render-operation.d.ts +21 -0
- package/dist/gpu-core/gpu-render-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-render-operation.js +22 -0
- package/dist/gpu-core/gpu-render-operation.js.map +1 -0
- package/dist/gpu-core/gpu-texture-plan.d.ts +3 -2
- package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-data/cpu-data.cjs +60 -0
- package/dist/gpu-data/cpu-data.d.ts +28 -0
- package/dist/gpu-data/cpu-data.d.ts.map +1 -0
- package/dist/gpu-data/cpu-data.js +41 -0
- package/dist/gpu-data/cpu-data.js.map +1 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
- package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
- package/dist/gpu-data/cpu-vector.cjs +42 -0
- package/dist/gpu-data/cpu-vector.d.ts +17 -0
- package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
- package/dist/gpu-data/cpu-vector.js +21 -0
- package/dist/gpu-data/cpu-vector.js.map +1 -0
- package/dist/gpu-data/index.cjs +13 -2
- package/dist/gpu-data/index.cjs.map +3 -3
- package/dist/gpu-data/index.d.ts +3 -0
- package/dist/gpu-data/index.d.ts.map +1 -1
- package/dist/gpu-data/index.js +3 -0
- package/dist/gpu-data/index.js.map +1 -1
- package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
- package/dist/gpu-graph/index.cjs +3 -0
- package/dist/gpu-graph/index.cjs.map +3 -3
- package/dist/gpu-graph/index.d.ts +2 -0
- package/dist/gpu-graph/index.d.ts.map +1 -1
- package/dist/gpu-graph/index.js +1 -0
- package/dist/gpu-graph/index.js.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
- package/dist/gpu-physics/index.cjs.map +1 -1
- package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
- package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
- package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
- package/dist/gpu-project/coordinate-projection-graph.js +40 -0
- package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
- package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
- package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
- package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
- package/dist/gpu-project/cpu-geoarrow.js +103 -0
- package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
- package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
- package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
- package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
- package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
- package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
- package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
- package/dist/gpu-project/cpu-projection-operation.js +37 -0
- package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
- package/dist/gpu-project/geoarrow.cjs +36 -0
- package/dist/gpu-project/geoarrow.cjs.map +6 -0
- package/dist/gpu-project/geoarrow.d.ts +3 -0
- package/dist/gpu-project/geoarrow.d.ts.map +1 -0
- package/dist/gpu-project/geoarrow.js +7 -0
- package/dist/gpu-project/geoarrow.js.map +1 -0
- package/dist/gpu-project/graph.cjs +27 -0
- package/dist/gpu-project/graph.cjs.map +6 -0
- package/dist/gpu-project/graph.d.ts +2 -0
- package/dist/gpu-project/graph.d.ts.map +1 -0
- package/dist/gpu-project/graph.js +6 -0
- package/dist/gpu-project/graph.js.map +1 -0
- package/dist/gpu-project/index.cjs +3 -0
- package/dist/gpu-project/index.cjs.map +3 -3
- package/dist/gpu-project/index.d.ts +1 -0
- package/dist/gpu-project/index.d.ts.map +1 -1
- package/dist/gpu-project/index.js +1 -0
- package/dist/gpu-project/index.js.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +24 -2
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +2 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +29 -2
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
- package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
- package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
- package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +17 -6
- package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
- package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
- package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
- package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
- package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
- package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
- package/src/arrow/index.ts +11 -0
- package/src/gpu-core/compiled-gpu-graph.ts +55 -1
- package/src/gpu-core/gpu-command-graph.ts +27 -7
- package/src/gpu-core/gpu-cpu-execution.ts +345 -0
- package/src/gpu-core/gpu-cpu-operation.ts +65 -0
- package/src/gpu-core/gpu-expression-operation.ts +1 -1
- package/src/gpu-core/gpu-expression-plan.ts +5 -3
- package/src/gpu-core/gpu-graph.ts +3 -3
- package/src/gpu-core/gpu-operation.ts +9 -7
- package/src/gpu-core/gpu-render-operation.ts +42 -0
- package/src/gpu-core/gpu-texture-plan.ts +3 -2
- package/src/gpu-core/index.ts +10 -0
- package/src/gpu-data/cpu-data.ts +62 -0
- package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
- package/src/gpu-data/cpu-vector.ts +31 -0
- package/src/gpu-data/index.ts +5 -0
- package/src/gpu-graph/index.ts +8 -0
- package/src/gpu-project/coordinate-projection-graph.ts +59 -0
- package/src/gpu-project/cpu-geoarrow.ts +135 -0
- package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
- package/src/gpu-project/cpu-projection-operation.ts +49 -0
- package/src/gpu-project/geoarrow.ts +11 -0
- package/src/gpu-project/graph.ts +10 -0
- package/src/gpu-project/index.ts +2 -0
- package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +39 -2
- package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
- package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
- package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
- package/src/index.ts +8 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
|
|
6
|
+
import {assert} from '@luma.gl/core';
|
|
7
|
+
import {CPUData, CPUVector, getGPUVectorFormatInfo} from '@luma.gl/graph/gpu-data';
|
|
8
|
+
import type {Projection} from '@math.gl/geospatial/projection/types';
|
|
9
|
+
import {
|
|
10
|
+
tessellateGeoArrowPolygons,
|
|
11
|
+
type GeoArrowColumn,
|
|
12
|
+
type TessellateGeoArrowPolygonsOptions
|
|
13
|
+
} from '@math.gl/arrow/geoarrow-utils';
|
|
14
|
+
import {makeGeoArrowColumnFromCPUVector, makeCPUVectorFromGeoArrowColumn} from './cpu-geoarrow';
|
|
15
|
+
|
|
16
|
+
/** Project Float32 coordinates while retaining single-level row topology and null rows. */
|
|
17
|
+
export async function projectCPUVector(
|
|
18
|
+
vector: CPUVector,
|
|
19
|
+
projection: Pick<Projection, 'projectFlat'>
|
|
20
|
+
): Promise<CPUVector> {
|
|
21
|
+
const {name, format} = vector;
|
|
22
|
+
vector = makeCPUVectorFromGeoArrowColumn(makeGeoArrowColumnFromCPUVector(vector));
|
|
23
|
+
const info = getGPUVectorFormatInfo(vector.format);
|
|
24
|
+
assert(
|
|
25
|
+
info.signedDataType === 'float32' &&
|
|
26
|
+
(info.components === 2 || info.components === 3) &&
|
|
27
|
+
!info.fixedSizeList
|
|
28
|
+
);
|
|
29
|
+
const data: CPUData[] = [];
|
|
30
|
+
for (const chunk of vector.data) {
|
|
31
|
+
const variable = info.vertexList || info.valueList;
|
|
32
|
+
const count = variable ? chunk.valueLength : chunk.length;
|
|
33
|
+
const values = new Float32Array(count * info.components);
|
|
34
|
+
const bytes = new Uint8Array(values.buffer);
|
|
35
|
+
for (let index = 0; index < count; index++)
|
|
36
|
+
bytes.set(
|
|
37
|
+
new Uint8Array(chunk.buffer, chunk.byteOffset + index * chunk.byteStride, info.byteLength),
|
|
38
|
+
index * info.byteLength
|
|
39
|
+
);
|
|
40
|
+
if (variable) assert(chunk.valueOffsets);
|
|
41
|
+
let row = 0;
|
|
42
|
+
while (row < chunk.length) {
|
|
43
|
+
if (chunk.nullBitmap && !(chunk.nullBitmap[row >> 3] & (1 << (row & 7)))) {
|
|
44
|
+
row++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const firstRow = row++;
|
|
48
|
+
while (
|
|
49
|
+
row < chunk.length &&
|
|
50
|
+
(!chunk.nullBitmap || chunk.nullBitmap[row >> 3] & (1 << (row & 7)))
|
|
51
|
+
)
|
|
52
|
+
row++;
|
|
53
|
+
const start = variable ? chunk.valueOffsets![firstRow] : firstRow;
|
|
54
|
+
const end = variable ? chunk.valueOffsets![row] : row;
|
|
55
|
+
if (end > start)
|
|
56
|
+
values.set(
|
|
57
|
+
await projection.projectFlat(
|
|
58
|
+
values.slice(start * info.components, end * info.components),
|
|
59
|
+
info.components
|
|
60
|
+
),
|
|
61
|
+
start * info.components
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
data.push(
|
|
65
|
+
new CPUData({
|
|
66
|
+
buffer: values,
|
|
67
|
+
format,
|
|
68
|
+
length: chunk.length,
|
|
69
|
+
valueLength: chunk.valueLength,
|
|
70
|
+
valueOffsets: chunk.valueOffsets?.slice(),
|
|
71
|
+
nullBitmap: chunk.nullBitmap?.slice()
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return new CPUVector({name, format, data});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Tessellate one simple polygon ring per list row, preserving source chunks and row identities. */
|
|
79
|
+
export function tessellateCPUVectorPolygons(vector: CPUVector): {
|
|
80
|
+
positions: CPUVector<'vertex-list<float32x4>'>;
|
|
81
|
+
indices: CPUVector<'vertex-list<uint32>'>;
|
|
82
|
+
rowIndices: CPUVector<'vertex-list<uint32>'>;
|
|
83
|
+
} {
|
|
84
|
+
return tessellateGeoArrowColumnToCPUVectors(
|
|
85
|
+
makeGeoArrowColumnFromCPUVector(vector, {encoding: 'geoarrow.polygon'})
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Full native GeoArrow polygon tessellation, including holes, multipolygons and mixed columns. */
|
|
90
|
+
export function tessellateGeoArrowColumnToCPUVectors(
|
|
91
|
+
column: GeoArrowColumn,
|
|
92
|
+
options: TessellateGeoArrowPolygonsOptions = {}
|
|
93
|
+
): {
|
|
94
|
+
positions: CPUVector<'vertex-list<float32x4>'>;
|
|
95
|
+
indices: CPUVector<'vertex-list<uint32>'>;
|
|
96
|
+
rowIndices: CPUVector<'vertex-list<uint32>'>;
|
|
97
|
+
} {
|
|
98
|
+
const positions: CPUData<'vertex-list<float32x4>'>[] = [];
|
|
99
|
+
const indices: CPUData<'vertex-list<uint32>'>[] = [];
|
|
100
|
+
const rowIndices: CPUData<'vertex-list<uint32>'>[] = [];
|
|
101
|
+
let rowOffset = options.sourceRowOffset ?? 0;
|
|
102
|
+
for (const rings of column.chunks) {
|
|
103
|
+
const mesh = tessellateGeoArrowPolygons(
|
|
104
|
+
{...column, chunks: [rings]},
|
|
105
|
+
{...options, positionSize: 4, sourceRowOffset: rowOffset}
|
|
106
|
+
);
|
|
107
|
+
const vertexOffsets = new Int32Array(rings.length + 1);
|
|
108
|
+
const indexOffsets = new Int32Array(rings.length + 1);
|
|
109
|
+
for (const source of mesh.sourceRowIndices) vertexOffsets[source - rowOffset + 1]++;
|
|
110
|
+
for (const index of mesh.indices) indexOffsets[mesh.sourceRowIndices[index] - rowOffset + 1]++;
|
|
111
|
+
for (let row = 1; row <= rings.length; row++) {
|
|
112
|
+
vertexOffsets[row] += vertexOffsets[row - 1];
|
|
113
|
+
indexOffsets[row] += indexOffsets[row - 1];
|
|
114
|
+
}
|
|
115
|
+
let nullBitmap: Uint8Array | undefined;
|
|
116
|
+
if (rings.validity) {
|
|
117
|
+
nullBitmap = new Uint8Array(Math.ceil(rings.length / 8));
|
|
118
|
+
for (let row = 0; row < rings.length; row++) {
|
|
119
|
+
const bit = row + (rings.validity.bitOffset ?? 0);
|
|
120
|
+
if (rings.validity.values[bit >> 3] & (1 << (bit & 7)))
|
|
121
|
+
nullBitmap[row >> 3] |= 1 << (row & 7);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const common = {length: rings.length, nullBitmap};
|
|
125
|
+
positions.push(
|
|
126
|
+
new CPUData({
|
|
127
|
+
...common,
|
|
128
|
+
format: 'vertex-list<float32x4>',
|
|
129
|
+
buffer: mesh.positions,
|
|
130
|
+
valueLength: mesh.vertexCount,
|
|
131
|
+
valueOffsets: vertexOffsets
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
indices.push(
|
|
135
|
+
new CPUData({
|
|
136
|
+
...common,
|
|
137
|
+
format: 'vertex-list<uint32>',
|
|
138
|
+
buffer: Uint32Array.from(mesh.indices),
|
|
139
|
+
valueLength: mesh.indices.length,
|
|
140
|
+
valueOffsets: indexOffsets
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
rowIndices.push(
|
|
144
|
+
new CPUData({
|
|
145
|
+
...common,
|
|
146
|
+
format: 'vertex-list<uint32>',
|
|
147
|
+
buffer: mesh.sourceRowIndices,
|
|
148
|
+
valueLength: mesh.vertexCount,
|
|
149
|
+
valueOffsets: vertexOffsets
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
rowOffset += rings.length;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
positions: new CPUVector({format: 'vertex-list<float32x4>', data: positions}),
|
|
156
|
+
indices: new CPUVector({format: 'vertex-list<uint32>', data: indices}),
|
|
157
|
+
rowIndices: new CPUVector({format: 'vertex-list<uint32>', data: rowIndices})
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
|
|
6
|
+
import {assert} from '@luma.gl/core';
|
|
7
|
+
import type {Projection} from '@math.gl/geospatial/projection/types';
|
|
8
|
+
import {GPUCPUOperation} from '../gpu-core/gpu-cpu-operation';
|
|
9
|
+
import {gpuGraph} from '../gpu-core/gpu-graph-value';
|
|
10
|
+
|
|
11
|
+
export type CPUProjectionOperationProps = {
|
|
12
|
+
id: string;
|
|
13
|
+
input: string;
|
|
14
|
+
output: string;
|
|
15
|
+
format: 'float32x2' | 'float32x3';
|
|
16
|
+
projection: Pick<Projection, 'projectFlat'>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Forward projection on the CPU with executor-managed GPU readback and upload. */
|
|
20
|
+
export class CPUProjectionOperation extends GPUCPUOperation {
|
|
21
|
+
constructor(props: CPUProjectionOperationProps) {
|
|
22
|
+
const dimension = props.format === 'float32x2' ? 2 : 3;
|
|
23
|
+
super({
|
|
24
|
+
id: props.id,
|
|
25
|
+
inputs: {positions: props.input},
|
|
26
|
+
outputs: {[props.output]: gpuGraph.vector(props.format)},
|
|
27
|
+
async execute({inputs}) {
|
|
28
|
+
const input = inputs['positions'];
|
|
29
|
+
// Coordinates must match the declared packed Float32 dimension.
|
|
30
|
+
assert(typeof input !== 'number' && input.format === props.format);
|
|
31
|
+
return {
|
|
32
|
+
[props.output]: {
|
|
33
|
+
chunks: await Promise.all(
|
|
34
|
+
input.chunks.map(async chunk => {
|
|
35
|
+
assert(chunk.values instanceof Float32Array);
|
|
36
|
+
const values = chunk.values.slice();
|
|
37
|
+
return {
|
|
38
|
+
values: values.length
|
|
39
|
+
? await props.projection.projectFlat(values, dimension)
|
|
40
|
+
: values
|
|
41
|
+
};
|
|
42
|
+
})
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
|
|
6
|
+
export {makeGeoArrowColumnFromCPUVector, makeCPUVectorFromGeoArrowColumn} from './cpu-geoarrow';
|
|
7
|
+
export {
|
|
8
|
+
projectCPUVector,
|
|
9
|
+
tessellateCPUVectorPolygons,
|
|
10
|
+
tessellateGeoArrowColumnToCPUVectors
|
|
11
|
+
} from './cpu-geometry-pipelines';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
CoordinateProjectionGraph,
|
|
8
|
+
type CoordinateProjectionGraphProps,
|
|
9
|
+
type ProjectedCoordinateResult
|
|
10
|
+
} from './coordinate-projection-graph';
|
package/src/gpu-project/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type ArithmeticOp,
|
|
15
15
|
type ArithmeticArgument
|
|
16
16
|
} from './operations/arithmetic-operation';
|
|
17
|
-
import {GPUVector} from '@luma.gl/graph/gpu-data';
|
|
17
|
+
import {CPUVector, GPUVector} from '@luma.gl/graph/gpu-data';
|
|
18
18
|
import type {GPUGraph} from '../gpu-core/gpu-graph';
|
|
19
19
|
import {
|
|
20
20
|
GPUExpressionOperation,
|
|
@@ -39,11 +39,16 @@ import type {GPUGraphOutputs} from '../gpu-core/gpu-texture-plan';
|
|
|
39
39
|
import {GPUExpressionCastOperation} from './gpu-expression-cast-operation';
|
|
40
40
|
import {GPUExpressionRowOperation} from './gpu-expression-row-operation';
|
|
41
41
|
|
|
42
|
+
import {GPUCPUOperation} from '../gpu-core/gpu-cpu-operation';
|
|
43
|
+
import {GPUCPUExecution} from '../gpu-core/gpu-cpu-execution';
|
|
44
|
+
|
|
42
45
|
/** Reusable expression program implemented through the unchanged evaluator API. */
|
|
43
46
|
export class CompiledGPUSimpleExpressionGraph<
|
|
44
47
|
Outputs extends GPUGraphOutputs = Record<string, GPUVector>
|
|
45
48
|
> {
|
|
46
49
|
private readonly program: GPUExpressionProgram;
|
|
50
|
+
private cpuExecution?: GPUCPUExecution;
|
|
51
|
+
private readonly outputLocations: Readonly<Record<string, 'cpu' | 'gpu'>>;
|
|
47
52
|
private running = false;
|
|
48
53
|
private destroyed = false;
|
|
49
54
|
|
|
@@ -54,6 +59,7 @@ export class CompiledGPUSimpleExpressionGraph<
|
|
|
54
59
|
) {
|
|
55
60
|
if (options.lowerings) throw new Error('Custom lowerings require GPUGraph');
|
|
56
61
|
this.program = new GPUExpressionProgram(source, options);
|
|
62
|
+
this.outputLocations = options.outputLocations ?? {};
|
|
57
63
|
if (this.program.textures.length && device.type !== 'webgpu')
|
|
58
64
|
throw new Error('SimpleGraph texture execution requires WebGPU');
|
|
59
65
|
if (this.program.vectors.some(value => value.role === 'state'))
|
|
@@ -62,6 +68,7 @@ export class CompiledGPUSimpleExpressionGraph<
|
|
|
62
68
|
this.program.operations.some(
|
|
63
69
|
operation =>
|
|
64
70
|
!(
|
|
71
|
+
operation instanceof GPUCPUOperation ||
|
|
65
72
|
operation instanceof GPUExpressionOperation ||
|
|
66
73
|
operation instanceof GPUUploadOperation ||
|
|
67
74
|
operation instanceof GPUCopyOperation
|
|
@@ -69,7 +76,16 @@ export class CompiledGPUSimpleExpressionGraph<
|
|
|
69
76
|
)
|
|
70
77
|
)
|
|
71
78
|
throw new Error(
|
|
72
|
-
'SimpleGraph declarative execution supports expression, upload and copy operations only'
|
|
79
|
+
'SimpleGraph declarative execution supports expression, CPU, upload and copy operations only'
|
|
80
|
+
);
|
|
81
|
+
if (
|
|
82
|
+
this.program.operations.some(operation => operation instanceof GPUCPUOperation) ||
|
|
83
|
+
Object.values(this.outputLocations).includes('cpu')
|
|
84
|
+
)
|
|
85
|
+
this.cpuExecution = new GPUCPUExecution(
|
|
86
|
+
device,
|
|
87
|
+
this.program,
|
|
88
|
+
(source, outputs) => new CompiledGPUSimpleExpressionGraph(device, source, {outputs})
|
|
73
89
|
);
|
|
74
90
|
}
|
|
75
91
|
|
|
@@ -123,7 +139,27 @@ export class CompiledGPUSimpleExpressionGraph<
|
|
|
123
139
|
const resolvedBindings = this.program.resolveBindings(supplied, options);
|
|
124
140
|
const bindings = resolvedBindings.bindings;
|
|
125
141
|
options = resolvedBindings.options;
|
|
142
|
+
const suppliedInputs = 'inputs' in supplied ? supplied.inputs : supplied;
|
|
143
|
+
const useCPU =
|
|
144
|
+
this.program.operations.some(operation => operation instanceof GPUCPUOperation) ||
|
|
145
|
+
Object.values(this.outputLocations).includes('cpu') ||
|
|
146
|
+
Object.values(suppliedInputs ?? {}).some(value => value instanceof CPUVector);
|
|
147
|
+
if (!this.cpuExecution && useCPU)
|
|
148
|
+
this.cpuExecution = new GPUCPUExecution(
|
|
149
|
+
this.device,
|
|
150
|
+
this.program,
|
|
151
|
+
(source, outputs) => new CompiledGPUSimpleExpressionGraph(this.device, source, {outputs})
|
|
152
|
+
);
|
|
126
153
|
this.running = true;
|
|
154
|
+
if (useCPU && this.cpuExecution) {
|
|
155
|
+
try {
|
|
156
|
+
// Dynamic CPU results cannot be prepared into caller-owned storage yet.
|
|
157
|
+
assert(!options.outputTargets || Object.keys(options.outputTargets).length === 0);
|
|
158
|
+
return (await this.cpuExecution.run(bindings, this.outputLocations)) as Outputs;
|
|
159
|
+
} finally {
|
|
160
|
+
this.running = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
127
163
|
const evaluators = new Set<GPUDataEvaluator>();
|
|
128
164
|
const scalarBuffers = new Set<Buffer>();
|
|
129
165
|
let scope: GPUEvaluationScope | undefined;
|
|
@@ -373,6 +409,7 @@ export class CompiledGPUSimpleExpressionGraph<
|
|
|
373
409
|
destroy(): void {
|
|
374
410
|
// A running program owns evaluator resources until execution finishes.
|
|
375
411
|
assert(!this.running);
|
|
412
|
+
this.cpuExecution?.destroy();
|
|
376
413
|
this.destroyed = true;
|
|
377
414
|
}
|
|
378
415
|
}
|
|
@@ -39,6 +39,7 @@ export type SimpleOperation =
|
|
|
39
39
|
export class SimpleGraphLowering {
|
|
40
40
|
readonly owned = new Set<GPUDataEvaluator | GPUVectorEvaluator>();
|
|
41
41
|
readonly outputs = new Map<string, GPUSimpleGraphOperation>();
|
|
42
|
+
readonly inputs = new Map<string, GPUDataEvaluator | GPUVectorEvaluator>();
|
|
42
43
|
private readonly graphValues = new Map<GPUSimpleGraphValue, GPUDataEvaluator>();
|
|
43
44
|
private readonly scalars = new Map<object, GPUDataEvaluator>();
|
|
44
45
|
private readonly vectors = new Map<object, GPUVectorEvaluator>();
|
|
@@ -188,6 +189,15 @@ export class SimpleGraphLowering {
|
|
|
188
189
|
// Semantic output IDs and explicitly wrapped evaluator IDs share one namespace.
|
|
189
190
|
assert(!this.outputs.has(id));
|
|
190
191
|
this.outputs.set(id, new GPUSimpleGraphOperation({id, evaluator}));
|
|
192
|
+
const chunks =
|
|
193
|
+
evaluator instanceof GPUVectorEvaluator ? evaluator.gpuDataEvaluators : [evaluator];
|
|
194
|
+
if (chunks.every(chunk => !chunk.source)) this.registerInput(id, evaluator);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private registerInput(id: string, evaluator: GPUDataEvaluator | GPUVectorEvaluator): void {
|
|
198
|
+
// An invalidation name must identify exactly one input, including semantic vector bindings.
|
|
199
|
+
assert(!this.inputs.has(id) || this.inputs.get(id) === evaluator);
|
|
200
|
+
this.inputs.set(id, evaluator);
|
|
191
201
|
}
|
|
192
202
|
|
|
193
203
|
private resolveVector(vector: GPUGraphVector<'float32'>): GPUVectorEvaluator {
|
|
@@ -215,6 +225,7 @@ export class SimpleGraphLowering {
|
|
|
215
225
|
);
|
|
216
226
|
this.owned.add(evaluator);
|
|
217
227
|
this.vectors.set(vector, evaluator);
|
|
228
|
+
this.registerInput(vector.id, evaluator);
|
|
218
229
|
return evaluator;
|
|
219
230
|
}
|
|
220
231
|
}
|