@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.
Files changed (228) 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 +533 -108
  37. package/dist/dist.min.js +70 -70
  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 +32 -0
  41. package/dist/gpu-core/compiled-gpu-graph.d.ts +4 -0
  42. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  43. package/dist/gpu-core/compiled-gpu-graph.js +39 -1
  44. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +19 -7
  46. package/dist/gpu-core/gpu-command-graph.d.ts +11 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +24 -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 +1 -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 +2 -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-texture-plan.d.ts +3 -2
  82. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
  83. package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
  84. package/dist/gpu-core/index.cjs +6 -0
  85. package/dist/gpu-core/index.cjs.map +3 -3
  86. package/dist/gpu-core/index.d.ts +4 -0
  87. package/dist/gpu-core/index.d.ts.map +1 -1
  88. package/dist/gpu-core/index.js +2 -0
  89. package/dist/gpu-core/index.js.map +1 -1
  90. package/dist/gpu-data/cpu-data.cjs +60 -0
  91. package/dist/gpu-data/cpu-data.d.ts +28 -0
  92. package/dist/gpu-data/cpu-data.d.ts.map +1 -0
  93. package/dist/gpu-data/cpu-data.js +41 -0
  94. package/dist/gpu-data/cpu-data.js.map +1 -0
  95. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
  96. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
  97. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
  98. package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
  99. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
  100. package/dist/gpu-data/cpu-vector.cjs +42 -0
  101. package/dist/gpu-data/cpu-vector.d.ts +17 -0
  102. package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
  103. package/dist/gpu-data/cpu-vector.js +21 -0
  104. package/dist/gpu-data/cpu-vector.js.map +1 -0
  105. package/dist/gpu-data/index.cjs +13 -2
  106. package/dist/gpu-data/index.cjs.map +3 -3
  107. package/dist/gpu-data/index.d.ts +3 -0
  108. package/dist/gpu-data/index.d.ts.map +1 -1
  109. package/dist/gpu-data/index.js +3 -0
  110. package/dist/gpu-data/index.js.map +1 -1
  111. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  112. package/dist/gpu-graph/index.cjs +3 -0
  113. package/dist/gpu-graph/index.cjs.map +3 -3
  114. package/dist/gpu-graph/index.d.ts +2 -0
  115. package/dist/gpu-graph/index.d.ts.map +1 -1
  116. package/dist/gpu-graph/index.js +1 -0
  117. package/dist/gpu-graph/index.js.map +1 -1
  118. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  119. package/dist/gpu-physics/index.cjs.map +1 -1
  120. package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
  121. package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
  122. package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
  123. package/dist/gpu-project/coordinate-projection-graph.js +40 -0
  124. package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
  125. package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
  126. package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
  127. package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
  128. package/dist/gpu-project/cpu-geoarrow.js +103 -0
  129. package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
  130. package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
  131. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
  132. package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
  133. package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
  134. package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
  135. package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
  136. package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
  137. package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
  138. package/dist/gpu-project/cpu-projection-operation.js +37 -0
  139. package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
  140. package/dist/gpu-project/geoarrow.cjs +36 -0
  141. package/dist/gpu-project/geoarrow.cjs.map +6 -0
  142. package/dist/gpu-project/geoarrow.d.ts +3 -0
  143. package/dist/gpu-project/geoarrow.d.ts.map +1 -0
  144. package/dist/gpu-project/geoarrow.js +7 -0
  145. package/dist/gpu-project/geoarrow.js.map +1 -0
  146. package/dist/gpu-project/graph.cjs +27 -0
  147. package/dist/gpu-project/graph.cjs.map +6 -0
  148. package/dist/gpu-project/graph.d.ts +2 -0
  149. package/dist/gpu-project/graph.d.ts.map +1 -0
  150. package/dist/gpu-project/graph.js +6 -0
  151. package/dist/gpu-project/graph.js.map +1 -0
  152. package/dist/gpu-project/index.cjs +3 -0
  153. package/dist/gpu-project/index.cjs.map +3 -3
  154. package/dist/gpu-project/index.d.ts +1 -0
  155. package/dist/gpu-project/index.d.ts.map +1 -1
  156. package/dist/gpu-project/index.js +1 -0
  157. package/dist/gpu-project/index.js.map +1 -1
  158. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +24 -2
  159. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +2 -0
  160. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  161. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +29 -2
  162. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  163. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
  164. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
  165. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
  166. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
  167. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
  168. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
  169. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
  170. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  171. package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
  172. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  173. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  174. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
  175. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
  176. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  177. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
  178. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  179. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
  180. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
  181. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
  182. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
  183. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
  184. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
  185. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  186. package/dist/index.cjs +3 -0
  187. package/dist/index.cjs.map +3 -3
  188. package/dist/index.d.ts +2 -0
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +1 -0
  191. package/dist/index.js.map +1 -1
  192. package/package.json +17 -6
  193. package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
  194. package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
  195. package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
  196. package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
  197. package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
  198. package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
  199. package/src/arrow/index.ts +11 -0
  200. package/src/gpu-core/compiled-gpu-graph.ts +55 -1
  201. package/src/gpu-core/gpu-command-graph.ts +27 -7
  202. package/src/gpu-core/gpu-cpu-execution.ts +345 -0
  203. package/src/gpu-core/gpu-cpu-operation.ts +65 -0
  204. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  205. package/src/gpu-core/gpu-expression-plan.ts +5 -3
  206. package/src/gpu-core/gpu-graph.ts +3 -3
  207. package/src/gpu-core/gpu-operation.ts +9 -7
  208. package/src/gpu-core/gpu-render-operation.ts +42 -0
  209. package/src/gpu-core/gpu-texture-plan.ts +3 -2
  210. package/src/gpu-core/index.ts +10 -0
  211. package/src/gpu-data/cpu-data.ts +62 -0
  212. package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
  213. package/src/gpu-data/cpu-vector.ts +31 -0
  214. package/src/gpu-data/index.ts +5 -0
  215. package/src/gpu-graph/index.ts +8 -0
  216. package/src/gpu-project/coordinate-projection-graph.ts +59 -0
  217. package/src/gpu-project/cpu-geoarrow.ts +135 -0
  218. package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
  219. package/src/gpu-project/cpu-projection-operation.ts +49 -0
  220. package/src/gpu-project/geoarrow.ts +11 -0
  221. package/src/gpu-project/graph.ts +10 -0
  222. package/src/gpu-project/index.ts +2 -0
  223. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +39 -2
  224. package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
  225. package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
  226. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
  227. package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
  228. package/src/index.ts +8 -0
@@ -49,30 +49,32 @@ export type GPUGraphOperation =
49
49
  export type GPUOperationLike = GPUGraphOperation | readonly GPUOperationLike[];
50
50
 
51
51
  /** Semantic hierarchy. Grouping never implies synchronization or a command-graph child graph. */
52
- export class GPUCompositeOperation implements GPUOperation {
52
+ export class GPUCompositeOperation<Operation extends GPUGraphOperation = GPUGraphOperation>
53
+ implements GPUOperation
54
+ {
53
55
  readonly id: string;
54
56
  readonly type: string = 'composite';
55
- readonly operations: readonly GPUGraphOperation[];
57
+ readonly operations: readonly Operation[];
56
58
  readonly metadata?: GPUOperationMetadata;
57
59
 
58
60
  constructor(
59
61
  props:
60
- | readonly GPUGraphOperation[]
62
+ | readonly Operation[]
61
63
  | {
62
64
  id?: string;
63
- operations: readonly GPUGraphOperation[];
65
+ operations: readonly Operation[];
64
66
  metadata?: GPUOperationMetadata;
65
67
  }
66
68
  ) {
67
69
  const normalized: {
68
70
  id?: string;
69
- operations: readonly GPUGraphOperation[];
71
+ operations: readonly Operation[];
70
72
  metadata?: GPUOperationMetadata;
71
73
  } = Array.isArray(props)
72
- ? {operations: props as readonly GPUGraphOperation[]}
74
+ ? {operations: props as readonly Operation[]}
73
75
  : (props as {
74
76
  id?: string;
75
- operations: readonly GPUGraphOperation[];
77
+ operations: readonly Operation[];
76
78
  metadata?: GPUOperationMetadata;
77
79
  });
78
80
  this.id = normalized.id ?? 'gpu-composite-operation';
@@ -0,0 +1,42 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {GPUCommandGraph} from './gpu-command-graph';
6
+ import type {GPURenderCommandNode} from './gpu-command-node';
7
+
8
+ /** Resource declarations shared by SimpleGraph and full WebGPU graphs. */
9
+ export type GPURenderOperationResources<Parameters = unknown> = Pick<
10
+ GPUCommandGraph<Parameters>,
11
+ 'device' | 'importBuffer' | 'importTexture' | 'createTransientTexture' | 'createTextureView'
12
+ >;
13
+
14
+ /**
15
+ * A reusable render primitive. Each compilation creates fresh logical resources and executables.
16
+ * Declare every buffer and texture access so the containing graph can schedule its passes.
17
+ * Omit the parameter type for passes that do not inspect application parameters.
18
+ */
19
+ export class GPURenderOperation<Parameters = unknown> {
20
+ readonly type = 'render-operation';
21
+ readonly id: string;
22
+ private readonly createNodes: (
23
+ graph: GPURenderOperationResources<Parameters>
24
+ ) => readonly GPURenderCommandNode<Parameters>[];
25
+
26
+ constructor(props: {
27
+ id: string;
28
+ createNodes: (
29
+ graph: GPURenderOperationResources<Parameters>
30
+ ) => readonly GPURenderCommandNode<Parameters>[];
31
+ }) {
32
+ this.id = props.id;
33
+ this.createNodes = props.createNodes;
34
+ }
35
+
36
+ /** Contributes individual passes to the containing graph; never compiles or submits it. */
37
+ getCommandNodes(
38
+ graph: GPURenderOperationResources<Parameters>
39
+ ): readonly GPURenderCommandNode<Parameters>[] {
40
+ return this.createNodes(graph);
41
+ }
42
+ }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import type {CPUVector} from '../gpu-data/cpu-vector';
5
6
  import {assert, Texture, TextureView, type Device, type TextureViewProps} from '@luma.gl/core';
6
7
  import type {GPUVector} from '@luma.gl/graph/gpu-data';
7
8
  import type {GPUGraphTexture, GPUGraphTextureDescriptor} from './gpu-graph-value';
@@ -10,7 +11,7 @@ import {getGPUOperationValueName} from './gpu-operation-contract';
10
11
  import type {GraphTextureUsage, GraphTextureViewProps} from './gpu-command-graph';
11
12
 
12
13
  export type GPUGraphTextureBinding = Texture | TextureView;
13
- export type GPUGraphOutput = GPUVector | GPUGraphTextureBinding;
14
+ export type GPUGraphOutput = CPUVector | GPUVector | GPUGraphTextureBinding;
14
15
  export type GPUGraphOutputs = Record<string, GPUGraphOutput>;
15
16
 
16
17
  /** Selected view geometry, without creating another view. @internal */
@@ -109,7 +110,7 @@ export class GPUTextureInvocation {
109
110
  device: Device,
110
111
  declarations: readonly GPUGraphTexture[],
111
112
  contracts: readonly GPUOperationContract[],
112
- bindings: Readonly<Record<string, GPUVector | number | GPUGraphTextureBinding>>,
113
+ bindings: Readonly<Record<string, GPUVector | CPUVector | number | GPUGraphTextureBinding>>,
113
114
  targets: Readonly<Record<string, GPUGraphOutput>>
114
115
  ) {
115
116
  const usages = new Map<string, number>();
@@ -653,6 +653,8 @@ export type {
653
653
  export type {GPUResourcePreview} from './gpu-resource-preview';
654
654
 
655
655
  export type {GPUIndexPickInfo} from './gpu-index-picking-target';
656
+ export {GPURenderOperation} from './gpu-render-operation';
657
+ export type {GPURenderOperationResources} from './gpu-render-operation';
656
658
 
657
659
  export {GPUExpressionOperation} from './gpu-expression-operation';
658
660
  export type {GPUExpressionOperationProps, GPUExpressionAST} from './gpu-expression-operation';
@@ -690,3 +692,11 @@ export type {GPUCompactionOperationProps} from './gpu-compaction-operation';
690
692
 
691
693
  export type {GPUGraphTextureDescriptor, GPUGraphTextureExtent} from './gpu-graph-value';
692
694
  export type {GPUGraphTextureBinding, GPUGraphOutput, GPUGraphOutputs} from './gpu-texture-plan';
695
+
696
+ export {GPUCPUOperation} from './gpu-cpu-operation';
697
+ export type {
698
+ GPUCPUOperationProps,
699
+ GPUCPUArray,
700
+ GPUCPUVector,
701
+ GPUCPUResult
702
+ } from './gpu-cpu-operation';
@@ -0,0 +1,62 @@
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 {getGPUVectorFormatInfo, type GPUVectorFormat} from './gpu-vector-format';
7
+
8
+ export type CPUDataProps<T extends GPUVectorFormat = GPUVectorFormat> = {
9
+ buffer: ArrayBuffer | ArrayBufferView;
10
+ format: T;
11
+ length: number;
12
+ valueLength?: number;
13
+ /** Byte offset relative to the supplied buffer or view. */
14
+ byteOffset?: number;
15
+ byteStride?: number;
16
+ rowByteLength?: number;
17
+ valueOffsets?: Int32Array;
18
+ nullBitmap?: Uint8Array;
19
+ };
20
+
21
+ /** Borrowed CPU storage for fixed rows or one level of list elements. No allocation or copying. */
22
+ export class CPUData<T extends GPUVectorFormat = GPUVectorFormat> {
23
+ readonly buffer: ArrayBufferLike;
24
+ readonly format: T;
25
+ readonly length: number;
26
+ readonly valueLength: number;
27
+ /** Absolute offset into buffer. */
28
+ readonly byteOffset: number;
29
+ readonly byteStride: number;
30
+ readonly rowByteLength: number;
31
+ readonly valueOffsets?: Int32Array;
32
+ readonly nullBitmap?: Uint8Array;
33
+
34
+ constructor(props: CPUDataProps<T>) {
35
+ const info = getGPUVectorFormatInfo(props.format);
36
+ const view = ArrayBuffer.isView(props.buffer) ? props.buffer : undefined;
37
+ this.buffer = view ? view.buffer : (props.buffer as ArrayBuffer);
38
+ this.format = props.format;
39
+ this.length = props.length;
40
+ this.valueLength = props.valueLength ?? props.length * (info.listSize ?? 1);
41
+ const offset = props.byteOffset ?? 0;
42
+ this.byteOffset = (view?.byteOffset ?? 0) + offset;
43
+ this.rowByteLength = props.rowByteLength ?? info.byteLength;
44
+ this.byteStride = props.byteStride ?? this.rowByteLength;
45
+ this.valueOffsets = props.valueOffsets;
46
+ this.nullBitmap = props.nullBitmap;
47
+ const variable = info.vertexList || info.valueList;
48
+ const count = variable ? this.valueLength : this.length;
49
+ // Layouts must describe complete rows within the supplied view, including empty ranges.
50
+ assert(
51
+ [this.length, this.valueLength, offset, this.rowByteLength, this.byteStride].every(
52
+ value => Number.isSafeInteger(value) && value >= 0
53
+ )
54
+ );
55
+ assert(this.rowByteLength >= info.byteLength && this.byteStride >= this.rowByteLength);
56
+ assert(variable || this.valueLength === this.length * (info.listSize ?? 1));
57
+ assert(
58
+ offset + (count ? (count - 1) * this.byteStride + this.rowByteLength : 0) <=
59
+ props.buffer.byteLength
60
+ );
61
+ }
62
+ }
@@ -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
+ }