@luma.gl/graph 10.0.0-alpha.10 → 10.0.0-alpha.12

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.
Files changed (240) hide show
  1. package/dist/arrow/cpu/arrow-coordinate-projection.cjs +30 -0
  2. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts +5 -0
  3. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts.map +1 -0
  4. package/dist/arrow/cpu/arrow-coordinate-projection.js +9 -0
  5. package/dist/arrow/cpu/arrow-coordinate-projection.js.map +1 -0
  6. package/dist/arrow/cpu/arrow-cpu-pipelines.cjs +31 -0
  7. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts +2 -0
  8. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts.map +1 -0
  9. package/dist/arrow/cpu/arrow-cpu-pipelines.js +5 -0
  10. package/dist/arrow/cpu/arrow-cpu-pipelines.js.map +1 -0
  11. package/dist/arrow/cpu/arrow-cpu-vector-adapters.cjs +99 -0
  12. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts +9 -0
  13. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts.map +1 -0
  14. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js +100 -0
  15. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js.map +1 -0
  16. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +10 -371
  17. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +9 -28
  18. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -1
  19. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +5 -381
  20. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -1
  21. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +11 -11
  22. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +2 -0
  23. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -1
  24. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +3 -3
  25. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -1
  26. package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +2 -2
  27. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +1 -1
  28. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -1
  29. package/dist/arrow/index.cjs +17 -2
  30. package/dist/arrow/index.cjs.map +3 -3
  31. package/dist/arrow/index.d.ts +3 -0
  32. package/dist/arrow/index.d.ts.map +1 -1
  33. package/dist/arrow/index.js +3 -0
  34. package/dist/arrow/index.js.map +1 -1
  35. package/dist/arrow/internal.cjs.map +2 -2
  36. package/dist/dist.dev.js +1233 -442
  37. package/dist/dist.min.js +126 -108
  38. package/dist/experimental/index.cjs.map +1 -1
  39. package/dist/experimental/simulation/index.cjs.map +1 -1
  40. package/dist/gpu-core/compiled-gpu-graph.cjs +47 -0
  41. package/dist/gpu-core/compiled-gpu-graph.d.ts +5 -0
  42. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  43. package/dist/gpu-core/compiled-gpu-graph.js +54 -1
  44. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +28 -7
  46. package/dist/gpu-core/gpu-command-graph.d.ts +13 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +33 -7
  49. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  50. package/dist/gpu-core/gpu-cpu-execution.cjs +279 -0
  51. package/dist/gpu-core/gpu-cpu-execution.d.ts +22 -0
  52. package/dist/gpu-core/gpu-cpu-execution.d.ts.map +1 -0
  53. package/dist/gpu-core/gpu-cpu-execution.js +294 -0
  54. package/dist/gpu-core/gpu-cpu-execution.js.map +1 -0
  55. package/dist/gpu-core/gpu-cpu-operation.cjs +54 -0
  56. package/dist/gpu-core/gpu-cpu-operation.d.ts +40 -0
  57. package/dist/gpu-core/gpu-cpu-operation.d.ts.map +1 -0
  58. package/dist/gpu-core/gpu-cpu-operation.js +35 -0
  59. package/dist/gpu-core/gpu-cpu-operation.js.map +1 -0
  60. package/dist/gpu-core/gpu-expression-operation.cjs +2 -2
  61. package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
  62. package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
  63. package/dist/gpu-core/gpu-expression-operation.js +1 -1
  64. package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
  65. package/dist/gpu-core/gpu-expression-plan.cjs +5 -1
  66. package/dist/gpu-core/gpu-expression-plan.d.ts +3 -2
  67. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  68. package/dist/gpu-core/gpu-expression-plan.js +7 -1
  69. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  70. package/dist/gpu-core/gpu-graph.d.ts +2 -2
  71. package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
  72. package/dist/gpu-core/gpu-graph.js.map +1 -1
  73. package/dist/gpu-core/gpu-operation.d.ts +4 -4
  74. package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
  75. package/dist/gpu-core/gpu-operation.js.map +1 -1
  76. package/dist/gpu-core/gpu-render-operation.cjs +39 -0
  77. package/dist/gpu-core/gpu-render-operation.d.ts +21 -0
  78. package/dist/gpu-core/gpu-render-operation.d.ts.map +1 -0
  79. package/dist/gpu-core/gpu-render-operation.js +22 -0
  80. package/dist/gpu-core/gpu-render-operation.js.map +1 -0
  81. package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
  82. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
  83. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
  84. package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
  85. package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
  86. package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
  87. package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
  88. package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
  89. package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
  90. package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
  91. package/dist/gpu-core/gpu-texture-plan.d.ts +3 -2
  92. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
  93. package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
  94. package/dist/gpu-core/index.cjs +9 -0
  95. package/dist/gpu-core/index.cjs.map +3 -3
  96. package/dist/gpu-core/index.d.ts +6 -0
  97. package/dist/gpu-core/index.d.ts.map +1 -1
  98. package/dist/gpu-core/index.js +3 -0
  99. package/dist/gpu-core/index.js.map +1 -1
  100. package/dist/gpu-data/cpu-data.cjs +60 -0
  101. package/dist/gpu-data/cpu-data.d.ts +28 -0
  102. package/dist/gpu-data/cpu-data.d.ts.map +1 -0
  103. package/dist/gpu-data/cpu-data.js +41 -0
  104. package/dist/gpu-data/cpu-data.js.map +1 -0
  105. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
  106. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
  107. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
  108. package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
  109. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
  110. package/dist/gpu-data/cpu-vector.cjs +42 -0
  111. package/dist/gpu-data/cpu-vector.d.ts +17 -0
  112. package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
  113. package/dist/gpu-data/cpu-vector.js +21 -0
  114. package/dist/gpu-data/cpu-vector.js.map +1 -0
  115. package/dist/gpu-data/index.cjs +13 -2
  116. package/dist/gpu-data/index.cjs.map +3 -3
  117. package/dist/gpu-data/index.d.ts +3 -0
  118. package/dist/gpu-data/index.d.ts.map +1 -1
  119. package/dist/gpu-data/index.js +3 -0
  120. package/dist/gpu-data/index.js.map +1 -1
  121. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  122. package/dist/gpu-graph/index.cjs +3 -0
  123. package/dist/gpu-graph/index.cjs.map +3 -3
  124. package/dist/gpu-graph/index.d.ts +2 -0
  125. package/dist/gpu-graph/index.d.ts.map +1 -1
  126. package/dist/gpu-graph/index.js +1 -0
  127. package/dist/gpu-graph/index.js.map +1 -1
  128. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  129. package/dist/gpu-physics/index.cjs.map +1 -1
  130. package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
  131. package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
  132. package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
  133. package/dist/gpu-project/coordinate-projection-graph.js +40 -0
  134. package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
  135. package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
  136. package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
  137. package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
  138. package/dist/gpu-project/cpu-geoarrow.js +103 -0
  139. package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
  140. package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
  141. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
  142. package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
  143. package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
  144. package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
  145. package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
  146. package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
  147. package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
  148. package/dist/gpu-project/cpu-projection-operation.js +37 -0
  149. package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
  150. package/dist/gpu-project/geoarrow.cjs +36 -0
  151. package/dist/gpu-project/geoarrow.cjs.map +6 -0
  152. package/dist/gpu-project/geoarrow.d.ts +3 -0
  153. package/dist/gpu-project/geoarrow.d.ts.map +1 -0
  154. package/dist/gpu-project/geoarrow.js +7 -0
  155. package/dist/gpu-project/geoarrow.js.map +1 -0
  156. package/dist/gpu-project/graph.cjs +27 -0
  157. package/dist/gpu-project/graph.cjs.map +6 -0
  158. package/dist/gpu-project/graph.d.ts +2 -0
  159. package/dist/gpu-project/graph.d.ts.map +1 -0
  160. package/dist/gpu-project/graph.js +6 -0
  161. package/dist/gpu-project/graph.js.map +1 -0
  162. package/dist/gpu-project/index.cjs +3 -0
  163. package/dist/gpu-project/index.cjs.map +3 -3
  164. package/dist/gpu-project/index.d.ts +1 -0
  165. package/dist/gpu-project/index.d.ts.map +1 -1
  166. package/dist/gpu-project/index.js +1 -0
  167. package/dist/gpu-project/index.js.map +1 -1
  168. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +75 -5
  169. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +5 -1
  170. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  171. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +86 -6
  172. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  173. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
  174. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
  175. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
  176. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
  177. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
  178. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
  179. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
  180. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  181. package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
  182. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  183. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  184. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
  185. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
  186. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  187. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
  188. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  189. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
  190. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
  191. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
  192. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
  193. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
  194. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
  195. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  196. package/dist/index.cjs +6 -0
  197. package/dist/index.cjs.map +3 -3
  198. package/dist/index.d.ts +4 -0
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +2 -0
  201. package/dist/index.js.map +1 -1
  202. package/package.json +17 -6
  203. package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
  204. package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
  205. package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
  206. package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
  207. package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
  208. package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
  209. package/src/arrow/index.ts +11 -0
  210. package/src/gpu-core/compiled-gpu-graph.ts +73 -1
  211. package/src/gpu-core/gpu-command-graph.ts +37 -7
  212. package/src/gpu-core/gpu-cpu-execution.ts +345 -0
  213. package/src/gpu-core/gpu-cpu-operation.ts +65 -0
  214. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  215. package/src/gpu-core/gpu-expression-plan.ts +11 -3
  216. package/src/gpu-core/gpu-graph.ts +3 -3
  217. package/src/gpu-core/gpu-operation.ts +9 -7
  218. package/src/gpu-core/gpu-render-operation.ts +42 -0
  219. package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
  220. package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
  221. package/src/gpu-core/gpu-texture-plan.ts +3 -2
  222. package/src/gpu-core/index.ts +12 -0
  223. package/src/gpu-data/cpu-data.ts +62 -0
  224. package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
  225. package/src/gpu-data/cpu-vector.ts +31 -0
  226. package/src/gpu-data/index.ts +5 -0
  227. package/src/gpu-graph/index.ts +8 -0
  228. package/src/gpu-project/coordinate-projection-graph.ts +59 -0
  229. package/src/gpu-project/cpu-geoarrow.ts +135 -0
  230. package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
  231. package/src/gpu-project/cpu-projection-operation.ts +49 -0
  232. package/src/gpu-project/geoarrow.ts +11 -0
  233. package/src/gpu-project/graph.ts +10 -0
  234. package/src/gpu-project/index.ts +2 -0
  235. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +97 -6
  236. package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
  237. package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
  238. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
  239. package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
  240. package/src/index.ts +10 -0
@@ -0,0 +1,107 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {assert, Buffer, type Device, type BufferProps} from '@luma.gl/core';
6
+ import {CPUData} from './cpu-data';
7
+ import {CPUVector} from './cpu-vector';
8
+ import {GPUData} from './gpu-data';
9
+ import {GPUVector} from './gpu-vector';
10
+ import {getGPUVectorFormatInfo, type GPUVectorFormat} from './gpu-vector-format';
11
+
12
+ /** Explicit upload preserving chunk-local list offsets and validity metadata. */
13
+ export function makeGPUVectorFromCPUVector<T extends GPUVectorFormat>(
14
+ device: Device,
15
+ vector: CPUVector<T>,
16
+ options: Pick<BufferProps, 'usage' | 'indexType'> = {}
17
+ ): GPUVector<T> {
18
+ const data: GPUData<T>[] = [];
19
+ try {
20
+ for (const chunk of vector.data) {
21
+ const info = getGPUVectorFormatInfo(vector.format);
22
+ const inferredIndexType =
23
+ info.elementFormat === 'uint32'
24
+ ? 'uint32'
25
+ : info.elementFormat === 'uint16'
26
+ ? 'uint16'
27
+ : undefined;
28
+ // Index usage must match stored elements; raw bytes must never trigger device conversion.
29
+ if ((options.usage ?? 0) & Buffer.INDEX)
30
+ assert(
31
+ inferredIndexType && (!options.indexType || options.indexType === inferredIndexType)
32
+ );
33
+ const count = info.vertexList || info.valueList ? chunk.valueLength : chunk.length;
34
+ const bytes = new Uint8Array(count * info.byteLength);
35
+ for (let index = 0; index < count; index++)
36
+ bytes.set(
37
+ new Uint8Array(
38
+ chunk.buffer,
39
+ chunk.byteOffset + index * chunk.byteStride,
40
+ info.byteLength
41
+ ),
42
+ index * info.byteLength
43
+ );
44
+ data.push(
45
+ new GPUData({
46
+ buffer: device.createBuffer({
47
+ data: bytes.length ? bytes : new Uint8Array(4),
48
+ usage:
49
+ Buffer.COPY_SRC |
50
+ Buffer.COPY_DST |
51
+ Buffer.STORAGE |
52
+ Buffer.VERTEX |
53
+ (options.usage ?? 0),
54
+ indexType:
55
+ options.indexType ??
56
+ ((options.usage ?? 0) & Buffer.INDEX ? inferredIndexType : undefined)
57
+ }),
58
+ format: vector.format,
59
+ length: chunk.length,
60
+ valueLength: chunk.valueLength,
61
+ valueOffsets: chunk.valueOffsets?.slice(),
62
+ nullBitmap: chunk.nullBitmap?.slice(),
63
+ ownsBuffer: true
64
+ })
65
+ );
66
+ }
67
+ return new GPUVector({
68
+ type: 'data',
69
+ name: vector.name,
70
+ format: vector.format,
71
+ data,
72
+ ownsData: true
73
+ });
74
+ } catch (error) {
75
+ for (const chunk of data) chunk.destroy();
76
+ throw error;
77
+ }
78
+ }
79
+
80
+ /** Explicit asynchronous readback preserving physical formats, chunks, lists and parent validity. */
81
+ export async function makeCPUVectorFromGPUVector<T extends GPUVectorFormat>(
82
+ vector: GPUVector<T>
83
+ ): Promise<CPUVector<T>> {
84
+ const data: CPUData<T>[] = [];
85
+ for (const chunk of vector.data) {
86
+ const info = getGPUVectorFormatInfo(vector.format!);
87
+ const count = info.vertexList || info.valueList ? chunk.valueLength : chunk.length;
88
+ const bytes = count
89
+ ? await chunk.buffer.readAsync(
90
+ chunk.byteOffset,
91
+ (count - 1) * chunk.byteStride + info.byteLength
92
+ )
93
+ : new Uint8Array(0);
94
+ data.push(
95
+ new CPUData({
96
+ buffer: bytes,
97
+ format: vector.format!,
98
+ length: chunk.length,
99
+ valueLength: chunk.valueLength,
100
+ byteStride: chunk.byteStride,
101
+ valueOffsets: chunk.valueOffsets?.slice(),
102
+ nullBitmap: chunk.nullBitmap?.slice()
103
+ })
104
+ );
105
+ }
106
+ return new CPUVector({name: vector.name, format: vector.format!, data});
107
+ }
@@ -0,0 +1,31 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {assert} from '@luma.gl/core';
6
+ import {CPUData} from './cpu-data';
7
+ import type {GPUVectorFormat} from './gpu-vector-format';
8
+
9
+ export type CPUVectorProps<T extends GPUVectorFormat = GPUVectorFormat> = {
10
+ name?: string;
11
+ format: T;
12
+ data: readonly CPUData<T>[];
13
+ };
14
+
15
+ /** Ordered borrowed CPU chunks. Construction preserves buffers and chunk boundaries. */
16
+ export class CPUVector<T extends GPUVectorFormat = GPUVectorFormat> {
17
+ readonly name: string;
18
+ readonly format: T;
19
+ readonly data: readonly CPUData<T>[];
20
+ readonly length: number;
21
+ readonly valueLength: number;
22
+
23
+ constructor(props: CPUVectorProps<T>) {
24
+ assert(props.data.every(chunk => chunk.format === props.format));
25
+ this.name = props.name ?? '';
26
+ this.format = props.format;
27
+ this.data = Object.freeze([...props.data]);
28
+ this.length = this.data.reduce((total, chunk) => total + chunk.length, 0);
29
+ this.valueLength = this.data.reduce((total, chunk) => total + chunk.valueLength, 0);
30
+ }
31
+ }
@@ -68,3 +68,8 @@ export {
68
68
  export {getGPUVectorChunks, type GPUVectorChunk} from './gpu-vector-chunks';
69
69
 
70
70
  export type {GPUVectorLike, GPUVectorInput} from './gpu-vector-like';
71
+
72
+ export {CPUData, type CPUDataProps} from './cpu-data';
73
+ export {CPUVector, type CPUVectorProps} from './cpu-vector';
74
+
75
+ export {makeGPUVectorFromCPUVector, makeCPUVectorFromGPUVector} from './cpu-gpu-vector-transfer';
@@ -74,3 +74,11 @@ export type {
74
74
  } from '../gpu-core/gpu-operation-contract';
75
75
 
76
76
  export {CompiledGPUGraph, PreparedGPUGraphExecution} from '../gpu-core/compiled-gpu-graph';
77
+
78
+ export {GPUCPUOperation} from '../gpu-core/gpu-cpu-operation';
79
+ export type {
80
+ GPUCPUOperationProps,
81
+ GPUCPUArray,
82
+ GPUCPUVector,
83
+ GPUCPUResult
84
+ } from '../gpu-core/gpu-cpu-operation';
@@ -0,0 +1,59 @@
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, type Device} from '@luma.gl/core';
7
+ import {CPUVector, GPUVector} from '@luma.gl/graph/gpu-data';
8
+ import {GPUSimpleGraph} from '../gpu-simple-graph/gpu-simple-graph';
9
+ import {GPUGraph} from '../gpu-core/gpu-graph';
10
+ import type {CompiledGPUGraph} from '../gpu-core/compiled-gpu-graph';
11
+ import type {CompiledGPUSimpleExpressionGraph} from '../gpu-simple-graph/compiled-gpu-expression-graph';
12
+ import {gpuGraph} from '../gpu-core/gpu-graph-value';
13
+ import {CPUProjectionOperation, type CPUProjectionOperationProps} from './cpu-projection-operation';
14
+
15
+ export type CoordinateProjectionGraphProps = {
16
+ format: 'float32x2' | 'float32x3';
17
+ projection: CPUProjectionOperationProps['projection'];
18
+ };
19
+ export type ProjectedCoordinateResult = {
20
+ positions: GPUVector;
21
+ /** Release this invocation's GPU result after downstream consumers finish. */
22
+ destroy(): void;
23
+ };
24
+
25
+ /** Reusable layer-facing point-coordinate pipeline. Projection loading remains caller-owned. */
26
+ export class CoordinateProjectionGraph {
27
+ private readonly graph: CompiledGPUGraph | CompiledGPUSimpleExpressionGraph;
28
+ readonly format: CoordinateProjectionGraphProps['format'];
29
+
30
+ constructor(device: Device, props: CoordinateProjectionGraphProps) {
31
+ this.format = props.format;
32
+ const graph = device.type === 'webgpu' ? new GPUGraph() : new GPUSimpleGraph();
33
+ graph.addInput('source', gpuGraph.vector(props.format));
34
+ graph.add(
35
+ new CPUProjectionOperation({
36
+ id: 'project-coordinates',
37
+ input: 'source',
38
+ output: 'positions',
39
+ format: props.format,
40
+ projection: props.projection
41
+ })
42
+ );
43
+ this.graph = graph.compile(device, {outputs: ['positions']});
44
+ }
45
+
46
+ /** Borrow input storage and preserve row/chunk boundaries; each result owns independent storage. */
47
+ async run(source: CPUVector | GPUVector): Promise<ProjectedCoordinateResult> {
48
+ assert(source.format === this.format);
49
+ // Point layers must handle null filtering before this numeric projection boundary.
50
+ assert(source.data.every(chunk => !chunk.nullBitmap && !chunk.valueOffsets));
51
+ const {positions} = await this.graph.run({inputs: {source}});
52
+ return {positions, destroy: () => positions.destroy()};
53
+ }
54
+
55
+ /** Destroy the compiled pipeline. Previously returned results remain caller-owned. */
56
+ destroy(): void {
57
+ this.graph.destroy();
58
+ }
59
+ }
@@ -0,0 +1,135 @@
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 {
9
+ GeoArrowColumn,
10
+ GeoArrowDimension,
11
+ GeoArrowArray,
12
+ GeoArrowFixedSizeList
13
+ } from '@math.gl/arrow/geoarrow-utils';
14
+
15
+ /** Borrow CPU coordinate chunks as native GeoArrow points or single-level coordinate lists. */
16
+ export function makeGeoArrowColumnFromCPUVector(
17
+ vector: CPUVector,
18
+ options: {
19
+ encoding?:
20
+ | 'geoarrow.point'
21
+ | 'geoarrow.linestring'
22
+ | 'geoarrow.multipoint'
23
+ | 'geoarrow.polygon';
24
+ dimension?: GeoArrowDimension;
25
+ } = {}
26
+ ): GeoArrowColumn {
27
+ const info = getGPUVectorFormatInfo(vector.format);
28
+ assert(info.signedDataType === 'float32' && info.components >= 2 && !info.fixedSizeList);
29
+ const variable = info.vertexList || info.valueList;
30
+ const encoding = options.encoding ?? (variable ? 'geoarrow.linestring' : 'geoarrow.point');
31
+ assert(variable === (encoding !== 'geoarrow.point'));
32
+ const dimension =
33
+ options.dimension ?? (info.components === 2 ? 'xy' : info.components === 3 ? 'xyz' : 'xyzm');
34
+ assert((dimension === 'xy' ? 2 : dimension === 'xyzm' ? 4 : 3) === info.components);
35
+ const chunks = vector.data.map(chunk => {
36
+ // GeoArrow primitive scalar stride cannot express padding between coordinate tuples.
37
+ const packed = chunk.byteStride === info.byteLength && chunk.byteOffset % 4 === 0;
38
+ const count = variable ? chunk.valueLength : chunk.length;
39
+ let values: Float32Array;
40
+ if (packed) values = new Float32Array(chunk.buffer, chunk.byteOffset, count * info.components);
41
+ else {
42
+ values = new Float32Array(count * info.components);
43
+ const bytes = new Uint8Array(values.buffer);
44
+ for (let index = 0; index < count; index++)
45
+ bytes.set(
46
+ new Uint8Array(
47
+ chunk.buffer,
48
+ chunk.byteOffset + index * chunk.byteStride,
49
+ info.byteLength
50
+ ),
51
+ index * info.byteLength
52
+ );
53
+ }
54
+ const coordinates: GeoArrowFixedSizeList = {
55
+ kind: 'fixed-size-list',
56
+ length: count,
57
+ size: info.components,
58
+ child: {
59
+ kind: 'primitive',
60
+ length: count * info.components,
61
+ values
62
+ }
63
+ };
64
+ const validity = chunk.nullBitmap ? {values: chunk.nullBitmap} : undefined;
65
+ if (!variable) return {...coordinates, validity};
66
+ assert(chunk.valueOffsets);
67
+ const rings: GeoArrowArray = {
68
+ kind: 'list',
69
+ length: chunk.length,
70
+ offsets: chunk.valueOffsets,
71
+ child: coordinates,
72
+ validity
73
+ };
74
+ return encoding === 'geoarrow.polygon'
75
+ ? {
76
+ kind: 'list' as const,
77
+ length: chunk.length,
78
+ offsets: Int32Array.from({length: chunk.length + 1}, (_, index) => index),
79
+ child: rings,
80
+ validity
81
+ }
82
+ : rings;
83
+ });
84
+ return {encoding, dimension, coordinateLayout: 'interleaved', chunks};
85
+ }
86
+
87
+ /** Borrow packed Float32 GeoArrow points/lines/multipoints as CPU chunks. Nested polygons stay GeoArrow. */
88
+ export function makeCPUVectorFromGeoArrowColumn(column: GeoArrowColumn): CPUVector {
89
+ assert(
90
+ column.coordinateLayout === 'interleaved' &&
91
+ ['geoarrow.point', 'geoarrow.linestring', 'geoarrow.multipoint'].includes(column.encoding)
92
+ );
93
+ const components = column.dimension === 'xy' ? 2 : column.dimension === 'xyzm' ? 4 : 3;
94
+ const variable = column.encoding !== 'geoarrow.point';
95
+ const element = `float32x${components}` as 'float32x2' | 'float32x3' | 'float32x4';
96
+ const format = variable ? (`vertex-list<${element}>` as const) : element;
97
+ const data = column.chunks.map(chunk => {
98
+ assert(!chunk.validity?.bitOffset);
99
+ const coordinates = variable && chunk.kind === 'list' ? chunk.child : chunk;
100
+ assert(
101
+ coordinates.kind === 'fixed-size-list' &&
102
+ coordinates.size === components &&
103
+ !coordinates.offset &&
104
+ (!variable || !coordinates.validity)
105
+ );
106
+ const primitive = coordinates.child;
107
+ assert(
108
+ primitive.kind === 'primitive' &&
109
+ primitive.values instanceof Float32Array &&
110
+ !primitive.validity &&
111
+ (!primitive.stride || primitive.stride === 1)
112
+ );
113
+ const offset = primitive.offset ?? 0;
114
+ const values = primitive.values.subarray(offset, offset + coordinates.length * components);
115
+ let valueOffsets: Int32Array | undefined;
116
+ if (variable) {
117
+ assert(
118
+ chunk.kind === 'list' &&
119
+ chunk.offsets instanceof Int32Array &&
120
+ !chunk.offset &&
121
+ !chunk.offsetBase
122
+ );
123
+ valueOffsets = chunk.offsets;
124
+ }
125
+ return new CPUData({
126
+ buffer: values,
127
+ format,
128
+ length: chunk.length,
129
+ valueLength: variable ? coordinates.length : undefined,
130
+ valueOffsets,
131
+ nullBitmap: chunk.validity?.values
132
+ });
133
+ });
134
+ return new CPUVector({format, data});
135
+ }
@@ -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';
@@ -84,3 +84,5 @@ export type {
84
84
  GPUProjectionProps,
85
85
  GPUProjectionValidity
86
86
  } from './gpu-projection';
87
+
88
+ export {CPUProjectionOperation, type CPUProjectionOperationProps} from './cpu-projection-operation';