@luma.gl/graph 10.0.0-alpha.7 → 10.0.0-alpha.8

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 (177) hide show
  1. package/dist/dist.dev.js +5096 -7269
  2. package/dist/dist.min.js +270 -83
  3. package/dist/experimental/index.cjs.map +2 -2
  4. package/dist/experimental/simulation/index.cjs.map +2 -2
  5. package/dist/gpu-core/compiled-gpu-graph.cjs +99 -14
  6. package/dist/gpu-core/compiled-gpu-graph.d.ts +26 -4
  7. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  8. package/dist/gpu-core/compiled-gpu-graph.js +101 -13
  9. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  10. package/dist/gpu-core/gpu-command-graph-compiler.cjs +35 -3
  11. package/dist/gpu-core/gpu-command-graph-compiler.js +40 -4
  12. package/dist/gpu-core/gpu-command-graph-compiler.js.map +1 -1
  13. package/dist/gpu-core/gpu-command-graph-types.d.ts +2 -0
  14. package/dist/gpu-core/gpu-command-graph-types.d.ts.map +1 -1
  15. package/dist/gpu-core/gpu-compaction-operation.cjs +56 -0
  16. package/dist/gpu-core/gpu-compaction-operation.d.ts +20 -0
  17. package/dist/gpu-core/gpu-compaction-operation.d.ts.map +1 -0
  18. package/dist/gpu-core/gpu-compaction-operation.js +36 -0
  19. package/dist/gpu-core/gpu-compaction-operation.js.map +1 -0
  20. package/dist/gpu-core/gpu-compaction.cjs +35 -3
  21. package/dist/gpu-core/gpu-compaction.d.ts.map +1 -1
  22. package/dist/gpu-core/gpu-compaction.js +38 -3
  23. package/dist/gpu-core/gpu-compaction.js.map +1 -1
  24. package/dist/gpu-core/gpu-expression-operation.cjs +18 -2
  25. package/dist/gpu-core/gpu-expression-operation.d.ts +2 -2
  26. package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
  27. package/dist/gpu-core/gpu-expression-operation.js +20 -1
  28. package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
  29. package/dist/gpu-core/gpu-expression-plan.cjs +140 -29
  30. package/dist/gpu-core/gpu-expression-plan.d.ts +26 -5
  31. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  32. package/dist/gpu-core/gpu-expression-plan.js +168 -34
  33. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  34. package/dist/gpu-core/gpu-graph-compiler.cjs +100 -11
  35. package/dist/gpu-core/gpu-graph-compiler.d.ts +7 -3
  36. package/dist/gpu-core/gpu-graph-compiler.d.ts.map +1 -1
  37. package/dist/gpu-core/gpu-graph-compiler.js +109 -9
  38. package/dist/gpu-core/gpu-graph-compiler.js.map +1 -1
  39. package/dist/gpu-core/gpu-graph-declarations.cjs +120 -0
  40. package/dist/gpu-core/gpu-graph-declarations.d.ts +4 -0
  41. package/dist/gpu-core/gpu-graph-declarations.d.ts.map +1 -0
  42. package/dist/gpu-core/gpu-graph-declarations.js +110 -0
  43. package/dist/gpu-core/gpu-graph-declarations.js.map +1 -0
  44. package/dist/gpu-core/gpu-graph-validation.cjs +33 -2
  45. package/dist/gpu-core/gpu-graph-validation.d.ts.map +1 -1
  46. package/dist/gpu-core/gpu-graph-validation.js +32 -0
  47. package/dist/gpu-core/gpu-graph-validation.js.map +1 -1
  48. package/dist/gpu-core/gpu-graph-value.cjs +38 -3
  49. package/dist/gpu-core/gpu-graph-value.d.ts +50 -4
  50. package/dist/gpu-core/gpu-graph-value.d.ts.map +1 -1
  51. package/dist/gpu-core/gpu-graph-value.js +39 -1
  52. package/dist/gpu-core/gpu-graph-value.js.map +1 -1
  53. package/dist/gpu-core/gpu-graph.cjs +65 -0
  54. package/dist/gpu-core/gpu-graph.d.ts +15 -2
  55. package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
  56. package/dist/gpu-core/gpu-graph.js +70 -0
  57. package/dist/gpu-core/gpu-graph.js.map +1 -1
  58. package/dist/gpu-core/gpu-operation-contract.cjs +5 -0
  59. package/dist/gpu-core/gpu-operation-contract.d.ts +10 -0
  60. package/dist/gpu-core/gpu-operation-contract.d.ts.map +1 -1
  61. package/dist/gpu-core/gpu-operation-contract.js +6 -1
  62. package/dist/gpu-core/gpu-operation-contract.js.map +1 -1
  63. package/dist/gpu-core/gpu-scan.cjs +11 -2
  64. package/dist/gpu-core/gpu-scan.d.ts.map +1 -1
  65. package/dist/gpu-core/gpu-scan.js +11 -2
  66. package/dist/gpu-core/gpu-scan.js.map +1 -1
  67. package/dist/gpu-core/gpu-texture-copy.cjs +53 -0
  68. package/dist/gpu-core/gpu-texture-copy.d.ts +7 -0
  69. package/dist/gpu-core/gpu-texture-copy.d.ts.map +1 -0
  70. package/dist/gpu-core/gpu-texture-copy.js +39 -0
  71. package/dist/gpu-core/gpu-texture-copy.js.map +1 -0
  72. package/dist/gpu-core/gpu-texture-plan.cjs +181 -0
  73. package/dist/gpu-core/gpu-texture-plan.d.ts +32 -0
  74. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -0
  75. package/dist/gpu-core/gpu-texture-plan.js +215 -0
  76. package/dist/gpu-core/gpu-texture-plan.js.map +1 -0
  77. package/dist/gpu-core/gpu-transfer-lowering.cjs +109 -0
  78. package/dist/gpu-core/gpu-transfer-lowering.d.ts +9 -0
  79. package/dist/gpu-core/gpu-transfer-lowering.d.ts.map +1 -0
  80. package/dist/gpu-core/gpu-transfer-lowering.js +88 -0
  81. package/dist/gpu-core/gpu-transfer-lowering.js.map +1 -0
  82. package/dist/gpu-core/gpu-transfer-operation.cjs +100 -0
  83. package/dist/gpu-core/gpu-transfer-operation.d.ts +38 -0
  84. package/dist/gpu-core/gpu-transfer-operation.d.ts.map +1 -0
  85. package/dist/gpu-core/gpu-transfer-operation.js +84 -0
  86. package/dist/gpu-core/gpu-transfer-operation.js.map +1 -0
  87. package/dist/gpu-core/index.cjs +13 -0
  88. package/dist/gpu-core/index.cjs.map +3 -3
  89. package/dist/gpu-core/index.d.ts +11 -1
  90. package/dist/gpu-core/index.d.ts.map +1 -1
  91. package/dist/gpu-core/index.js +4 -1
  92. package/dist/gpu-core/index.js.map +1 -1
  93. package/dist/gpu-dggs/benchmarks.cjs.map +2 -2
  94. package/dist/gpu-graph/index.cjs +8 -0
  95. package/dist/gpu-graph/index.cjs.map +3 -3
  96. package/dist/gpu-graph/index.d.ts +5 -0
  97. package/dist/gpu-graph/index.d.ts.map +1 -1
  98. package/dist/gpu-graph/index.js +2 -0
  99. package/dist/gpu-graph/index.js.map +1 -1
  100. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +3 -3
  101. package/dist/gpu-graph-algorithms/index.cjs.map +2 -2
  102. package/dist/gpu-physics/gpu-rigid-body-world.cjs +56 -17
  103. package/dist/gpu-physics/gpu-rigid-body-world.d.ts +1 -1
  104. package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
  105. package/dist/gpu-physics/gpu-rigid-body-world.js +42 -2
  106. package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
  107. package/dist/gpu-physics/index.cjs.map +2 -2
  108. package/dist/gpu-physics/rigid-body-joints.cjs +6 -1
  109. package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
  110. package/dist/gpu-physics/rigid-body-joints.js +9 -1
  111. package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
  112. package/dist/gpu-physics/rigid-body-parallel-shaders.cjs +4 -2
  113. package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts.map +1 -1
  114. package/dist/gpu-physics/rigid-body-parallel-shaders.js +4 -2
  115. package/dist/gpu-physics/rigid-body-parallel-shaders.js.map +1 -1
  116. package/dist/gpu-physics/rigid-body-shaders.cjs +1 -0
  117. package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
  118. package/dist/gpu-physics/rigid-body-shaders.js +1 -0
  119. package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
  120. package/dist/gpu-pointcloud/index.cjs.map +1 -1
  121. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +54 -7
  122. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +11 -4
  123. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  124. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +56 -4
  125. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  126. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +16 -0
  127. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +11 -4
  128. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  129. package/dist/gpu-simple-graph/gpu-simple-graph.js +18 -0
  130. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  131. package/dist/gpu-simple-graph/gpu-transfer-execution.cjs +82 -0
  132. package/dist/gpu-simple-graph/gpu-transfer-execution.d.ts +7 -0
  133. package/dist/gpu-simple-graph/gpu-transfer-execution.d.ts.map +1 -0
  134. package/dist/gpu-simple-graph/gpu-transfer-execution.js +64 -0
  135. package/dist/gpu-simple-graph/gpu-transfer-execution.js.map +1 -0
  136. package/dist/gpu-simple-graph/index.cjs +3 -0
  137. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  138. package/dist/gpu-simple-graph/index.d.ts +3 -0
  139. package/dist/gpu-simple-graph/index.d.ts.map +1 -1
  140. package/dist/gpu-simple-graph/index.js +1 -0
  141. package/dist/gpu-simple-graph/index.js.map +1 -1
  142. package/dist/index.cjs +13 -0
  143. package/dist/index.cjs.map +3 -3
  144. package/dist/index.d.ts +11 -1
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/index.js +4 -1
  147. package/dist/index.js.map +1 -1
  148. package/package.json +6 -7
  149. package/src/gpu-core/compiled-gpu-graph.ts +118 -15
  150. package/src/gpu-core/gpu-command-graph-compiler.ts +38 -6
  151. package/src/gpu-core/gpu-command-graph-types.ts +2 -0
  152. package/src/gpu-core/gpu-compaction-operation.ts +49 -0
  153. package/src/gpu-core/gpu-compaction.ts +47 -3
  154. package/src/gpu-core/gpu-expression-operation.ts +23 -2
  155. package/src/gpu-core/gpu-expression-plan.ts +247 -44
  156. package/src/gpu-core/gpu-graph-compiler.ts +130 -11
  157. package/src/gpu-core/gpu-graph-declarations.ts +137 -0
  158. package/src/gpu-core/gpu-graph-validation.ts +32 -0
  159. package/src/gpu-core/gpu-graph-value.ts +88 -4
  160. package/src/gpu-core/gpu-graph.ts +104 -2
  161. package/src/gpu-core/gpu-operation-contract.ts +18 -0
  162. package/src/gpu-core/gpu-scan.ts +15 -2
  163. package/src/gpu-core/gpu-texture-copy.ts +51 -0
  164. package/src/gpu-core/gpu-texture-plan.ts +248 -0
  165. package/src/gpu-core/gpu-transfer-lowering.ts +102 -0
  166. package/src/gpu-core/gpu-transfer-operation.ts +110 -0
  167. package/src/gpu-core/index.ts +22 -1
  168. package/src/gpu-graph/index.ts +15 -0
  169. package/src/gpu-physics/gpu-rigid-body-world.ts +44 -3
  170. package/src/gpu-physics/rigid-body-joints.ts +11 -2
  171. package/src/gpu-physics/rigid-body-parallel-shaders.ts +4 -2
  172. package/src/gpu-physics/rigid-body-shaders.ts +1 -0
  173. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +90 -8
  174. package/src/gpu-simple-graph/gpu-simple-graph.ts +56 -3
  175. package/src/gpu-simple-graph/gpu-transfer-execution.ts +73 -0
  176. package/src/gpu-simple-graph/index.ts +9 -0
  177. package/src/index.ts +29 -1
package/dist/index.d.ts CHANGED
@@ -15,8 +15,18 @@ export { RenderKernel } from "./execution/compute/render-kernel.js";
15
15
  export type { RenderKernelProps, RenderKernelDrawOptions, RenderKernelIndirectDrawOptions } from "./execution/compute/render-kernel.js";
16
16
  export { GPUExpressionOperation } from "./gpu-core/gpu-expression-operation.js";
17
17
  export type { GPUExpressionOperationProps, GPUExpressionAST } from "./gpu-core/gpu-expression-operation.js";
18
- export { CompiledGPUGraph } from "./gpu-core/compiled-gpu-graph.js";
18
+ export { CompiledGPUGraph, PreparedGPUGraphExecution } from "./gpu-core/compiled-gpu-graph.js";
19
19
  export type { GPUGraphCompileOptions, GPUGraphRunBindings, GPUGraphRunOptions } from "./gpu-core/gpu-expression-plan.js";
20
20
  export type { GPUOperationContract, GPUOperationValueReference, GPUOperationValueUse, GPUOperationVectorShape } from "./gpu-core/gpu-operation-contract.js";
21
21
  export type { GPUOperation } from "./gpu-core/gpu-operation.js";
22
+ export { gpuGraph } from "./gpu-core/gpu-graph-value.js";
23
+ export type { GPUGraphScalarDescriptor, GPUGraphVectorDescriptor, GPUGraphValueDescriptor, GPUGraphValueRole } from "./gpu-core/gpu-graph-value.js";
24
+ export type { GPUGraphExecutionBindings } from "./gpu-core/gpu-expression-plan.js";
25
+ export type { GPUOperationOutputDeclarations, GPUOperationContractContext } from "./gpu-core/gpu-operation-contract.js";
26
+ export { GPUUploadOperation, GPUCopyOperation } from "./gpu-core/gpu-transfer-operation.js";
27
+ export type { GPUUploadOperationProps, GPUCopyOperationProps } from "./gpu-core/gpu-transfer-operation.js";
28
+ export { GPUCompactionOperation } from "./gpu-core/gpu-compaction-operation.js";
29
+ export type { GPUCompactionOperationProps } from "./gpu-core/gpu-compaction-operation.js";
30
+ export type { GPUGraphTextureDescriptor, GPUGraphTextureExtent } from "./gpu-core/gpu-graph-value.js";
31
+ export type { GPUGraphTextureBinding, GPUGraphOutput, GPUGraphOutputs } from "./gpu-core/gpu-texture-plan.js";
22
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACz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OAAO,EAAC,QAAQ,EAAC,sCAAmC;AACpD,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EAClB,sCAAmC;AACpC,YAAY,EAAC,yBAAyB,EAAC,0CAAuC;AAC9E,YAAY,EACV,8BAA8B,EAC9B,2BAA2B,EAC5B,6CAA0C;AAE3C,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,6CAA0C;AACvF,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACtB,6CAA0C;AAC3C,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAC3E,YAAY,EAAC,2BAA2B,EAAC,+CAA4C;AAErF,YAAY,EAAC,yBAAyB,EAAE,qBAAqB,EAAC,sCAAmC;AACjG,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,eAAe,EAChB,uCAAoC"}
package/dist/index.js CHANGED
@@ -11,5 +11,8 @@ export { getPlatformInfo } from "./execution/utils/get-platform-info.js";
11
11
  export { Kernel } from "./execution/compute/kernel.js";
12
12
  export { RenderKernel } from "./execution/compute/render-kernel.js";
13
13
  export { GPUExpressionOperation } from "./gpu-core/gpu-expression-operation.js";
14
- export { CompiledGPUGraph } from "./gpu-core/compiled-gpu-graph.js";
14
+ export { CompiledGPUGraph, PreparedGPUGraphExecution } from "./gpu-core/compiled-gpu-graph.js";
15
+ export { gpuGraph } from "./gpu-core/gpu-graph-value.js";
16
+ export { GPUUploadOperation, GPUCopyOperation } from "./gpu-core/gpu-transfer-operation.js";
17
+ export { GPUCompactionOperation } from "./gpu-core/gpu-compaction-operation.js";
15
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,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AAkD;AACxE,OAAO,EAAC,eAAe,EAAC,+CAA4C;AAMpE,OAAO,EAAC,MAAM,EAAC,sCAAmC;AAClD,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAO/D,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAK3E,OAAO,EAAC,gBAAgB,EAAE,yBAAyB,EAAC,yCAAsC;AAe1F,OAAO,EAAC,QAAQ,EAAC,sCAAmC;AAapD,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,6CAA0C;AAKvF,OAAO,EAAC,sBAAsB,EAAC,+CAA4C"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "10.0.0-alpha.7",
6
+ "version": "10.0.0-alpha.8",
7
7
  "type": "module",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -230,8 +230,8 @@
230
230
  }
231
231
  },
232
232
  "peerDependencies": {
233
- "@luma.gl/core": "~10.0.0-alpha.7",
234
- "@luma.gl/shaders": "~10.0.0-alpha.7",
233
+ "@luma.gl/core": "~10.0.0-alpha.8",
234
+ "@luma.gl/shaders": "~10.0.0-alpha.8",
235
235
  "apache-arrow": ">=17.0.0"
236
236
  },
237
237
  "peerDependenciesMeta": {
@@ -240,10 +240,9 @@
240
240
  }
241
241
  },
242
242
  "dependencies": {
243
- "@math.gl/core": "~5.0.0-beta.2",
244
- "@math.gl/expressions": "5.0.0-alpha.18",
245
- "@math.gl/geospatial": "~5.0.0-beta.2",
243
+ "@math.gl/core": "~5.0.0-beta.4",
244
+ "@math.gl/geospatial": "~5.0.0-beta.4",
246
245
  "probe.gl": "^5.0.0"
247
246
  },
248
- "gitHead": "e3979f06848a6d04547ac7a26f844212ba569806"
247
+ "gitHead": "b609e6c8c8bd989364b9a0509df623542b26440e"
249
248
  }
@@ -2,8 +2,13 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
- import {assert, type Device} from '@luma.gl/core';
5
+ import {assert, type CommandEncoder, type Device} from '@luma.gl/core';
6
6
  import {GPUVector} from '@luma.gl/graph/gpu-data';
7
+ import {
8
+ getTextureBindingInfo,
9
+ type GPUGraphTextureBinding,
10
+ type GPUGraphOutputs
11
+ } from './gpu-texture-plan';
7
12
  import {GPUGraph} from './gpu-graph';
8
13
  import type {CompiledGPUCommandGraph} from './gpu-command-graph';
9
14
  import {GPUGraphCompiler} from './gpu-graph-compiler';
@@ -11,14 +16,16 @@ import type {GPUOperationLowering} from './gpu-graph-lowering';
11
16
  import {GPUExpressionOperation} from './gpu-expression-operation';
12
17
  import {
13
18
  GPUExpressionProgram,
19
+ type GPUExpressionInvocation,
14
20
  type GPUGraphCompileOptions,
15
21
  type GPUGraphRunBindings,
22
+ type GPUGraphExecutionBindings,
16
23
  type GPUGraphRunOptions
17
24
  } from './gpu-expression-plan';
18
25
  import {GPUExpressionKernel} from './gpu-expression-kernel';
19
26
 
20
27
  /** Reusable WebGPU program. Returned output vectors belong to the caller. */
21
- export class CompiledGPUGraph {
28
+ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, GPUVector>> {
22
29
  private readonly program: GPUExpressionProgram;
23
30
  private readonly compiler: GPUGraphCompiler;
24
31
  private readonly kernels = new Map<GPUExpressionOperation, GPUExpressionKernel>();
@@ -31,8 +38,6 @@ export class CompiledGPUGraph {
31
38
  lowerings?: readonly GPUOperationLowering[]
32
39
  ) {
33
40
  if (device.type !== 'webgpu') throw new Error('GPUGraph execution requires WebGPU');
34
- if (source.textures.length)
35
- throw new Error('Reusable expression programs do not yet support texture declarations');
36
41
  this.program = new GPUExpressionProgram(source, options);
37
42
  this.compiler = new GPUGraphCompiler(device, [
38
43
  ...(lowerings ?? options.lowerings ?? []),
@@ -52,14 +57,37 @@ export class CompiledGPUGraph {
52
57
  }
53
58
 
54
59
  async run(
55
- bindings: GPUGraphRunBindings,
60
+ supplied: GPUGraphRunBindings | GPUGraphExecutionBindings,
61
+ options: GPUGraphRunOptions = {}
62
+ ): Promise<Outputs> {
63
+ const execution = this.prepare(supplied, options);
64
+ let encoder: CommandEncoder | undefined;
65
+ try {
66
+ encoder = this.device.createCommandEncoder();
67
+ execution.encode(encoder);
68
+ this.device.submit(encoder.finish());
69
+ return execution.outputs;
70
+ } catch (error) {
71
+ execution.discard();
72
+ throw error;
73
+ } finally {
74
+ execution.destroy();
75
+ encoder?.destroy();
76
+ }
77
+ }
78
+
79
+ /** Bind one invocation without encoding or submitting commands. */
80
+ prepare(
81
+ supplied: GPUGraphRunBindings | GPUGraphExecutionBindings,
56
82
  options: GPUGraphRunOptions = {}
57
- ): Promise<Record<string, GPUVector>> {
83
+ ): PreparedGPUGraphExecution<Outputs> {
58
84
  // A destroyed compiled program cannot encode further work.
59
85
  assert(!this.destroyed);
60
- const invocation = this.program.prepare(this.device, bindings, options);
86
+ const resolvedBindings = this.program.resolveBindings(supplied, options);
87
+ const bindings = resolvedBindings.bindings;
88
+ options = resolvedBindings.options;
89
+ const invocation = this.program.prepare(this.device, bindings, options, true);
61
90
  let executable: CompiledGPUCommandGraph | undefined;
62
- const encoder = this.device.createCommandEncoder();
63
91
  try {
64
92
  const resolved = new GPUGraph();
65
93
  for (const scalar of this.program.scalars) resolved.scalar(scalar.id, scalar.format);
@@ -74,6 +102,20 @@ export class CompiledGPUGraph {
74
102
  }
75
103
  for (const vector of this.program.vectors) {
76
104
  const binding = vectors[vector.id];
105
+ const transient = invocation.transientVectors.get(vector.id);
106
+ if (transient) {
107
+ resolved.addDeclaration(
108
+ vector.id,
109
+ {
110
+ type: 'vector',
111
+ format: vector.format,
112
+ length: transient.length,
113
+ chunkLengths: transient.chunkLengths
114
+ },
115
+ 'value'
116
+ );
117
+ continue;
118
+ }
77
119
  if (!binding && vector.length === undefined)
78
120
  throw new Error(`Missing length or execution binding for ${vector.id}`);
79
121
  resolved.vector(vector.id, vector.format, binding?.length ?? vector.length, {
@@ -81,8 +123,25 @@ export class CompiledGPUGraph {
81
123
  chunkLengths: binding?.data.map(chunk => chunk.length) ?? vector.chunkLengths
82
124
  });
83
125
  }
126
+ const textures: Record<string, GPUGraphTextureBinding> = Object.create(null);
127
+ for (const texture of this.program.textures) {
128
+ const binding = invocation.textures!.values.get(texture.id)!;
129
+ const info = getTextureBindingInfo(binding);
130
+ resolved.texture(texture.id, {
131
+ format: info.format,
132
+ dimension: info.dimension,
133
+ width: info.width,
134
+ height: info.height,
135
+ depth: info.depth,
136
+ mipLevels: info.mipLevels,
137
+ samples: info.samples,
138
+ usage: info.texture.props.usage,
139
+ external: true
140
+ });
141
+ textures[texture.id] = binding;
142
+ }
84
143
  resolved.add(this.program.operations);
85
- const compilation = this.compiler.compile(resolved, {vectors, scalars});
144
+ const compilation = this.compiler.compile(resolved, {vectors, scalars, textures});
86
145
  for (const scalar of this.program.scalars) {
87
146
  const target = invocation.values.get(scalar.id);
88
147
  if (!(target instanceof GPUVector)) continue;
@@ -108,15 +167,14 @@ export class CompiledGPUGraph {
108
167
  });
109
168
  }
110
169
  executable = compilation.graph.compile();
111
- executable.encode(encoder, {parameters: undefined});
112
- this.device.submit(encoder.finish());
113
- return invocation.finish();
170
+ return new PreparedGPUGraphExecution<Outputs>(this.device, invocation, executable, () => {
171
+ // Keep the compiled program alive until encoding and submission have completed.
172
+ assert(!this.destroyed);
173
+ });
114
174
  } catch (error) {
175
+ executable?.destroy();
115
176
  invocation.destroy();
116
177
  throw error;
117
- } finally {
118
- executable?.destroy();
119
- encoder.destroy();
120
178
  }
121
179
  }
122
180
 
@@ -126,3 +184,48 @@ export class CompiledGPUGraph {
126
184
  this.destroyed = true;
127
185
  }
128
186
  }
187
+
188
+ /** One bound invocation. Outputs remain caller-owned after destruction. */
189
+ export class PreparedGPUGraphExecution<
190
+ Outputs extends GPUGraphOutputs = Record<string, GPUVector>
191
+ > {
192
+ readonly outputs: Outputs;
193
+ private encoded = false;
194
+ private destroyed = false;
195
+
196
+ /** @internal Use CompiledGPUGraph.prepare(). */
197
+ constructor(
198
+ private readonly device: Device,
199
+ private readonly invocation: GPUExpressionInvocation,
200
+ private readonly executable: CompiledGPUCommandGraph,
201
+ private readonly checkProgram: () => void
202
+ ) {
203
+ this.outputs = invocation.getOutputs<Outputs>();
204
+ }
205
+
206
+ /** Append commands once to a caller-owned encoder; never finish or submit it. */
207
+ encode(commandEncoder: CommandEncoder): void {
208
+ // An execution is single-use, and its encoder must belong to the same device.
209
+ assert(!this.destroyed && !this.encoded && commandEncoder.device === this.device);
210
+ this.checkProgram();
211
+ // A partial encoding cannot be retried. Discard the caller's encoder on failure.
212
+ this.encoded = true;
213
+ this.executable.encode(commandEncoder, {parameters: undefined});
214
+ }
215
+
216
+ /** Release scratch after submission, or after abandoning an unsubmitted encoder. */
217
+ destroy(): void {
218
+ if (this.destroyed) return;
219
+ this.destroyed = true;
220
+ this.executable.destroy();
221
+ this.invocation.finish();
222
+ }
223
+
224
+ /** @internal run() has no caller to receive allocated outputs when it fails. */
225
+ discard(): void {
226
+ if (this.destroyed) return;
227
+ this.destroyed = true;
228
+ this.executable.destroy();
229
+ this.invocation.destroy();
230
+ }
231
+ }
@@ -805,6 +805,27 @@ function getBufferTransientAllocationPlan<Parameters>(
805
805
  const lifetimes = getResourceLifetimes(nodes, resource =>
806
806
  isGraphBufferUse(resource) ? getBufferHandle(resource.buffer) : null
807
807
  );
808
+ // Each operation shares one retained-buffer list across all its command nodes. Find the
809
+ // scope once, rather than visiting every chunk on every node in a chunked operation.
810
+ const scopes = new Map<readonly GraphBufferHandle[], {firstUse: number; lastUse: number}>();
811
+ nodes.forEach((node, nodeIndex) => {
812
+ if (!node.retainedBuffers?.length) return;
813
+ const scope = scopes.get(node.retainedBuffers);
814
+ if (scope) scope.lastUse = nodeIndex;
815
+ else scopes.set(node.retainedBuffers, {firstUse: nodeIndex, lastUse: nodeIndex});
816
+ });
817
+ // Logical operation inputs/results overlap even for multi-pass lowerings. Private command
818
+ // scratch continues to use its precise command-level lifetime.
819
+ for (const [buffers, scope] of scopes) {
820
+ for (const buffer of buffers) {
821
+ if (!buffer.transient) continue;
822
+ const lifetime = lifetimes.get(buffer);
823
+ lifetimes.set(buffer, {
824
+ firstUse: Math.min(lifetime?.firstUse ?? scope.firstUse, scope.firstUse),
825
+ lastUse: Math.max(lifetime?.lastUse ?? scope.lastUse, scope.lastUse)
826
+ });
827
+ }
828
+ }
808
829
  const allocations: BufferTransientAllocation[] = [];
809
830
  const transientBuffers = Array.from(buffers)
810
831
  .filter(buffer => buffer.transient)
@@ -821,19 +842,30 @@ function getBufferTransientAllocationPlan<Parameters>(
821
842
  const active = new GPUPlanningHeap<Candidate>(
822
843
  (left, right) => left.allocation.lastUse - right.allocation.lastUse || left.index - right.index
823
844
  );
824
- const available = new GPUPlanningHeap<Candidate>(
825
- (left, right) =>
826
- left.allocation.byteLength - right.allocation.byteLength || left.index - right.index
827
- );
845
+ // Mappable staging buffers cannot combine their usages with storage/vertex buffers.
846
+ const available = new Map<number, GPUPlanningHeap<Candidate>>();
847
+ const getAvailable = (usage: number): GPUPlanningHeap<Candidate> => {
848
+ const key = usage & (Buffer.MAP_READ | Buffer.MAP_WRITE);
849
+ let pool = available.get(key);
850
+ if (!pool) {
851
+ pool = new GPUPlanningHeap<Candidate>(
852
+ (left, right) =>
853
+ left.allocation.byteLength - right.allocation.byteLength || left.index - right.index
854
+ );
855
+ available.set(key, pool);
856
+ }
857
+ return pool;
858
+ };
828
859
 
829
860
  for (const {buffer, lifetime} of transientBuffers) {
830
861
  if (!lifetime) {
831
862
  continue;
832
863
  }
833
864
  while (active.peek() && active.peek()!.allocation.lastUse < lifetime.firstUse) {
834
- available.push(active.pop()!);
865
+ const completed = active.pop()!;
866
+ getAvailable(completed.allocation.usage).push(completed);
835
867
  }
836
- let candidate = available.pop();
868
+ let candidate = getAvailable(buffer.usage).pop();
837
869
  if (!candidate) {
838
870
  candidate = {
839
871
  allocation: {byteLength: 0, usage: 0, lastUse: -1, handles: []},
@@ -549,6 +549,8 @@ export type GPUCommandGraphNodeConditionPreflight = {
549
549
  };
550
550
 
551
551
  type GPUCommandGraphNodeBase<Condition> = {
552
+ /** @internal Logical result buffers kept live across the containing operation. */
553
+ retainedBuffers?: readonly GraphBufferHandle[];
552
554
  /** Optional plain-text explanation shown in debugging tools and retained in traces. */
553
555
  description?: string;
554
556
  /** Graph-wide node identifier. */
@@ -0,0 +1,49 @@
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 {gpuGraph} from './gpu-graph-value';
7
+ import type {GPUOperation} from './gpu-operation';
8
+ import type {GPUOperationContract} from './gpu-operation-contract';
9
+
10
+ export type GPUCompactionOperationProps = {
11
+ id?: string;
12
+ input: string;
13
+ /** uint32 selection mask: zero rejects, nonzero accepts. */
14
+ flags: string;
15
+ output: string;
16
+ /** Produced uint32 scalar. Only the first count rows of output are valid. */
17
+ count: string;
18
+ };
19
+
20
+ /** Stable uint32 compaction with input-sized capacity and a separate GPU logical count. */
21
+ export class GPUCompactionOperation implements GPUOperation {
22
+ readonly type = 'compaction';
23
+ readonly id: string;
24
+ readonly props: Readonly<GPUCompactionOperationProps>;
25
+ constructor(props: GPUCompactionOperationProps) {
26
+ this.id = props.id ?? `${props.output}-compaction`;
27
+ this.props = Object.freeze({...props});
28
+ }
29
+ get contract(): GPUOperationContract {
30
+ const {input, flags, output, count} = this.props;
31
+ return {
32
+ outputs: ({getValue}) => {
33
+ for (const name of [input, flags]) {
34
+ const value = getValue(name);
35
+ // The existing compaction kernel accepts packed uint32 values and flags.
36
+ assert(value.type === 'vector' && value.format === 'uint32');
37
+ }
38
+ assert(output !== count);
39
+ return {[output]: gpuGraph.vector('uint32'), [count]: gpuGraph.scalar('uint32')};
40
+ },
41
+ values: [
42
+ {value: input, access: 'read'},
43
+ {value: flags, access: 'read'},
44
+ {value: output, access: 'write', shape: {like: input}},
45
+ {value: count, access: 'write'}
46
+ ]
47
+ };
48
+ }
49
+ }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
+ import {setGPUComputeDispatchWorkgroups} from './gpu-command-dispatch-metadata';
5
6
  import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-node';
6
7
  import {Kernel} from '../execution/compute/kernel';
7
8
  import {GPUCommandGraph, GraphVectorView, type GraphDataView} from './gpu-command-graph';
@@ -134,9 +135,46 @@ export function getGPUCompactionCommandNodesWithDispatchLimit<Parameters>(
134
135
  compaction.flags instanceof GraphVectorView
135
136
  ? createTransientVectorView(graph, `${compaction.id}-offsets`, compaction.flags)
136
137
  : createTransientView(graph, `${compaction.id}-offsets`, 'uint32', compaction.flags.length);
138
+ // Normalize nonzero flags before the prefix sum, matching the scatter's selection semantics.
139
+ const normalized =
140
+ compaction.flags instanceof GraphVectorView
141
+ ? createTransientVectorView(graph, `${compaction.id}-flags`, compaction.flags)
142
+ : createTransientView(graph, `${compaction.id}-flags`, 'uint32', compaction.flags.length);
143
+ for (const [index, input] of getCompactionChunks(compaction.flags).entries()) {
144
+ if (!input.length) continue;
145
+ const output = getCompactionChunks(normalized)[index];
146
+ const dispatchLayout = getBoundedDispatchLayout(
147
+ compaction.id,
148
+ input.length,
149
+ COMPACTION_WORKGROUP_SIZE,
150
+ maxComputeWorkgroupsPerDimension
151
+ );
152
+ nodes.push(
153
+ ...addCompactionPass(graph, {
154
+ id: `${compaction.id}-normalize-${index}`,
155
+ source: `
156
+ @group(0) @binding(0) var<storage, read> inputValues: array<u32>;
157
+ @group(0) @binding(1) var<storage, read_write> outputValues: array<u32>;
158
+ @compute @workgroup_size(${COMPACTION_WORKGROUP_SIZE}) fn main(
159
+ @builtin(local_invocation_index) localInvocationIndex: u32,
160
+ @builtin(workgroup_id) workgroupId: vec3<u32>
161
+ ) {
162
+ ${getBoundedInvocationIndexSource(dispatchLayout, COMPACTION_WORKGROUP_SIZE)}
163
+ if (index >= ${input.length}u) { return; }
164
+ outputValues[${getViewElementOffset(output)}u + index] = min(inputValues[${getViewElementOffset(input)}u + index], 1u);
165
+ }`,
166
+ resources: [
167
+ {buffer: input, usage: 'storage-read'},
168
+ {buffer: output, usage: 'storage-write'}
169
+ ],
170
+ bindings: {inputValues: input, outputValues: output},
171
+ dispatchLayout
172
+ })
173
+ );
174
+ }
137
175
  const scan = new GPUScan({
138
176
  id: `${compaction.id}-scan`,
139
- input: compaction.flags,
177
+ input: normalized,
140
178
  output: offsets
141
179
  });
142
180
  nodes.push(
@@ -193,7 +231,7 @@ function addClearCountPass<Parameters>(
193
231
  })
194
232
  );
195
233
 
196
- return nodes;
234
+ return nodes.map(node => setGPUComputeDispatchWorkgroups(node, [1, 1, 1]));
197
235
  }
198
236
 
199
237
  /** Routes every non-empty input chunk through each non-empty logical output range. */
@@ -415,7 +453,13 @@ function addCompactionPass<Parameters>(
415
453
  })
416
454
  );
417
455
 
418
- return nodes;
456
+ return nodes.map(node =>
457
+ setGPUComputeDispatchWorkgroups(node, [
458
+ props.dispatchLayout.x,
459
+ props.dispatchLayout.y,
460
+ props.dispatchLayout.z
461
+ ])
462
+ );
419
463
  }
420
464
 
421
465
  /** Normalizes one compaction input or vector into its ordered atomic chunks. */
@@ -2,9 +2,9 @@
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/expressions';
5
+ import {parse, type Expression} from '@math.gl/core';
6
6
  import {getGPUVectorFormatInfo} from '@luma.gl/graph/gpu-data';
7
- import type {GPUGraphVectorFormat} from './gpu-graph-value';
7
+ import {gpuGraph, type GPUGraphVectorFormat} from './gpu-graph-value';
8
8
  import type {GPUOperationContract} from './gpu-operation-contract';
9
9
  import type {GPUOperation} from './gpu-operation';
10
10
 
@@ -21,7 +21,28 @@ export type GPUExpressionOperationProps = {
21
21
  /** A named, backend-independent numeric expression. Parsing and validation happen at compilation. */
22
22
  export class GPUExpressionOperation implements GPUOperation {
23
23
  get contract(): GPUOperationContract {
24
+ const expression = parseGPUExpression(this.expression);
25
+ const references = getGPUExpressionReferences(expression);
24
26
  return {
27
+ outputs: ({getValue}) => {
28
+ const inputs = references.map(name => {
29
+ const value = getValue(name);
30
+ if (value.type === 'texture') throw new Error('Numeric expressions cannot read textures');
31
+ return [name, value] as const;
32
+ });
33
+ const format = getGPUExpressionFormat(
34
+ expression,
35
+ new Map(inputs.map(([name, value]) => [name, value.format]))
36
+ );
37
+ const vector = inputs.some(([, value]) => value.type === 'vector');
38
+ // A multi-component constant is a one-row vector, not a scalar.
39
+ return {
40
+ [this.output]:
41
+ vector || !isGPUExpressionFormat(format)
42
+ ? gpuGraph.vector(format, vector ? {} : {length: 1})
43
+ : gpuGraph.scalar(format)
44
+ };
45
+ },
25
46
  values: [
26
47
  ...getGPUExpressionReferences(parseGPUExpression(this.expression)).map(value => ({
27
48
  value,