@luma.gl/engine 9.3.0-alpha.6 → 9.3.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 (128) hide show
  1. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  2. package/dist/animation-loop/animation-loop.js +3 -0
  3. package/dist/animation-loop/animation-loop.js.map +1 -1
  4. package/dist/compute/computation.d.ts +3 -7
  5. package/dist/compute/computation.d.ts.map +1 -1
  6. package/dist/compute/computation.js +14 -12
  7. package/dist/compute/computation.js.map +1 -1
  8. package/dist/dist.dev.js +1751 -831
  9. package/dist/dist.min.js +296 -148
  10. package/dist/dynamic-texture/dynamic-texture.d.ts +9 -2
  11. package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
  12. package/dist/dynamic-texture/dynamic-texture.js +54 -5
  13. package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
  14. package/dist/dynamic-texture/texture-data.d.ts +4 -1
  15. package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
  16. package/dist/dynamic-texture/texture-data.js +19 -2
  17. package/dist/dynamic-texture/texture-data.js.map +1 -1
  18. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  19. package/dist/geometry/gpu-geometry.js +8 -3
  20. package/dist/geometry/gpu-geometry.js.map +1 -1
  21. package/dist/index.cjs +1711 -847
  22. package/dist/index.cjs.map +4 -4
  23. package/dist/index.d.ts +12 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +8 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/material/material-factory.d.ts +73 -0
  28. package/dist/material/material-factory.d.ts.map +1 -0
  29. package/dist/material/material-factory.js +111 -0
  30. package/dist/material/material-factory.js.map +1 -0
  31. package/dist/material/material.d.ts +84 -0
  32. package/dist/material/material.d.ts.map +1 -0
  33. package/dist/material/material.js +176 -0
  34. package/dist/material/material.js.map +1 -0
  35. package/dist/model/model.d.ts +14 -6
  36. package/dist/model/model.d.ts.map +1 -1
  37. package/dist/model/model.js +69 -25
  38. package/dist/model/model.js.map +1 -1
  39. package/dist/model/split-uniforms-and-bindings.d.ts +4 -3
  40. package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
  41. package/dist/model/split-uniforms-and-bindings.js +2 -2
  42. package/dist/model/split-uniforms-and-bindings.js.map +1 -1
  43. package/dist/models/directional-light-model.d.ts +7 -0
  44. package/dist/models/directional-light-model.d.ts.map +1 -0
  45. package/dist/models/directional-light-model.js +23 -0
  46. package/dist/models/directional-light-model.js.map +1 -0
  47. package/dist/models/light-model-utils.d.ts +69 -0
  48. package/dist/models/light-model-utils.d.ts.map +1 -0
  49. package/dist/models/light-model-utils.js +395 -0
  50. package/dist/models/light-model-utils.js.map +1 -0
  51. package/dist/models/point-light-model.d.ts +7 -0
  52. package/dist/models/point-light-model.d.ts.map +1 -0
  53. package/dist/models/point-light-model.js +22 -0
  54. package/dist/models/point-light-model.js.map +1 -0
  55. package/dist/models/spot-light-model.d.ts +7 -0
  56. package/dist/models/spot-light-model.d.ts.map +1 -0
  57. package/dist/models/spot-light-model.js +23 -0
  58. package/dist/models/spot-light-model.js.map +1 -0
  59. package/dist/modules/picking/color-picking.d.ts +5 -9
  60. package/dist/modules/picking/color-picking.d.ts.map +1 -1
  61. package/dist/modules/picking/color-picking.js +122 -115
  62. package/dist/modules/picking/color-picking.js.map +1 -1
  63. package/dist/modules/picking/index-picking.d.ts +2 -2
  64. package/dist/modules/picking/index-picking.d.ts.map +1 -1
  65. package/dist/modules/picking/index-picking.js +36 -10
  66. package/dist/modules/picking/index-picking.js.map +1 -1
  67. package/dist/modules/picking/legacy-color-picking.d.ts +26 -0
  68. package/dist/modules/picking/legacy-color-picking.d.ts.map +1 -0
  69. package/dist/modules/picking/legacy-color-picking.js +7 -0
  70. package/dist/modules/picking/legacy-color-picking.js.map +1 -0
  71. package/dist/modules/picking/picking-manager.d.ts +29 -3
  72. package/dist/modules/picking/picking-manager.d.ts.map +1 -1
  73. package/dist/modules/picking/picking-manager.js +188 -41
  74. package/dist/modules/picking/picking-manager.js.map +1 -1
  75. package/dist/modules/picking/picking-uniforms.d.ts +12 -11
  76. package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
  77. package/dist/modules/picking/picking-uniforms.js +26 -13
  78. package/dist/modules/picking/picking-uniforms.js.map +1 -1
  79. package/dist/modules/picking/picking.d.ts +25 -0
  80. package/dist/modules/picking/picking.d.ts.map +1 -0
  81. package/dist/modules/picking/picking.js +18 -0
  82. package/dist/modules/picking/picking.js.map +1 -0
  83. package/dist/shader-inputs.d.ts +9 -7
  84. package/dist/shader-inputs.d.ts.map +1 -1
  85. package/dist/shader-inputs.js +84 -4
  86. package/dist/shader-inputs.js.map +1 -1
  87. package/dist/utils/shader-module-utils.d.ts +7 -0
  88. package/dist/utils/shader-module-utils.d.ts.map +1 -0
  89. package/dist/utils/shader-module-utils.js +46 -0
  90. package/dist/utils/shader-module-utils.js.map +1 -0
  91. package/package.json +4 -4
  92. package/src/animation-loop/animation-loop.ts +3 -0
  93. package/src/compute/computation.ts +31 -17
  94. package/src/dynamic-texture/dynamic-texture.ts +79 -7
  95. package/src/dynamic-texture/texture-data.ts +25 -4
  96. package/src/geometry/gpu-geometry.ts +8 -3
  97. package/src/index.ts +29 -4
  98. package/src/material/material-factory.ts +157 -0
  99. package/src/material/material.ts +254 -0
  100. package/src/model/model.ts +108 -40
  101. package/src/model/split-uniforms-and-bindings.ts +8 -6
  102. package/src/models/directional-light-model.ts +32 -0
  103. package/src/models/light-model-utils.ts +587 -0
  104. package/src/models/point-light-model.ts +31 -0
  105. package/src/models/spot-light-model.ts +32 -0
  106. package/src/modules/picking/color-picking.ts +123 -122
  107. package/src/modules/picking/index-picking.ts +36 -10
  108. package/src/modules/picking/legacy-color-picking.ts +8 -0
  109. package/src/modules/picking/picking-manager.ts +252 -50
  110. package/src/modules/picking/picking-uniforms.ts +38 -23
  111. package/src/modules/picking/picking.ts +22 -0
  112. package/src/shader-inputs.ts +165 -15
  113. package/src/utils/shader-module-utils.ts +65 -0
  114. package/dist/factories/pipeline-factory.d.ts +0 -39
  115. package/dist/factories/pipeline-factory.d.ts.map +0 -1
  116. package/dist/factories/pipeline-factory.js +0 -216
  117. package/dist/factories/pipeline-factory.js.map +0 -1
  118. package/dist/factories/shader-factory.d.ts +0 -19
  119. package/dist/factories/shader-factory.d.ts.map +0 -1
  120. package/dist/factories/shader-factory.js +0 -83
  121. package/dist/factories/shader-factory.js.map +0 -1
  122. package/dist/types.d.ts +0 -7
  123. package/dist/types.d.ts.map +0 -1
  124. package/dist/types.js +0 -5
  125. package/dist/types.js.map +0 -1
  126. package/src/factories/pipeline-factory.ts +0 -266
  127. package/src/factories/shader-factory.ts +0 -101
  128. package/src/types.ts +0 -11
@@ -2,16 +2,25 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {Binding, UniformValue} from '@luma.gl/core';
5
+ import type {Binding, CompositeShaderType} from '@luma.gl/core';
6
6
  import {log} from '@luma.gl/core';
7
7
  // import type {VariableShaderType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';
8
- import {getShaderModuleDependencies, ShaderModule} from '@luma.gl/shadertools';
8
+ import {
9
+ getShaderModuleDependencies,
10
+ ShaderModule,
11
+ ShaderModuleUniformValue
12
+ } from '@luma.gl/shadertools';
9
13
  import {splitUniformsAndBindings} from './model/split-uniforms-and-bindings';
10
14
 
11
15
  export type ShaderInputsOptions = {
12
16
  disableWarnings?: boolean;
13
17
  };
14
18
 
19
+ type ShaderInputsModule = Pick<
20
+ ShaderModule<any, any, any>,
21
+ 'bindingLayout' | 'defaultUniforms' | 'dependencies' | 'getUniforms' | 'name' | 'uniformTypes'
22
+ >;
23
+
15
24
  /**
16
25
  * ShaderInputs holds uniform and binding values for one or more shader modules,
17
26
  * - It can generate binary data for any uniform buffer
@@ -33,10 +42,10 @@ export class ShaderInputs<
33
42
  * @todo should should this include the resolved dependencies?
34
43
  */
35
44
  // @ts-ignore Fix typings
36
- modules: Readonly<{[P in keyof ShaderPropsT]: ShaderModule<ShaderPropsT[P]>}>;
45
+ modules: Readonly<{[P in keyof ShaderPropsT]: ShaderInputsModule}>;
37
46
 
38
47
  /** Stores the uniform values for each module */
39
- moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;
48
+ moduleUniforms: Record<keyof ShaderPropsT, Record<string, ShaderModuleUniformValue>>;
40
49
  /** Stores the uniform bindings for each module */
41
50
  moduleBindings: Record<keyof ShaderPropsT, Record<string, Binding>>;
42
51
  /** Tracks if uniforms have changed */
@@ -48,14 +57,14 @@ export class ShaderInputs<
48
57
  */
49
58
  constructor(
50
59
  // @ts-ignore Fix typings
51
- modules: {[P in keyof ShaderPropsT]?: ShaderModule<ShaderPropsT[P], any>},
60
+ modules: {[P in keyof ShaderPropsT]?: ShaderInputsModule},
52
61
  options?: ShaderInputsOptions
53
62
  ) {
54
63
  Object.assign(this.options, options);
55
64
 
56
65
  // Extract modules with dependencies
57
66
  const resolvedModules = getShaderModuleDependencies(
58
- Object.values(modules).filter(module => module.dependencies)
67
+ Object.values(modules).filter(isShaderInputsModuleWithDependencies)
59
68
  );
60
69
  for (const resolvedModule of resolvedModules) {
61
70
  // @ts-ignore
@@ -66,12 +75,19 @@ export class ShaderInputs<
66
75
 
67
76
  // Store the module definitions and create storage for uniform values and binding values, per module
68
77
  // @ts-ignore Fix typings
69
- this.modules = modules as {[P in keyof ShaderPropsT]: ShaderModule<ShaderPropsT[P]>};
70
- this.moduleUniforms = {} as Record<keyof ShaderPropsT, Record<string, UniformValue>>;
78
+ this.modules = modules as {[P in keyof ShaderPropsT]: ShaderInputsModule};
79
+ this.moduleUniforms = {} as Record<
80
+ keyof ShaderPropsT,
81
+ Record<string, ShaderModuleUniformValue>
82
+ >;
71
83
  this.moduleBindings = {} as Record<keyof ShaderPropsT, Record<string, Binding>>;
72
84
 
73
85
  // Initialize the modules
74
86
  for (const [name, module] of Object.entries(modules)) {
87
+ if (!module) {
88
+ continue;
89
+ }
90
+
75
91
  this._addModule(module);
76
92
  if (module.name && name !== module.name && !this.options.disableWarnings) {
77
93
  log.warn(`Module name: ${name} vs ${module.name}`)();
@@ -98,13 +114,20 @@ export class ShaderInputs<
98
114
  continue; // eslint-disable-line no-continue
99
115
  }
100
116
 
101
- const oldUniforms = this.moduleUniforms[moduleName] as (typeof module)['uniforms'];
117
+ const oldUniforms = this.moduleUniforms[moduleName];
102
118
  const oldBindings = this.moduleBindings[moduleName];
103
119
  const uniformsAndBindings =
104
120
  module.getUniforms?.(moduleProps, oldUniforms) || (moduleProps as any);
105
121
 
106
- const {uniforms, bindings} = splitUniformsAndBindings(uniformsAndBindings);
107
- this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};
122
+ const {uniforms, bindings} = splitUniformsAndBindings(
123
+ uniformsAndBindings,
124
+ module.uniformTypes as Readonly<Record<string, CompositeShaderType>>
125
+ );
126
+ this.moduleUniforms[moduleName] = mergeModuleUniforms(
127
+ oldUniforms as Record<string, ShaderModuleUniformValue>,
128
+ uniforms,
129
+ module.uniformTypes as Readonly<Record<string, CompositeShaderType>>
130
+ );
108
131
  this.moduleBindings[moduleName] = {...oldBindings, ...bindings};
109
132
  // this.moduleUniformsChanged ||= moduleName;
110
133
 
@@ -117,11 +140,13 @@ export class ShaderInputs<
117
140
  * @todo should should this include the resolved dependencies?
118
141
  */
119
142
  getModules(): ShaderModule[] {
120
- return Object.values(this.modules);
143
+ return Object.values(this.modules) as ShaderModule[];
121
144
  }
122
145
 
123
146
  /** Get all uniform values for all modules */
124
- getUniformValues(): Partial<Record<keyof ShaderPropsT, Record<string, UniformValue>>> {
147
+ getUniformValues(): Partial<
148
+ Record<keyof ShaderPropsT, Record<string, ShaderModuleUniformValue>>
149
+ > {
125
150
  return this.moduleUniforms;
126
151
  }
127
152
 
@@ -150,10 +175,135 @@ export class ShaderInputs<
150
175
  return table;
151
176
  }
152
177
 
153
- _addModule(module: ShaderModule): void {
178
+ _addModule(module: ShaderInputsModule): void {
154
179
  const moduleName = module.name as keyof ShaderPropsT;
155
180
  // Get default uniforms from module
156
- this.moduleUniforms[moduleName] = module.defaultUniforms || {};
181
+ this.moduleUniforms[moduleName] = mergeModuleUniforms(
182
+ {},
183
+ (module.defaultUniforms || {}) as Record<string, ShaderModuleUniformValue>,
184
+ module.uniformTypes as Readonly<Record<string, CompositeShaderType>>
185
+ );
157
186
  this.moduleBindings[moduleName] = {};
158
187
  }
159
188
  }
189
+
190
+ function mergeModuleUniforms(
191
+ currentUniforms: Record<string, ShaderModuleUniformValue> = {},
192
+ nextUniforms: Record<string, ShaderModuleUniformValue> = {},
193
+ uniformTypes: Readonly<Record<string, CompositeShaderType>> = {}
194
+ ): Record<string, ShaderModuleUniformValue> {
195
+ const mergedUniforms = {...currentUniforms};
196
+ for (const [key, value] of Object.entries(nextUniforms)) {
197
+ if (value === undefined) {
198
+ continue;
199
+ }
200
+
201
+ mergedUniforms[key] = mergeModuleUniformValue(currentUniforms[key], value, uniformTypes[key]);
202
+ }
203
+ return mergedUniforms;
204
+ }
205
+
206
+ function mergeModuleUniformValue(
207
+ currentValue: ShaderModuleUniformValue | undefined,
208
+ nextValue: ShaderModuleUniformValue,
209
+ uniformType: CompositeShaderType | undefined
210
+ ): ShaderModuleUniformValue {
211
+ if (!uniformType || typeof uniformType === 'string') {
212
+ return cloneModuleUniformValue(nextValue);
213
+ }
214
+
215
+ if (Array.isArray(uniformType)) {
216
+ if (isPackedUniformArrayValue(nextValue) || !Array.isArray(nextValue)) {
217
+ return cloneModuleUniformValue(nextValue);
218
+ }
219
+
220
+ const currentArray: Array<ShaderModuleUniformValue | undefined> =
221
+ Array.isArray(currentValue) && !isPackedUniformArrayValue(currentValue)
222
+ ? [...currentValue]
223
+ : [];
224
+ const mergedArray = currentArray.slice();
225
+ for (let index = 0; index < nextValue.length; index++) {
226
+ const elementValue = nextValue[index];
227
+ if (elementValue === undefined) {
228
+ continue;
229
+ }
230
+
231
+ mergedArray[index] = mergeModuleUniformValue(
232
+ currentArray[index],
233
+ elementValue,
234
+ uniformType[0] as CompositeShaderType
235
+ );
236
+ }
237
+ return mergedArray;
238
+ }
239
+
240
+ if (!isPlainUniformObject(nextValue)) {
241
+ return cloneModuleUniformValue(nextValue);
242
+ }
243
+
244
+ const uniformStruct = uniformType as Record<string, CompositeShaderType>;
245
+ const currentObject = isPlainUniformObject(currentValue) ? currentValue : {};
246
+ const mergedObject: Record<string, ShaderModuleUniformValue | undefined> = {...currentObject};
247
+ for (const [key, value] of Object.entries(nextValue)) {
248
+ if (value === undefined) {
249
+ continue;
250
+ }
251
+
252
+ mergedObject[key] = mergeModuleUniformValue(currentObject[key], value, uniformStruct[key]);
253
+ }
254
+ return mergedObject as ShaderModuleUniformValue;
255
+ }
256
+
257
+ function cloneModuleUniformValue(value: ShaderModuleUniformValue): ShaderModuleUniformValue {
258
+ if (ArrayBuffer.isView(value)) {
259
+ return Array.prototype.slice.call(value) as ShaderModuleUniformValue;
260
+ }
261
+
262
+ if (Array.isArray(value)) {
263
+ if (isPackedUniformArrayValue(value)) {
264
+ return value.slice() as ShaderModuleUniformValue;
265
+ }
266
+
267
+ const compositeArray = value as ReadonlyArray<ShaderModuleUniformValue | undefined>;
268
+ return compositeArray.map(element =>
269
+ element === undefined ? undefined : cloneModuleUniformValue(element)
270
+ ) as ShaderModuleUniformValue;
271
+ }
272
+
273
+ if (isPlainUniformObject(value)) {
274
+ return Object.fromEntries(
275
+ Object.entries(value).map(([key, nestedValue]) => [
276
+ key,
277
+ nestedValue === undefined ? undefined : cloneModuleUniformValue(nestedValue)
278
+ ])
279
+ ) as ShaderModuleUniformValue;
280
+ }
281
+
282
+ return value;
283
+ }
284
+
285
+ function isPackedUniformArrayValue(
286
+ value: unknown
287
+ ): value is ReadonlyArray<number> | ArrayBufferView {
288
+ return (
289
+ ArrayBuffer.isView(value) ||
290
+ (Array.isArray(value) && (value.length === 0 || typeof value[0] === 'number'))
291
+ );
292
+ }
293
+
294
+ function isPlainUniformObject(
295
+ value: unknown
296
+ ): value is Record<string, ShaderModuleUniformValue | undefined> {
297
+ return (
298
+ Boolean(value) &&
299
+ typeof value === 'object' &&
300
+ !Array.isArray(value) &&
301
+ !ArrayBuffer.isView(value)
302
+ );
303
+ }
304
+
305
+ function isShaderInputsModuleWithDependencies(
306
+ module: ShaderInputsModule | undefined
307
+ ): module is ShaderInputsModule & {dependencies: NonNullable<ShaderInputsModule['dependencies']>} {
308
+ return Boolean(module?.dependencies);
309
+ }
@@ -0,0 +1,65 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {ComputeShaderLayout, ShaderLayout} from '@luma.gl/core';
6
+ import type {ShaderModule} from '@luma.gl/shadertools';
7
+
8
+ type AnyShaderLayout = ShaderLayout | ComputeShaderLayout;
9
+
10
+ export function mergeShaderModuleBindingsIntoLayout<TShaderLayout extends AnyShaderLayout>(
11
+ shaderLayout: TShaderLayout | null | undefined,
12
+ modules: ShaderModule[]
13
+ ): TShaderLayout | null | undefined {
14
+ if (!shaderLayout || !modules.some(module => module.bindingLayout?.length)) {
15
+ return shaderLayout;
16
+ }
17
+
18
+ const mergedLayout = {
19
+ ...shaderLayout,
20
+ bindings: shaderLayout.bindings.map(binding => ({...binding}))
21
+ } as TShaderLayout;
22
+
23
+ if ('attributes' in (shaderLayout || {})) {
24
+ (mergedLayout as ShaderLayout).attributes = (shaderLayout as ShaderLayout)?.attributes || [];
25
+ }
26
+
27
+ for (const module of modules) {
28
+ for (const bindingLayout of module.bindingLayout || []) {
29
+ for (const relatedBindingName of getRelatedBindingNames(bindingLayout.name)) {
30
+ const binding = mergedLayout.bindings.find(
31
+ candidate => candidate.name === relatedBindingName
32
+ );
33
+ if (binding?.group === 0) {
34
+ binding.group = bindingLayout.group;
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ return mergedLayout;
41
+ }
42
+
43
+ export function shaderModuleHasUniforms(module: ShaderModule): boolean {
44
+ return Boolean(module.uniformTypes && !isObjectEmpty(module.uniformTypes));
45
+ }
46
+
47
+ /** Returns binding-name aliases that should share the module-declared bind group. */
48
+ function getRelatedBindingNames(bindingName: string): string[] {
49
+ const bindingNames = new Set<string>([bindingName, `${bindingName}Uniforms`]);
50
+
51
+ if (!bindingName.endsWith('Uniforms')) {
52
+ bindingNames.add(`${bindingName}Sampler`);
53
+ }
54
+
55
+ return [...bindingNames];
56
+ }
57
+
58
+ function isObjectEmpty(obj: object): boolean {
59
+ // @ts-ignore key is intentionally unused
60
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
+ for (const key in obj) {
62
+ return false;
63
+ }
64
+ return true;
65
+ }
@@ -1,39 +0,0 @@
1
- import type { RenderPipelineProps, ComputePipelineProps, SharedRenderPipeline } from '@luma.gl/core';
2
- import { Device, RenderPipeline, ComputePipeline } from '@luma.gl/core';
3
- export type PipelineFactoryProps = RenderPipelineProps;
4
- /**
5
- * Efficiently creates / caches pipelines
6
- */
7
- export declare class PipelineFactory {
8
- static defaultProps: Required<PipelineFactoryProps>;
9
- /** Get the singleton default pipeline factory for the specified device */
10
- static getDefaultPipelineFactory(device: Device): PipelineFactory;
11
- readonly device: Device;
12
- private _hashCounter;
13
- private readonly _hashes;
14
- private readonly _renderPipelineCache;
15
- private readonly _computePipelineCache;
16
- private readonly _sharedRenderPipelineCache;
17
- get [Symbol.toStringTag](): string;
18
- toString(): string;
19
- constructor(device: Device);
20
- /** Return a RenderPipeline matching supplied props. Reuses an equivalent pipeline if already created. */
21
- createRenderPipeline(props: RenderPipelineProps): RenderPipeline;
22
- /** Return a ComputePipeline matching supplied props. Reuses an equivalent pipeline if already created. */
23
- createComputePipeline(props: ComputePipelineProps): ComputePipeline;
24
- release(pipeline: RenderPipeline | ComputePipeline): void;
25
- createSharedRenderPipeline(props: RenderPipelineProps): SharedRenderPipeline;
26
- releaseSharedRenderPipeline(pipeline: RenderPipeline): void;
27
- /** Destroy a cached pipeline, removing it from the cache if configured to do so. */
28
- private _destroyPipeline;
29
- /** Get the appropriate cache for the type of pipeline */
30
- private _getCache;
31
- /** Calculate a hash based on all the inputs for a compute pipeline */
32
- private _hashComputePipeline;
33
- /** Calculate a hash based on all the inputs for a render pipeline */
34
- private _hashRenderPipeline;
35
- private _hashSharedRenderPipeline;
36
- private _getHash;
37
- private _getWebGLVaryingHash;
38
- }
39
- //# sourceMappingURL=pipeline-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/factories/pipeline-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AACnG,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,eAAe,EAAgB,MAAM,eAAe,CAAC;AAIrF,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAIvD;;GAEG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAoC;IAEvF,0EAA0E;IAC1E,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;IAMjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAiD;IACtF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAkD;IACxF,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAuD;IAElG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAED,QAAQ,IAAI,MAAM;gBAIN,MAAM,EAAE,MAAM;IAI1B,yGAAyG;IACzG,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc;IAuChE,0GAA0G;IAC1G,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe;IAkCnE,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI;IAuBzD,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,GAAG,oBAAoB;IAY5E,2BAA2B,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAoB3D,oFAAoF;IACpF,OAAO,CAAC,gBAAgB;IAexB,yDAAyD;IACzD,OAAO,CAAC,SAAS;IAsBjB,sEAAsE;IACtE,OAAO,CAAC,oBAAoB;IAM5B,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,oBAAoB;CAI7B"}
@@ -1,216 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { RenderPipeline, ComputePipeline, log } from '@luma.gl/core';
5
- import { uid } from "../utils/uid.js";
6
- /**
7
- * Efficiently creates / caches pipelines
8
- */
9
- export class PipelineFactory {
10
- static defaultProps = { ...RenderPipeline.defaultProps };
11
- /** Get the singleton default pipeline factory for the specified device */
12
- static getDefaultPipelineFactory(device) {
13
- const moduleData = device.getModuleData('@luma.gl/engine');
14
- moduleData.defaultPipelineFactory ||= new PipelineFactory(device);
15
- return moduleData.defaultPipelineFactory;
16
- }
17
- device;
18
- _hashCounter = 0;
19
- _hashes = {};
20
- _renderPipelineCache = {};
21
- _computePipelineCache = {};
22
- _sharedRenderPipelineCache = {};
23
- get [Symbol.toStringTag]() {
24
- return 'PipelineFactory';
25
- }
26
- toString() {
27
- return `PipelineFactory(${this.device.id})`;
28
- }
29
- constructor(device) {
30
- this.device = device;
31
- }
32
- /** Return a RenderPipeline matching supplied props. Reuses an equivalent pipeline if already created. */
33
- createRenderPipeline(props) {
34
- if (!this.device.props._cachePipelines) {
35
- return this.device.createRenderPipeline(props);
36
- }
37
- const allProps = { ...RenderPipeline.defaultProps, ...props };
38
- const cache = this._renderPipelineCache;
39
- const hash = this._hashRenderPipeline(allProps);
40
- let pipeline = cache[hash]?.resource;
41
- if (!pipeline) {
42
- const sharedRenderPipeline = this.device.type === 'webgl' && this.device.props._sharePipelines
43
- ? this.createSharedRenderPipeline(allProps)
44
- : undefined;
45
- pipeline = this.device.createRenderPipeline({
46
- ...allProps,
47
- id: allProps.id ? `${allProps.id}-cached` : uid('unnamed-cached'),
48
- _sharedRenderPipeline: sharedRenderPipeline
49
- });
50
- pipeline.hash = hash;
51
- cache[hash] = { resource: pipeline, useCount: 1 };
52
- if (this.device.props.debugFactories) {
53
- log.log(3, `${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
54
- }
55
- }
56
- else {
57
- cache[hash].useCount++;
58
- if (this.device.props.debugFactories) {
59
- log.log(3, `${this}: ${cache[hash].resource} reused, count=${cache[hash].useCount}, (id=${props.id})`)();
60
- }
61
- }
62
- return pipeline;
63
- }
64
- /** Return a ComputePipeline matching supplied props. Reuses an equivalent pipeline if already created. */
65
- createComputePipeline(props) {
66
- if (!this.device.props._cachePipelines) {
67
- return this.device.createComputePipeline(props);
68
- }
69
- const allProps = { ...ComputePipeline.defaultProps, ...props };
70
- const cache = this._computePipelineCache;
71
- const hash = this._hashComputePipeline(allProps);
72
- let pipeline = cache[hash]?.resource;
73
- if (!pipeline) {
74
- pipeline = this.device.createComputePipeline({
75
- ...allProps,
76
- id: allProps.id ? `${allProps.id}-cached` : undefined
77
- });
78
- pipeline.hash = hash;
79
- cache[hash] = { resource: pipeline, useCount: 1 };
80
- if (this.device.props.debugFactories) {
81
- log.log(3, `${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
82
- }
83
- }
84
- else {
85
- cache[hash].useCount++;
86
- if (this.device.props.debugFactories) {
87
- log.log(3, `${this}: ${cache[hash].resource} reused, count=${cache[hash].useCount}, (id=${props.id})`)();
88
- }
89
- }
90
- return pipeline;
91
- }
92
- release(pipeline) {
93
- if (!this.device.props._cachePipelines) {
94
- pipeline.destroy();
95
- return;
96
- }
97
- const cache = this._getCache(pipeline);
98
- const hash = pipeline.hash;
99
- cache[hash].useCount--;
100
- if (cache[hash].useCount === 0) {
101
- this._destroyPipeline(pipeline);
102
- if (this.device.props.debugFactories) {
103
- log.log(3, `${this}: ${pipeline} released and destroyed`)();
104
- }
105
- }
106
- else if (cache[hash].useCount < 0) {
107
- log.error(`${this}: ${pipeline} released, useCount < 0, resetting`)();
108
- cache[hash].useCount = 0;
109
- }
110
- else if (this.device.props.debugFactories) {
111
- log.log(3, `${this}: ${pipeline} released, count=${cache[hash].useCount}`)();
112
- }
113
- }
114
- createSharedRenderPipeline(props) {
115
- const sharedPipelineHash = this._hashSharedRenderPipeline(props);
116
- let sharedCacheItem = this._sharedRenderPipelineCache[sharedPipelineHash];
117
- if (!sharedCacheItem) {
118
- const sharedRenderPipeline = this.device._createSharedRenderPipelineWebGL(props);
119
- sharedCacheItem = { resource: sharedRenderPipeline, useCount: 0 };
120
- this._sharedRenderPipelineCache[sharedPipelineHash] = sharedCacheItem;
121
- }
122
- sharedCacheItem.useCount++;
123
- return sharedCacheItem.resource;
124
- }
125
- releaseSharedRenderPipeline(pipeline) {
126
- if (!pipeline.sharedRenderPipeline) {
127
- return;
128
- }
129
- const sharedPipelineHash = this._hashSharedRenderPipeline(pipeline.sharedRenderPipeline.props);
130
- const sharedCacheItem = this._sharedRenderPipelineCache[sharedPipelineHash];
131
- if (!sharedCacheItem) {
132
- return;
133
- }
134
- sharedCacheItem.useCount--;
135
- if (sharedCacheItem.useCount === 0) {
136
- sharedCacheItem.resource.destroy();
137
- delete this._sharedRenderPipelineCache[sharedPipelineHash];
138
- }
139
- }
140
- // PRIVATE
141
- /** Destroy a cached pipeline, removing it from the cache if configured to do so. */
142
- _destroyPipeline(pipeline) {
143
- const cache = this._getCache(pipeline);
144
- if (!this.device.props._destroyPipelines) {
145
- return false;
146
- }
147
- delete cache[pipeline.hash];
148
- pipeline.destroy();
149
- if (pipeline instanceof RenderPipeline) {
150
- this.releaseSharedRenderPipeline(pipeline);
151
- }
152
- return true;
153
- }
154
- /** Get the appropriate cache for the type of pipeline */
155
- _getCache(pipeline) {
156
- let cache;
157
- if (pipeline instanceof ComputePipeline) {
158
- cache = this._computePipelineCache;
159
- }
160
- if (pipeline instanceof RenderPipeline) {
161
- cache = this._renderPipelineCache;
162
- }
163
- if (!cache) {
164
- throw new Error(`${this}`);
165
- }
166
- if (!cache[pipeline.hash]) {
167
- throw new Error(`${this}: ${pipeline} matched incorrect entry`);
168
- }
169
- return cache;
170
- }
171
- /** Calculate a hash based on all the inputs for a compute pipeline */
172
- _hashComputePipeline(props) {
173
- const { type } = this.device;
174
- const shaderHash = this._getHash(props.shader.source);
175
- return `${type}/C/${shaderHash}`;
176
- }
177
- /** Calculate a hash based on all the inputs for a render pipeline */
178
- _hashRenderPipeline(props) {
179
- const vsHash = props.vs ? this._getHash(props.vs.source) : 0;
180
- const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
181
- const varyingHash = this._getWebGLVaryingHash(props);
182
- const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
183
- const { type } = this.device;
184
- switch (type) {
185
- case 'webgl':
186
- // WebGL wrappers preserve default topology and parameter semantics for direct
187
- // callers, even though the underlying linked program may be shared separately.
188
- const webglParameterHash = this._getHash(JSON.stringify(props.parameters));
189
- return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${webglParameterHash}BL${bufferLayoutHash}`;
190
- case 'webgpu':
191
- default:
192
- // On WebGPU we need to rebuild the pipeline if topology, parameters or bufferLayout change
193
- const parameterHash = this._getHash(JSON.stringify(props.parameters));
194
- // TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?
195
- // create a deepHash() to deduplicate?
196
- return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}`;
197
- }
198
- }
199
- _hashSharedRenderPipeline(props) {
200
- const vsHash = props.vs ? this._getHash(props.vs.source) : 0;
201
- const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
202
- const varyingHash = this._getWebGLVaryingHash(props);
203
- return `webgl/S/${vsHash}/${fsHash}V${varyingHash}`;
204
- }
205
- _getHash(key) {
206
- if (this._hashes[key] === undefined) {
207
- this._hashes[key] = this._hashCounter++;
208
- }
209
- return this._hashes[key];
210
- }
211
- _getWebGLVaryingHash(props) {
212
- const { varyings = [], bufferMode = null } = props;
213
- return this._getHash(JSON.stringify({ varyings, bufferMode }));
214
- }
215
- }
216
- //# sourceMappingURL=pipeline-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline-factory.js","sourceRoot":"","sources":["../../src/factories/pipeline-factory.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAS,cAAc,EAAE,eAAe,EAAY,GAAG,EAAC,MAAM,eAAe,CAAC;AAErF,OAAO,EAAC,GAAG,EAAC,wBAAqB;AAMjC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAC,YAAY,GAAmC,EAAC,GAAG,cAAc,CAAC,YAAY,EAAC,CAAC;IAEvF,0EAA0E;IAC1E,MAAM,CAAC,yBAAyB,CAAC,MAAc;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAoB,iBAAiB,CAAC,CAAC;QAC9E,UAAU,CAAC,sBAAsB,KAAK,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QAClE,OAAO,UAAU,CAAC,sBAAsB,CAAC;IAC3C,CAAC;IAEQ,MAAM,CAAS;IAEhB,YAAY,GAAW,CAAC,CAAC;IAChB,OAAO,GAA2B,EAAE,CAAC;IACrC,oBAAoB,GAA8C,EAAE,CAAC;IACrE,qBAAqB,GAA+C,EAAE,CAAC;IACvE,0BAA0B,GAAoD,EAAE,CAAC;IAElG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,iBAAiB,CAAC;I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GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEO,oBAAoB,CAAC,KAA0B;QACrD,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,UAAU,GAAG,IAAI,EAAC,GAAG,KAAK,CAAC;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAC,CAAC,CAAC,CAAC;IAC/D,CAAC"}
@@ -1,19 +0,0 @@
1
- import { Device, Shader, ShaderProps } from '@luma.gl/core';
2
- /** Manages a cached pool of Shaders for reuse. */
3
- export declare class ShaderFactory {
4
- static readonly defaultProps: Required<ShaderProps>;
5
- /** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
6
- static getDefaultShaderFactory(device: Device): ShaderFactory;
7
- readonly device: Device;
8
- private readonly _cache;
9
- get [Symbol.toStringTag](): string;
10
- toString(): string;
11
- /** @internal */
12
- constructor(device: Device);
13
- /** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
14
- createShader(props: ShaderProps): Shader;
15
- /** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
16
- release(shader: Shader): void;
17
- protected _hashShader(value: Shader | ShaderProps): string;
18
- }
19
- //# sourceMappingURL=shader-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader-factory.d.ts","sourceRoot":"","sources":["../../src/factories/shader-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAM,MAAM,eAAe,CAAC;AAK/D,kDAAkD;AAClD,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAA4B;IAE/E,iGAAiG;IACjG,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAM7D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAED,QAAQ,IAAI,MAAM;IAIlB,gBAAgB;gBACJ,MAAM,EAAE,MAAM;IAI1B,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IA8BxC,wFAAwF;IACxF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IA4B7B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM;CAG3D"}