@luma.gl/engine 9.2.5 → 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/animation-loop/animation-loop.d.ts +11 -5
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +83 -47
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +7 -1
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/animation-loop/request-animation-frame.d.ts.map +1 -1
- package/dist/animation-loop/request-animation-frame.js +23 -6
- package/dist/animation-loop/request-animation-frame.js.map +1 -1
- package/dist/compute/computation.d.ts +3 -7
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +16 -13
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts +2 -0
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js +10 -5
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +2639 -1290
- package/dist/dist.min.js +325 -210
- package/dist/dynamic-texture/dynamic-texture.d.ts +102 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -0
- package/dist/dynamic-texture/dynamic-texture.js +556 -0
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -0
- package/dist/dynamic-texture/texture-data.d.ts +144 -0
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -0
- package/dist/dynamic-texture/texture-data.js +208 -0
- package/dist/dynamic-texture/texture-data.js.map +1 -0
- package/dist/geometries/cone-geometry.d.ts +3 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +2 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +8 -3
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +2497 -1212
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +20 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.d.ts +73 -0
- package/dist/material/material-factory.d.ts.map +1 -0
- package/dist/material/material-factory.js +111 -0
- package/dist/material/material-factory.js.map +1 -0
- package/dist/material/material.d.ts +84 -0
- package/dist/material/material.d.ts.map +1 -0
- package/dist/material/material.js +176 -0
- package/dist/material/material.js.map +1 -0
- package/dist/model/model.d.ts +47 -16
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +113 -47
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts +4 -3
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +2 -2
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts +8 -5
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +77 -23
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.d.ts +1 -1
- package/dist/models/billboard-texture-module.js +1 -1
- package/dist/models/clip-space.js +7 -7
- package/dist/models/directional-light-model.d.ts +7 -0
- package/dist/models/directional-light-model.d.ts.map +1 -0
- package/dist/models/directional-light-model.js +23 -0
- package/dist/models/directional-light-model.js.map +1 -0
- package/dist/models/light-model-utils.d.ts +69 -0
- package/dist/models/light-model-utils.d.ts.map +1 -0
- package/dist/models/light-model-utils.js +395 -0
- package/dist/models/light-model-utils.js.map +1 -0
- package/dist/models/point-light-model.d.ts +7 -0
- package/dist/models/point-light-model.d.ts.map +1 -0
- package/dist/models/point-light-model.js +22 -0
- package/dist/models/point-light-model.js.map +1 -0
- package/dist/models/spot-light-model.d.ts +7 -0
- package/dist/models/spot-light-model.d.ts.map +1 -0
- package/dist/models/spot-light-model.js +23 -0
- package/dist/models/spot-light-model.js.map +1 -0
- package/dist/modules/picking/color-picking.d.ts +5 -9
- package/dist/modules/picking/color-picking.d.ts.map +1 -1
- package/dist/modules/picking/color-picking.js +122 -115
- package/dist/modules/picking/color-picking.js.map +1 -1
- package/dist/modules/picking/index-picking.d.ts +4 -4
- package/dist/modules/picking/index-picking.d.ts.map +1 -1
- package/dist/modules/picking/index-picking.js +36 -16
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/legacy-color-picking.d.ts +26 -0
- package/dist/modules/picking/legacy-color-picking.d.ts.map +1 -0
- package/dist/modules/picking/legacy-color-picking.js +7 -0
- package/dist/modules/picking/legacy-color-picking.js.map +1 -0
- package/dist/modules/picking/picking-manager.d.ts +29 -3
- package/dist/modules/picking/picking-manager.d.ts.map +1 -1
- package/dist/modules/picking/picking-manager.js +188 -41
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +13 -12
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +27 -14
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.d.ts +25 -0
- package/dist/modules/picking/picking.d.ts.map +1 -0
- package/dist/modules/picking/picking.js +18 -0
- package/dist/modules/picking/picking.js.map +1 -0
- package/dist/passes/get-fragment-shader.js +12 -27
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +5 -7
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +16 -42
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts +5 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +12 -0
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +23 -15
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/shader-inputs.d.ts +9 -7
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +84 -4
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/buffer-layout-order.d.ts.map +1 -1
- package/dist/utils/buffer-layout-order.js +12 -2
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/dist/utils/shader-module-utils.d.ts +7 -0
- package/dist/utils/shader-module-utils.d.ts.map +1 -0
- package/dist/utils/shader-module-utils.js +46 -0
- package/dist/utils/shader-module-utils.js.map +1 -0
- package/package.json +6 -6
- package/src/animation-loop/animation-loop.ts +89 -50
- package/src/animation-loop/make-animation-loop.ts +13 -5
- package/src/animation-loop/request-animation-frame.ts +32 -6
- package/src/compute/computation.ts +32 -17
- package/src/compute/swap.ts +13 -7
- package/src/dynamic-texture/dynamic-texture.ts +732 -0
- package/src/dynamic-texture/texture-data.ts +336 -0
- package/src/geometries/cone-geometry.ts +6 -1
- package/src/geometries/cylinder-geometry.ts +5 -1
- package/src/geometry/gpu-geometry.ts +8 -3
- package/src/index.ts +38 -8
- package/src/material/material-factory.ts +157 -0
- package/src/material/material.ts +254 -0
- package/src/model/model.ts +158 -67
- package/src/model/split-uniforms-and-bindings.ts +8 -6
- package/src/models/billboard-texture-model.ts +88 -27
- package/src/models/billboard-texture-module.ts +1 -1
- package/src/models/clip-space.ts +7 -7
- package/src/models/directional-light-model.ts +32 -0
- package/src/models/light-model-utils.ts +587 -0
- package/src/models/point-light-model.ts +31 -0
- package/src/models/spot-light-model.ts +32 -0
- package/src/modules/picking/color-picking.ts +123 -122
- package/src/modules/picking/index-picking.ts +36 -16
- package/src/modules/picking/legacy-color-picking.ts +8 -0
- package/src/modules/picking/picking-manager.ts +252 -50
- package/src/modules/picking/picking-uniforms.ts +39 -24
- package/src/modules/picking/picking.ts +22 -0
- package/src/passes/get-fragment-shader.ts +12 -27
- package/src/passes/shader-pass-renderer.ts +25 -48
- package/src/scenegraph/group-node.ts +16 -0
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +27 -16
- package/src/shader-inputs.ts +165 -15
- package/src/utils/buffer-layout-order.ts +18 -2
- package/src/utils/shader-module-utils.ts +65 -0
- package/dist/async-texture/async-texture.d.ts +0 -166
- package/dist/async-texture/async-texture.d.ts.map +0 -1
- package/dist/async-texture/async-texture.js +0 -386
- package/dist/async-texture/async-texture.js.map +0 -1
- package/dist/factories/pipeline-factory.d.ts +0 -37
- package/dist/factories/pipeline-factory.d.ts.map +0 -1
- package/dist/factories/pipeline-factory.js +0 -181
- package/dist/factories/pipeline-factory.js.map +0 -1
- package/dist/factories/shader-factory.d.ts +0 -22
- package/dist/factories/shader-factory.d.ts.map +0 -1
- package/dist/factories/shader-factory.js +0 -88
- package/dist/factories/shader-factory.js.map +0 -1
- package/src/async-texture/async-texture.ts +0 -551
- package/src/factories/pipeline-factory.ts +0 -224
- package/src/factories/shader-factory.ts +0 -103
- /package/src/{async-texture/texture-setters.ts.disabled → dynamic-texture/texture-data.ts.disabled} +0 -0
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
function getMinLocation(attributeNames, shaderLayoutMap) {
|
|
5
|
+
let minLocation = Infinity;
|
|
6
|
+
for (const name of attributeNames) {
|
|
7
|
+
const location = shaderLayoutMap[name];
|
|
8
|
+
if (location !== undefined) {
|
|
9
|
+
minLocation = Math.min(minLocation, location);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return minLocation;
|
|
13
|
+
}
|
|
4
14
|
export function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
5
15
|
const shaderLayoutMap = Object.fromEntries(shaderLayout.attributes.map(attr => [attr.name, attr.location]));
|
|
6
16
|
const sortedLayout = bufferLayout.slice();
|
|
7
17
|
sortedLayout.sort((a, b) => {
|
|
8
18
|
const attributeNamesA = a.attributes ? a.attributes.map(attr => attr.attribute) : [a.name];
|
|
9
19
|
const attributeNamesB = b.attributes ? b.attributes.map(attr => attr.attribute) : [b.name];
|
|
10
|
-
const minLocationA =
|
|
11
|
-
const minLocationB =
|
|
20
|
+
const minLocationA = getMinLocation(attributeNamesA, shaderLayoutMap);
|
|
21
|
+
const minLocationB = getMinLocation(attributeNamesB, shaderLayoutMap);
|
|
12
22
|
return minLocationA - minLocationB;
|
|
13
23
|
});
|
|
14
24
|
return sortedLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,UAAU,yCAAyC,CACvD,YAA0B,EAC1B,YAA4B;IAE5B,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CACxC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAChE,CAAC;IAEF,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,eAAe,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3F,MAAM,eAAe,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3F,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,SAAS,cAAc,CACrB,cAAwB,EACxB,eAAmD;IAEnD,IAAI,WAAW,GAAG,QAAQ,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yCAAyC,CACvD,YAA0B,EAC1B,YAA4B;IAE5B,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CACxC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAChE,CAAC;IAEF,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,eAAe,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3F,MAAM,eAAe,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3F,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QAEtE,OAAO,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComputeShaderLayout, ShaderLayout } from '@luma.gl/core';
|
|
2
|
+
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
3
|
+
type AnyShaderLayout = ShaderLayout | ComputeShaderLayout;
|
|
4
|
+
export declare function mergeShaderModuleBindingsIntoLayout<TShaderLayout extends AnyShaderLayout>(shaderLayout: TShaderLayout | null | undefined, modules: ShaderModule[]): TShaderLayout | null | undefined;
|
|
5
|
+
export declare function shaderModuleHasUniforms(module: ShaderModule): boolean;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=shader-module-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-module-utils.d.ts","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,KAAK,eAAe,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAE1D,wBAAgB,mCAAmC,CAAC,aAAa,SAAS,eAAe,EACvF,YAAY,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EAC9C,OAAO,EAAE,YAAY,EAAE,GACtB,aAAa,GAAG,IAAI,GAAG,SAAS,CA4BlC;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAErE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export function mergeShaderModuleBindingsIntoLayout(shaderLayout, modules) {
|
|
5
|
+
if (!shaderLayout || !modules.some(module => module.bindingLayout?.length)) {
|
|
6
|
+
return shaderLayout;
|
|
7
|
+
}
|
|
8
|
+
const mergedLayout = {
|
|
9
|
+
...shaderLayout,
|
|
10
|
+
bindings: shaderLayout.bindings.map(binding => ({ ...binding }))
|
|
11
|
+
};
|
|
12
|
+
if ('attributes' in (shaderLayout || {})) {
|
|
13
|
+
mergedLayout.attributes = shaderLayout?.attributes || [];
|
|
14
|
+
}
|
|
15
|
+
for (const module of modules) {
|
|
16
|
+
for (const bindingLayout of module.bindingLayout || []) {
|
|
17
|
+
for (const relatedBindingName of getRelatedBindingNames(bindingLayout.name)) {
|
|
18
|
+
const binding = mergedLayout.bindings.find(candidate => candidate.name === relatedBindingName);
|
|
19
|
+
if (binding?.group === 0) {
|
|
20
|
+
binding.group = bindingLayout.group;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return mergedLayout;
|
|
26
|
+
}
|
|
27
|
+
export function shaderModuleHasUniforms(module) {
|
|
28
|
+
return Boolean(module.uniformTypes && !isObjectEmpty(module.uniformTypes));
|
|
29
|
+
}
|
|
30
|
+
/** Returns binding-name aliases that should share the module-declared bind group. */
|
|
31
|
+
function getRelatedBindingNames(bindingName) {
|
|
32
|
+
const bindingNames = new Set([bindingName, `${bindingName}Uniforms`]);
|
|
33
|
+
if (!bindingName.endsWith('Uniforms')) {
|
|
34
|
+
bindingNames.add(`${bindingName}Sampler`);
|
|
35
|
+
}
|
|
36
|
+
return [...bindingNames];
|
|
37
|
+
}
|
|
38
|
+
function isObjectEmpty(obj) {
|
|
39
|
+
// @ts-ignore key is intentionally unused
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
+
for (const key in obj) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=shader-module-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-module-utils.js","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAOpC,MAAM,UAAU,mCAAmC,CACjD,YAA8C,EAC9C,OAAuB;IAEvB,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC;QAC3E,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,YAAY,GAAG;QACnB,GAAG,YAAY;QACf,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAC,GAAG,OAAO,EAAC,CAAC,CAAC;KAC9C,CAAC;IAEnB,IAAI,YAAY,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,CAAC;QACxC,YAA6B,CAAC,UAAU,GAAI,YAA6B,EAAE,UAAU,IAAI,EAAE,CAAC;IAC/F,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;YACvD,KAAK,MAAM,kBAAkB,IAAI,sBAAsB,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5E,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CACxC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,kBAAkB,CACnD,CAAC;gBACF,IAAI,OAAO,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,MAAoB;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,qFAAqF;AACrF,SAAS,sBAAsB,CAAC,WAAmB;IACjD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,CAAC,WAAW,EAAE,GAAG,WAAW,UAAU,CAAC,CAAC,CAAC;IAE9E,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,yCAAyC;IACzC,6DAA6D;IAC7D,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0-alpha.10",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "
|
|
44
|
-
"@luma.gl/shadertools": "
|
|
43
|
+
"@luma.gl/core": "9.3.0-alpha.6",
|
|
44
|
+
"@luma.gl/shadertools": "9.3.0-alpha.6"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@math.gl/core": "^4.1.0",
|
|
48
48
|
"@math.gl/types": "^4.1.0",
|
|
49
|
-
"@probe.gl/log": "^4.
|
|
50
|
-
"@probe.gl/stats": "^4.
|
|
49
|
+
"@probe.gl/log": "^4.1.1",
|
|
50
|
+
"@probe.gl/stats": "^4.1.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "ca3a841517106f8608ce392440fa7f324863a84f"
|
|
53
53
|
}
|
|
@@ -12,6 +12,7 @@ import {AnimationProps} from './animation-props';
|
|
|
12
12
|
import {Stats, Stat} from '@probe.gl/stats';
|
|
13
13
|
|
|
14
14
|
let statIdCounter = 0;
|
|
15
|
+
const ANIMATION_LOOP_STATS = 'Animation Loop';
|
|
15
16
|
|
|
16
17
|
/** AnimationLoop properties */
|
|
17
18
|
export type AnimationLoopProps = {
|
|
@@ -45,7 +46,7 @@ export class AnimationLoop {
|
|
|
45
46
|
onFinalize: () => {},
|
|
46
47
|
onError: error => console.error(error), // eslint-disable-line no-console
|
|
47
48
|
|
|
48
|
-
stats:
|
|
49
|
+
stats: undefined!,
|
|
49
50
|
|
|
50
51
|
// view parameters
|
|
51
52
|
autoResizeViewport: false
|
|
@@ -58,13 +59,14 @@ export class AnimationLoop {
|
|
|
58
59
|
animationProps: AnimationProps | null = null;
|
|
59
60
|
timeline: Timeline | null = null;
|
|
60
61
|
stats: Stats;
|
|
62
|
+
sharedStats: Stats;
|
|
61
63
|
cpuTime: Stat;
|
|
62
64
|
gpuTime: Stat;
|
|
63
65
|
frameRate: Stat;
|
|
64
66
|
|
|
65
67
|
display: any;
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
private _needsRedraw: string | false = 'initialized';
|
|
68
70
|
|
|
69
71
|
_initialized: boolean = false;
|
|
70
72
|
_running: boolean = false;
|
|
@@ -73,8 +75,7 @@ export class AnimationLoop {
|
|
|
73
75
|
_resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;
|
|
74
76
|
_cpuStartTime: number = 0;
|
|
75
77
|
_error: Error | null = null;
|
|
76
|
-
|
|
77
|
-
// _gpuTimeQuery: Query | null = null;
|
|
78
|
+
_lastFrameTime: number = 0;
|
|
78
79
|
|
|
79
80
|
/*
|
|
80
81
|
* @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context
|
|
@@ -88,10 +89,12 @@ export class AnimationLoop {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
// state
|
|
91
|
-
this.stats = props.stats || new Stats({id:
|
|
92
|
+
this.stats = props.stats || new Stats({id: `animation-loop-${statIdCounter++}`});
|
|
93
|
+
this.sharedStats = luma.stats.get(ANIMATION_LOOP_STATS);
|
|
94
|
+
this.frameRate = this.stats.get('Frame Rate');
|
|
95
|
+
this.frameRate.setSampleSize(1);
|
|
92
96
|
this.cpuTime = this.stats.get('CPU Time');
|
|
93
97
|
this.gpuTime = this.stats.get('GPU Time');
|
|
94
|
-
this.frameRate = this.stats.get('Frame Rate');
|
|
95
98
|
|
|
96
99
|
this.setProps({autoResizeViewport: props.autoResizeViewport});
|
|
97
100
|
|
|
@@ -106,6 +109,7 @@ export class AnimationLoop {
|
|
|
106
109
|
destroy(): void {
|
|
107
110
|
this.stop();
|
|
108
111
|
this._setDisplay(null);
|
|
112
|
+
this.device?._disableDebugGPUTime();
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/** @deprecated Use .destroy() */
|
|
@@ -120,10 +124,17 @@ export class AnimationLoop {
|
|
|
120
124
|
|
|
121
125
|
/** Flags this animation loop as needing redraw */
|
|
122
126
|
setNeedsRedraw(reason: string): this {
|
|
123
|
-
this.
|
|
127
|
+
this._needsRedraw = this._needsRedraw || reason;
|
|
124
128
|
return this;
|
|
125
129
|
}
|
|
126
130
|
|
|
131
|
+
/** Query redraw status. Clears the flag. */
|
|
132
|
+
needsRedraw(): false | string {
|
|
133
|
+
const reason = this._needsRedraw;
|
|
134
|
+
this._needsRedraw = false;
|
|
135
|
+
return reason;
|
|
136
|
+
}
|
|
137
|
+
|
|
127
138
|
setProps(props: MutableAnimationLoopProps): this {
|
|
128
139
|
if ('autoResizeViewport' in props) {
|
|
129
140
|
this.props.autoResizeViewport = props.autoResizeViewport || false;
|
|
@@ -145,6 +156,9 @@ export class AnimationLoop {
|
|
|
145
156
|
// Create the WebGL context
|
|
146
157
|
await this._initDevice();
|
|
147
158
|
this._initialize();
|
|
159
|
+
if (!this._running) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
148
162
|
|
|
149
163
|
// Note: onIntialize can return a promise (e.g. in case app needs to load resources)
|
|
150
164
|
await this.props.onInitialize(this._getAnimationProps());
|
|
@@ -185,17 +199,18 @@ export class AnimationLoop {
|
|
|
185
199
|
this._nextFramePromise = null;
|
|
186
200
|
this._resolveNextFrame = null;
|
|
187
201
|
this._running = false;
|
|
202
|
+
this._lastFrameTime = 0;
|
|
188
203
|
}
|
|
189
204
|
return this;
|
|
190
205
|
}
|
|
191
206
|
|
|
192
207
|
/** Explicitly draw a frame */
|
|
193
|
-
redraw(): this {
|
|
208
|
+
redraw(time?: number): this {
|
|
194
209
|
if (this.device?.isLost || this._error) {
|
|
195
210
|
return this;
|
|
196
211
|
}
|
|
197
212
|
|
|
198
|
-
this._beginFrameTimers();
|
|
213
|
+
this._beginFrameTimers(time);
|
|
199
214
|
|
|
200
215
|
this._setupFrame();
|
|
201
216
|
this._updateAnimationProps();
|
|
@@ -261,7 +276,7 @@ export class AnimationLoop {
|
|
|
261
276
|
// Default viewport setup, in case onInitialize wants to render
|
|
262
277
|
this._resizeViewport();
|
|
263
278
|
|
|
264
|
-
|
|
279
|
+
this.device?._enableDebugGPUTime();
|
|
265
280
|
}
|
|
266
281
|
|
|
267
282
|
_setDisplay(display: any): void {
|
|
@@ -307,11 +322,11 @@ export class AnimationLoop {
|
|
|
307
322
|
this._animationFrameId = null;
|
|
308
323
|
}
|
|
309
324
|
|
|
310
|
-
_animationFrame(): void {
|
|
325
|
+
_animationFrame(time: number): void {
|
|
311
326
|
if (!this._running) {
|
|
312
327
|
return;
|
|
313
328
|
}
|
|
314
|
-
this.redraw();
|
|
329
|
+
this.redraw(time);
|
|
315
330
|
this._requestAnimationFrame();
|
|
316
331
|
}
|
|
317
332
|
|
|
@@ -333,7 +348,7 @@ export class AnimationLoop {
|
|
|
333
348
|
}
|
|
334
349
|
|
|
335
350
|
_clearNeedsRedraw(): void {
|
|
336
|
-
this.
|
|
351
|
+
this._needsRedraw = false;
|
|
337
352
|
}
|
|
338
353
|
|
|
339
354
|
_setupFrame(): void {
|
|
@@ -406,7 +421,7 @@ export class AnimationLoop {
|
|
|
406
421
|
this.animationProps.height = height;
|
|
407
422
|
this.animationProps.aspect = aspect;
|
|
408
423
|
|
|
409
|
-
this.animationProps.needsRedraw = this.
|
|
424
|
+
this.animationProps.needsRedraw = this._needsRedraw;
|
|
410
425
|
|
|
411
426
|
// Update time properties
|
|
412
427
|
this.animationProps.engineTime = Date.now() - this.animationProps.startTime;
|
|
@@ -460,20 +475,10 @@ export class AnimationLoop {
|
|
|
460
475
|
if (!this.device) {
|
|
461
476
|
return {width: 1, height: 1, aspect: 1};
|
|
462
477
|
}
|
|
463
|
-
//
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
let aspect = 1;
|
|
468
|
-
const canvas = this.device?.getDefaultCanvasContext().canvas;
|
|
469
|
-
|
|
470
|
-
// @ts-expect-error
|
|
471
|
-
if (canvas && canvas.clientHeight) {
|
|
472
|
-
// @ts-expect-error
|
|
473
|
-
aspect = canvas.clientWidth / canvas.clientHeight;
|
|
474
|
-
} else if (width > 0 && height > 0) {
|
|
475
|
-
aspect = width / height;
|
|
476
|
-
}
|
|
478
|
+
// Match projection setup to the actual render target dimensions, which may
|
|
479
|
+
// differ from the CSS size when device-pixel scaling or backend clamping applies.
|
|
480
|
+
const [width, height] = this.device.getDefaultCanvasContext().getDrawingBufferSize();
|
|
481
|
+
const aspect = width > 0 && height > 0 ? width / height : 1;
|
|
477
482
|
|
|
478
483
|
return {width, height, aspect};
|
|
479
484
|
}
|
|
@@ -495,36 +500,70 @@ export class AnimationLoop {
|
|
|
495
500
|
}
|
|
496
501
|
}
|
|
497
502
|
|
|
498
|
-
_beginFrameTimers() {
|
|
499
|
-
|
|
500
|
-
this.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
// this._gpuTimeQuery.isResultAvailable() &&
|
|
508
|
-
// !this._gpuTimeQuery.isTimerDisjoint()
|
|
509
|
-
// ) {
|
|
510
|
-
// this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());
|
|
511
|
-
// }
|
|
503
|
+
_beginFrameTimers(time?: number) {
|
|
504
|
+
const now = time ?? (typeof performance !== 'undefined' ? performance.now() : Date.now());
|
|
505
|
+
if (this._lastFrameTime) {
|
|
506
|
+
const frameTime = now - this._lastFrameTime;
|
|
507
|
+
if (frameTime > 0) {
|
|
508
|
+
this.frameRate.addTime(frameTime);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
this._lastFrameTime = now;
|
|
512
512
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
// }
|
|
513
|
+
if (this.device?._isDebugGPUTimeEnabled()) {
|
|
514
|
+
this._consumeEncodedGpuTime();
|
|
515
|
+
}
|
|
517
516
|
|
|
518
517
|
this.cpuTime.timeStart();
|
|
519
518
|
}
|
|
520
519
|
|
|
521
520
|
_endFrameTimers() {
|
|
521
|
+
if (this.device?._isDebugGPUTimeEnabled()) {
|
|
522
|
+
this._consumeEncodedGpuTime();
|
|
523
|
+
}
|
|
524
|
+
|
|
522
525
|
this.cpuTime.timeEnd();
|
|
526
|
+
this._updateSharedStats();
|
|
527
|
+
}
|
|
523
528
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
529
|
+
_consumeEncodedGpuTime(): void {
|
|
530
|
+
if (!this.device) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const gpuTimeMs = this.device.commandEncoder._gpuTimeMs;
|
|
535
|
+
if (gpuTimeMs !== undefined) {
|
|
536
|
+
this.gpuTime.addTime(gpuTimeMs);
|
|
537
|
+
this.device.commandEncoder._gpuTimeMs = undefined;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
_updateSharedStats(): void {
|
|
542
|
+
if (this.stats === this.sharedStats) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
for (const name of Object.keys(this.sharedStats.stats)) {
|
|
547
|
+
if (!this.stats.stats[name]) {
|
|
548
|
+
delete this.sharedStats.stats[name];
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
this.stats.forEach(sourceStat => {
|
|
553
|
+
const targetStat = this.sharedStats.get(sourceStat.name, sourceStat.type);
|
|
554
|
+
targetStat.sampleSize = sourceStat.sampleSize;
|
|
555
|
+
targetStat.time = sourceStat.time;
|
|
556
|
+
targetStat.count = sourceStat.count;
|
|
557
|
+
targetStat.samples = sourceStat.samples;
|
|
558
|
+
targetStat.lastTiming = sourceStat.lastTiming;
|
|
559
|
+
targetStat.lastSampleTime = sourceStat.lastSampleTime;
|
|
560
|
+
targetStat.lastSampleCount = sourceStat.lastSampleCount;
|
|
561
|
+
targetStat._count = sourceStat._count;
|
|
562
|
+
targetStat._time = sourceStat._time;
|
|
563
|
+
targetStat._samples = sourceStat._samples;
|
|
564
|
+
targetStat._startTime = sourceStat._startTime;
|
|
565
|
+
targetStat._timerPending = sourceStat._timerPending;
|
|
566
|
+
});
|
|
528
567
|
}
|
|
529
568
|
|
|
530
569
|
// Event handling
|
|
@@ -36,14 +36,14 @@ export function makeAnimationLoop(
|
|
|
36
36
|
device,
|
|
37
37
|
|
|
38
38
|
async onInitialize(animationProps: AnimationProps): Promise<unknown> {
|
|
39
|
-
clearError(animationProps.animationLoop.device
|
|
39
|
+
clearError(animationProps.animationLoop.device);
|
|
40
40
|
try {
|
|
41
41
|
// @ts-expect-error abstract to prevent instantiation
|
|
42
42
|
renderLoop = new AnimationLoopTemplateCtor(animationProps);
|
|
43
43
|
// Any async loading can be handled here
|
|
44
44
|
return await renderLoop?.onInitialize(animationProps);
|
|
45
45
|
} catch (error) {
|
|
46
|
-
setError(animationProps.animationLoop.device
|
|
46
|
+
setError(animationProps.animationLoop.device, error as Error);
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
},
|
|
@@ -63,8 +63,12 @@ export function makeAnimationLoop(
|
|
|
63
63
|
return animationLoop;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function setError(device: Device, error: Error): void {
|
|
67
|
-
|
|
66
|
+
function setError(device: Device | null, error: Error): void {
|
|
67
|
+
if (!device) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const canvas = device.getDefaultCanvasContext().canvas;
|
|
68
72
|
if (canvas instanceof HTMLCanvasElement) {
|
|
69
73
|
canvas.style.overflow = 'visible';
|
|
70
74
|
let errorDiv = document.getElementById('animation-loop-error');
|
|
@@ -82,7 +86,11 @@ function setError(device: Device, error: Error): void {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
function clearError(device: Device): void {
|
|
89
|
+
function clearError(device: Device | null): void {
|
|
90
|
+
if (!device) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
const errorDiv = document.getElementById('animation-loop-error');
|
|
87
95
|
if (errorDiv) {
|
|
88
96
|
errorDiv.remove();
|
|
@@ -7,14 +7,40 @@
|
|
|
7
7
|
/** Node.js polyfill for requestAnimationFrame */
|
|
8
8
|
// / <reference types="@types/node" />
|
|
9
9
|
export function requestAnimationFramePolyfill(callback: (time?: any) => void): any {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const browserRequestAnimationFrame =
|
|
11
|
+
typeof window !== 'undefined'
|
|
12
|
+
? window.requestAnimationFrame ||
|
|
13
|
+
(window as Window & {webkitRequestAnimationFrame?: (cb: FrameRequestCallback) => number})
|
|
14
|
+
.webkitRequestAnimationFrame ||
|
|
15
|
+
(window as Window & {mozRequestAnimationFrame?: (cb: FrameRequestCallback) => number})
|
|
16
|
+
.mozRequestAnimationFrame
|
|
17
|
+
: null;
|
|
18
|
+
|
|
19
|
+
if (browserRequestAnimationFrame) {
|
|
20
|
+
return browserRequestAnimationFrame.call(window, callback);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return setTimeout(
|
|
24
|
+
() => callback(typeof performance !== 'undefined' ? performance.now() : Date.now()),
|
|
25
|
+
1000 / 60
|
|
26
|
+
);
|
|
13
27
|
}
|
|
14
28
|
|
|
15
29
|
/** Node.js polyfill for cancelAnimationFrame */
|
|
16
30
|
export function cancelAnimationFramePolyfill(timerId: any): void {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
const browserCancelAnimationFrame =
|
|
32
|
+
typeof window !== 'undefined'
|
|
33
|
+
? window.cancelAnimationFrame ||
|
|
34
|
+
(window as Window & {webkitCancelAnimationFrame?: (handle: number) => void})
|
|
35
|
+
.webkitCancelAnimationFrame ||
|
|
36
|
+
(window as Window & {mozCancelAnimationFrame?: (handle: number) => void})
|
|
37
|
+
.mozCancelAnimationFrame
|
|
38
|
+
: null;
|
|
39
|
+
|
|
40
|
+
if (browserCancelAnimationFrame) {
|
|
41
|
+
browserCancelAnimationFrame.call(window, timerId);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
clearTimeout(timerId);
|
|
20
46
|
}
|
|
@@ -2,22 +2,28 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {DeviceFeature, ComputePipelineProps, Shader, Binding} from '@luma.gl/core';
|
|
6
5
|
import {
|
|
6
|
+
type DeviceFeature,
|
|
7
|
+
type ComputePipelineProps,
|
|
8
|
+
type Shader,
|
|
9
|
+
type Binding,
|
|
7
10
|
Device,
|
|
8
11
|
Buffer,
|
|
9
12
|
ComputePipeline,
|
|
10
13
|
ComputePass,
|
|
14
|
+
PipelineFactory,
|
|
15
|
+
ShaderFactory,
|
|
11
16
|
UniformStore,
|
|
12
17
|
log,
|
|
13
|
-
|
|
18
|
+
dataTypeDecoder
|
|
14
19
|
} from '@luma.gl/core';
|
|
15
|
-
import type
|
|
16
|
-
import {
|
|
17
|
-
import {TypedArray, isNumericArray} from '@math.gl/types';
|
|
20
|
+
import {type ShaderModule, type PlatformInfo, ShaderAssembler} from '@luma.gl/shadertools';
|
|
21
|
+
import {type TypedArray, isNumericArray} from '@math.gl/types';
|
|
18
22
|
import {ShaderInputs} from '../shader-inputs';
|
|
19
|
-
import {
|
|
20
|
-
|
|
23
|
+
import {
|
|
24
|
+
mergeShaderModuleBindingsIntoLayout,
|
|
25
|
+
shaderModuleHasUniforms
|
|
26
|
+
} from '../utils/shader-module-utils';
|
|
21
27
|
import {uid} from '../utils/uid';
|
|
22
28
|
// import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
|
|
23
29
|
|
|
@@ -131,10 +137,6 @@ export class Computation {
|
|
|
131
137
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
132
138
|
this.setShaderInputs(this.shaderInputs);
|
|
133
139
|
|
|
134
|
-
// Support WGSL shader layout introspection
|
|
135
|
-
// TODO - Don't modify props!!
|
|
136
|
-
this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source);
|
|
137
|
-
|
|
138
140
|
// Setup shader assembler
|
|
139
141
|
const platformInfo = getPlatformInfo(device);
|
|
140
142
|
|
|
@@ -142,6 +144,9 @@ export class Computation {
|
|
|
142
144
|
const modules =
|
|
143
145
|
(this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
|
|
144
146
|
|
|
147
|
+
this.props.shaderLayout =
|
|
148
|
+
mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
149
|
+
|
|
145
150
|
this.pipelineFactory =
|
|
146
151
|
props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
147
152
|
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
@@ -155,6 +160,14 @@ export class Computation {
|
|
|
155
160
|
this.source = source;
|
|
156
161
|
// @ts-ignore
|
|
157
162
|
this._getModuleUniforms = getUniforms;
|
|
163
|
+
const inferredShaderLayout = (
|
|
164
|
+
device as Device & {getShaderLayout?: (source: string) => any}
|
|
165
|
+
).getShaderLayout?.(this.source);
|
|
166
|
+
this.props.shaderLayout =
|
|
167
|
+
mergeShaderModuleBindingsIntoLayout(
|
|
168
|
+
this.props.shaderLayout || inferredShaderLayout || null,
|
|
169
|
+
modules
|
|
170
|
+
) || null;
|
|
158
171
|
|
|
159
172
|
// Create the pipeline
|
|
160
173
|
// @note order is important
|
|
@@ -197,7 +210,7 @@ export class Computation {
|
|
|
197
210
|
this.pipeline.setBindings(this.bindings);
|
|
198
211
|
computePass.setPipeline(this.pipeline);
|
|
199
212
|
// @ts-expect-error
|
|
200
|
-
computePass.setBindings(
|
|
213
|
+
computePass.setBindings({});
|
|
201
214
|
|
|
202
215
|
computePass.dispatch(x, y, z);
|
|
203
216
|
} finally {
|
|
@@ -227,11 +240,13 @@ export class Computation {
|
|
|
227
240
|
|
|
228
241
|
setShaderInputs(shaderInputs: ShaderInputs): void {
|
|
229
242
|
this.shaderInputs = shaderInputs;
|
|
230
|
-
this._uniformStore = new UniformStore(this.shaderInputs.modules);
|
|
243
|
+
this._uniformStore = new UniformStore(this.device, this.shaderInputs.modules);
|
|
231
244
|
// Create uniform buffer bindings for all modules
|
|
232
|
-
for (const moduleName of Object.
|
|
233
|
-
|
|
234
|
-
|
|
245
|
+
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
246
|
+
if (shaderModuleHasUniforms(module)) {
|
|
247
|
+
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
248
|
+
this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
|
|
249
|
+
}
|
|
235
250
|
}
|
|
236
251
|
}
|
|
237
252
|
|
|
@@ -340,7 +355,7 @@ export class Computation {
|
|
|
340
355
|
|
|
341
356
|
// TODO - fix typing of luma data types
|
|
342
357
|
_getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string {
|
|
343
|
-
const TypedArrayConstructor = getTypedArrayConstructor(dataType);
|
|
358
|
+
const TypedArrayConstructor = dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
344
359
|
const typedArray =
|
|
345
360
|
attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
346
361
|
return typedArray.toString();
|
package/src/compute/swap.ts
CHANGED
|
@@ -12,12 +12,15 @@ import {Device, Resource, Buffer, Framebuffer, Texture} from '@luma.gl/core';
|
|
|
12
12
|
* @note the two resources can be destroyed by calling `destroy()`
|
|
13
13
|
*/
|
|
14
14
|
export class Swap<T extends Resource<any>> {
|
|
15
|
+
id: string;
|
|
16
|
+
|
|
15
17
|
/** The current resource - usually the source for renders or computations */
|
|
16
18
|
current: T;
|
|
17
19
|
/** The next resource - usually the target/destination for transforms / computations */
|
|
18
20
|
next: T;
|
|
19
21
|
|
|
20
|
-
constructor(props: {current: T; next: T}) {
|
|
22
|
+
constructor(props: {current: T; next: T; id?: string}) {
|
|
23
|
+
this.id = props.id || 'swap';
|
|
21
24
|
this.current = props.current;
|
|
22
25
|
this.next = props.next;
|
|
23
26
|
}
|
|
@@ -41,14 +44,17 @@ export class SwapFramebuffers extends Swap<Framebuffer> {
|
|
|
41
44
|
constructor(device: Device, props: FramebufferProps) {
|
|
42
45
|
props = {...props};
|
|
43
46
|
|
|
47
|
+
const {width = 1, height = 1} = props;
|
|
48
|
+
|
|
44
49
|
let colorAttachments = props.colorAttachments?.map(colorAttachment =>
|
|
45
50
|
typeof colorAttachment !== 'string'
|
|
46
51
|
? colorAttachment
|
|
47
52
|
: device.createTexture({
|
|
53
|
+
id: `${props.id}-texture-0`,
|
|
48
54
|
format: colorAttachment,
|
|
49
55
|
usage: Texture.SAMPLE | Texture.RENDER | Texture.COPY_SRC | Texture.COPY_DST,
|
|
50
|
-
width
|
|
51
|
-
height
|
|
56
|
+
width,
|
|
57
|
+
height
|
|
52
58
|
})
|
|
53
59
|
);
|
|
54
60
|
|
|
@@ -58,11 +64,11 @@ export class SwapFramebuffers extends Swap<Framebuffer> {
|
|
|
58
64
|
typeof colorAttachment !== 'string'
|
|
59
65
|
? colorAttachment
|
|
60
66
|
: device.createTexture({
|
|
67
|
+
id: `${props.id}-texture-1`,
|
|
61
68
|
format: colorAttachment,
|
|
62
|
-
usage:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
height: 1
|
|
69
|
+
usage: Texture.SAMPLE | Texture.RENDER | Texture.COPY_SRC | Texture.COPY_DST,
|
|
70
|
+
width,
|
|
71
|
+
height
|
|
66
72
|
})
|
|
67
73
|
);
|
|
68
74
|
|