@luma.gl/graph 10.0.0-alpha.13 → 10.0.0-alpha.15

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 (236) hide show
  1. package/dist/arrow/arrow-colors.cjs +99 -18
  2. package/dist/arrow/arrow-colors.d.ts +27 -10
  3. package/dist/arrow/arrow-colors.d.ts.map +1 -1
  4. package/dist/arrow/arrow-colors.js +107 -24
  5. package/dist/arrow/arrow-colors.js.map +1 -1
  6. package/dist/arrow/gpu/arrow-column-gpu-vector.cjs +27 -8
  7. package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts +11 -1
  8. package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts.map +1 -1
  9. package/dist/arrow/gpu/arrow-column-gpu-vector.js +33 -8
  10. package/dist/arrow/gpu/arrow-column-gpu-vector.js.map +1 -1
  11. package/dist/arrow/gpu/arrow-gpu-vector-adapters.cjs +2 -0
  12. package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts +1 -0
  13. package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts.map +1 -1
  14. package/dist/arrow/gpu/arrow-gpu-vector-adapters.js +1 -1
  15. package/dist/arrow/gpu/arrow-gpu-vector-adapters.js.map +1 -1
  16. package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +32 -3
  17. package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +6 -1
  18. package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
  19. package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +37 -3
  20. package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
  21. package/dist/arrow/index.cjs +2 -0
  22. package/dist/arrow/index.cjs.map +3 -3
  23. package/dist/arrow/index.d.ts +1 -1
  24. package/dist/arrow/index.d.ts.map +1 -1
  25. package/dist/arrow/index.js +1 -1
  26. package/dist/arrow/index.js.map +1 -1
  27. package/dist/dist.dev.js +98 -43
  28. package/dist/dist.min.js +63 -63
  29. package/dist/experimental/index.cjs.map +1 -1
  30. package/dist/experimental/simulation/index.cjs.map +1 -1
  31. package/dist/geospatial/gpu-point-spatial-query.cjs +2 -15
  32. package/dist/geospatial/gpu-point-spatial-query.d.ts.map +1 -1
  33. package/dist/geospatial/gpu-point-spatial-query.js +2 -15
  34. package/dist/geospatial/gpu-point-spatial-query.js.map +1 -1
  35. package/dist/geospatial/index.cjs.map +2 -2
  36. package/dist/gpu-a5/index.cjs.map +1 -1
  37. package/dist/gpu-core/gpu-command-graph-compiler.cjs +11 -2
  38. package/dist/gpu-core/gpu-command-graph-compiler.d.ts +2 -1
  39. package/dist/gpu-core/gpu-command-graph-compiler.d.ts.map +1 -1
  40. package/dist/gpu-core/gpu-command-graph-compiler.js +13 -2
  41. package/dist/gpu-core/gpu-command-graph-compiler.js.map +1 -1
  42. package/dist/gpu-core/gpu-command-graph-types.d.ts +16 -1
  43. package/dist/gpu-core/gpu-command-graph-types.d.ts.map +1 -1
  44. package/dist/gpu-core/gpu-command-graph-types.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +6 -4
  46. package/dist/gpu-core/gpu-command-graph.d.ts +4 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +6 -4
  49. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  50. package/dist/gpu-core/gpu-dispatch-utils.cjs +7 -3
  51. package/dist/gpu-core/gpu-dispatch-utils.d.ts +2 -0
  52. package/dist/gpu-core/gpu-dispatch-utils.d.ts.map +1 -1
  53. package/dist/gpu-core/gpu-dispatch-utils.js +4 -1
  54. package/dist/gpu-core/gpu-dispatch-utils.js.map +1 -1
  55. package/dist/gpu-core/gpu-expression-operation.cjs +1 -1
  56. package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
  57. package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
  58. package/dist/gpu-core/gpu-expression-operation.js +1 -1
  59. package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
  60. package/dist/gpu-core/gpu-grid-aggregation.cjs +2 -5
  61. package/dist/gpu-core/gpu-grid-aggregation.d.ts.map +1 -1
  62. package/dist/gpu-core/gpu-grid-aggregation.js +2 -5
  63. package/dist/gpu-core/gpu-grid-aggregation.js.map +1 -1
  64. package/dist/gpu-core/gpu-grid-binning.cjs +2 -5
  65. package/dist/gpu-core/gpu-grid-binning.d.ts.map +1 -1
  66. package/dist/gpu-core/gpu-grid-binning.js +2 -5
  67. package/dist/gpu-core/gpu-grid-binning.js.map +1 -1
  68. package/dist/gpu-core/gpu-grid-coordinate.cjs +41 -0
  69. package/dist/gpu-core/gpu-grid-coordinate.d.ts +7 -0
  70. package/dist/gpu-core/gpu-grid-coordinate.d.ts.map +1 -0
  71. package/dist/gpu-core/gpu-grid-coordinate.js +24 -0
  72. package/dist/gpu-core/gpu-grid-coordinate.js.map +1 -0
  73. package/dist/gpu-core/gpu-grid-index-internals.cjs +2 -15
  74. package/dist/gpu-core/gpu-grid-index-internals.d.ts.map +1 -1
  75. package/dist/gpu-core/gpu-grid-index-internals.js +2 -15
  76. package/dist/gpu-core/gpu-grid-index-internals.js.map +1 -1
  77. package/dist/gpu-core/gpu-grid-index-query.cjs +2 -16
  78. package/dist/gpu-core/gpu-grid-index-query.d.ts.map +1 -1
  79. package/dist/gpu-core/gpu-grid-index-query.js +2 -16
  80. package/dist/gpu-core/gpu-grid-index-query.js.map +1 -1
  81. package/dist/gpu-core/gpu-scan.cjs +46 -32
  82. package/dist/gpu-core/gpu-scan.d.ts.map +1 -1
  83. package/dist/gpu-core/gpu-scan.js +56 -44
  84. package/dist/gpu-core/gpu-scan.js.map +1 -1
  85. package/dist/gpu-core/gpu-segmented-reduction.cjs +12 -9
  86. package/dist/gpu-core/gpu-segmented-reduction.d.ts +1 -1
  87. package/dist/gpu-core/gpu-segmented-reduction.d.ts.map +1 -1
  88. package/dist/gpu-core/gpu-segmented-reduction.js +12 -9
  89. package/dist/gpu-core/gpu-segmented-reduction.js.map +1 -1
  90. package/dist/gpu-core/gpu-segmented-scan.cjs +73 -16
  91. package/dist/gpu-core/gpu-segmented-scan.d.ts.map +1 -1
  92. package/dist/gpu-core/gpu-segmented-scan.js +73 -16
  93. package/dist/gpu-core/gpu-segmented-scan.js.map +1 -1
  94. package/dist/gpu-core/index.cjs +18 -0
  95. package/dist/gpu-core/index.cjs.map +3 -3
  96. package/dist/gpu-core/index.d.ts +13 -1
  97. package/dist/gpu-core/index.d.ts.map +1 -1
  98. package/dist/gpu-core/index.js +6 -0
  99. package/dist/gpu-core/index.js.map +1 -1
  100. package/dist/gpu-data/color-conversion.cjs +105 -0
  101. package/dist/gpu-data/color-conversion.d.ts +30 -0
  102. package/dist/gpu-data/color-conversion.d.ts.map +1 -0
  103. package/dist/gpu-data/color-conversion.js +109 -0
  104. package/dist/gpu-data/color-conversion.js.map +1 -0
  105. package/dist/gpu-data/gpu-vector-wgsl-layout.cjs +50 -0
  106. package/dist/gpu-data/gpu-vector-wgsl-layout.d.ts +41 -0
  107. package/dist/gpu-data/gpu-vector-wgsl-layout.d.ts.map +1 -0
  108. package/dist/gpu-data/gpu-vector-wgsl-layout.js +45 -0
  109. package/dist/gpu-data/gpu-vector-wgsl-layout.js.map +1 -0
  110. package/dist/gpu-data/index.cjs +10 -2
  111. package/dist/gpu-data/index.cjs.map +3 -3
  112. package/dist/gpu-data/index.d.ts +3 -0
  113. package/dist/gpu-data/index.d.ts.map +1 -1
  114. package/dist/gpu-data/index.js +2 -0
  115. package/dist/gpu-data/index.js.map +1 -1
  116. package/dist/gpu-dataframe/gpu-data-frame-query.cjs +1 -16
  117. package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
  118. package/dist/gpu-dataframe/gpu-data-frame-query.js +1 -23
  119. package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
  120. package/dist/gpu-dataframe/gpu-expression.cjs +91 -2
  121. package/dist/gpu-dataframe/gpu-expression.d.ts +37 -0
  122. package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
  123. package/dist/gpu-dataframe/gpu-expression.js +106 -0
  124. package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
  125. package/dist/gpu-dataframe/index.cjs +12 -2
  126. package/dist/gpu-dataframe/index.cjs.map +3 -3
  127. package/dist/gpu-dataframe/index.d.ts +4 -0
  128. package/dist/gpu-dataframe/index.d.ts.map +1 -1
  129. package/dist/gpu-dataframe/index.js +2 -0
  130. package/dist/gpu-dataframe/index.js.map +1 -1
  131. package/dist/gpu-dataframe/portable-expression.cjs +103 -0
  132. package/dist/gpu-dataframe/portable-expression.d.ts +19 -0
  133. package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -0
  134. package/dist/gpu-dataframe/portable-expression.js +98 -0
  135. package/dist/gpu-dataframe/portable-expression.js.map +1 -0
  136. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  137. package/dist/gpu-dggs/index.cjs.map +1 -1
  138. package/dist/gpu-geometry/index.cjs.map +1 -1
  139. package/dist/gpu-graph/index.cjs.map +1 -1
  140. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +2 -2
  141. package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.cjs +2 -15
  142. package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.d.ts.map +1 -1
  143. package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js +2 -15
  144. package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js.map +1 -1
  145. package/dist/gpu-graph-algorithms/index.cjs.map +2 -2
  146. package/dist/gpu-h3/index.cjs.map +1 -1
  147. package/dist/gpu-physics/gpu-rigid-body-world.cjs +3 -1
  148. package/dist/gpu-physics/gpu-rigid-body-world.d.ts +4 -0
  149. package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
  150. package/dist/gpu-physics/gpu-rigid-body-world.js +3 -1
  151. package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
  152. package/dist/gpu-physics/index.cjs.map +1 -1
  153. package/dist/gpu-physics/rigid-body-parallel-shaders.cjs +24 -9
  154. package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts +1 -1
  155. package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts.map +1 -1
  156. package/dist/gpu-physics/rigid-body-parallel-shaders.js +28 -9
  157. package/dist/gpu-physics/rigid-body-parallel-shaders.js.map +1 -1
  158. package/dist/gpu-physics/rigid-body-shaders.cjs +2 -2
  159. package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
  160. package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
  161. package/dist/gpu-physics/rigid-body-shaders.js +2 -2
  162. package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
  163. package/dist/gpu-pointcloud/index.cjs.map +1 -1
  164. package/dist/gpu-project/graph.cjs.map +3 -3
  165. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  166. package/dist/gpu-simple-graph/index.d.ts +1 -1
  167. package/dist/gpu-simple-graph/index.d.ts.map +1 -1
  168. package/dist/gpu-simple-graph/index.js.map +1 -1
  169. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +2 -0
  170. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +3 -0
  171. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  172. package/dist/gpu-simple-graph/operations/convert-colors.cjs +6 -6
  173. package/dist/gpu-simple-graph/operations/convert-colors.d.ts +5 -1
  174. package/dist/gpu-simple-graph/operations/convert-colors.d.ts.map +1 -1
  175. package/dist/gpu-simple-graph/operations/convert-colors.js +12 -7
  176. package/dist/gpu-simple-graph/operations/convert-colors.js.map +1 -1
  177. package/dist/gpu-simple-graph/operations/cpu/convert-colors.cjs +16 -33
  178. package/dist/gpu-simple-graph/operations/cpu/convert-colors.d.ts.map +1 -1
  179. package/dist/gpu-simple-graph/operations/cpu/convert-colors.js +22 -35
  180. package/dist/gpu-simple-graph/operations/cpu/convert-colors.js.map +1 -1
  181. package/dist/gpu-simple-graph/operations/cpu/index.cjs.map +3 -3
  182. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +3 -3
  183. package/dist/gpu-simple-graph/operations/webgpu/convert-colors.cjs +31 -13
  184. package/dist/gpu-simple-graph/operations/webgpu/convert-colors.d.ts.map +1 -1
  185. package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js +42 -13
  186. package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js.map +1 -1
  187. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  188. package/dist/gpu-sql/gpu-sql.cjs +98 -5
  189. package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
  190. package/dist/gpu-sql/gpu-sql.js +100 -5
  191. package/dist/gpu-sql/gpu-sql.js.map +1 -1
  192. package/dist/gpu-sql/index.cjs.map +2 -2
  193. package/dist/gpu-timeseries/index.cjs.map +1 -1
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.d.ts +1 -1
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js.map +1 -1
  198. package/package.json +8 -7
  199. package/src/arrow/arrow-colors.ts +194 -33
  200. package/src/arrow/gpu/arrow-column-gpu-vector.ts +67 -14
  201. package/src/arrow/gpu/arrow-gpu-vector-adapters.ts +3 -1
  202. package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +46 -4
  203. package/src/arrow/index.ts +2 -0
  204. package/src/geospatial/gpu-point-spatial-query.ts +2 -15
  205. package/src/gpu-core/gpu-command-graph-compiler.ts +25 -2
  206. package/src/gpu-core/gpu-command-graph-types.ts +20 -0
  207. package/src/gpu-core/gpu-command-graph.ts +11 -4
  208. package/src/gpu-core/gpu-dispatch-utils.ts +13 -1
  209. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  210. package/src/gpu-core/gpu-grid-aggregation.ts +2 -5
  211. package/src/gpu-core/gpu-grid-binning.ts +2 -5
  212. package/src/gpu-core/gpu-grid-coordinate.ts +24 -0
  213. package/src/gpu-core/gpu-grid-index-internals.ts +2 -15
  214. package/src/gpu-core/gpu-grid-index-query.ts +2 -16
  215. package/src/gpu-core/gpu-scan.ts +59 -45
  216. package/src/gpu-core/gpu-segmented-reduction.ts +20 -10
  217. package/src/gpu-core/gpu-segmented-scan.ts +82 -17
  218. package/src/gpu-core/index.ts +21 -0
  219. package/src/gpu-data/color-conversion.ts +158 -0
  220. package/src/gpu-data/gpu-vector-wgsl-layout.ts +79 -0
  221. package/src/gpu-data/index.ts +10 -0
  222. package/src/gpu-dataframe/gpu-data-frame-query.ts +6 -26
  223. package/src/gpu-dataframe/gpu-expression.ts +135 -0
  224. package/src/gpu-dataframe/index.ts +11 -0
  225. package/src/gpu-dataframe/portable-expression.ts +117 -0
  226. package/src/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.ts +2 -15
  227. package/src/gpu-physics/gpu-rigid-body-world.ts +8 -1
  228. package/src/gpu-physics/rigid-body-parallel-shaders.ts +32 -9
  229. package/src/gpu-physics/rigid-body-shaders.ts +3 -2
  230. package/src/gpu-simple-graph/index.ts +1 -0
  231. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +2 -0
  232. package/src/gpu-simple-graph/operations/convert-colors.ts +22 -7
  233. package/src/gpu-simple-graph/operations/cpu/convert-colors.ts +31 -48
  234. package/src/gpu-simple-graph/operations/webgpu/convert-colors.ts +47 -13
  235. package/src/gpu-sql/gpu-sql.ts +106 -6
  236. package/src/index.ts +2 -0
@@ -10,6 +10,7 @@ import type {
10
10
  GPUCommandGraphCopyExecutable,
11
11
  GPUCommandGraphNode,
12
12
  GPUCommandGraphPreflightReport,
13
+ GPUCommandGraphCompileOptions,
13
14
  GPUCommandGraphRenderExecutable,
14
15
  GPUCommandGraphStats,
15
16
  GPUCommandGraphResourceSummary,
@@ -113,6 +114,7 @@ type GPUCommandGraphCompilerProps<Parameters> = {
113
114
  textures: Map<string, GraphTextureHandle>;
114
115
  externalTextures: Map<string, GraphExternalTextureHandle>;
115
116
  nodes: GPUCommandGraphNode<Parameters>[];
117
+ kernelMetadata?: GPUCommandGraphCompileOptions['kernelMetadata'];
116
118
  };
117
119
 
118
120
  /**
@@ -363,7 +365,12 @@ function finishGPUCommandGraphCompilation<Parameters>(
363
365
  'physical transient resource estimates'
364
366
  )
365
367
  };
366
- const preflight = getGPUCommandGraphPreflightReport(props.device, logicalBuffers, nodeOrder);
368
+ const preflight = getGPUCommandGraphPreflightReport(
369
+ props.device,
370
+ logicalBuffers,
371
+ nodeOrder,
372
+ props.kernelMetadata
373
+ );
367
374
 
368
375
  return {
369
376
  device: props.device,
@@ -421,14 +428,30 @@ function summarizeResource(resource: GraphResourceUse): GPUCommandGraphResourceS
421
428
  function getGPUCommandGraphPreflightReport<Parameters>(
422
429
  device: Device,
423
430
  buffers: GraphBufferHandle[],
424
- nodes: GPUCommandGraphNode<Parameters>[]
431
+ nodes: GPUCommandGraphNode<Parameters>[],
432
+ kernelMetadata: GPUCommandGraphCompileOptions['kernelMetadata']
425
433
  ): GPUCommandGraphPreflightReport {
426
434
  const nodeReports = nodes.map(node => {
427
435
  const workload = node.workload ?? {};
436
+ const kernel = kernelMetadata && node.type === 'compute' ? node.kernel : undefined;
428
437
  return Object.freeze({
429
438
  id: node.id,
430
439
  ...(node.description === undefined ? {} : {description: node.description}),
431
440
  type: node.type,
441
+ ...(kernel && {
442
+ kernel: Object.freeze({
443
+ entryPoint: kernel.entryPoint,
444
+ workgroupSize: Object.freeze([...kernel.workgroupSize] as const),
445
+ bindings: Object.freeze(
446
+ kernel.bindings.map(({name, type, group, location}) =>
447
+ Object.freeze({name, type, group, location})
448
+ )
449
+ ),
450
+ ...(kernelMetadata === 'source' && kernel.source !== undefined
451
+ ? {source: kernel.source}
452
+ : {})
453
+ })
454
+ }),
432
455
  resources: Object.freeze((node.resources ?? []).map(summarizeResource)),
433
456
  ...(workload.operation ? {operation: workload.operation} : {}),
434
457
  ...(workload.variant ? {variant: workload.variant} : {}),
@@ -14,6 +14,7 @@ import type {
14
14
  ExternalTexture,
15
15
  RenderPass,
16
16
  RenderPassProps,
17
+ ComputeShaderLayout,
17
18
  Texture,
18
19
  TextureFormat,
19
20
  TextureView
@@ -612,6 +613,22 @@ export type GPUCommandGraphResourceSummary = Readonly<{
612
613
  depth?: number;
613
614
  }>;
614
615
 
616
+ /** Static description of a compute kernel supplied by a command node. */
617
+ export type GPUCommandGraphKernelMetadata = Readonly<{
618
+ entryPoint: string;
619
+ workgroupSize: readonly [number, number, number];
620
+ bindings: readonly Readonly<
621
+ Pick<ComputeShaderLayout['bindings'][number], 'name' | 'type' | 'group' | 'location'>
622
+ >[];
623
+ source?: string;
624
+ }>;
625
+
626
+ /** Controls which kernel details a compiled graph exposes to inspectors. */
627
+ export type GPUCommandGraphCompileOptions = {
628
+ /** Collect declared kernel metadata. Use 'source' to also include WGSL text. */
629
+ kernelMetadata?: 'layout' | 'source';
630
+ };
631
+
615
632
  /** Immutable per-node workload entry in a compiled graph preflight report. */
616
633
  export type GPUCommandGraphNodePreflight = Readonly<
617
634
  Required<Omit<GPUCommandGraphNodeWorkloadEstimate, 'operation' | 'variant'>> & {
@@ -619,6 +636,7 @@ export type GPUCommandGraphNodePreflight = Readonly<
619
636
  type: GPUCommandGraphNodeType;
620
637
  description?: string;
621
638
  resources?: readonly GPUCommandGraphResourceSummary[];
639
+ kernel?: GPUCommandGraphKernelMetadata;
622
640
  operation?: string;
623
641
  variant?: string;
624
642
  publication?: Readonly<GPUCommandGraphNodePublication>;
@@ -651,6 +669,8 @@ export type GPUCommandGraphComputeNode<Parameters> = GPUCommandGraphNodeBase<
651
669
  > & {
652
670
  /** Node discriminator. */
653
671
  type: 'compute';
672
+ /** Optional kernel details for graph inspection. */
673
+ kernel?: GPUCommandGraphKernelMetadata;
654
674
  /** Creates reusable node resources and the encode callback. */
655
675
  compile: (context: GPUCommandGraphCompileContext) => GPUCommandGraphComputeExecutable<Parameters>;
656
676
  /** Creates reusable node resources through asynchronous backend compilation when available. */
@@ -61,6 +61,7 @@ import type {
61
61
  GPUCommandGraphNodeEncodingStats,
62
62
  GPUCommandGraphNodeTiming,
63
63
  GPUCommandGraphNodePreflight,
64
+ GPUCommandGraphCompileOptions,
64
65
  GPUCommandGraphNodePublication,
65
66
  GPUCommandGraphPreflightReport,
66
67
  GPUCommandGraphRenderExecutable,
@@ -108,6 +109,8 @@ export type {
108
109
  GPUCommandGraphNodeConditionPreflight,
109
110
  GPUCommandGraphNodeEncodingStats,
110
111
  GPUCommandGraphNodePreflight,
112
+ GPUCommandGraphCompileOptions,
113
+ GPUCommandGraphKernelMetadata,
111
114
  GPUCommandGraphResourceSummary,
112
115
  GPUCommandGraphNodePublication,
113
116
  GPUCommandGraphNodeTiming,
@@ -987,7 +990,7 @@ export class GPUCommandGraphBuilder<Parameters = void> {
987
990
  *
988
991
  * @returns An executable graph that owns compiled node state and transient allocations.
989
992
  */
990
- compile(): CompiledGPUCommandGraph<Parameters> {
993
+ compile(options: GPUCommandGraphCompileOptions = {}): CompiledGPUCommandGraph<Parameters> {
991
994
  this.assertMutable();
992
995
  assertDeviceAvailable(this.device, 'compilation');
993
996
  this.compiled = true;
@@ -998,7 +1001,8 @@ export class GPUCommandGraphBuilder<Parameters = void> {
998
1001
  buffers: this.buffers,
999
1002
  textures: this.textures,
1000
1003
  externalTextures: this.externalTextures,
1001
- nodes: this.nodes
1004
+ nodes: this.nodes,
1005
+ kernelMetadata: options.kernelMetadata
1002
1006
  })
1003
1007
  );
1004
1008
  }
@@ -1015,7 +1019,9 @@ export class GPUCommandGraphBuilder<Parameters = void> {
1015
1019
  *
1016
1020
  * @returns An executable graph whose pipelines are ready before the promise resolves.
1017
1021
  */
1018
- async compileAsync(): Promise<CompiledGPUCommandGraph<Parameters>> {
1022
+ async compileAsync(
1023
+ options: GPUCommandGraphCompileOptions = {}
1024
+ ): Promise<CompiledGPUCommandGraph<Parameters>> {
1019
1025
  this.assertMutable();
1020
1026
  assertDeviceAvailable(this.device, 'compilation');
1021
1027
  this.compiled = true;
@@ -1026,7 +1032,8 @@ export class GPUCommandGraphBuilder<Parameters = void> {
1026
1032
  buffers: this.buffers,
1027
1033
  textures: this.textures,
1028
1034
  externalTextures: this.externalTextures,
1029
- nodes: this.nodes
1035
+ nodes: this.nodes,
1036
+ kernelMetadata: options.kernelMetadata
1030
1037
  })
1031
1038
  );
1032
1039
  }
@@ -23,12 +23,24 @@ export function getBoundedDispatchLayout(
23
23
  throw new Error(`${operationName} element count must be a non-negative uint32`);
24
24
  }
25
25
  validateWorkgroupSize(operationName, workgroupSize);
26
+ return getBoundedWorkgroupLayout(
27
+ operationName,
28
+ Math.max(1, Math.ceil(elementCount / workgroupSize)),
29
+ maxComputeWorkgroupsPerDimension
30
+ );
31
+ }
32
+
33
+ /** Plans a bounded dispatch for kernels that index their work directly by workgroup. Requires a positive count. @internal */
34
+ export function getBoundedWorkgroupLayout(
35
+ operationName: string,
36
+ workgroupCount: number,
37
+ maxComputeWorkgroupsPerDimension: number
38
+ ): GPUBoundedDispatchLayout {
26
39
  const maximum = Math.floor(maxComputeWorkgroupsPerDimension);
27
40
  if (!Number.isSafeInteger(maximum) || maximum < 1) {
28
41
  throw new Error('maxComputeWorkgroupsPerDimension must be a positive integer');
29
42
  }
30
43
 
31
- const workgroupCount = Math.max(1, Math.ceil(elementCount / workgroupSize));
32
44
  const x = Math.min(workgroupCount, maximum);
33
45
  const y = Math.min(Math.ceil(workgroupCount / x), maximum);
34
46
  const z = Math.ceil(workgroupCount / x / y);
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
- import {parse, type Expression} from '@math.gl/core/expressions';
5
+ import {parse, type Expression} from '@math.gl/expressions';
6
6
  import {getGPUVectorFormatInfo} from '@luma.gl/graph/gpu-data';
7
7
  import {gpuGraph, type GPUGraphVectorFormat} from './gpu-graph-value';
8
8
  import type {GPUOperationContract} from './gpu-operation-contract';
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import {GPU_GRID_COORDINATE_WGSL} from './gpu-grid-coordinate';
5
6
  import type {GPUCommandNode} from './gpu-command-node';
6
7
  import {
7
8
  GPUCommandGraph,
@@ -346,11 +347,7 @@ ${boundsBinding}
346
347
  @group(0) @binding(${outputBinding}) var<storage, read_write> outputValues: array<atomic<u32>>;
347
348
  ${countsBinding}
348
349
 
349
- fn getCoordinate(value: f32, minimum: f32, maximum: f32, size: u32) -> u32 {
350
- if (maximum == minimum || value == minimum) { return 0u; }
351
- if (value == maximum) { return size - 1u; }
352
- return min(u32((value - minimum) / (maximum - minimum) * f32(size)), size - 1u);
353
- }
350
+ ${GPU_GRID_COORDINATE_WGSL}
354
351
 
355
352
  ${getAggregationFunction(aggregation.operation)}
356
353
  ${useSubgroups ? getSubgroupBallotHelpersWGSL() : ''}
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import {GPU_GRID_COORDINATE_WGSL} from './gpu-grid-coordinate';
5
6
  import type {GPUCommandNode} from './gpu-command-node';
6
7
  import {
7
8
  GPUCommandGraph,
@@ -291,11 +292,7 @@ ${boundsBinding}
291
292
  ${local ? `var<workgroup> localCounts: array<atomic<u32>, ${binning.output.length}>;` : ''}
292
293
  ${useSubgroups ? getSubgroupBallotHelpersWGSL() : ''}
293
294
 
294
- fn getCoordinate(value: f32, minimum: f32, maximum: f32, size: u32) -> u32 {
295
- if (maximum == minimum || value == minimum) { return 0u; }
296
- if (value == maximum) { return size - 1u; }
297
- return min(u32((value - minimum) / (maximum - minimum) * f32(size)), size - 1u);
298
- }
295
+ ${GPU_GRID_COORDINATE_WGSL}
299
296
 
300
297
  @compute @workgroup_size(${GRID_WORKGROUP_SIZE}) fn main(
301
298
  @builtin(workgroup_id) workgroupId: vec3<u32>,
@@ -0,0 +1,24 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ /**
6
+ * WGSL `getCoordinate(value, minimum, maximum, size)` for grids.
7
+ * Supply a finite value, inclusive bounds, and a positive cell count.
8
+ * Coordinates outside the bounds clamp to the first or last cell.
9
+ */
10
+ export const GPU_GRID_COORDINATE_WGSL = `fn getCoordinate(value: f32, minimum: f32, maximum: f32, size: u32) -> u32 {
11
+ if (maximum == minimum || value <= minimum) { return 0u; }
12
+ if (value >= maximum) { return size - 1u; }
13
+ if (minimum < 0.0 && maximum > 3.402823466e+38 + minimum) {
14
+ let scale = max(abs(minimum), abs(maximum));
15
+ let scaledValue = value / scale;
16
+ let scaledMinimum = minimum / scale;
17
+ let scaledMaximum = maximum / scale;
18
+ return min(
19
+ u32((scaledValue - scaledMinimum) / (scaledMaximum - scaledMinimum) * f32(size)),
20
+ size - 1u
21
+ );
22
+ }
23
+ return min(u32((value - minimum) / (maximum - minimum) * f32(size)), size - 1u);
24
+ }`;
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import {GPU_GRID_COORDINATE_WGSL} from './gpu-grid-coordinate';
5
6
  import {type GPUCommandNode} from './gpu-command-node';
6
7
  import {type GPUCommandGraph, type GraphDataView} from './gpu-command-graph';
7
8
  import {
@@ -246,21 +247,7 @@ const DEPTH: u32 = ${depth}u;
246
247
  @group(0) @binding(0) var<storage, read> positions: array<f32>;
247
248
  ${bindings}
248
249
 
249
- fn getCoordinate(value: f32, minimum: f32, maximum: f32, size: u32) -> u32 {
250
- if (maximum == minimum || value == minimum) { return 0u; }
251
- if (value == maximum) { return size - 1u; }
252
- if (minimum < 0.0 && maximum > 0.0) {
253
- let scale = max(abs(minimum), abs(maximum));
254
- let scaledValue = value / scale;
255
- let scaledMinimum = minimum / scale;
256
- let scaledMaximum = maximum / scale;
257
- return min(
258
- u32((scaledValue - scaledMinimum) / (scaledMaximum - scaledMinimum) * f32(size)),
259
- size - 1u
260
- );
261
- }
262
- return min(u32((value - minimum) / (maximum - minimum) * f32(size)), size - 1u);
263
- }
250
+ ${GPU_GRID_COORDINATE_WGSL}
264
251
 
265
252
  @compute @workgroup_size(256)
266
253
  fn main(@builtin(workgroup_id) workgroupId: vec3u, @builtin(local_invocation_index) localInvocationIndex: u32) {
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import {GPU_GRID_COORDINATE_WGSL} from './gpu-grid-coordinate';
5
6
  import {type GPUCommandNode} from './gpu-command-node';
6
7
  import {GPUCommandGraph, type GraphDataView, type GraphVectorView} from './gpu-command-graph';
7
8
  import type {GPUGridIndexBounds, GPUGridIndexSize} from './gpu-grid-index';
@@ -223,22 +224,7 @@ fn finite(value: f32) -> bool {
223
224
  return value == value && abs(value) <= 3.402823466e+38;
224
225
  }
225
226
 
226
- fn getCoordinate(value: f32, minimum: f32, maximum: f32, size: u32) -> u32 {
227
- if (!finite(value)) { return 0u; }
228
- if (maximum == minimum || value == minimum) { return 0u; }
229
- if (value == maximum) { return size - 1u; }
230
- if (minimum < 0.0 && maximum > 0.0) {
231
- let scale = max(abs(minimum), abs(maximum));
232
- let scaledValue = value / scale;
233
- let scaledMinimum = minimum / scale;
234
- let scaledMaximum = maximum / scale;
235
- return min(
236
- u32((scaledValue - scaledMinimum) / (scaledMaximum - scaledMinimum) * f32(size)),
237
- size - 1u
238
- );
239
- }
240
- return min(u32((value - minimum) / (maximum - minimum) * f32(size)), size - 1u);
241
- }
227
+ ${GPU_GRID_COORDINATE_WGSL}
242
228
  fn cellMinimum(coordinate: u32, size: u32, minimum: f32, maximum: f32) -> f32 {
243
229
  let ratio = f32(coordinate) / f32(size);
244
230
  return minimum * (1.0 - ratio) + maximum * ratio;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {setGPUComputeDispatchWorkgroups} from './gpu-command-dispatch-metadata';
6
6
  import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-node';
7
- import {type Binding, type Device} from '@luma.gl/core';
7
+ import {type Binding, type Device, type ComputeShaderLayout} from '@luma.gl/core';
8
8
  import {Kernel} from '../execution/compute/kernel';
9
9
  import {GPUCommandGraph, type GraphDataView, GraphVectorView} from './gpu-command-graph';
10
10
  import {
@@ -602,9 +602,39 @@ ${props.segmentFlags ? `var<workgroup> segmentScratch: array<u32, ${SCAN_WORKGRO
602
602
  ? getSubgroupBlockScanSource(props, sumOutput, sumBinding)
603
603
  : portableSource;
604
604
 
605
+ const shaderLayout: ComputeShaderLayout = {
606
+ bindings: [
607
+ {name: 'inputValues', type: 'storage', group: 0, location: 0},
608
+ {name: 'outputValues', type: 'storage', group: 0, location: 1},
609
+ ...(sumOutput ? [{name: 'sumValues', type: 'storage' as const, group: 0, location: 2}] : []),
610
+ ...(props.segmentFlags
611
+ ? [{name: 'segmentFlags', type: 'storage' as const, group: 0, location: 3}]
612
+ : []),
613
+ ...(props.segmentPrefixes
614
+ ? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 4}]
615
+ : []),
616
+ ...(segmentFlagOutput
617
+ ? [
618
+ {
619
+ name: 'summarySegmentFlags',
620
+ type: 'storage' as const,
621
+ group: 0,
622
+ location: 5
623
+ }
624
+ ]
625
+ : [])
626
+ ]
627
+ };
628
+
605
629
  nodes.push(
606
630
  createGPUComputeCommandNode<Parameters>({
607
631
  id: props.id,
632
+ kernel: {
633
+ entryPoint: 'main',
634
+ workgroupSize: [SCAN_WORKGROUP_SIZE, 1, 1],
635
+ bindings: shaderLayout.bindings,
636
+ source
637
+ },
608
638
  workload: {
609
639
  operation: 'GPUScan',
610
640
  variant: strategy,
@@ -637,31 +667,7 @@ ${props.segmentFlags ? `var<workgroup> segmentScratch: array<u32, ${SCAN_WORKGRO
637
667
  const kernel = new Kernel(device, {
638
668
  id: props.id,
639
669
  source,
640
- shaderLayout: {
641
- bindings: [
642
- {name: 'inputValues', type: 'storage', group: 0, location: 0},
643
- {name: 'outputValues', type: 'storage', group: 0, location: 1},
644
- ...(sumOutput
645
- ? [{name: 'sumValues', type: 'storage' as const, group: 0, location: 2}]
646
- : []),
647
- ...(props.segmentFlags
648
- ? [{name: 'segmentFlags', type: 'storage' as const, group: 0, location: 3}]
649
- : []),
650
- ...(props.segmentPrefixes
651
- ? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 4}]
652
- : []),
653
- ...(segmentFlagOutput
654
- ? [
655
- {
656
- name: 'summarySegmentFlags',
657
- type: 'storage' as const,
658
- group: 0,
659
- location: 5
660
- }
661
- ]
662
- : [])
663
- ]
664
- }
670
+ shaderLayout
665
671
  });
666
672
  return {
667
673
  encode: ({computePass, getBuffer}) => {
@@ -854,9 +860,35 @@ ${props.offsetSegmentPrefixes ? '@group(0) @binding(3) var<storage, read> offset
854
860
  ${props.segmentPrefixes && props.offsetSegmentPrefixes ? 'segmentPrefixes[SEGMENT_PREFIXES_OFFSET + index] = segmentPrefix | offsetSegmentPrefix;' : ''}
855
861
  }
856
862
  }`;
863
+ const shaderLayout: ComputeShaderLayout = {
864
+ bindings: [
865
+ {name: 'outputValues', type: 'storage', group: 0, location: 0},
866
+ {name: 'offsets', type: 'storage', group: 0, location: 1},
867
+ ...(props.segmentPrefixes
868
+ ? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 2}]
869
+ : []),
870
+ ...(props.offsetSegmentPrefixes
871
+ ? [
872
+ {
873
+ name: 'offsetSegmentPrefixes',
874
+ type: 'storage' as const,
875
+ group: 0,
876
+ location: 3
877
+ }
878
+ ]
879
+ : [])
880
+ ]
881
+ };
882
+
857
883
  nodes.push(
858
884
  createGPUComputeCommandNode<Parameters>({
859
885
  id: props.id,
886
+ kernel: {
887
+ entryPoint: 'main',
888
+ workgroupSize: [SCAN_WORKGROUP_SIZE, 1, 1],
889
+ bindings: shaderLayout.bindings,
890
+ source
891
+ },
860
892
  workload: {
861
893
  operation: 'GPUScan',
862
894
  commandCount: 1,
@@ -889,25 +921,7 @@ ${props.offsetSegmentPrefixes ? '@group(0) @binding(3) var<storage, read> offset
889
921
  const kernel = new Kernel(device, {
890
922
  id: props.id,
891
923
  source,
892
- shaderLayout: {
893
- bindings: [
894
- {name: 'outputValues', type: 'storage', group: 0, location: 0},
895
- {name: 'offsets', type: 'storage', group: 0, location: 1},
896
- ...(props.segmentPrefixes
897
- ? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 2}]
898
- : []),
899
- ...(props.offsetSegmentPrefixes
900
- ? [
901
- {
902
- name: 'offsetSegmentPrefixes',
903
- type: 'storage' as const,
904
- group: 0,
905
- location: 3
906
- }
907
- ]
908
- : [])
909
- ]
910
- }
924
+ shaderLayout
911
925
  });
912
926
  return {
913
927
  encode: ({computePass, getBuffer}) => {
@@ -6,6 +6,7 @@ import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-no
6
6
  import type {Binding} from '@luma.gl/core';
7
7
  import {Kernel} from '../execution/compute/kernel';
8
8
  import {GPUCommandGraph, type GraphDataView} from './gpu-command-graph';
9
+ import {getBoundedWorkgroupLayout, type GPUBoundedDispatchLayout} from './gpu-dispatch-utils';
9
10
  import {
10
11
  getViewBinding,
11
12
  getViewElementOffset,
@@ -22,7 +23,7 @@ export type GPUSegmentedReductionOperation = 'sum' | 'min' | 'max';
22
23
  export type GPUSegmentedReductionProps<T extends GPUScalarFormat = GPUScalarFormat> = {
23
24
  id?: string;
24
25
  input: GraphDataView<T>;
25
- /** CSR-style element offsets. Length must equal output.length + 1. */
26
+ /** Nondecreasing element offsets relative to input. Length must equal output.length + 1. */
26
27
  segmentOffsets: GraphDataView<'uint32'>;
27
28
  output: GraphDataView<T>;
28
29
  operation: GPUSegmentedReductionOperation;
@@ -73,15 +74,20 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
73
74
  }
74
75
  if (this.output.length === 0) return nodes;
75
76
 
76
- const source = makeShaderSource(this);
77
+ const dispatch = getBoundedWorkgroupLayout(
78
+ this.id,
79
+ this.output.length,
80
+ graph.device.limits.maxComputeWorkgroupsPerDimension
81
+ );
82
+ const source = makeShaderSource(this, dispatch);
77
83
  nodes.push(
78
84
  createGPUComputeCommandNode<Parameters>({
79
85
  id: this.id,
80
86
  workload: {
81
87
  operation: 'GPUSegmentedReduction',
82
88
  commandCount: 1,
83
- maximumWorkgroupCount: this.output.length,
84
- maximumInvocationCount: this.output.length * WORKGROUP_SIZE,
89
+ maximumWorkgroupCount: dispatch.x * dispatch.y * dispatch.z,
90
+ maximumInvocationCount: dispatch.x * dispatch.y * dispatch.z * WORKGROUP_SIZE,
85
91
  readByteLength: this.input.length * 4 + this.segmentOffsets.length * 4,
86
92
  writeByteLength: this.output.length * 4
87
93
  },
@@ -110,7 +116,7 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
110
116
  outputValues: getViewBinding(this.output, getBuffer)
111
117
  };
112
118
 
113
- kernel.dispatch(computePass, {bindings, x: this.output.length, y: 1, z: 1});
119
+ kernel.dispatch(computePass, {bindings, ...dispatch});
114
120
  },
115
121
  destroy: () => kernel.destroy()
116
122
  };
@@ -122,7 +128,10 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
122
128
  }
123
129
  }
124
130
 
125
- function makeShaderSource(reduction: GPUSegmentedReduction): string {
131
+ function makeShaderSource(
132
+ reduction: GPUSegmentedReduction,
133
+ dispatch: GPUBoundedDispatchLayout
134
+ ): string {
126
135
  const type =
127
136
  reduction.input.format === 'uint32'
128
137
  ? 'u32'
@@ -161,9 +170,10 @@ var<workgroup> scratch: array<${type}, ${WORKGROUP_SIZE}>;
161
170
  fn combine(a: ${type}, b: ${type}) -> ${type} { return ${combine}; }
162
171
  @compute @workgroup_size(${WORKGROUP_SIZE})
163
172
  fn main(@builtin(workgroup_id) wg: vec3u, @builtin(local_invocation_index) lane: u32) {
164
- let segment = wg.x;
165
- let begin = segmentOffsets[SEGMENT_OFFSET + segment];
166
- let end = segmentOffsets[SEGMENT_OFFSET + segment + 1u];
173
+ let segment = (wg.z * ${dispatch.y}u + wg.y) * ${dispatch.x}u + wg.x;
174
+ if (segment >= ${reduction.output.length}u) { return; }
175
+ let begin = min(segmentOffsets[SEGMENT_OFFSET + segment], ${reduction.input.length}u);
176
+ let end = min(segmentOffsets[SEGMENT_OFFSET + segment + 1u], ${reduction.input.length}u);
167
177
  var value: ${type} = ${identity};
168
178
  var i = begin + lane;
169
179
  loop {
@@ -181,7 +191,7 @@ fn main(@builtin(workgroup_id) wg: vec3u, @builtin(local_invocation_index) lane:
181
191
  stride = stride / 2u;
182
192
  }
183
193
  if (lane == 0u) {
184
- outputValues[OUTPUT_OFFSET + segment] = select(scratch[0], ${type}(${reduction.operation === 'sum' ? '0' : '0'}), begin == end);
194
+ outputValues[OUTPUT_OFFSET + segment] = select(scratch[0], ${type}(0), begin >= end);
185
195
  }
186
196
  }`;
187
197
  }