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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/dist/arrow/cpu/arrow-coordinate-projection.cjs +30 -0
  2. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts +5 -0
  3. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts.map +1 -0
  4. package/dist/arrow/cpu/arrow-coordinate-projection.js +9 -0
  5. package/dist/arrow/cpu/arrow-coordinate-projection.js.map +1 -0
  6. package/dist/arrow/cpu/arrow-cpu-pipelines.cjs +31 -0
  7. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts +2 -0
  8. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts.map +1 -0
  9. package/dist/arrow/cpu/arrow-cpu-pipelines.js +5 -0
  10. package/dist/arrow/cpu/arrow-cpu-pipelines.js.map +1 -0
  11. package/dist/arrow/cpu/arrow-cpu-vector-adapters.cjs +99 -0
  12. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts +9 -0
  13. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts.map +1 -0
  14. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js +100 -0
  15. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js.map +1 -0
  16. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +10 -371
  17. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +9 -28
  18. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -1
  19. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +5 -381
  20. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -1
  21. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +11 -11
  22. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +2 -0
  23. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -1
  24. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +3 -3
  25. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -1
  26. package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +2 -2
  27. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +1 -1
  28. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -1
  29. package/dist/arrow/index.cjs +17 -2
  30. package/dist/arrow/index.cjs.map +3 -3
  31. package/dist/arrow/index.d.ts +3 -0
  32. package/dist/arrow/index.d.ts.map +1 -1
  33. package/dist/arrow/index.js +3 -0
  34. package/dist/arrow/index.js.map +1 -1
  35. package/dist/arrow/internal.cjs.map +2 -2
  36. package/dist/dist.dev.js +1233 -442
  37. package/dist/dist.min.js +126 -108
  38. package/dist/experimental/index.cjs.map +1 -1
  39. package/dist/experimental/simulation/index.cjs.map +1 -1
  40. package/dist/gpu-core/compiled-gpu-graph.cjs +47 -0
  41. package/dist/gpu-core/compiled-gpu-graph.d.ts +5 -0
  42. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  43. package/dist/gpu-core/compiled-gpu-graph.js +54 -1
  44. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +28 -7
  46. package/dist/gpu-core/gpu-command-graph.d.ts +13 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +33 -7
  49. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  50. package/dist/gpu-core/gpu-cpu-execution.cjs +279 -0
  51. package/dist/gpu-core/gpu-cpu-execution.d.ts +22 -0
  52. package/dist/gpu-core/gpu-cpu-execution.d.ts.map +1 -0
  53. package/dist/gpu-core/gpu-cpu-execution.js +294 -0
  54. package/dist/gpu-core/gpu-cpu-execution.js.map +1 -0
  55. package/dist/gpu-core/gpu-cpu-operation.cjs +54 -0
  56. package/dist/gpu-core/gpu-cpu-operation.d.ts +40 -0
  57. package/dist/gpu-core/gpu-cpu-operation.d.ts.map +1 -0
  58. package/dist/gpu-core/gpu-cpu-operation.js +35 -0
  59. package/dist/gpu-core/gpu-cpu-operation.js.map +1 -0
  60. package/dist/gpu-core/gpu-expression-operation.cjs +2 -2
  61. package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
  62. package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
  63. package/dist/gpu-core/gpu-expression-operation.js +1 -1
  64. package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
  65. package/dist/gpu-core/gpu-expression-plan.cjs +5 -1
  66. package/dist/gpu-core/gpu-expression-plan.d.ts +3 -2
  67. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  68. package/dist/gpu-core/gpu-expression-plan.js +7 -1
  69. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  70. package/dist/gpu-core/gpu-graph.d.ts +2 -2
  71. package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
  72. package/dist/gpu-core/gpu-graph.js.map +1 -1
  73. package/dist/gpu-core/gpu-operation.d.ts +4 -4
  74. package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
  75. package/dist/gpu-core/gpu-operation.js.map +1 -1
  76. package/dist/gpu-core/gpu-render-operation.cjs +39 -0
  77. package/dist/gpu-core/gpu-render-operation.d.ts +21 -0
  78. package/dist/gpu-core/gpu-render-operation.d.ts.map +1 -0
  79. package/dist/gpu-core/gpu-render-operation.js +22 -0
  80. package/dist/gpu-core/gpu-render-operation.js.map +1 -0
  81. package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
  82. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
  83. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
  84. package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
  85. package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
  86. package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
  87. package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
  88. package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
  89. package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
  90. package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
  91. package/dist/gpu-core/gpu-texture-plan.d.ts +3 -2
  92. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
  93. package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
  94. package/dist/gpu-core/index.cjs +9 -0
  95. package/dist/gpu-core/index.cjs.map +3 -3
  96. package/dist/gpu-core/index.d.ts +6 -0
  97. package/dist/gpu-core/index.d.ts.map +1 -1
  98. package/dist/gpu-core/index.js +3 -0
  99. package/dist/gpu-core/index.js.map +1 -1
  100. package/dist/gpu-data/cpu-data.cjs +60 -0
  101. package/dist/gpu-data/cpu-data.d.ts +28 -0
  102. package/dist/gpu-data/cpu-data.d.ts.map +1 -0
  103. package/dist/gpu-data/cpu-data.js +41 -0
  104. package/dist/gpu-data/cpu-data.js.map +1 -0
  105. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
  106. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
  107. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
  108. package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
  109. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
  110. package/dist/gpu-data/cpu-vector.cjs +42 -0
  111. package/dist/gpu-data/cpu-vector.d.ts +17 -0
  112. package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
  113. package/dist/gpu-data/cpu-vector.js +21 -0
  114. package/dist/gpu-data/cpu-vector.js.map +1 -0
  115. package/dist/gpu-data/index.cjs +13 -2
  116. package/dist/gpu-data/index.cjs.map +3 -3
  117. package/dist/gpu-data/index.d.ts +3 -0
  118. package/dist/gpu-data/index.d.ts.map +1 -1
  119. package/dist/gpu-data/index.js +3 -0
  120. package/dist/gpu-data/index.js.map +1 -1
  121. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  122. package/dist/gpu-graph/index.cjs +3 -0
  123. package/dist/gpu-graph/index.cjs.map +3 -3
  124. package/dist/gpu-graph/index.d.ts +2 -0
  125. package/dist/gpu-graph/index.d.ts.map +1 -1
  126. package/dist/gpu-graph/index.js +1 -0
  127. package/dist/gpu-graph/index.js.map +1 -1
  128. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  129. package/dist/gpu-physics/index.cjs.map +1 -1
  130. package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
  131. package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
  132. package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
  133. package/dist/gpu-project/coordinate-projection-graph.js +40 -0
  134. package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
  135. package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
  136. package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
  137. package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
  138. package/dist/gpu-project/cpu-geoarrow.js +103 -0
  139. package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
  140. package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
  141. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
  142. package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
  143. package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
  144. package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
  145. package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
  146. package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
  147. package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
  148. package/dist/gpu-project/cpu-projection-operation.js +37 -0
  149. package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
  150. package/dist/gpu-project/geoarrow.cjs +36 -0
  151. package/dist/gpu-project/geoarrow.cjs.map +6 -0
  152. package/dist/gpu-project/geoarrow.d.ts +3 -0
  153. package/dist/gpu-project/geoarrow.d.ts.map +1 -0
  154. package/dist/gpu-project/geoarrow.js +7 -0
  155. package/dist/gpu-project/geoarrow.js.map +1 -0
  156. package/dist/gpu-project/graph.cjs +27 -0
  157. package/dist/gpu-project/graph.cjs.map +6 -0
  158. package/dist/gpu-project/graph.d.ts +2 -0
  159. package/dist/gpu-project/graph.d.ts.map +1 -0
  160. package/dist/gpu-project/graph.js +6 -0
  161. package/dist/gpu-project/graph.js.map +1 -0
  162. package/dist/gpu-project/index.cjs +3 -0
  163. package/dist/gpu-project/index.cjs.map +3 -3
  164. package/dist/gpu-project/index.d.ts +1 -0
  165. package/dist/gpu-project/index.d.ts.map +1 -1
  166. package/dist/gpu-project/index.js +1 -0
  167. package/dist/gpu-project/index.js.map +1 -1
  168. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +75 -5
  169. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +5 -1
  170. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  171. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +86 -6
  172. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  173. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
  174. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
  175. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
  176. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
  177. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
  178. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
  179. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
  180. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  181. package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
  182. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  183. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  184. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
  185. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
  186. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  187. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
  188. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  189. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
  190. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
  191. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
  192. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
  193. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
  194. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
  195. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  196. package/dist/index.cjs +6 -0
  197. package/dist/index.cjs.map +3 -3
  198. package/dist/index.d.ts +4 -0
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +2 -0
  201. package/dist/index.js.map +1 -1
  202. package/package.json +17 -6
  203. package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
  204. package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
  205. package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
  206. package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
  207. package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
  208. package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
  209. package/src/arrow/index.ts +11 -0
  210. package/src/gpu-core/compiled-gpu-graph.ts +73 -1
  211. package/src/gpu-core/gpu-command-graph.ts +37 -7
  212. package/src/gpu-core/gpu-cpu-execution.ts +345 -0
  213. package/src/gpu-core/gpu-cpu-operation.ts +65 -0
  214. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  215. package/src/gpu-core/gpu-expression-plan.ts +11 -3
  216. package/src/gpu-core/gpu-graph.ts +3 -3
  217. package/src/gpu-core/gpu-operation.ts +9 -7
  218. package/src/gpu-core/gpu-render-operation.ts +42 -0
  219. package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
  220. package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
  221. package/src/gpu-core/gpu-texture-plan.ts +3 -2
  222. package/src/gpu-core/index.ts +12 -0
  223. package/src/gpu-data/cpu-data.ts +62 -0
  224. package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
  225. package/src/gpu-data/cpu-vector.ts +31 -0
  226. package/src/gpu-data/index.ts +5 -0
  227. package/src/gpu-graph/index.ts +8 -0
  228. package/src/gpu-project/coordinate-projection-graph.ts +59 -0
  229. package/src/gpu-project/cpu-geoarrow.ts +135 -0
  230. package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
  231. package/src/gpu-project/cpu-projection-operation.ts +49 -0
  232. package/src/gpu-project/geoarrow.ts +11 -0
  233. package/src/gpu-project/graph.ts +10 -0
  234. package/src/gpu-project/index.ts +2 -0
  235. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +97 -6
  236. package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
  237. package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
  238. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
  239. package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
  240. package/src/index.ts +10 -0
@@ -14,7 +14,7 @@ import {
14
14
  type ArithmeticOp,
15
15
  type ArithmeticArgument
16
16
  } from './operations/arithmetic-operation';
17
- import {GPUVector} from '@luma.gl/graph/gpu-data';
17
+ import {CPUVector, GPUVector} from '@luma.gl/graph/gpu-data';
18
18
  import type {GPUGraph} from '../gpu-core/gpu-graph';
19
19
  import {
20
20
  GPUExpressionOperation,
@@ -38,12 +38,20 @@ import type {GPUGraphOutputs} from '../gpu-core/gpu-texture-plan';
38
38
 
39
39
  import {GPUExpressionCastOperation} from './gpu-expression-cast-operation';
40
40
  import {GPUExpressionRowOperation} from './gpu-expression-row-operation';
41
+ import {GPUShaderPassOperation} from '../gpu-core/gpu-shader-pass-operation';
42
+ import {GPUShaderPassKernel} from '../gpu-core/gpu-shader-pass-kernel';
43
+
44
+ import {GPUCPUOperation} from '../gpu-core/gpu-cpu-operation';
45
+ import {GPUCPUExecution} from '../gpu-core/gpu-cpu-execution';
41
46
 
42
47
  /** Reusable expression program implemented through the unchanged evaluator API. */
43
48
  export class CompiledGPUSimpleExpressionGraph<
44
49
  Outputs extends GPUGraphOutputs = Record<string, GPUVector>
45
50
  > {
46
51
  private readonly program: GPUExpressionProgram;
52
+ private readonly shaderPasses = new Map<GPUShaderPassOperation, GPUShaderPassKernel>();
53
+ private cpuExecution?: GPUCPUExecution;
54
+ private readonly outputLocations: Readonly<Record<string, 'cpu' | 'gpu'>>;
47
55
  private running = false;
48
56
  private destroyed = false;
49
57
 
@@ -54,6 +62,7 @@ export class CompiledGPUSimpleExpressionGraph<
54
62
  ) {
55
63
  if (options.lowerings) throw new Error('Custom lowerings require GPUGraph');
56
64
  this.program = new GPUExpressionProgram(source, options);
65
+ this.outputLocations = options.outputLocations ?? {};
57
66
  if (this.program.textures.length && device.type !== 'webgpu')
58
67
  throw new Error('SimpleGraph texture execution requires WebGPU');
59
68
  if (this.program.vectors.some(value => value.role === 'state'))
@@ -62,18 +71,40 @@ export class CompiledGPUSimpleExpressionGraph<
62
71
  this.program.operations.some(
63
72
  operation =>
64
73
  !(
74
+ operation instanceof GPUCPUOperation ||
65
75
  operation instanceof GPUExpressionOperation ||
66
76
  operation instanceof GPUUploadOperation ||
77
+ operation instanceof GPUShaderPassOperation ||
67
78
  operation instanceof GPUCopyOperation
68
79
  )
69
80
  )
70
81
  )
71
82
  throw new Error(
72
- 'SimpleGraph declarative execution supports expression, upload and copy operations only'
83
+ 'SimpleGraph declarative execution supports expression, CPU, upload, copy and shader-pass operations only'
84
+ );
85
+ if (
86
+ this.program.operations.some(operation => operation instanceof GPUCPUOperation) ||
87
+ Object.values(this.outputLocations).includes('cpu')
88
+ )
89
+ this.cpuExecution = new GPUCPUExecution(
90
+ device,
91
+ this.program,
92
+ (source, outputs) => new CompiledGPUSimpleExpressionGraph(device, source, {outputs})
73
93
  );
94
+ try {
95
+ for (const operation of this.program.operations)
96
+ if (operation instanceof GPUShaderPassOperation)
97
+ this.shaderPasses.set(
98
+ operation,
99
+ new GPUShaderPassKernel(device, operation, this.program)
100
+ );
101
+ } catch (error) {
102
+ this.destroy();
103
+ throw error;
104
+ }
74
105
  }
75
106
 
76
- /** Prepare a straight-line texture-copy program without submitting work. */
107
+ /** Prepare straight-line texture copies and shader passes without submitting work. */
77
108
  prepare(
78
109
  supplied: GPUGraphRunBindings | GPUGraphExecutionBindings,
79
110
  options: GPUGraphRunOptions = {}
@@ -83,13 +114,23 @@ export class CompiledGPUSimpleExpressionGraph<
83
114
  !this.program.textures.length ||
84
115
  this.program.operations.some(
85
116
  operation =>
86
- !(operation instanceof GPUCopyOperation) ||
87
- !this.program.textures.some(texture => texture.id === operation.input)
117
+ !(operation instanceof GPUShaderPassOperation) &&
118
+ (!(operation instanceof GPUCopyOperation) ||
119
+ !this.program.textures.some(texture => texture.id === operation.input))
88
120
  )
89
121
  )
90
- throw new Error('SimpleGraph prepare currently supports texture-copy programs only');
122
+ throw new Error(
123
+ 'SimpleGraph prepare currently supports texture-copy and shader-pass programs only'
124
+ );
91
125
  const resolved = this.program.resolveBindings(supplied, options);
92
126
  const invocation = this.program.prepare(this.device, resolved.bindings, resolved.options);
127
+ let shaderPasses;
128
+ try {
129
+ shaderPasses = this.prepareShaderPasses(invocation);
130
+ } catch (error) {
131
+ invocation.destroy();
132
+ throw error;
133
+ }
93
134
  let encoded = false;
94
135
  let destroyed = false;
95
136
  return {
@@ -98,6 +139,10 @@ export class CompiledGPUSimpleExpressionGraph<
98
139
  assert(!this.destroyed && !destroyed && !encoded && encoder.device === this.device);
99
140
  encoded = true;
100
141
  for (const operation of this.program.operations) {
142
+ if (operation instanceof GPUShaderPassOperation) {
143
+ shaderPasses.get(operation)!.encode(encoder);
144
+ continue;
145
+ }
101
146
  assert(operation instanceof GPUCopyOperation);
102
147
  encodeTextureCopy(
103
148
  encoder,
@@ -109,6 +154,7 @@ export class CompiledGPUSimpleExpressionGraph<
109
154
  destroy: (): void => {
110
155
  if (destroyed) return;
111
156
  destroyed = true;
157
+ for (const pass of shaderPasses.values()) pass.destroy();
112
158
  invocation.finish();
113
159
  }
114
160
  };
@@ -123,19 +169,48 @@ export class CompiledGPUSimpleExpressionGraph<
123
169
  const resolvedBindings = this.program.resolveBindings(supplied, options);
124
170
  const bindings = resolvedBindings.bindings;
125
171
  options = resolvedBindings.options;
172
+ const suppliedInputs = 'inputs' in supplied ? supplied.inputs : supplied;
173
+ const useCPU =
174
+ this.program.operations.some(operation => operation instanceof GPUCPUOperation) ||
175
+ Object.values(this.outputLocations).includes('cpu') ||
176
+ Object.values(suppliedInputs ?? {}).some(value => value instanceof CPUVector);
177
+ if (!this.cpuExecution && useCPU)
178
+ this.cpuExecution = new GPUCPUExecution(
179
+ this.device,
180
+ this.program,
181
+ (source, outputs) => new CompiledGPUSimpleExpressionGraph(this.device, source, {outputs})
182
+ );
126
183
  this.running = true;
184
+ if (useCPU && this.cpuExecution) {
185
+ try {
186
+ // Dynamic CPU results cannot be prepared into caller-owned storage yet.
187
+ assert(!options.outputTargets || Object.keys(options.outputTargets).length === 0);
188
+ return (await this.cpuExecution.run(bindings, this.outputLocations)) as Outputs;
189
+ } finally {
190
+ this.running = false;
191
+ }
192
+ }
127
193
  const evaluators = new Set<GPUDataEvaluator>();
128
194
  const scalarBuffers = new Set<Buffer>();
129
195
  let scope: GPUEvaluationScope | undefined;
130
196
  let invocation: ReturnType<GPUExpressionProgram['prepare']> | undefined;
197
+ let shaderPasses:
198
+ | ReturnType<CompiledGPUSimpleExpressionGraph['prepareShaderPasses']>
199
+ | undefined;
131
200
  try {
132
201
  invocation = this.program.prepare(this.device, bindings, options);
202
+ shaderPasses = this.prepareShaderPasses(invocation);
133
203
  if (this.device.type === 'webgpu') scope = new GPUEvaluationScope(this.device);
134
204
  const retain = (evaluator: GPUDataEvaluator): GPUDataEvaluator => {
135
205
  evaluators.add(evaluator);
136
206
  return evaluator;
137
207
  };
138
208
  for (const operation of this.program.operations) {
209
+ if (operation instanceof GPUShaderPassOperation) {
210
+ assert(scope);
211
+ shaderPasses.get(operation)!.encode(scope.commandEncoder);
212
+ continue;
213
+ }
139
214
  if (operation instanceof GPUUploadOperation || operation instanceof GPUCopyOperation) {
140
215
  if (
141
216
  operation instanceof GPUCopyOperation &&
@@ -364,6 +439,7 @@ export class CompiledGPUSimpleExpressionGraph<
364
439
  invocation?.destroy();
365
440
  throw error;
366
441
  } finally {
442
+ for (const pass of shaderPasses?.values() ?? []) pass.destroy();
367
443
  for (const evaluator of evaluators) evaluator.destroy();
368
444
  for (const buffer of scalarBuffers) buffer.destroy();
369
445
  this.running = false;
@@ -373,8 +449,23 @@ export class CompiledGPUSimpleExpressionGraph<
373
449
  destroy(): void {
374
450
  // A running program owns evaluator resources until execution finishes.
375
451
  assert(!this.running);
452
+ this.cpuExecution?.destroy();
453
+ for (const kernel of this.shaderPasses.values()) kernel.destroy();
454
+ this.shaderPasses.clear();
376
455
  this.destroyed = true;
377
456
  }
457
+
458
+ private prepareShaderPasses(invocation: ReturnType<GPUExpressionProgram['prepare']>) {
459
+ const passes = new Map<GPUShaderPassOperation, ReturnType<GPUShaderPassKernel['prepare']>>();
460
+ try {
461
+ for (const [operation, kernel] of this.shaderPasses)
462
+ passes.set(operation, kernel.prepare(invocation.textures!.values, invocation.values));
463
+ return passes;
464
+ } catch (error) {
465
+ for (const pass of passes.values()) pass.destroy();
466
+ throw error;
467
+ }
468
+ }
378
469
  }
379
470
 
380
471
  /** Keep graph scalar arithmetic on the GPU with the same float32 boundaries as vectors. */
@@ -39,6 +39,7 @@ export type SimpleOperation =
39
39
  export class SimpleGraphLowering {
40
40
  readonly owned = new Set<GPUDataEvaluator | GPUVectorEvaluator>();
41
41
  readonly outputs = new Map<string, GPUSimpleGraphOperation>();
42
+ readonly inputs = new Map<string, GPUDataEvaluator | GPUVectorEvaluator>();
42
43
  private readonly graphValues = new Map<GPUSimpleGraphValue, GPUDataEvaluator>();
43
44
  private readonly scalars = new Map<object, GPUDataEvaluator>();
44
45
  private readonly vectors = new Map<object, GPUVectorEvaluator>();
@@ -188,6 +189,15 @@ export class SimpleGraphLowering {
188
189
  // Semantic output IDs and explicitly wrapped evaluator IDs share one namespace.
189
190
  assert(!this.outputs.has(id));
190
191
  this.outputs.set(id, new GPUSimpleGraphOperation({id, evaluator}));
192
+ const chunks =
193
+ evaluator instanceof GPUVectorEvaluator ? evaluator.gpuDataEvaluators : [evaluator];
194
+ if (chunks.every(chunk => !chunk.source)) this.registerInput(id, evaluator);
195
+ }
196
+
197
+ private registerInput(id: string, evaluator: GPUDataEvaluator | GPUVectorEvaluator): void {
198
+ // An invalidation name must identify exactly one input, including semantic vector bindings.
199
+ assert(!this.inputs.has(id) || this.inputs.get(id) === evaluator);
200
+ this.inputs.set(id, evaluator);
191
201
  }
192
202
 
193
203
  private resolveVector(vector: GPUGraphVector<'float32'>): GPUVectorEvaluator {
@@ -215,6 +225,7 @@ export class SimpleGraphLowering {
215
225
  );
216
226
  this.owned.add(evaluator);
217
227
  this.vectors.set(vector, evaluator);
228
+ this.registerInput(vector.id, evaluator);
218
229
  return evaluator;
219
230
  }
220
231
  }
@@ -26,6 +26,8 @@ import {type GPUEvaluationScope} from './operation/gpu-evaluation-scope';
26
26
  import type {GPUVector, GPUVectorFormat} from '@luma.gl/graph/gpu-data';
27
27
 
28
28
  import {
29
+ GPURenderOperation,
30
+ type GPUCommandGraphEncodeOptions,
29
31
  GPUCompositeOperation,
30
32
  GPUGraphScalarLiteral,
31
33
  GPUGraphScalarOperation,
@@ -48,6 +50,7 @@ import {
48
50
  } from './gpu-simple-graph-transfer';
49
51
  import {GPUSimpleGraphValue, GPUSimpleGraphValueOperation} from './gpu-simple-graph-value';
50
52
  import {SimpleGraphLowering, type SimpleOperation} from './gpu-simple-graph-lowering';
53
+ import {GPUCommandGraphBuilder, type CompiledGPUCommandGraph} from '../gpu-core/gpu-command-graph';
51
54
 
52
55
  /** Inspection record for one evaluator in dependency order. */
53
56
  export type GPUSimpleGraphNode = {
@@ -72,7 +75,10 @@ export type GPUSimpleGraphCompileOptions = {
72
75
  };
73
76
 
74
77
  /** Run options; scopes defer submission until the caller submits or cancels. */
75
- export type GPUSimpleGraphRunOptions = {scope?: GPUEvaluationScope};
78
+ export type GPUSimpleGraphRunOptions<Parameters = void> = {
79
+ scope?: GPUEvaluationScope;
80
+ } & Pick<GPUCommandGraphEncodeOptions<Parameters>, 'buffers' | 'textures'> &
81
+ ([Parameters] extends [void] ? {parameters?: Parameters} : {parameters: Parameters});
76
82
 
77
83
  /**
78
84
  * Prototype graph-shaped interface to the existing lazy GPGPU evaluator.
@@ -80,7 +86,7 @@ export type GPUSimpleGraphRunOptions = {scope?: GPUEvaluationScope};
80
86
  * Operations, backend selection, fusion, caching, and storage ownership remain with
81
87
  * the evaluators. Explicit evaluator inputs are borrowed; semantic lowering owns its adapters.
82
88
  */
83
- export class GPUSimpleGraph {
89
+ export class GPUSimpleGraph<Parameters = void> {
84
90
  private readonly declarations = new GPUGraph();
85
91
  readonly device?: Device;
86
92
  readonly id: string;
@@ -88,12 +94,14 @@ export class GPUSimpleGraph {
88
94
  private readonly evaluatorIds = new Set<string>();
89
95
  private readonly programOperations: GPUGraphOperation[] = [];
90
96
  private compiled = false;
97
+ private readonly renderOperations: GPURenderOperation<Parameters>[] = [];
91
98
 
92
99
  /** Execution capabilities; evaluators retain control of backend submission. */
93
100
  readonly capabilities: Readonly<{
94
101
  callerControlledSubmission: boolean;
95
- dynamicBindings: boolean;
96
- transientAllocation: false;
102
+ dynamicBindings: true;
103
+ /** Evaluator render mode uses graph-managed transient resources. */
104
+ transientAllocation: boolean;
97
105
  }>;
98
106
 
99
107
  constructor(deviceOrProps?: Device | {id?: string}, props: {id?: string} = {}) {
@@ -102,8 +110,8 @@ export class GPUSimpleGraph {
102
110
  this.id = (device ? props.id : deviceOrProps?.id) ?? 'simple-graph';
103
111
  this.capabilities = Object.freeze({
104
112
  callerControlledSubmission: device?.type === 'webgpu',
105
- dynamicBindings: !device,
106
- transientAllocation: false
113
+ dynamicBindings: true,
114
+ transientAllocation: Boolean(device)
107
115
  });
108
116
  }
109
117
 
@@ -156,14 +164,24 @@ export class GPUSimpleGraph {
156
164
  }
157
165
 
158
166
  /** Accepts evaluator operations, semantic composites, and recursively nested arrays. */
159
- add(operation: GPUOperationLike): this {
167
+ add<Operation extends GPUOperationLike>(
168
+ operation: Operation &
169
+ (true extends HasIncompatibleRenderParameters<NoInfer<Operation>, Parameters>
170
+ ? never
171
+ : unknown)
172
+ ): this {
173
+ return this.addOperations(operation);
174
+ }
175
+
176
+ private addOperations(operation: GPUOperationLike): this {
160
177
  // Compilation freezes the builder, as it does for GPUCommandGraph.
161
178
  assert(!this.compiled);
162
179
  if (!this.device || operation instanceof GPUExpressionOperation) {
163
180
  this.declarations.add(operation);
164
181
  return this;
165
182
  }
166
- const pending: SimpleOperation[] = [];
183
+ const pending: (SimpleOperation | GPURenderOperation<Parameters>)[] = [];
184
+ let hasRenderOperation = this.renderOperations.length > 0;
167
185
  const pendingEvaluatorIds = new Set<string>();
168
186
  const operations: GPUGraphOperation[] = [];
169
187
  const visit = (value: GPUOperationLike): void => {
@@ -173,7 +191,12 @@ export class GPUSimpleGraph {
173
191
  // Control-flow composites cannot be executed as unconditional groups.
174
192
  assert(value.type === 'composite');
175
193
  for (const child of value.operations) visit(child);
194
+ } else if (value instanceof GPURenderOperation) {
195
+ hasRenderOperation = true;
196
+ pending.push(value);
176
197
  } else {
198
+ // Evaluator work precedes render work; never silently reorder the authored graph.
199
+ assert(!hasRenderOperation);
177
200
  // Only the initial portable semantic subset and explicit evaluator adapters are supported.
178
201
  assert(
179
202
  value instanceof GPUSimpleGraphValueOperation ||
@@ -210,7 +233,10 @@ export class GPUSimpleGraph {
210
233
  };
211
234
  visit(operation);
212
235
  collect(operation);
213
- this.leafOperations.push(...pending);
236
+ for (const value of pending) {
237
+ if (value instanceof GPURenderOperation) this.renderOperations.push(value);
238
+ else this.leafOperations.push(value);
239
+ }
214
240
  for (const identifier of pendingEvaluatorIds) this.evaluatorIds.add(identifier);
215
241
  this.programOperations.push(...operations);
216
242
  return this;
@@ -221,7 +247,7 @@ export class GPUSimpleGraph {
221
247
  identifier: string,
222
248
  value: Value
223
249
  ): Value {
224
- this.add(new GPUSimpleGraphValueOperation({id: identifier, value}));
250
+ this.addOperations(new GPUSimpleGraphValueOperation({id: identifier, value}));
225
251
  return value;
226
252
  }
227
253
 
@@ -230,10 +256,15 @@ export class GPUSimpleGraph {
230
256
  identifier: string,
231
257
  evaluator: Evaluator
232
258
  ): Evaluator {
233
- this.add(new GPUSimpleGraphOperation({id: identifier, evaluator}));
259
+ this.addOperations(new GPUSimpleGraphOperation({id: identifier, evaluator}));
234
260
  return evaluator;
235
261
  }
236
262
 
263
+ /** Appends shared render passes after the evaluator phase. Use the same operation in GPUGraph. */
264
+ addRenderOperation(operation: GPURenderOperation<Parameters>): this {
265
+ return this.addOperations(operation);
266
+ }
267
+
237
268
  get operationTree(): readonly GPUOperationTree[] {
238
269
  return Object.freeze(
239
270
  [...this.programOperations, ...this.declarations.operations].map(getGPUOperationTree)
@@ -245,13 +276,16 @@ export class GPUSimpleGraph {
245
276
  device: Device,
246
277
  options?: GPUGraphCompileOptions
247
278
  ): CompiledGPUSimpleExpressionGraph<Outputs>;
248
- compile(options?: GPUSimpleGraphCompileOptions): CompiledGPUSimpleGraph;
279
+ compile(options?: GPUSimpleGraphCompileOptions): CompiledGPUSimpleGraph<Parameters>;
249
280
  compile(
250
281
  deviceOrOptions: Device | GPUSimpleGraphCompileOptions = {},
251
282
  expressionOptions: GPUGraphCompileOptions = {}
252
- ): CompiledGPUSimpleGraph | CompiledGPUSimpleExpressionGraph<GPUGraphOutputs> {
283
+ ): CompiledGPUSimpleGraph<Parameters> | CompiledGPUSimpleExpressionGraph<GPUGraphOutputs> {
253
284
  if ('type' in deviceOrOptions) {
254
- assert(!this.compiled && this.leafOperations.length === 0);
285
+ // Reusable expression compilation cannot silently discard evaluator/render recipes.
286
+ assert(
287
+ !this.compiled && this.leafOperations.length === 0 && this.renderOperations.length === 0
288
+ );
255
289
  this.compiled = true;
256
290
  return new CompiledGPUSimpleExpressionGraph(
257
291
  deviceOrOptions,
@@ -259,7 +293,7 @@ export class GPUSimpleGraph {
259
293
  expressionOptions
260
294
  );
261
295
  }
262
- // Legacy evaluator graphs bind their device in the constructor.
296
+ // Evaluator recipes bind their device in the constructor.
263
297
  assert(this.device && this.declarations.operations.length === 0);
264
298
  if (
265
299
  [
@@ -274,6 +308,7 @@ export class GPUSimpleGraph {
274
308
  assert(!this.compiled);
275
309
  this.compiled = true;
276
310
  const lowering = new SimpleGraphLowering(options.bindings ?? {});
311
+ let renderGraph: CompiledGPUCommandGraph<Parameters> | undefined;
277
312
  try {
278
313
  for (const operation of this.leafOperations) lowering.lower(operation);
279
314
  const evaluators = lowering.outputs;
@@ -354,15 +389,25 @@ export class GPUSimpleGraph {
354
389
  });
355
390
  }
356
391
  }
392
+ if (this.renderOperations.length) {
393
+ const renderBuilder = new GPUCommandGraphBuilder<Parameters>(this.device, {
394
+ id: `${this.id}-render`
395
+ });
396
+ for (const operation of this.renderOperations) renderBuilder.add(operation);
397
+ renderGraph = renderBuilder.compile();
398
+ }
357
399
  return new CompiledGPUSimpleGraph(
358
400
  this.device,
359
401
  nodes,
360
402
  roots,
361
403
  this.operationTree,
362
404
  lowering.owned,
363
- Object.fromEntries(roots.map(({id, evaluator}) => [id, getIdentifier(evaluator)]))
405
+ Object.fromEntries(roots.map(({id, evaluator}) => [id, getIdentifier(evaluator)])),
406
+ renderGraph,
407
+ lowering.inputs
364
408
  );
365
409
  } catch (error) {
410
+ renderGraph?.destroy();
366
411
  lowering.destroy();
367
412
  throw error;
368
413
  }
@@ -370,7 +415,7 @@ export class GPUSimpleGraph {
370
415
  }
371
416
 
372
417
  /** Snapshot of named evaluator outputs and their reachable dependency plan. */
373
- export class CompiledGPUSimpleGraph {
418
+ export class CompiledGPUSimpleGraph<Parameters = void> {
374
419
  readonly nodes: readonly GPUSimpleGraphNode[];
375
420
  readonly outputs: Readonly<Record<string, GPUSimpleGraphEvaluator>>;
376
421
  /** Maps every selected output ID, including aliases, to its dependency inspection node. */
@@ -388,7 +433,10 @@ export class CompiledGPUSimpleGraph {
388
433
  roots: readonly GPUSimpleGraphOperation[],
389
434
  operationTree: readonly GPUOperationTree[],
390
435
  private readonly ownedEvaluators: ReadonlySet<GPUSimpleGraphEvaluator> = new Set(),
391
- outputNodes: Readonly<Record<string, string>> = {}
436
+ outputNodes: Readonly<Record<string, string>> = {},
437
+ /** Shared render executor, including buffer/texture inspection and ownership. */
438
+ readonly renderGraph?: CompiledGPUCommandGraph<Parameters>,
439
+ private readonly inputs: ReadonlyMap<string, GPUSimpleGraphEvaluator> = new Map()
392
440
  ) {
393
441
  this.device = device;
394
442
  this.nodes = Object.freeze(
@@ -404,17 +452,99 @@ export class CompiledGPUSimpleGraph {
404
452
  );
405
453
  }
406
454
 
455
+ /** Invalidates changed named inputs and their reachable consumers, preserving other channels. */
456
+ invalidate(inputIds: readonly string[]): void {
457
+ assert(!this.running && !this.destroyed && !this.pendingScope);
458
+ const changed = new Set<GPUSimpleGraphEvaluator>();
459
+ for (const identifier of inputIds) {
460
+ const input = this.inputs.get(identifier);
461
+ // Only graph-owned, named leaf inputs can be invalidated through this API.
462
+ assert(input && this.ownedEvaluators.has(input));
463
+ changed.add(input);
464
+ if (input instanceof GPUVectorEvaluator) {
465
+ for (const chunk of input.gpuDataEvaluators) changed.add(chunk);
466
+ }
467
+ }
468
+ const affected = new Map<GPUSimpleGraphEvaluator, boolean>();
469
+ const visit = (evaluator: GPUSimpleGraphEvaluator): boolean => {
470
+ const existing = affected.get(evaluator);
471
+ if (existing !== undefined) return existing;
472
+ // Visit every dependency, even if an earlier dependency is already dirty.
473
+ const dependencies = getDependencies(evaluator).map(visit);
474
+ const dirty = changed.has(evaluator) || dependencies.some(Boolean);
475
+ affected.set(evaluator, dirty);
476
+ return dirty;
477
+ };
478
+ for (const input of changed) visit(input);
479
+ for (const {evaluator} of this.executionPlan) visit(evaluator);
480
+ // Validate the whole change before clearing anything; borrowed evaluator caches stay untouched.
481
+ for (const [evaluator, dirty] of affected) {
482
+ if (dirty) assert(this.ownedEvaluators.has(evaluator));
483
+ }
484
+ for (const [evaluator, dirty] of affected) {
485
+ if (dirty) evaluator.invalidate();
486
+ }
487
+ }
488
+
407
489
  /** Releases semantic evaluator results, preserving borrowed inputs and wrappers. */
408
490
  destroy(): void {
409
491
  // Results must no longer be in use; borrowed evaluators and input buffers remain caller-owned.
410
492
  assert(!this.running && !this.pendingScope);
411
493
  if (this.destroyed) return;
494
+ this.renderGraph?.destroy();
412
495
  for (const evaluator of this.ownedEvaluators) evaluator.destroy();
413
496
  this.destroyed = true;
414
497
  }
415
498
 
499
+ /** Executes supported synchronous evaluators and render passes on WebGL, without readback. */
500
+ runSync(this: CompiledGPUSimpleGraph<void>): Record<string, GPUVector>;
501
+ runSync(options: GPUSimpleGraphRunOptions<Parameters>): Record<string, GPUVector>;
502
+ runSync(options?: GPUSimpleGraphRunOptions<Parameters>): Record<string, GPUVector> {
503
+ assert(this.device.type === 'webgl' && !options?.scope);
504
+ assert(!this.running && !this.destroyed && !this.pendingScope);
505
+ this.running = true;
506
+ try {
507
+ const results: Record<string, GPUVector> = {};
508
+ const evaluated = new Set<GPUSimpleGraphEvaluator>();
509
+ const evaluate = (evaluator: GPUSimpleGraphEvaluator): void => {
510
+ if (evaluated.has(evaluator)) return;
511
+ for (const dependency of getDependencies(evaluator)) evaluate(dependency);
512
+ evaluator.evaluateSync(this.device);
513
+ evaluated.add(evaluator);
514
+ };
515
+ for (const {id, evaluator} of this.executionPlan) {
516
+ evaluate(evaluator);
517
+ results[id] = evaluator.gpuVector;
518
+ }
519
+ this.encodeRenderPasses(options);
520
+ return results;
521
+ } finally {
522
+ this.running = false;
523
+ }
524
+ }
525
+
526
+ private encodeRenderPasses(options?: GPUSimpleGraphRunOptions<Parameters>): void {
527
+ const scope = options?.scope;
528
+ if (!this.renderGraph) return;
529
+ const commandEncoder = scope?.commandEncoder ?? this.device.createCommandEncoder();
530
+ try {
531
+ this.renderGraph.encode(commandEncoder, {
532
+ buffers: options?.buffers,
533
+ textures: options?.textures,
534
+ // The public overload requires parameters unless Parameters is void.
535
+ parameters: options?.parameters as Parameters
536
+ });
537
+ if (!scope) this.device.submit(commandEncoder.finish());
538
+ } finally {
539
+ if (!scope) commandEncoder.destroy();
540
+ }
541
+ }
542
+
416
543
  /** Materializes selected outputs without CPU readback. Semantic results live until destroy(). */
417
- async run({scope}: GPUSimpleGraphRunOptions = {}): Promise<Record<string, GPUVector>> {
544
+ run(this: CompiledGPUSimpleGraph<void>): Promise<Record<string, GPUVector>>;
545
+ run(options: GPUSimpleGraphRunOptions<Parameters>): Promise<Record<string, GPUVector>>;
546
+ async run(options?: GPUSimpleGraphRunOptions<Parameters>): Promise<Record<string, GPUVector>> {
547
+ const scope = options?.scope;
418
548
  // The underlying evaluators do not support concurrent evaluation of shared outputs.
419
549
  assert(!this.running && !this.destroyed && !this.pendingScope);
420
550
  if (scope) {
@@ -444,6 +574,7 @@ export class CompiledGPUSimpleGraph {
444
574
  else await evaluateDependencies(evaluator);
445
575
  results.push([id, evaluator.gpuVector]);
446
576
  }
577
+ this.encodeRenderPasses(options);
447
578
  return Object.fromEntries(results);
448
579
  } catch (error) {
449
580
  scope?.cancel();
@@ -459,3 +590,16 @@ function getDependencies(evaluator: GPUSimpleGraphEvaluator): readonly GPUSimple
459
590
  if (evaluator.source instanceof GPUDataEvaluator) return [evaluator.source];
460
591
  return evaluator.source?.dependencies ?? [];
461
592
  }
593
+
594
+ /** Preserve render parameter requirements without expanding the recursive GPUOperationLike type. */
595
+ type HasIncompatibleRenderParameters<Operation, Parameters> = GPUOperationLike extends Operation
596
+ ? false
597
+ : Operation extends GPURenderOperation<infer RequiredParameters>
598
+ ? [Parameters] extends [RequiredParameters]
599
+ ? false
600
+ : true
601
+ : Operation extends GPUCompositeOperation<infer Child>
602
+ ? HasIncompatibleRenderParameters<Child, Parameters>
603
+ : Operation extends readonly (infer Child)[]
604
+ ? HasIncompatibleRenderParameters<Child, Parameters>
605
+ : false;
@@ -721,6 +721,28 @@ export class GPUDataEvaluator {
721
721
  return this._id ?? this.source?.toString() ?? this.constructor.name;
722
722
  }
723
723
 
724
+ /**
725
+ * Clears cached results after an input changes, without changing its fixed layout.
726
+ * Does not propagate to consumers. Caller-owned input/target buffers remain borrowed.
727
+ * Call only when no evaluation or readback is in flight.
728
+ */
729
+ invalidate(): void {
730
+ this.assertScopeAccess();
731
+ if (this._destroyed) throw new Error('Cannot invalidate a destroyed evaluator');
732
+ if (this.source || this._bufferOwnership === 'borrowed') this._value = undefined;
733
+ // A buffer-backed leaf keeps its source buffer. Only its readback cache is stale.
734
+ if (!this.source && this._bufferOwnership === 'borrowed') return;
735
+ if (this._gpuVector) {
736
+ const buffer = getBufferFromGPUVector(this._gpuVector);
737
+ if (this._bufferOwnership === 'owned') bufferPool.recycle(buffer);
738
+ else if (!(this.source instanceof GPUDataEvaluator)) {
739
+ // Preserve the explicit borrowed destination and its layout on the next evaluation.
740
+ this._targetBuffer = {buffer, byteOffset: this.offset, byteStride: this.stride};
741
+ }
742
+ this._gpuVector = undefined;
743
+ }
744
+ }
745
+
724
746
  /** Releases cached GPU storage owned by this evaluator and prevents future evaluation. */
725
747
  destroy(): void {
726
748
  this.assertScopeAccess();
@@ -243,6 +243,13 @@ export class GPUVectorEvaluator {
243
243
  return this._gpuVector;
244
244
  }
245
245
 
246
+ /** Clears only the collected vector view. Invalidate changed children separately. */
247
+ invalidate(): void {
248
+ this.assertScopeAccess();
249
+ if (this._destroyed) throw new Error('Cannot invalidate a destroyed evaluator');
250
+ this._gpuVector = undefined;
251
+ }
252
+
246
253
  /** Releases cached GPU resources owned through child `GPUDataEvaluator` instances. */
247
254
  destroy(): void {
248
255
  this.assertScopeAccess();
package/src/index.ts CHANGED
@@ -193,6 +193,8 @@ export type {
193
193
  } from './gpu-core/gpu-operation-contract';
194
194
 
195
195
  export {GPUUploadOperation, GPUCopyOperation} from './gpu-core/gpu-transfer-operation';
196
+ export {GPUShaderPassOperation} from './gpu-core/gpu-shader-pass-operation';
197
+ export type {GPUShaderPassOperationProps} from './gpu-core/gpu-shader-pass-operation';
196
198
  export type {
197
199
  GPUUploadOperationProps,
198
200
  GPUCopyOperationProps
@@ -206,3 +208,11 @@ export type {
206
208
  GPUGraphOutput,
207
209
  GPUGraphOutputs
208
210
  } from './gpu-core/gpu-texture-plan';
211
+
212
+ export {GPUCPUOperation} from './gpu-core/gpu-cpu-operation';
213
+ export type {
214
+ GPUCPUOperationProps,
215
+ GPUCPUArray,
216
+ GPUCPUVector,
217
+ GPUCPUResult
218
+ } from './gpu-core/gpu-cpu-operation';