@luma.gl/core 9.2.6 → 9.3.0-alpha.10
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.
- package/dist/adapter/canvas-context.d.ts +6 -162
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -419
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +81 -16
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +191 -10
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +1 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +14 -6
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +3 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -1
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +30 -7
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +68 -2
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/fence.d.ts +16 -0
- package/dist/adapter/resources/fence.d.ts.map +1 -0
- package/dist/adapter/resources/fence.js +17 -0
- package/dist/adapter/resources/fence.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +15 -12
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +28 -10
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +21 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +13 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +243 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +168 -28
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +284 -25
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +1 -1
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +3 -1
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +10 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +6 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -1
- package/dist/adapter-utils/bind-groups.d.ts +9 -0
- package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
- package/dist/adapter-utils/bind-groups.js +41 -0
- package/dist/adapter-utils/bind-groups.js.map +1 -0
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +2686 -644
- package/dist/dist.min.js +10 -9
- package/dist/factories/bind-group-factory.d.ts +20 -0
- package/dist/factories/bind-group-factory.d.ts.map +1 -0
- package/dist/factories/bind-group-factory.js +79 -0
- package/dist/factories/bind-group-factory.js.map +1 -0
- package/dist/factories/core-module-state.d.ts +7 -0
- package/dist/factories/core-module-state.d.ts.map +1 -0
- package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
- package/dist/factories/core-module-state.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +54 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -0
- package/dist/factories/pipeline-factory.js +270 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/shader-factory.d.ts +20 -0
- package/dist/factories/shader-factory.d.ts.map +1 -0
- package/dist/factories/shader-factory.js +84 -0
- package/dist/factories/shader-factory.js.map +1 -0
- package/dist/index.cjs +2422 -554
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/shader-block-writer.d.ts +51 -0
- package/dist/portable/shader-block-writer.d.ts.map +1 -0
- package/dist/portable/shader-block-writer.js +185 -0
- package/dist/portable/shader-block-writer.js.map +1 -0
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-store.d.ts +55 -24
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +73 -25
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
- package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
- package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
- package/dist/shadertypes/data-types/data-types.d.ts +31 -12
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.js +2 -1
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
- package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
- package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
- package/dist/shadertypes/image-types/image-types.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
- package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.js +30 -0
- package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
- package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
- package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
- package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
- package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
- package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
- package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.js +41 -0
- package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -556
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +308 -24
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +13 -5
- package/src/adapter/resources/command-buffer.ts +4 -2
- package/src/adapter/resources/command-encoder.ts +101 -10
- package/src/adapter/resources/compute-pipeline.ts +2 -2
- package/src/adapter/resources/fence.ts +32 -0
- package/src/adapter/resources/framebuffer.ts +16 -13
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +52 -16
- package/src/adapter/resources/resource.ts +289 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +427 -49
- package/src/adapter/types/attachments.ts +1 -1
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +4 -1
- package/src/adapter/types/shader-layout.ts +15 -9
- package/src/adapter/types/uniforms.ts +12 -0
- package/src/adapter-utils/bind-groups.ts +71 -0
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
- package/src/factories/bind-group-factory.ts +139 -0
- package/src/factories/core-module-state.ts +11 -0
- package/src/factories/pipeline-factory.ts +328 -0
- package/src/factories/shader-factory.ts +103 -0
- package/src/index.ts +70 -26
- package/src/portable/shader-block-writer.ts +254 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +98 -40
- package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
- package/src/shadertypes/data-types/data-types.ts +100 -48
- package/src/shadertypes/data-types/decode-data-types.ts +2 -1
- package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
- package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
- package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
- package/src/shadertypes/shader-types/shader-types.ts +207 -0
- package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
- package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
- package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
- package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
- package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
- package/src/shadertypes/texture-types/texture-layout.ts +60 -0
- package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
- package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
- package/dist/image-utils/image-types.d.ts.map +0 -1
- package/dist/image-utils/image-types.js.map +0 -1
- package/dist/portable/uniform-buffer-layout.d.ts +0 -28
- package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/portable/uniform-buffer-layout.js +0 -96
- package/dist/portable/uniform-buffer-layout.js.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
- package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/shader-types.js.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
- package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-formats.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
- package/src/portable/uniform-buffer-layout.ts +0 -118
- package/src/shadertypes/data-types/shader-types.ts +0 -87
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
- /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
- /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Device} from '../adapter/device';
|
|
6
|
+
import {ComputePipeline, type ComputePipelineProps} from '../adapter/resources/compute-pipeline';
|
|
7
|
+
import {RenderPipeline, type RenderPipelineProps} from '../adapter/resources/render-pipeline';
|
|
8
|
+
import {Resource} from '../adapter/resources/resource';
|
|
9
|
+
import type {SharedRenderPipeline} from '../adapter/resources/shared-render-pipeline';
|
|
10
|
+
import {log} from '../utils/log';
|
|
11
|
+
import {uid} from '../utils/uid';
|
|
12
|
+
import type {CoreModuleState} from './core-module-state';
|
|
13
|
+
|
|
14
|
+
export type PipelineFactoryProps = RenderPipelineProps;
|
|
15
|
+
|
|
16
|
+
type CacheItem<ResourceT extends Resource<any>> = {resource: ResourceT; useCount: number};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Efficiently creates / caches pipelines
|
|
20
|
+
*/
|
|
21
|
+
export class PipelineFactory {
|
|
22
|
+
static defaultProps: Required<PipelineFactoryProps> = {...RenderPipeline.defaultProps};
|
|
23
|
+
|
|
24
|
+
/** Get the singleton default pipeline factory for the specified device */
|
|
25
|
+
static getDefaultPipelineFactory(device: Device): PipelineFactory {
|
|
26
|
+
const moduleData = device.getModuleData<CoreModuleState>('@luma.gl/core');
|
|
27
|
+
moduleData.defaultPipelineFactory ||= new PipelineFactory(device);
|
|
28
|
+
return moduleData.defaultPipelineFactory;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
readonly device: Device;
|
|
32
|
+
|
|
33
|
+
private _hashCounter: number = 0;
|
|
34
|
+
private readonly _hashes: Record<string, number> = {};
|
|
35
|
+
private readonly _renderPipelineCache: Record<string, CacheItem<RenderPipeline>> = {};
|
|
36
|
+
private readonly _computePipelineCache: Record<string, CacheItem<ComputePipeline>> = {};
|
|
37
|
+
private readonly _sharedRenderPipelineCache: Record<string, CacheItem<SharedRenderPipeline>> = {};
|
|
38
|
+
|
|
39
|
+
get [Symbol.toStringTag](): string {
|
|
40
|
+
return 'PipelineFactory';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toString(): string {
|
|
44
|
+
return `PipelineFactory(${this.device.id})`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor(device: Device) {
|
|
48
|
+
this.device = device;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* WebGL has two cache layers with different priorities:
|
|
53
|
+
* - `_sharedRenderPipelineCache` owns `WEBGLSharedRenderPipeline` / `WebGLProgram` reuse.
|
|
54
|
+
* - `_renderPipelineCache` owns `RenderPipeline` wrapper reuse.
|
|
55
|
+
*
|
|
56
|
+
* Shared WebGL program reuse is the hard requirement. Wrapper reuse is beneficial,
|
|
57
|
+
* but wrapper cache misses are acceptable if that keeps the cache logic simple and
|
|
58
|
+
* prevents incorrect cache hits.
|
|
59
|
+
*
|
|
60
|
+
* In particular, wrapper hash logic must never force program creation or linked-program
|
|
61
|
+
* introspection just to decide whether a shared WebGL program can be reused.
|
|
62
|
+
*/
|
|
63
|
+
/** Return a RenderPipeline matching supplied props. Reuses an equivalent pipeline if already created. */
|
|
64
|
+
createRenderPipeline(props: RenderPipelineProps): RenderPipeline {
|
|
65
|
+
if (!this.device.props._cachePipelines) {
|
|
66
|
+
return this.device.createRenderPipeline(props);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const allProps: Required<RenderPipelineProps> = {...RenderPipeline.defaultProps, ...props};
|
|
70
|
+
|
|
71
|
+
const cache = this._renderPipelineCache;
|
|
72
|
+
const hash = this._hashRenderPipeline(allProps);
|
|
73
|
+
|
|
74
|
+
let pipeline: RenderPipeline = cache[hash]?.resource;
|
|
75
|
+
if (!pipeline) {
|
|
76
|
+
const sharedRenderPipeline =
|
|
77
|
+
this.device.type === 'webgl' && this.device.props._sharePipelines
|
|
78
|
+
? this.createSharedRenderPipeline(allProps)
|
|
79
|
+
: undefined;
|
|
80
|
+
pipeline = this.device.createRenderPipeline({
|
|
81
|
+
...allProps,
|
|
82
|
+
id: allProps.id ? `${allProps.id}-cached` : uid('unnamed-cached'),
|
|
83
|
+
_sharedRenderPipeline: sharedRenderPipeline
|
|
84
|
+
});
|
|
85
|
+
pipeline.hash = hash;
|
|
86
|
+
cache[hash] = {resource: pipeline, useCount: 1};
|
|
87
|
+
if (this.device.props.debugFactories) {
|
|
88
|
+
log.log(3, `${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
cache[hash].useCount++;
|
|
92
|
+
if (this.device.props.debugFactories) {
|
|
93
|
+
log.log(
|
|
94
|
+
3,
|
|
95
|
+
`${this}: ${cache[hash].resource} reused, count=${cache[hash].useCount}, (id=${props.id})`
|
|
96
|
+
)();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return pipeline;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Return a ComputePipeline matching supplied props. Reuses an equivalent pipeline if already created. */
|
|
104
|
+
createComputePipeline(props: ComputePipelineProps): ComputePipeline {
|
|
105
|
+
if (!this.device.props._cachePipelines) {
|
|
106
|
+
return this.device.createComputePipeline(props);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const allProps: Required<ComputePipelineProps> = {...ComputePipeline.defaultProps, ...props};
|
|
110
|
+
|
|
111
|
+
const cache = this._computePipelineCache;
|
|
112
|
+
const hash = this._hashComputePipeline(allProps);
|
|
113
|
+
|
|
114
|
+
let pipeline: ComputePipeline = cache[hash]?.resource;
|
|
115
|
+
if (!pipeline) {
|
|
116
|
+
pipeline = this.device.createComputePipeline({
|
|
117
|
+
...allProps,
|
|
118
|
+
id: allProps.id ? `${allProps.id}-cached` : undefined
|
|
119
|
+
});
|
|
120
|
+
pipeline.hash = hash;
|
|
121
|
+
cache[hash] = {resource: pipeline, useCount: 1};
|
|
122
|
+
if (this.device.props.debugFactories) {
|
|
123
|
+
log.log(3, `${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
cache[hash].useCount++;
|
|
127
|
+
if (this.device.props.debugFactories) {
|
|
128
|
+
log.log(
|
|
129
|
+
3,
|
|
130
|
+
`${this}: ${cache[hash].resource} reused, count=${cache[hash].useCount}, (id=${props.id})`
|
|
131
|
+
)();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return pipeline;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
release(pipeline: RenderPipeline | ComputePipeline): void {
|
|
139
|
+
if (!this.device.props._cachePipelines) {
|
|
140
|
+
pipeline.destroy();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const cache = this._getCache(pipeline);
|
|
145
|
+
const hash = pipeline.hash;
|
|
146
|
+
|
|
147
|
+
cache[hash].useCount--;
|
|
148
|
+
if (cache[hash].useCount === 0) {
|
|
149
|
+
this._destroyPipeline(pipeline);
|
|
150
|
+
if (this.device.props.debugFactories) {
|
|
151
|
+
log.log(3, `${this}: ${pipeline} released and destroyed`)();
|
|
152
|
+
}
|
|
153
|
+
} else if (cache[hash].useCount < 0) {
|
|
154
|
+
log.error(`${this}: ${pipeline} released, useCount < 0, resetting`)();
|
|
155
|
+
cache[hash].useCount = 0;
|
|
156
|
+
} else if (this.device.props.debugFactories) {
|
|
157
|
+
log.log(3, `${this}: ${pipeline} released, count=${cache[hash].useCount}`)();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
createSharedRenderPipeline(props: RenderPipelineProps): SharedRenderPipeline {
|
|
162
|
+
const sharedPipelineHash = this._hashSharedRenderPipeline(props);
|
|
163
|
+
let sharedCacheItem = this._sharedRenderPipelineCache[sharedPipelineHash];
|
|
164
|
+
if (!sharedCacheItem) {
|
|
165
|
+
const sharedRenderPipeline = this.device._createSharedRenderPipelineWebGL(props);
|
|
166
|
+
sharedCacheItem = {resource: sharedRenderPipeline, useCount: 0};
|
|
167
|
+
this._sharedRenderPipelineCache[sharedPipelineHash] = sharedCacheItem;
|
|
168
|
+
}
|
|
169
|
+
sharedCacheItem.useCount++;
|
|
170
|
+
return sharedCacheItem.resource;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
releaseSharedRenderPipeline(pipeline: RenderPipeline): void {
|
|
174
|
+
if (!pipeline.sharedRenderPipeline) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const sharedPipelineHash = this._hashSharedRenderPipeline(pipeline.sharedRenderPipeline.props);
|
|
179
|
+
const sharedCacheItem = this._sharedRenderPipelineCache[sharedPipelineHash];
|
|
180
|
+
if (!sharedCacheItem) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
sharedCacheItem.useCount--;
|
|
185
|
+
if (sharedCacheItem.useCount === 0) {
|
|
186
|
+
sharedCacheItem.resource.destroy();
|
|
187
|
+
delete this._sharedRenderPipelineCache[sharedPipelineHash];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// PRIVATE
|
|
192
|
+
|
|
193
|
+
/** Destroy a cached pipeline, removing it from the cache if configured to do so. */
|
|
194
|
+
private _destroyPipeline(pipeline: RenderPipeline | ComputePipeline): boolean {
|
|
195
|
+
const cache = this._getCache(pipeline);
|
|
196
|
+
|
|
197
|
+
if (!this.device.props._destroyPipelines) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
delete cache[pipeline.hash];
|
|
202
|
+
pipeline.destroy();
|
|
203
|
+
if (pipeline instanceof RenderPipeline) {
|
|
204
|
+
this.releaseSharedRenderPipeline(pipeline);
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Get the appropriate cache for the type of pipeline */
|
|
210
|
+
private _getCache(
|
|
211
|
+
pipeline: RenderPipeline | ComputePipeline
|
|
212
|
+
): Record<string, CacheItem<RenderPipeline>> | Record<string, CacheItem<ComputePipeline>> {
|
|
213
|
+
let cache:
|
|
214
|
+
| Record<string, CacheItem<RenderPipeline>>
|
|
215
|
+
| Record<string, CacheItem<ComputePipeline>>
|
|
216
|
+
| undefined;
|
|
217
|
+
if (pipeline instanceof ComputePipeline) {
|
|
218
|
+
cache = this._computePipelineCache;
|
|
219
|
+
}
|
|
220
|
+
if (pipeline instanceof RenderPipeline) {
|
|
221
|
+
cache = this._renderPipelineCache;
|
|
222
|
+
}
|
|
223
|
+
if (!cache) {
|
|
224
|
+
throw new Error(`${this}`);
|
|
225
|
+
}
|
|
226
|
+
if (!cache[pipeline.hash]) {
|
|
227
|
+
throw new Error(`${this}: ${pipeline} matched incorrect entry`);
|
|
228
|
+
}
|
|
229
|
+
return cache;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Calculate a hash based on all the inputs for a compute pipeline */
|
|
233
|
+
private _hashComputePipeline(props: ComputePipelineProps): string {
|
|
234
|
+
const {type} = this.device;
|
|
235
|
+
const shaderHash = this._getHash(props.shader.source);
|
|
236
|
+
const shaderLayoutHash = this._getHash(JSON.stringify(props.shaderLayout));
|
|
237
|
+
return `${type}/C/${shaderHash}SL${shaderLayoutHash}`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
241
|
+
private _hashRenderPipeline(props: RenderPipelineProps): string {
|
|
242
|
+
// Backend-specific hashing requirements:
|
|
243
|
+
// - WebGPU hash keys must include every immutable descriptor-shaping input that can
|
|
244
|
+
// change the created `GPURenderPipeline`, including attachment formats.
|
|
245
|
+
// - WebGL hash keys only govern wrapper reuse. They must remain compatible with
|
|
246
|
+
// shared-program reuse and must not depend on linked-program introspection just
|
|
247
|
+
// to decide whether a shared `WebGLProgram` can be reused.
|
|
248
|
+
//
|
|
249
|
+
// General exclusions:
|
|
250
|
+
// - `id`, `handle`: resource identity / caller-supplied handles, not cache shape
|
|
251
|
+
// - `bindings`: mutable per-pipeline compatibility state
|
|
252
|
+
// - `disableWarnings`: logging only, no rendering impact
|
|
253
|
+
// - `vsConstants`, `fsConstants`: currently unused by pipeline creation
|
|
254
|
+
const vsHash = props.vs ? this._getHash(props.vs.source) : 0;
|
|
255
|
+
const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
|
|
256
|
+
const varyingHash = this._getWebGLVaryingHash(props);
|
|
257
|
+
const shaderLayoutHash = this._getHash(JSON.stringify(props.shaderLayout));
|
|
258
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
259
|
+
|
|
260
|
+
const {type} = this.device;
|
|
261
|
+
switch (type) {
|
|
262
|
+
case 'webgl':
|
|
263
|
+
// WebGL wrappers preserve default topology and parameter semantics for direct
|
|
264
|
+
// callers, even though the underlying linked program may be shared separately.
|
|
265
|
+
// Future WebGL-only additions here must not turn wrapper reuse into a prerequisite
|
|
266
|
+
// for shared `WebGLProgram` reuse.
|
|
267
|
+
const webglParameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
268
|
+
return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${webglParameterHash}SL${shaderLayoutHash}BL${bufferLayoutHash}`;
|
|
269
|
+
|
|
270
|
+
case 'webgpu':
|
|
271
|
+
default:
|
|
272
|
+
// On WebGPU we need to rebuild the pipeline if topology, entry points,
|
|
273
|
+
// shader/layout data, parameters, bufferLayout or attachment formats change.
|
|
274
|
+
// Attachment formats must stay in the key so screen and offscreen passes do not
|
|
275
|
+
// accidentally alias the same cached `GPURenderPipeline`.
|
|
276
|
+
const entryPointHash = this._getHash(
|
|
277
|
+
JSON.stringify({
|
|
278
|
+
vertexEntryPoint: props.vertexEntryPoint,
|
|
279
|
+
fragmentEntryPoint: props.fragmentEntryPoint
|
|
280
|
+
})
|
|
281
|
+
);
|
|
282
|
+
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
283
|
+
const attachmentHash = this._getWebGPUAttachmentHash(props);
|
|
284
|
+
// TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?
|
|
285
|
+
// create a deepHash() to deduplicate?
|
|
286
|
+
return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}EP${entryPointHash}P${parameterHash}SL${shaderLayoutHash}BL${bufferLayoutHash}A${attachmentHash}`;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// This is the only gate for shared `WebGLProgram` reuse.
|
|
291
|
+
// Only include inputs that affect program linking or transform-feedback linkage.
|
|
292
|
+
// Wrapper-only concerns such as topology, parameters, attachment formats and layout
|
|
293
|
+
// overrides must not be added here.
|
|
294
|
+
private _hashSharedRenderPipeline(props: RenderPipelineProps): string {
|
|
295
|
+
const vsHash = props.vs ? this._getHash(props.vs.source) : 0;
|
|
296
|
+
const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
|
|
297
|
+
const varyingHash = this._getWebGLVaryingHash(props);
|
|
298
|
+
return `webgl/S/${vsHash}/${fsHash}V${varyingHash}`;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private _getHash(key: string): number {
|
|
302
|
+
if (this._hashes[key] === undefined) {
|
|
303
|
+
this._hashes[key] = this._hashCounter++;
|
|
304
|
+
}
|
|
305
|
+
return this._hashes[key];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private _getWebGLVaryingHash(props: RenderPipelineProps): number {
|
|
309
|
+
const {varyings = [], bufferMode = null} = props;
|
|
310
|
+
return this._getHash(JSON.stringify({varyings, bufferMode}));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private _getWebGPUAttachmentHash(props: RenderPipelineProps): number {
|
|
314
|
+
const colorAttachmentFormats = props.colorAttachmentFormats ?? [
|
|
315
|
+
this.device.preferredColorFormat
|
|
316
|
+
];
|
|
317
|
+
const depthStencilAttachmentFormat = props.parameters?.depthWriteEnabled
|
|
318
|
+
? props.depthStencilAttachmentFormat || this.device.preferredDepthFormat
|
|
319
|
+
: null;
|
|
320
|
+
|
|
321
|
+
return this._getHash(
|
|
322
|
+
JSON.stringify({
|
|
323
|
+
colorAttachmentFormats,
|
|
324
|
+
depthStencilAttachmentFormat
|
|
325
|
+
})
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Device} from '../adapter/device';
|
|
6
|
+
import {Shader, type ShaderProps} from '../adapter/resources/shader';
|
|
7
|
+
import {log} from '../utils/log';
|
|
8
|
+
import type {CoreModuleState} from './core-module-state';
|
|
9
|
+
|
|
10
|
+
type CacheItem = {resource: Shader; useCount: number};
|
|
11
|
+
|
|
12
|
+
/** Manages a cached pool of Shaders for reuse. */
|
|
13
|
+
export class ShaderFactory {
|
|
14
|
+
static readonly defaultProps: Required<ShaderProps> = {...Shader.defaultProps};
|
|
15
|
+
|
|
16
|
+
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
17
|
+
static getDefaultShaderFactory(device: Device): ShaderFactory {
|
|
18
|
+
const moduleData = device.getModuleData<CoreModuleState>('@luma.gl/core');
|
|
19
|
+
moduleData.defaultShaderFactory ||= new ShaderFactory(device);
|
|
20
|
+
return moduleData.defaultShaderFactory;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public readonly device: Device;
|
|
24
|
+
|
|
25
|
+
private readonly _cache: Record<string, CacheItem> = {};
|
|
26
|
+
|
|
27
|
+
get [Symbol.toStringTag](): string {
|
|
28
|
+
return 'ShaderFactory';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toString(): string {
|
|
32
|
+
return `${this[Symbol.toStringTag]}(${this.device.id})`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @internal */
|
|
36
|
+
constructor(device: Device) {
|
|
37
|
+
this.device = device;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
41
|
+
createShader(props: ShaderProps): Shader {
|
|
42
|
+
if (!this.device.props._cacheShaders) {
|
|
43
|
+
return this.device.createShader(props);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const key = this._hashShader(props);
|
|
47
|
+
|
|
48
|
+
let cacheEntry = this._cache[key];
|
|
49
|
+
if (!cacheEntry) {
|
|
50
|
+
const resource = this.device.createShader({
|
|
51
|
+
...props,
|
|
52
|
+
id: props.id ? `${props.id}-cached` : undefined
|
|
53
|
+
});
|
|
54
|
+
this._cache[key] = cacheEntry = {resource, useCount: 1};
|
|
55
|
+
if (this.device.props.debugFactories) {
|
|
56
|
+
log.log(3, `${this}: Created new shader ${resource.id}`)();
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
cacheEntry.useCount++;
|
|
60
|
+
if (this.device.props.debugFactories) {
|
|
61
|
+
log.log(
|
|
62
|
+
3,
|
|
63
|
+
`${this}: Reusing shader ${cacheEntry.resource.id} count=${cacheEntry.useCount}`
|
|
64
|
+
)();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return cacheEntry.resource;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
72
|
+
release(shader: Shader): void {
|
|
73
|
+
if (!this.device.props._cacheShaders) {
|
|
74
|
+
shader.destroy();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const key = this._hashShader(shader);
|
|
79
|
+
const cacheEntry = this._cache[key];
|
|
80
|
+
if (cacheEntry) {
|
|
81
|
+
cacheEntry.useCount--;
|
|
82
|
+
if (cacheEntry.useCount === 0) {
|
|
83
|
+
if (this.device.props._destroyShaders) {
|
|
84
|
+
delete this._cache[key];
|
|
85
|
+
cacheEntry.resource.destroy();
|
|
86
|
+
if (this.device.props.debugFactories) {
|
|
87
|
+
log.log(3, `${this}: Releasing shader ${shader.id}, destroyed`)();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else if (cacheEntry.useCount < 0) {
|
|
91
|
+
throw new Error(`ShaderFactory: Shader ${shader.id} released too many times`);
|
|
92
|
+
} else if (this.device.props.debugFactories) {
|
|
93
|
+
log.log(3, `${this}: Releasing shader ${shader.id} count=${cacheEntry.useCount}`)();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// PRIVATE
|
|
99
|
+
|
|
100
|
+
protected _hashShader(value: Shader | ShaderProps): string {
|
|
101
|
+
return `${value.stage}:${value.source}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,8 @@ export {Device, DeviceFeatures, DeviceLimits} from './adapter/device';
|
|
|
19
19
|
|
|
20
20
|
export type {CanvasContextProps} from './adapter/canvas-context';
|
|
21
21
|
export {CanvasContext} from './adapter/canvas-context';
|
|
22
|
+
export type {PresentationContextProps} from './adapter/presentation-context';
|
|
23
|
+
export {PresentationContext} from './adapter/presentation-context';
|
|
22
24
|
|
|
23
25
|
// GPU RESOURCES
|
|
24
26
|
export {Resource, type ResourceProps} from './adapter/resources/resource';
|
|
@@ -43,6 +45,14 @@ export {Framebuffer} from './adapter/resources/framebuffer';
|
|
|
43
45
|
|
|
44
46
|
export type {RenderPipelineProps} from './adapter/resources/render-pipeline';
|
|
45
47
|
export {RenderPipeline} from './adapter/resources/render-pipeline';
|
|
48
|
+
export {
|
|
49
|
+
SharedRenderPipeline,
|
|
50
|
+
type SharedRenderPipelineProps
|
|
51
|
+
} from './adapter/resources/shared-render-pipeline';
|
|
52
|
+
export type {PipelineFactoryProps} from './factories/pipeline-factory';
|
|
53
|
+
export {PipelineFactory} from './factories/pipeline-factory';
|
|
54
|
+
export {ShaderFactory} from './factories/shader-factory';
|
|
55
|
+
export {_getDefaultBindGroupFactory} from './factories/bind-group-factory';
|
|
46
56
|
|
|
47
57
|
export type {RenderPassProps} from './adapter/resources/render-pass';
|
|
48
58
|
export {RenderPass} from './adapter/resources/render-pass';
|
|
@@ -68,11 +78,19 @@ export {TransformFeedback} from './adapter/resources/transform-feedback';
|
|
|
68
78
|
export type {QuerySetProps} from './adapter/resources/query-set';
|
|
69
79
|
export {QuerySet} from './adapter/resources/query-set';
|
|
70
80
|
|
|
81
|
+
export {Fence, type FenceProps} from './adapter/resources/fence';
|
|
82
|
+
|
|
71
83
|
export type {PipelineLayoutProps} from './adapter/resources/pipeline-layout';
|
|
72
84
|
export {PipelineLayout} from './adapter/resources/pipeline-layout';
|
|
73
85
|
|
|
74
86
|
// PORTABLE API - UNIFORM BUFFERS
|
|
75
|
-
export {
|
|
87
|
+
export {
|
|
88
|
+
makeShaderBlockLayout,
|
|
89
|
+
type ShaderBlockLayout,
|
|
90
|
+
type ShaderBlockLayoutEntry,
|
|
91
|
+
type ShaderBlockLayoutOptions
|
|
92
|
+
} from './shadertypes/shader-types/shader-block-layout';
|
|
93
|
+
export {ShaderBlockWriter} from './portable/shader-block-writer';
|
|
76
94
|
export {UniformBlock} from './portable/uniform-block';
|
|
77
95
|
export {UniformStore} from './portable/uniform-store';
|
|
78
96
|
// TEXTURE TYPES
|
|
@@ -80,11 +98,13 @@ export {UniformStore} from './portable/uniform-store';
|
|
|
80
98
|
// API TYPES
|
|
81
99
|
export type {CompilerMessage} from './adapter/types/compiler-message';
|
|
82
100
|
|
|
83
|
-
export type {ExternalImage} from './image-
|
|
101
|
+
export type {ExternalImage} from './shadertypes/image-types/image-types';
|
|
84
102
|
|
|
85
103
|
export {
|
|
86
104
|
type CopyExternalImageOptions,
|
|
87
|
-
type CopyImageDataOptions
|
|
105
|
+
type CopyImageDataOptions,
|
|
106
|
+
type TextureReadOptions,
|
|
107
|
+
type TextureWriteOptions
|
|
88
108
|
} from './adapter/resources/texture';
|
|
89
109
|
|
|
90
110
|
export type {Parameters, PrimitiveTopology, IndexFormat} from './adapter/types/parameters';
|
|
@@ -114,6 +134,8 @@ export type {
|
|
|
114
134
|
AttributeDeclaration,
|
|
115
135
|
BindingDeclaration,
|
|
116
136
|
Binding,
|
|
137
|
+
Bindings,
|
|
138
|
+
BindingsByGroup,
|
|
117
139
|
UniformBufferBindingLayout,
|
|
118
140
|
StorageBufferBindingLayout,
|
|
119
141
|
TextureBindingLayout,
|
|
@@ -130,6 +152,11 @@ export type {
|
|
|
130
152
|
} from './adapter/types/shader-layout';
|
|
131
153
|
|
|
132
154
|
export type {UniformValue} from './adapter/types/uniforms';
|
|
155
|
+
export type {
|
|
156
|
+
CompositeUniformValue,
|
|
157
|
+
CompositeUniformValueArray,
|
|
158
|
+
CompositeUniformValueStruct
|
|
159
|
+
} from './adapter/types/uniforms';
|
|
133
160
|
|
|
134
161
|
// TYPED ARRAY TYPES
|
|
135
162
|
|
|
@@ -148,33 +175,38 @@ export {
|
|
|
148
175
|
type SignedDataType,
|
|
149
176
|
type NormalizedDataType,
|
|
150
177
|
type DataTypeInfo,
|
|
151
|
-
type
|
|
152
|
-
type
|
|
178
|
+
type PrimitiveDataTypeT,
|
|
179
|
+
type SignedDataTypeT,
|
|
180
|
+
type TypedArrayConstructorT,
|
|
181
|
+
type NormalizedTypedArrayConstructorT
|
|
153
182
|
} from './shadertypes/data-types/data-types';
|
|
183
|
+
export {dataTypeDecoder} from './shadertypes/data-types/data-type-decoder';
|
|
184
|
+
export {getTypedArrayConstructor} from './shadertypes/data-types/decode-data-types';
|
|
185
|
+
|
|
154
186
|
export {
|
|
187
|
+
type AttributeShaderTypeT,
|
|
155
188
|
type AttributeShaderType,
|
|
189
|
+
type ArrayShaderType,
|
|
190
|
+
type CompositeShaderType,
|
|
191
|
+
type StructShaderType,
|
|
192
|
+
type VariableShaderTypeT,
|
|
156
193
|
type VariableShaderType
|
|
157
|
-
} from './shadertypes/
|
|
158
|
-
export {
|
|
159
|
-
getDataTypeInfo,
|
|
160
|
-
getDataType,
|
|
161
|
-
getTypedArrayConstructor,
|
|
162
|
-
getNormalizedDataType
|
|
163
|
-
} from './shadertypes/data-types/decode-data-types';
|
|
194
|
+
} from './shadertypes/shader-types/shader-types';
|
|
164
195
|
export {
|
|
196
|
+
shaderTypeDecoder,
|
|
197
|
+
getAttributeShaderTypeInfo,
|
|
165
198
|
getVariableShaderTypeInfo,
|
|
166
|
-
|
|
167
|
-
} from './shadertypes/
|
|
199
|
+
type AttributeShaderTypeInfo
|
|
200
|
+
} from './shadertypes/shader-types/shader-type-decoder';
|
|
168
201
|
|
|
169
202
|
// GPU TYPE UTILS - VERTEX ARRAYs
|
|
170
203
|
|
|
171
|
-
export {type VertexFormat} from './shadertypes/vertex-arrays/vertex-formats';
|
|
172
|
-
|
|
173
204
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
205
|
+
type VertexFormat,
|
|
206
|
+
type VertexFormatDataTypeT
|
|
207
|
+
} from './shadertypes/vertex-types/vertex-formats';
|
|
208
|
+
|
|
209
|
+
export {vertexFormatDecoder} from './shadertypes/vertex-types/vertex-format-decoder';
|
|
178
210
|
|
|
179
211
|
// GPU TYPE UTILS - Texture Formats
|
|
180
212
|
|
|
@@ -182,17 +214,23 @@ export {
|
|
|
182
214
|
type TextureFormat,
|
|
183
215
|
type TextureFormatColor,
|
|
184
216
|
type TextureFormatDepthStencil,
|
|
217
|
+
type CompressedTextureFormat,
|
|
185
218
|
type TextureCompression,
|
|
186
219
|
type TextureFormatInfo,
|
|
187
|
-
type TextureFormatCapabilities
|
|
188
|
-
|
|
220
|
+
type TextureFormatCapabilities,
|
|
221
|
+
type TextureMemoryLayout
|
|
222
|
+
} from './shadertypes/texture-types/texture-formats';
|
|
223
|
+
export {type TextureFormatDataTypeT} from './shadertypes/texture-types/texture-format-generics';
|
|
189
224
|
|
|
190
225
|
export {
|
|
191
|
-
TextureFormatDecoder,
|
|
226
|
+
type TextureFormatDecoder,
|
|
192
227
|
textureFormatDecoder
|
|
193
|
-
} from './shadertypes/
|
|
228
|
+
} from './shadertypes/texture-types/texture-format-decoder';
|
|
194
229
|
|
|
195
|
-
export {
|
|
230
|
+
export {getTextureImageView, setTextureImageData} from './shadertypes/texture-types/texture-layout';
|
|
231
|
+
export {type PixelData, readPixel, writePixel} from './shadertypes/texture-types/pixel-utils';
|
|
232
|
+
|
|
233
|
+
export {isExternalImage, getExternalImageSize} from './shadertypes/image-types/image-types';
|
|
196
234
|
|
|
197
235
|
// GENERAL EXPORTS - FOR APPLICATIONS
|
|
198
236
|
|
|
@@ -209,6 +247,12 @@ export type {
|
|
|
209
247
|
|
|
210
248
|
// INTERNAL UTILS - for use in other luma.gl modules only
|
|
211
249
|
export {log} from './utils/log';
|
|
250
|
+
export {
|
|
251
|
+
getShaderLayoutBinding,
|
|
252
|
+
normalizeBindingsByGroup,
|
|
253
|
+
flattenBindingsByGroup
|
|
254
|
+
} from './adapter-utils/bind-groups';
|
|
255
|
+
export {assert, assertDefined} from './utils/assert';
|
|
212
256
|
export {getScratchArray} from './utils/array-utils-flat';
|
|
213
257
|
export type {AttributeInfo} from './adapter-utils/get-attribute-from-layouts';
|
|
214
258
|
export {getAttributeInfosFromLayouts} from './adapter-utils/get-attribute-from-layouts';
|
|
@@ -217,4 +261,4 @@ export {getAttributeInfosFromLayouts} from './adapter-utils/get-attribute-from-l
|
|
|
217
261
|
export {
|
|
218
262
|
getTextureFormatDefinition as _getTextureFormatDefinition,
|
|
219
263
|
getTextureFormatTable as _getTextureFormatTable
|
|
220
|
-
} from './shadertypes/
|
|
264
|
+
} from './shadertypes/texture-types/texture-format-table';
|