@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.2
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/LICENSE +3 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts +23 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop-template.js +7 -0
- package/dist/animation-loop/animation-loop-template.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +77 -192
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/debug/copy-texture-to-image.d.ts +26 -0
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
- package/dist/debug/copy-texture-to-image.js +46 -0
- package/dist/debug/copy-texture-to-image.js.map +1 -0
- package/dist/debug/debug-framebuffer.d.ts +11 -0
- package/dist/debug/debug-framebuffer.d.ts.map +1 -0
- package/dist/debug/debug-framebuffer.js +43 -0
- package/dist/debug/debug-framebuffer.js.map +1 -0
- package/dist/debug/debug-shader-layout.d.ts +9 -0
- package/dist/debug/debug-shader-layout.d.ts.map +1 -0
- package/dist/debug/debug-shader-layout.js +28 -0
- package/dist/debug/debug-shader-layout.js.map +1 -0
- package/dist/debug/pixel-data-utils.d.ts +24 -0
- package/dist/debug/pixel-data-utils.d.ts.map +1 -0
- package/dist/debug/pixel-data-utils.js +41 -0
- package/dist/debug/pixel-data-utils.js.map +1 -0
- package/dist/dist.dev.js +10073 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +16 -10
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +20 -86
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +110 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +3120 -0
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -46
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +36 -179
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +206 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +440 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +66 -0
- package/dist/shader-inputs.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +62 -0
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +293 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +15 -14
- package/src/animation-loop/animation-loop-template.ts +23 -0
- package/src/{lib → animation-loop}/animation-loop.ts +99 -88
- package/src/{lib → animation-loop}/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/debug/copy-texture-to-image.ts +72 -0
- package/src/debug/debug-framebuffer.ts +57 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +57 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +47 -45
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +6 -5
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +19 -3
- package/src/geometry/geometry.ts +65 -110
- package/src/geometry/gpu-geometry.ts +125 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +34 -10
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +48 -179
- package/src/model/model.ts +733 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +150 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -182
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -183
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
export type { AnimationProps } from './lib/animation-props';
|
|
2
|
-
export type { AnimationLoopProps } from './lib/animation-loop';
|
|
3
|
-
export { AnimationLoop } from './lib/animation-loop';
|
|
4
|
-
export { RenderLoop } from './lib/render-loop';
|
|
5
|
-
export type { ModelProps } from './lib/model';
|
|
6
|
-
export { default as Model } from './lib/model';
|
|
7
|
-
export { PipelineFactory } from './lib/pipeline-factory';
|
|
8
1
|
export { Timeline } from './animation/timeline';
|
|
9
2
|
export { KeyFrames } from './animation/key-frames';
|
|
10
|
-
export {
|
|
3
|
+
export type { AnimationProps } from './animation-loop/animation-props';
|
|
4
|
+
export { AnimationLoopTemplate } from './animation-loop/animation-loop-template';
|
|
5
|
+
export type { AnimationLoopProps } from './animation-loop/animation-loop';
|
|
6
|
+
export { AnimationLoop } from './animation-loop/animation-loop';
|
|
7
|
+
export type { MakeAnimationLoopProps } from './animation-loop/make-animation-loop';
|
|
8
|
+
export { makeAnimationLoop } from './animation-loop/make-animation-loop';
|
|
9
|
+
export type { ModelProps } from './model/model';
|
|
10
|
+
export { Model } from './model/model';
|
|
11
|
+
export type { BufferTransformProps } from './transform/buffer-transform';
|
|
12
|
+
export { BufferTransform } from './transform/buffer-transform';
|
|
13
|
+
export type { TextureTransformProps } from './transform/texture-transform';
|
|
14
|
+
export { TextureTransform } from './transform/texture-transform';
|
|
15
|
+
export { PipelineFactory } from './lib/pipeline-factory';
|
|
16
|
+
export { ClipSpace } from './lib/clip-space';
|
|
17
|
+
export { ScenegraphNode } from './scenegraph/scenegraph-node';
|
|
18
|
+
export { GroupNode } from './scenegraph/group-node';
|
|
19
|
+
export type { ModelNodeProps } from './scenegraph/model-node';
|
|
20
|
+
export { ModelNode } from './scenegraph/model-node';
|
|
21
|
+
export type { GeometryProps } from './geometry/geometry';
|
|
22
|
+
export { Geometry } from './geometry/geometry';
|
|
23
|
+
export type { GPUGeometryProps } from './geometry/gpu-geometry';
|
|
24
|
+
export { GPUGeometry } from './geometry/gpu-geometry';
|
|
11
25
|
export type { ConeGeometryProps } from './geometries/cone-geometry';
|
|
12
26
|
export { ConeGeometry } from './geometries/cone-geometry';
|
|
13
27
|
export type { CubeGeometryProps } from './geometries/cube-geometry';
|
|
@@ -22,4 +36,6 @@ export type { SphereGeometryProps } from './geometries/sphere-geometry';
|
|
|
22
36
|
export { SphereGeometry } from './geometries/sphere-geometry';
|
|
23
37
|
export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geometry';
|
|
24
38
|
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
|
|
39
|
+
export type { ShaderModuleInputs } from './shader-inputs';
|
|
40
|
+
export { ShaderInputs as _ShaderInputs } from './shader-inputs';
|
|
25
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAE/E,YAAY,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,YAAY,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AAEvE,YAAY,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAGpC,YAAY,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAC,SAAS,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;AACxD,OAAO,EAAC,YAAY,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
1
|
+
export { Timeline } from "./animation/timeline.js";
|
|
2
|
+
export { KeyFrames } from "./animation/key-frames.js";
|
|
3
|
+
export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.js";
|
|
4
|
+
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
5
|
+
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
6
|
+
export { Model } from "./model/model.js";
|
|
7
|
+
export { BufferTransform } from "./transform/buffer-transform.js";
|
|
8
|
+
export { TextureTransform } from "./transform/texture-transform.js";
|
|
9
|
+
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
10
|
+
export { ClipSpace } from "./lib/clip-space.js";
|
|
11
|
+
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
|
|
12
|
+
export { GroupNode } from "./scenegraph/group-node.js";
|
|
13
|
+
export { ModelNode } from "./scenegraph/model-node.js";
|
|
14
|
+
export { Geometry } from "./geometry/geometry.js";
|
|
15
|
+
export { GPUGeometry } from "./geometry/gpu-geometry.js";
|
|
16
|
+
export { ConeGeometry } from "./geometries/cone-geometry.js";
|
|
17
|
+
export { CubeGeometry } from "./geometries/cube-geometry.js";
|
|
18
|
+
export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
|
|
19
|
+
export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
|
|
20
|
+
export { PlaneGeometry } from "./geometries/plane-geometry.js";
|
|
21
|
+
export { SphereGeometry } from "./geometries/sphere-geometry.js";
|
|
22
|
+
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
23
|
+
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
15
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","BufferTransform","TextureTransform","PipelineFactory","ClipSpace","ScenegraphNode","GroupNode","ModelNode","Geometry","GPUGeometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry","ShaderInputs","_ShaderInputs"],"sources":["../src/index.ts"],"sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/animation-loop-template';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './model/model';\nexport {Model} from './model/model';\n\n// Transforms\nexport type {BufferTransformProps} from './transform/buffer-transform';\nexport {BufferTransform} from './transform/buffer-transform';\nexport type {TextureTransformProps} from './transform/texture-transform';\nexport {TextureTransform} from './transform/texture-transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// Utils\nexport {ClipSpace} from './lib/clip-space';\n\n// Scenegraph Core nodes\nexport {ScenegraphNode} from './scenegraph/scenegraph-node';\nexport {GroupNode} from './scenegraph/group-node';\nexport type {ModelNodeProps} from './scenegraph/model-node';\nexport {ModelNode} from './scenegraph/model-node';\n\n// Geometries\nexport type {GeometryProps} from './geometry/geometry';\nexport {Geometry} from './geometry/geometry';\nexport type {GPUGeometryProps} from './geometry/gpu-geometry';\nexport {GPUGeometry} from './geometry/gpu-geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n// EXPERIMENTAL\nexport type {ShaderModuleInputs} from './shader-inputs';\nexport {ShaderInputs as _ShaderInputs} from './shader-inputs';\n"],"mappings":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAILC,eAAe;AAAA,SAEfC,gBAAgB;AAAA,SAEhBC,eAAe;AAAA,SAGfC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,SAAS;AAAA,SAETC,SAAS;AAAA,SAITC,QAAQ;AAAA,SAERC,WAAW;AAAA,SAIXC,YAAY;AAAA,SAEZC,YAAY;AAAA,SAEZC,gBAAgB;AAAA,SAEhBC,iBAAiB;AAAA,SAEjBC,aAAa;AAAA,SAEbC,cAAc;AAAA,SAEdC,qBAAqB;AAAA,SAIrBC,YAAY,IAAIC,aAAa"}
|
package/dist/lib/clip-space.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
import { Device } from '@luma.gl/core';
|
|
2
|
+
import { Model, ModelProps } from '../model/model';
|
|
3
|
+
/**
|
|
4
|
+
* A flat geometry that covers the "visible area" that the GPU renders.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ClipSpace extends Model {
|
|
7
|
+
constructor(device: Device, opts?: ModelProps);
|
|
8
|
+
}
|
|
1
9
|
//# sourceMappingURL=clip-space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAO,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU;CAqB9C"}
|
package/dist/lib/clip-space.js
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
import { glsl } from '@luma.gl/core';
|
|
2
|
+
import { Model } from "../model/model.js";
|
|
3
|
+
import { Geometry } from "../geometry/geometry.js";
|
|
4
|
+
const CLIPSPACE_VERTEX_SHADER = glsl`\
|
|
5
|
+
in vec2 aClipSpacePosition;
|
|
6
|
+
in vec2 aTexCoord;
|
|
7
|
+
in vec2 aCoordinate;
|
|
1
8
|
|
|
9
|
+
out vec2 position;
|
|
10
|
+
out vec2 coordinate;
|
|
11
|
+
out vec2 uv;
|
|
12
|
+
|
|
13
|
+
void main(void) {
|
|
14
|
+
gl_Position = vec4(aClipSpacePosition, 0., 1.);
|
|
15
|
+
position = aClipSpacePosition;
|
|
16
|
+
coordinate = aCoordinate;
|
|
17
|
+
uv = aTexCoord;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
21
|
+
export class ClipSpace extends Model {
|
|
22
|
+
constructor(device, opts) {
|
|
23
|
+
const TEX_COORDS = POSITIONS.map(coord => coord === -1 ? 0 : coord);
|
|
24
|
+
super(device, {
|
|
25
|
+
...opts,
|
|
26
|
+
vs: CLIPSPACE_VERTEX_SHADER,
|
|
27
|
+
vertexCount: 4,
|
|
28
|
+
geometry: new Geometry({
|
|
29
|
+
topology: 'triangle-strip',
|
|
30
|
+
vertexCount: 4,
|
|
31
|
+
attributes: {
|
|
32
|
+
aClipSpacePosition: {
|
|
33
|
+
size: 2,
|
|
34
|
+
value: new Float32Array(POSITIONS)
|
|
35
|
+
},
|
|
36
|
+
aTexCoord: {
|
|
37
|
+
size: 2,
|
|
38
|
+
value: new Float32Array(TEX_COORDS)
|
|
39
|
+
},
|
|
40
|
+
aCoordinate: {
|
|
41
|
+
size: 2,
|
|
42
|
+
value: new Float32Array(TEX_COORDS)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
2
49
|
//# sourceMappingURL=clip-space.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"clip-space.js","names":["glsl","Model","Geometry","CLIPSPACE_VERTEX_SHADER","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","vs","vertexCount","geometry","topology","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport {Device, glsl} from '@luma.gl/core';\nimport {Model, ModelProps} from '../model/model';\nimport {Geometry} from '../geometry/geometry';\n\nconst CLIPSPACE_VERTEX_SHADER = glsl`\\\nin vec2 aClipSpacePosition;\nin vec2 aTexCoord;\nin vec2 aCoordinate;\n\nout vec2 position;\nout vec2 coordinate;\nout vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n`;\n\n/* eslint-disable indent, no-multi-spaces */\nconst POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];\n\n/**\n * A flat geometry that covers the \"visible area\" that the GPU renders.\n */\nexport class ClipSpace extends Model {\n constructor(device: Device, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n device,\n {\n ...opts,\n vs: CLIPSPACE_VERTEX_SHADER,\n vertexCount: 4,\n geometry: new Geometry({\n topology: 'triangle-strip',\n vertexCount: 4,\n attributes: {\n aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},\n aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},\n aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}\n }\n })\n }\n );\n }\n}\n"],"mappings":"AAEA,SAAgBA,IAAI,QAAO,eAAe;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGH,IAAK;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAGD,MAAMI,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAK9C,OAAO,MAAMC,SAAS,SAASJ,KAAK,CAAC;EACnCK,WAAWA,CAACC,MAAc,EAAEC,IAAiB,EAAE;IAC7C,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHJ,MAAM,EACN;MACE,GAAGC,IAAI;MACPI,EAAE,EAAET,uBAAuB;MAC3BU,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIZ,QAAQ,CAAC;QACrBa,QAAQ,EAAE,gBAAgB;QAC1BF,WAAW,EAAE,CAAC;QACdG,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAAChB,SAAS;UAAC,CAAC;UACjEiB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC,CAAC;UACzDa,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CACF,CAAC;EACH;AACF"}
|
|
@@ -1,60 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Device, RenderPipeline } from '@luma.gl/
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import type { RenderPipelineProps } from '@luma.gl/core';
|
|
2
|
+
import { Device, RenderPipeline } from '@luma.gl/core';
|
|
3
|
+
/** Todo - should be same as RenderPipelineProps */
|
|
4
|
+
export type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
5
5
|
vs: string;
|
|
6
|
-
fs: string
|
|
7
|
-
topology: PrimitiveTopology;
|
|
8
|
-
layout?: ShaderLayout | null;
|
|
9
|
-
parameters?: RenderPipelineParameters;
|
|
10
|
-
modules?: ShaderModule[];
|
|
11
|
-
defines?: Record<string, string | number | boolean>;
|
|
12
|
-
inject?: Record<string, string>;
|
|
13
|
-
transpileToGLSL100?: boolean;
|
|
14
|
-
varyings?: string[];
|
|
15
|
-
bufferMode?: number;
|
|
6
|
+
fs: string;
|
|
16
7
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
modules?: ShaderModule[];
|
|
21
|
-
defines?: Record<string, string>;
|
|
22
|
-
inject?: Record<string, string>;
|
|
23
|
-
transpileToGLSL100?: boolean;
|
|
24
|
-
varyings?: string[];
|
|
25
|
-
bufferMode?: number;
|
|
26
|
-
};
|
|
27
|
-
declare type GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;
|
|
28
|
-
/** Efficiently create shared pipelines with varying parameters */
|
|
8
|
+
/**
|
|
9
|
+
* Efficiently creates / caches pipelines
|
|
10
|
+
*/
|
|
29
11
|
export declare class PipelineFactory {
|
|
12
|
+
static defaultProps: Required<PipelineFactoryProps>;
|
|
30
13
|
readonly device: Device;
|
|
31
|
-
stateHash: number;
|
|
32
14
|
private _hashCounter;
|
|
33
15
|
private readonly _hashes;
|
|
34
16
|
private readonly _useCounts;
|
|
35
17
|
private readonly _pipelineCache;
|
|
36
|
-
private readonly _getUniforms;
|
|
37
|
-
private readonly _hookFunctions;
|
|
38
|
-
private _defaultModules;
|
|
39
18
|
static getDefaultPipelineFactory(device: Device): PipelineFactory;
|
|
40
19
|
constructor(device: Device);
|
|
41
|
-
|
|
42
|
-
removeDefaultModule(module: ShaderModule): void;
|
|
43
|
-
addShaderHook(hook: any, opts?: any): void;
|
|
44
|
-
createRenderPipeline(options: GetRenderPipelineOptions): {
|
|
45
|
-
pipeline: RenderPipeline;
|
|
46
|
-
getUniforms: GetUniformsFunc;
|
|
47
|
-
};
|
|
20
|
+
createRenderPipeline(options: PipelineFactoryProps): RenderPipeline;
|
|
48
21
|
release(pipeline: RenderPipeline): void;
|
|
49
|
-
getUniforms(pipeline: RenderPipeline): GetUniformsFunc;
|
|
50
|
-
_createRenderPipeline(props: GetRenderPipelineOptions): {
|
|
51
|
-
pipeline: RenderPipeline;
|
|
52
|
-
getUniforms: GetUniformsFunc;
|
|
53
|
-
};
|
|
54
22
|
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
55
|
-
_hashRenderPipeline
|
|
56
|
-
_getHash
|
|
57
|
-
_getModuleList(appModules?: ShaderModule[]): ShaderModule[];
|
|
23
|
+
private _hashRenderPipeline;
|
|
24
|
+
private _getHash;
|
|
58
25
|
}
|
|
59
|
-
export {};
|
|
60
26
|
//# sourceMappingURL=pipeline-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAE1E,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAIjD;IAEF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;gBAMrD,MAAM,EAAE,MAAM;IAI1B,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc;IAsBnE,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAYvC,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,QAAQ;CAMjB"}
|
|
@@ -1,219 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { assembleShaders } from '@luma.gl/shadertools';
|
|
3
|
-
const DEFAULT_RENDER_PIPELINE_OPTIONS = {
|
|
4
|
-
vs: '',
|
|
5
|
-
fs: '',
|
|
6
|
-
modules: [],
|
|
7
|
-
defines: {},
|
|
8
|
-
inject: {},
|
|
9
|
-
transpileToGLSL100: false,
|
|
10
|
-
layout: null,
|
|
11
|
-
varyings: [],
|
|
12
|
-
bufferMode: 0x8c8d,
|
|
13
|
-
topology: 'triangle-list',
|
|
14
|
-
parameters: {}
|
|
15
|
-
};
|
|
1
|
+
import { RenderPipeline } from '@luma.gl/core';
|
|
16
2
|
export class PipelineFactory {
|
|
17
3
|
static getDefaultPipelineFactory(device) {
|
|
18
|
-
device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
|
|
19
|
-
return device.defaultPipelineFactory;
|
|
4
|
+
device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
|
|
5
|
+
return device._lumaData.defaultPipelineFactory;
|
|
20
6
|
}
|
|
21
|
-
|
|
22
7
|
constructor(device) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_defineProperty(this, "_hashes", {});
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "_useCounts", {});
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "_pipelineCache", {});
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "_getUniforms", {});
|
|
36
|
-
|
|
37
|
-
_defineProperty(this, "_hookFunctions", []);
|
|
38
|
-
|
|
39
|
-
_defineProperty(this, "_defaultModules", []);
|
|
40
|
-
|
|
8
|
+
this.device = void 0;
|
|
9
|
+
this._hashCounter = 0;
|
|
10
|
+
this._hashes = {};
|
|
11
|
+
this._useCounts = {};
|
|
12
|
+
this._pipelineCache = {};
|
|
41
13
|
this.device = device;
|
|
42
14
|
}
|
|
43
|
-
|
|
44
|
-
addDefaultModule(module) {
|
|
45
|
-
if (!this._defaultModules.find(m => m.name === (typeof module === 'string' ? module : module.name))) {
|
|
46
|
-
this._defaultModules.push(module);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.stateHash++;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
removeDefaultModule(module) {
|
|
53
|
-
const moduleName = typeof module === 'string' ? module : module.name;
|
|
54
|
-
this._defaultModules = this._defaultModules.filter(m => m.name !== moduleName);
|
|
55
|
-
this.stateHash++;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
addShaderHook(hook, opts) {
|
|
59
|
-
if (opts) {
|
|
60
|
-
hook = Object.assign(opts, {
|
|
61
|
-
hook
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this._hookFunctions.push(hook);
|
|
66
|
-
|
|
67
|
-
this.stateHash++;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
15
|
createRenderPipeline(options) {
|
|
71
|
-
const props = {
|
|
16
|
+
const props = {
|
|
17
|
+
...PipelineFactory.defaultProps,
|
|
72
18
|
...options
|
|
73
19
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const hash = this._hashRenderPipeline({ ...props,
|
|
78
|
-
modules
|
|
20
|
+
const hash = this._hashRenderPipeline({
|
|
21
|
+
...props
|
|
79
22
|
});
|
|
80
|
-
|
|
81
23
|
if (!this._pipelineCache[hash]) {
|
|
82
|
-
const {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
24
|
+
const pipeline = this.device.createRenderPipeline({
|
|
25
|
+
...props,
|
|
26
|
+
vs: this.device.createShader({
|
|
27
|
+
stage: 'vertex',
|
|
28
|
+
source: props.vs
|
|
29
|
+
}),
|
|
30
|
+
fs: props.fs ? this.device.createShader({
|
|
31
|
+
stage: 'fragment',
|
|
32
|
+
source: props.fs
|
|
33
|
+
}) : null
|
|
87
34
|
});
|
|
88
|
-
|
|
89
35
|
pipeline.hash = hash;
|
|
90
36
|
this._pipelineCache[hash] = pipeline;
|
|
91
|
-
|
|
92
|
-
this._getUniforms[hash] = getUniforms || (x => ({}));
|
|
93
|
-
|
|
94
37
|
this._useCounts[hash] = 0;
|
|
95
38
|
}
|
|
96
|
-
|
|
97
39
|
this._useCounts[hash]++;
|
|
98
|
-
return
|
|
99
|
-
pipeline: this._pipelineCache[hash],
|
|
100
|
-
getUniforms: this._getUniforms[hash]
|
|
101
|
-
};
|
|
40
|
+
return this._pipelineCache[hash];
|
|
102
41
|
}
|
|
103
|
-
|
|
104
42
|
release(pipeline) {
|
|
105
43
|
const hash = pipeline.hash;
|
|
106
44
|
this._useCounts[hash]--;
|
|
107
|
-
|
|
108
45
|
if (this._useCounts[hash] === 0) {
|
|
109
46
|
this._pipelineCache[hash].destroy();
|
|
110
|
-
|
|
111
47
|
delete this._pipelineCache[hash];
|
|
112
|
-
delete this._getUniforms[hash];
|
|
113
48
|
delete this._useCounts[hash];
|
|
114
49
|
}
|
|
115
50
|
}
|
|
116
|
-
|
|
117
|
-
getUniforms(pipeline) {
|
|
118
|
-
return this._getUniforms[pipeline.hash] || null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
_createRenderPipeline(props) {
|
|
122
|
-
const platformInfo = {
|
|
123
|
-
gpu: this.device.info.gpu,
|
|
124
|
-
features: this.device.features
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
if (!props.fs) {
|
|
128
|
-
throw new Error('fs');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const assembled = assembleShaders(platformInfo, { ...props,
|
|
132
|
-
fs: props.fs,
|
|
133
|
-
hookFunctions: this._hookFunctions
|
|
134
|
-
});
|
|
135
|
-
const pipeline = this.device.createRenderPipeline({ ...props,
|
|
136
|
-
vs: this.device.createShader({
|
|
137
|
-
stage: 'vertex',
|
|
138
|
-
source: assembled.vs
|
|
139
|
-
}),
|
|
140
|
-
fs: assembled.fs ? this.device.createShader({
|
|
141
|
-
stage: 'fragment',
|
|
142
|
-
source: assembled.fs
|
|
143
|
-
}) : null
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
pipeline,
|
|
147
|
-
getUniforms: assembled.getUniforms
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
51
|
_hashRenderPipeline(props) {
|
|
152
|
-
const {
|
|
153
|
-
modules = [],
|
|
154
|
-
varyings = [],
|
|
155
|
-
defines = [],
|
|
156
|
-
inject = [],
|
|
157
|
-
parameters = []
|
|
158
|
-
} = props;
|
|
159
|
-
|
|
160
52
|
const vsHash = this._getHash(props.vs);
|
|
161
|
-
|
|
162
53
|
const fsHash = props.fs ? this._getHash(props.fs) : 0;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
defineHashes.push(this._getHash(key));
|
|
172
|
-
defineHashes.push(this._getHash(defines[key]));
|
|
54
|
+
const varyingHash = '-';
|
|
55
|
+
switch (this.device.info.type) {
|
|
56
|
+
case 'webgpu':
|
|
57
|
+
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
58
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
59
|
+
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
|
|
60
|
+
default:
|
|
61
|
+
return `${vsHash}/${fsHash}V${varyingHash}`;
|
|
173
62
|
}
|
|
174
|
-
|
|
175
|
-
for (const key of injectKeys) {
|
|
176
|
-
injectHashes.push(this._getHash(key));
|
|
177
|
-
injectHashes.push(this._getHash(inject[key]));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const parameterHash = JSON.stringify(parameters);
|
|
181
|
-
return "".concat(vsHash, "/").concat(fsHash, "D").concat(defineHashes.join('/'), "M").concat(moduleHashes.join('/'), "I").concat(injectHashes.join('/'), "V").concat(varyingHashes.join('/'), "H").concat(this.stateHash, "B").concat(props.bufferMode).concat(props.transpileToGLSL100 ? 'T' : '', "P").concat(parameterHash);
|
|
182
63
|
}
|
|
183
|
-
|
|
184
64
|
_getHash(key) {
|
|
185
65
|
if (this._hashes[key] === undefined) {
|
|
186
66
|
this._hashes[key] = this._hashCounter++;
|
|
187
67
|
}
|
|
188
|
-
|
|
189
68
|
return this._hashes[key];
|
|
190
69
|
}
|
|
191
|
-
|
|
192
|
-
_getModuleList(appModules = []) {
|
|
193
|
-
const modules = new Array(this._defaultModules.length + appModules.length);
|
|
194
|
-
const seen = {};
|
|
195
|
-
let count = 0;
|
|
196
|
-
|
|
197
|
-
for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
|
|
198
|
-
const module = this._defaultModules[i];
|
|
199
|
-
const name = module.name;
|
|
200
|
-
modules[count++] = module;
|
|
201
|
-
seen[name] = true;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
for (let i = 0, len = appModules.length; i < len; ++i) {
|
|
205
|
-
const module = appModules[i];
|
|
206
|
-
const name = module.name;
|
|
207
|
-
|
|
208
|
-
if (!seen[name]) {
|
|
209
|
-
modules[count++] = module;
|
|
210
|
-
seen[name] = true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
modules.length = count;
|
|
215
|
-
return modules;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
70
|
}
|
|
71
|
+
PipelineFactory.defaultProps = {
|
|
72
|
+
...RenderPipeline.defaultProps,
|
|
73
|
+
vs: undefined,
|
|
74
|
+
fs: undefined
|
|
75
|
+
};
|
|
219
76
|
//# sourceMappingURL=pipeline-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/pipeline-factory.ts"],"names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","addDefaultModule","module","_defaultModules","find","m","name","push","stateHash","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","pipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","parameterHash","JSON","stringify","join","_hashes","undefined","_hashCounter","appModules","Array","length","seen","count","i","len"],"mappings":";AAGA,SAAQA,eAAR,QAA8B,sBAA9B;AA+BA,MAAMC,+BAAmE,GAAG;AAC1EC,EAAAA,EAAE,EAAE,EADsE;AAE1EC,EAAAA,EAAE,EAAE,EAFsE;AAG1EC,EAAAA,OAAO,EAAE,EAHiE;AAI1EC,EAAAA,OAAO,EAAE,EAJiE;AAK1EC,EAAAA,MAAM,EAAE,EALkE;AAM1EC,EAAAA,kBAAkB,EAAE,KANsD;AAO1EC,EAAAA,MAAM,EAAE,IAPkE;AAS1EC,EAAAA,QAAQ,EAAE,EATgE;AAU1EC,EAAAA,UAAU,EAAE,MAV8D;AAW1EC,EAAAA,QAAQ,EAAE,eAXgE;AAY1EC,EAAAA,UAAU,EAAE;AAZ8D,CAA5E;AAkBA,OAAO,MAAMC,eAAN,CAAsB;AAeK,SAAzBC,yBAAyB,CAACC,MAAD,EAAkC;AAEhEA,IAAAA,MAAM,CAACC,sBAAP,GAAgCD,MAAM,CAACC,sBAAP,IAAiC,IAAIH,eAAJ,CAAoBE,MAApB,CAAjE;AAEA,WAAOA,MAAM,CAACC,sBAAd;AACD;;AAEDC,EAAAA,WAAW,CAACF,MAAD,EAAiB;AAAA;;AAAA,uCAnBR,CAmBQ;;AAAA,0CAlBG,CAkBH;;AAAA,qCAjBuB,EAiBvB;;AAAA,wCAhB0B,EAgB1B;;AAAA,4CAdsC,EActC;;AAAA,0CAZqC,EAYrC;;AAAA,4CAXa,EAWb;;AAAA,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AAMnE,MAAM,GAAG8D,UAAU,CAACK,CAAD,CAAzB;AACA,YAAM/D,IAAI,GAAGJ,MAAM,CAACI,IAApB;;AACA,UAAI,CAAC6D,IAAI,CAAC7D,IAAD,CAAT,EAAiB;AACfnB,QAAAA,OAAO,CAACiF,KAAK,EAAN,CAAP,GAAmBlE,MAAnB;AACAiE,QAAAA,IAAI,CAAC7D,IAAD,CAAJ,GAAa,IAAb;AACD;AACF;;AAEDnB,IAAAA,OAAO,CAAC+E,MAAR,GAAiBE,KAAjB;AAEA,WAAOjF,OAAP;AACD;;AApL0B","sourcesContent":["import type {RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';\nimport {Device, RenderPipeline, ComputePipeline} from '@luma.gl/api/';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook, opts?): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = [], inject = [], parameters = []} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(defines[key]));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"file":"pipeline-factory.js"}
|
|
1
|
+
{"version":3,"file":"pipeline-factory.js","names":["RenderPipeline","PipelineFactory","getDefaultPipelineFactory","device","_lumaData","defaultPipelineFactory","constructor","_hashCounter","_hashes","_useCounts","_pipelineCache","createRenderPipeline","options","props","defaultProps","hash","_hashRenderPipeline","pipeline","vs","createShader","stage","source","fs","release","destroy","vsHash","_getHash","fsHash","varyingHash","info","type","parameterHash","JSON","stringify","parameters","bufferLayoutHash","bufferLayout","topology","key","undefined"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {RenderPipelineProps} from '@luma.gl/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\n\n/** Todo - should be same as RenderPipelineProps */\nexport type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Only accepts string shaders\n vs: string;\n fs: string;\n};\n\n/**\n * Efficiently creates / caches pipelines\n */\nexport class PipelineFactory {\n static defaultProps: Required<PipelineFactoryProps> = {\n ...RenderPipeline.defaultProps,\n vs: undefined!,\n fs: undefined!\n };\n\n readonly device: Device;\n\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n device._lumaData.defaultPipelineFactory =\n device._lumaData.defaultPipelineFactory || new PipelineFactory(device);\n return device._lumaData.defaultPipelineFactory as PipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n createRenderPipeline(options: PipelineFactoryProps): RenderPipeline {\n const props: Required<PipelineFactoryProps> = {...PipelineFactory.defaultProps, ...options};\n\n const hash = this._hashRenderPipeline({...props});\n\n if (!this._pipelineCache[hash]) {\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null\n });\n\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._pipelineCache[hash];\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._useCounts[hash];\n }\n }\n\n // PRIVATE\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n private _hashRenderPipeline(props: PipelineFactoryProps): string {\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n // WebGL specific\n // const {varyings = [], bufferMode = {}} = props;\n // const varyingHashes = varyings.map((v) => this._getHash(v));\n const varyingHash = '-'; // `${varyingHashes.join('/')}B${bufferMode}`\n\n switch (this.device.info.type) {\n case 'webgpu':\n // On WebGPU we need to rebuild the pipeline if topology, parameters or bufferLayout change\n const parameterHash = this._getHash(JSON.stringify(props.parameters));\n const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));\n // TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?\n // create a deepHash() to deduplicate?\n return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;\n default:\n // WebGL is more dynamic\n return `${vsHash}/${fsHash}V${varyingHash}`;\n }\n }\n\n private _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n}\n"],"mappings":"AAEA,SAAgBA,cAAc,QAAO,eAAe;AAYpD,OAAO,MAAMC,eAAe,CAAC;EAc3B,OAAOC,yBAAyBA,CAACC,MAAc,EAAmB;IAChEA,MAAM,CAACC,SAAS,CAACC,sBAAsB,GACrCF,MAAM,CAACC,SAAS,CAACC,sBAAsB,IAAI,IAAIJ,eAAe,CAACE,MAAM,CAAC;IACxE,OAAOA,MAAM,CAACC,SAAS,CAACC,sBAAsB;EAChD;EAEAC,WAAWA,CAACH,MAAc,EAAE;IAAA,KAbnBA,MAAM;IAAA,KAEPI,YAAY,GAAW,CAAC;IAAA,KACfC,OAAO,GAA2B,CAAC,CAAC;IAAA,KACpCC,UAAU,GAA2B,CAAC,CAAC;IAAA,KACvCC,cAAc,GAAmC,CAAC,CAAC;IASlE,IAAI,CAACP,MAAM,GAAGA,MAAM;EACtB;EAEAQ,oBAAoBA,CAACC,OAA6B,EAAkB;IAClE,MAAMC,KAAqC,GAAG;MAAC,GAAGZ,eAAe,CAACa,YAAY;MAAE,GAAGF;IAAO,CAAC;IAE3F,MAAMG,IAAI,GAAG,IAAI,CAACC,mBAAmB,CAAC;MAAC,GAAGH;IAAK,CAAC,CAAC;IAEjD,IAAI,CAAC,IAAI,CAACH,cAAc,CAACK,IAAI,CAAC,EAAE;MAC9B,MAAME,QAAQ,GAAG,IAAI,CAACd,MAAM,CAACQ,oBAAoB,CAAC;QAChD,GAAGE,KAAK;QACRK,EAAE,EAAE,IAAI,CAACf,MAAM,CAACgB,YAAY,CAAC;UAACC,KAAK,EAAE,QAAQ;UAAEC,MAAM,EAAER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