@luma.gl/engine 9.1.0-beta.8 → 9.1.0-beta.9
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/compute/texture-transform.d.ts.map +1 -1
- package/dist/compute/texture-transform.js +2 -3
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/dist.dev.js +36 -150
- package/dist/dist.min.js +17 -17
- package/dist/factories/pipeline-factory.d.ts +1 -11
- package/dist/factories/pipeline-factory.d.ts.map +1 -1
- package/dist/factories/pipeline-factory.js +22 -104
- package/dist/factories/pipeline-factory.js.map +1 -1
- package/dist/factories/shader-factory.d.ts +1 -5
- package/dist/factories/shader-factory.d.ts.map +1 -1
- package/dist/factories/shader-factory.js +4 -38
- package/dist/factories/shader-factory.js.map +1 -1
- package/dist/index.cjs +36 -148
- package/dist/index.cjs.map +2 -2
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +12 -16
- package/dist/model/model.js.map +1 -1
- package/package.json +2 -2
- package/src/compute/texture-transform.ts +2 -3
- package/src/factories/pipeline-factory.ts +23 -119
- package/src/factories/shader-factory.ts +5 -41
- package/src/model/model.ts +12 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-transform.d.ts","sourceRoot":"","sources":["../../src/compute/texture-transform.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"texture-transform.d.ts","sourceRoot":"","sources":["../../src/compute/texture-transform.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,0BAAuB;AAGjD;;GAEG;AACH,MAAM,MAAM,qBAAqB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IAAI,IAAI;IAId,GAAG,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI;IAOpC,gBAAgB,IAAI,OAAO;IAK3B,cAAc,IAAI,WAAW,GAAG,SAAS;IAOzC,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IAI/C,eAAe,CAAC,KAAK,EAAE,qBAAqB;IAI5C,cAAc,CACZ,OAAO,EAAE,cAAc,EACvB,EAAC,aAAa,EAAE,cAAc,EAAE,aAAa,EAAC,EAAE,qBAAqB,GACpE,cAAc;IA8BjB,2BAA2B,IAAI,IAAI;CAOpC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
5
4
|
import { Model } from "../model/model.js";
|
|
6
|
-
import {
|
|
5
|
+
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
7
6
|
const FS_OUTPUT_VARIABLE = 'transform_output';
|
|
8
7
|
/**
|
|
9
8
|
* Creates a pipeline for texture→texture transforms.
|
|
@@ -28,7 +27,7 @@ export class TextureTransform {
|
|
|
28
27
|
mipmapFilter: 'nearest'
|
|
29
28
|
});
|
|
30
29
|
this.model = new Model(this.device, {
|
|
31
|
-
id: props.id ||
|
|
30
|
+
id: props.id || 'texture-transform-model',
|
|
32
31
|
fs: props.fs ||
|
|
33
32
|
getPassthroughFS({
|
|
34
33
|
input: props.targetTextureVarying,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-transform.js","sourceRoot":"","sources":["../../src/compute/texture-transform.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"texture-transform.js","sourceRoot":"","sources":["../../src/compute/texture-transform.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC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016
1016
|
return device._lumaData.defaultPipelineFactory;
|
|
1017
1017
|
}
|
|
1018
1018
|
device;
|
|
1019
|
-
cachingEnabled;
|
|
1020
1019
|
destroyPolicy;
|
|
1021
|
-
debug;
|
|
1022
1020
|
_hashCounter = 0;
|
|
1023
1021
|
_hashes = {};
|
|
1024
1022
|
_renderPipelineCache = {};
|
|
1025
1023
|
_computePipelineCache = {};
|
|
1026
|
-
get [Symbol.toStringTag]() {
|
|
1027
|
-
return "PipelineFactory";
|
|
1028
|
-
}
|
|
1029
|
-
toString() {
|
|
1030
|
-
return `PipelineFactory(${this.device.id})`;
|
|
1031
|
-
}
|
|
1032
1024
|
constructor(device) {
|
|
1033
1025
|
this.device = device;
|
|
1034
|
-
this.
|
|
1035
|
-
this.destroyPolicy = device.props._cacheDestroyPolicy;
|
|
1036
|
-
this.debug = device.props.debugFactories;
|
|
1026
|
+
this.destroyPolicy = device.props._factoryDestroyPolicy;
|
|
1037
1027
|
}
|
|
1038
|
-
/** Return a RenderPipeline matching
|
|
1028
|
+
/** Return a RenderPipeline matching props. Reuses a similar pipeline if already created. */
|
|
1039
1029
|
createRenderPipeline(props) {
|
|
1040
|
-
if (!this.cachingEnabled) {
|
|
1041
|
-
return this.device.createRenderPipeline(props);
|
|
1042
|
-
}
|
|
1043
1030
|
const allProps = { ...import_core4.RenderPipeline.defaultProps, ...props };
|
|
1044
|
-
const cache = this._renderPipelineCache;
|
|
1045
1031
|
const hash = this._hashRenderPipeline(allProps);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
pipeline = this.device.createRenderPipeline({
|
|
1032
|
+
if (!this._renderPipelineCache[hash]) {
|
|
1033
|
+
const pipeline = this.device.createRenderPipeline({
|
|
1049
1034
|
...allProps,
|
|
1050
|
-
id: allProps.id ? `${allProps.id}-cached` :
|
|
1035
|
+
id: allProps.id ? `${allProps.id}-cached` : void 0
|
|
1051
1036
|
});
|
|
1052
1037
|
pipeline.hash = hash;
|
|
1053
|
-
|
|
1054
|
-
if (this.debug) {
|
|
1055
|
-
import_core4.log.warn(`${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
|
|
1056
|
-
}
|
|
1057
|
-
} else {
|
|
1058
|
-
cache[hash].useCount++;
|
|
1059
|
-
if (this.debug) {
|
|
1060
|
-
import_core4.log.warn(
|
|
1061
|
-
`${this}: ${cache[hash].pipeline} reused, count=${cache[hash].useCount}, (id=${props.id})`
|
|
1062
|
-
)();
|
|
1063
|
-
}
|
|
1038
|
+
this._renderPipelineCache[hash] = { pipeline, useCount: 0 };
|
|
1064
1039
|
}
|
|
1065
|
-
|
|
1040
|
+
this._renderPipelineCache[hash].useCount++;
|
|
1041
|
+
return this._renderPipelineCache[hash].pipeline;
|
|
1066
1042
|
}
|
|
1067
|
-
/** Return a ComputePipeline matching supplied props. Reuses an equivalent pipeline if already created. */
|
|
1068
1043
|
createComputePipeline(props) {
|
|
1069
|
-
if (!this.cachingEnabled) {
|
|
1070
|
-
return this.device.createComputePipeline(props);
|
|
1071
|
-
}
|
|
1072
1044
|
const allProps = { ...import_core4.ComputePipeline.defaultProps, ...props };
|
|
1073
|
-
const cache = this._computePipelineCache;
|
|
1074
1045
|
const hash = this._hashComputePipeline(allProps);
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
pipeline = this.device.createComputePipeline({
|
|
1046
|
+
if (!this._computePipelineCache[hash]) {
|
|
1047
|
+
const pipeline = this.device.createComputePipeline({
|
|
1078
1048
|
...allProps,
|
|
1079
1049
|
id: allProps.id ? `${allProps.id}-cached` : void 0
|
|
1080
1050
|
});
|
|
1081
1051
|
pipeline.hash = hash;
|
|
1082
|
-
|
|
1083
|
-
if (this.debug) {
|
|
1084
|
-
import_core4.log.warn(`${this}: ${pipeline} created, count=${cache[hash].useCount}`)();
|
|
1085
|
-
}
|
|
1086
|
-
} else {
|
|
1087
|
-
cache[hash].useCount++;
|
|
1088
|
-
if (this.debug) {
|
|
1089
|
-
import_core4.log.warn(
|
|
1090
|
-
`${this}: ${cache[hash].pipeline} reused, count=${cache[hash].useCount}, (id=${props.id})`
|
|
1091
|
-
)();
|
|
1092
|
-
}
|
|
1052
|
+
this._computePipelineCache[hash] = { pipeline, useCount: 0 };
|
|
1093
1053
|
}
|
|
1094
|
-
|
|
1054
|
+
this._computePipelineCache[hash].useCount++;
|
|
1055
|
+
return this._computePipelineCache[hash].pipeline;
|
|
1095
1056
|
}
|
|
1096
1057
|
release(pipeline) {
|
|
1097
|
-
if (!this.cachingEnabled) {
|
|
1098
|
-
pipeline.destroy();
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
const cache = this._getCache(pipeline);
|
|
1102
1058
|
const hash = pipeline.hash;
|
|
1059
|
+
const cache = pipeline instanceof import_core4.ComputePipeline ? this._computePipelineCache : this._renderPipelineCache;
|
|
1103
1060
|
cache[hash].useCount--;
|
|
1104
1061
|
if (cache[hash].useCount === 0) {
|
|
1105
|
-
this.
|
|
1106
|
-
|
|
1107
|
-
|
|
1062
|
+
if (this.destroyPolicy === "unused") {
|
|
1063
|
+
cache[hash].pipeline.destroy();
|
|
1064
|
+
delete cache[hash];
|
|
1108
1065
|
}
|
|
1109
|
-
} else if (cache[hash].useCount < 0) {
|
|
1110
|
-
import_core4.log.error(`${this}: ${pipeline} released, useCount < 0, resetting`)();
|
|
1111
|
-
cache[hash].useCount = 0;
|
|
1112
|
-
} else if (this.debug) {
|
|
1113
|
-
import_core4.log.warn(`${this}: ${pipeline} released, count=${cache[hash].useCount}`)();
|
|
1114
1066
|
}
|
|
1115
1067
|
}
|
|
1116
1068
|
// PRIVATE
|
|
1117
|
-
/** Destroy a cached pipeline, removing it from the cache (depending on destroy policy) */
|
|
1118
|
-
_destroyPipeline(pipeline) {
|
|
1119
|
-
const cache = this._getCache(pipeline);
|
|
1120
|
-
switch (this.destroyPolicy) {
|
|
1121
|
-
case "never":
|
|
1122
|
-
return false;
|
|
1123
|
-
case "unused":
|
|
1124
|
-
delete cache[pipeline.hash];
|
|
1125
|
-
pipeline.destroy();
|
|
1126
|
-
return true;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
/** Get the appropriate cache for the type of pipeline */
|
|
1130
|
-
_getCache(pipeline) {
|
|
1131
|
-
let cache;
|
|
1132
|
-
if (pipeline instanceof import_core4.ComputePipeline) {
|
|
1133
|
-
cache = this._computePipelineCache;
|
|
1134
|
-
}
|
|
1135
|
-
if (pipeline instanceof import_core4.RenderPipeline) {
|
|
1136
|
-
cache = this._renderPipelineCache;
|
|
1137
|
-
}
|
|
1138
|
-
if (!cache) {
|
|
1139
|
-
throw new Error(`${this}`);
|
|
1140
|
-
}
|
|
1141
|
-
if (!cache[pipeline.hash]) {
|
|
1142
|
-
throw new Error(`${this}: ${pipeline} matched incorrect entry`);
|
|
1143
|
-
}
|
|
1144
|
-
return cache;
|
|
1145
|
-
}
|
|
1146
|
-
/** Calculate a hash based on all the inputs for a compute pipeline */
|
|
1147
1069
|
_hashComputePipeline(props) {
|
|
1148
|
-
const { type } = this.device;
|
|
1149
1070
|
const shaderHash = this._getHash(props.shader.source);
|
|
1150
|
-
return `${
|
|
1071
|
+
return `${shaderHash}`;
|
|
1151
1072
|
}
|
|
1152
1073
|
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
1153
1074
|
_hashRenderPipeline(props) {
|
|
@@ -1155,14 +1076,12 @@ var __exports__ = (() => {
|
|
|
1155
1076
|
const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
|
|
1156
1077
|
const varyingHash = "-";
|
|
1157
1078
|
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
1158
|
-
|
|
1159
|
-
switch (type) {
|
|
1079
|
+
switch (this.device.type) {
|
|
1160
1080
|
case "webgl":
|
|
1161
|
-
return `${
|
|
1162
|
-
case "webgpu":
|
|
1081
|
+
return `${vsHash}/${fsHash}V${varyingHash}BL${bufferLayoutHash}`;
|
|
1163
1082
|
default:
|
|
1164
1083
|
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
1165
|
-
return `${
|
|
1084
|
+
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}`;
|
|
1166
1085
|
}
|
|
1167
1086
|
}
|
|
1168
1087
|
_getHash(key) {
|
|
@@ -1184,28 +1103,15 @@ var __exports__ = (() => {
|
|
|
1184
1103
|
return device._lumaData.defaultShaderFactory;
|
|
1185
1104
|
}
|
|
1186
1105
|
device;
|
|
1187
|
-
cachingEnabled;
|
|
1188
1106
|
destroyPolicy;
|
|
1189
|
-
debug;
|
|
1190
1107
|
_cache = {};
|
|
1191
|
-
get [Symbol.toStringTag]() {
|
|
1192
|
-
return "ShaderFactory";
|
|
1193
|
-
}
|
|
1194
|
-
toString() {
|
|
1195
|
-
return `${this[Symbol.toStringTag]}(${this.device.id})`;
|
|
1196
|
-
}
|
|
1197
1108
|
/** @internal */
|
|
1198
1109
|
constructor(device) {
|
|
1199
1110
|
this.device = device;
|
|
1200
|
-
this.
|
|
1201
|
-
this.destroyPolicy = device.props._cacheDestroyPolicy;
|
|
1202
|
-
this.debug = true;
|
|
1111
|
+
this.destroyPolicy = device.props._factoryDestroyPolicy;
|
|
1203
1112
|
}
|
|
1204
1113
|
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
1205
1114
|
createShader(props) {
|
|
1206
|
-
if (!this.cachingEnabled) {
|
|
1207
|
-
return this.device.createShader(props);
|
|
1208
|
-
}
|
|
1209
1115
|
const key = this._hashShader(props);
|
|
1210
1116
|
let cacheEntry = this._cache[key];
|
|
1211
1117
|
if (!cacheEntry) {
|
|
@@ -1213,24 +1119,13 @@ var __exports__ = (() => {
|
|
|
1213
1119
|
...props,
|
|
1214
1120
|
id: props.id ? `${props.id}-cached` : void 0
|
|
1215
1121
|
});
|
|
1216
|
-
this._cache[key] = cacheEntry = { shader, useCount:
|
|
1217
|
-
if (this.debug) {
|
|
1218
|
-
import_core5.log.warn(`${this}: Created new shader ${shader.id}`)();
|
|
1219
|
-
}
|
|
1220
|
-
} else {
|
|
1221
|
-
cacheEntry.useCount++;
|
|
1222
|
-
if (this.debug) {
|
|
1223
|
-
import_core5.log.warn(`${this}: Reusing shader ${cacheEntry.shader.id} count=${cacheEntry.useCount}`)();
|
|
1224
|
-
}
|
|
1122
|
+
this._cache[key] = cacheEntry = { shader, useCount: 0 };
|
|
1225
1123
|
}
|
|
1124
|
+
cacheEntry.useCount++;
|
|
1226
1125
|
return cacheEntry.shader;
|
|
1227
1126
|
}
|
|
1228
1127
|
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
1229
1128
|
release(shader) {
|
|
1230
|
-
if (!this.cachingEnabled) {
|
|
1231
|
-
shader.destroy();
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
1129
|
const key = this._hashShader(shader);
|
|
1235
1130
|
const cacheEntry = this._cache[key];
|
|
1236
1131
|
if (cacheEntry) {
|
|
@@ -1239,14 +1134,7 @@ var __exports__ = (() => {
|
|
|
1239
1134
|
if (this.destroyPolicy === "unused") {
|
|
1240
1135
|
delete this._cache[key];
|
|
1241
1136
|
cacheEntry.shader.destroy();
|
|
1242
|
-
if (this.debug) {
|
|
1243
|
-
import_core5.log.warn(`${this}: Releasing shader ${shader.id}, destroyed`)();
|
|
1244
|
-
}
|
|
1245
1137
|
}
|
|
1246
|
-
} else if (cacheEntry.useCount < 0) {
|
|
1247
|
-
throw new Error(`ShaderFactory: Shader ${shader.id} released too many times`);
|
|
1248
|
-
} else if (this.debug) {
|
|
1249
|
-
import_core5.log.warn(`${this}: Releasing shader ${shader.id} count=${cacheEntry.useCount}`)();
|
|
1250
1138
|
}
|
|
1251
1139
|
}
|
|
1252
1140
|
}
|
|
@@ -1739,8 +1627,7 @@ var __exports__ = (() => {
|
|
|
1739
1627
|
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
1740
1628
|
this.pipeline = this._updatePipeline();
|
|
1741
1629
|
this.vertexArray = device.createVertexArray({
|
|
1742
|
-
|
|
1743
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
1630
|
+
renderPipeline: this.pipeline
|
|
1744
1631
|
});
|
|
1745
1632
|
if (this._gpuGeometry) {
|
|
1746
1633
|
this._setGeometryAttributes(this._gpuGeometry);
|
|
@@ -1778,16 +1665,16 @@ var __exports__ = (() => {
|
|
|
1778
1665
|
Object.seal(this);
|
|
1779
1666
|
}
|
|
1780
1667
|
destroy() {
|
|
1781
|
-
if (
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
this._uniformStore.destroy();
|
|
1788
|
-
this._gpuGeometry?.destroy();
|
|
1789
|
-
this._destroyed = true;
|
|
1668
|
+
if (this._destroyed)
|
|
1669
|
+
return;
|
|
1670
|
+
this.pipelineFactory.release(this.pipeline);
|
|
1671
|
+
this.shaderFactory.release(this.pipeline.vs);
|
|
1672
|
+
if (this.pipeline.fs) {
|
|
1673
|
+
this.shaderFactory.release(this.pipeline.fs);
|
|
1790
1674
|
}
|
|
1675
|
+
this._uniformStore.destroy();
|
|
1676
|
+
this._gpuGeometry?.destroy();
|
|
1677
|
+
this._destroyed = true;
|
|
1791
1678
|
}
|
|
1792
1679
|
// Draw call
|
|
1793
1680
|
/** Query redraw status. Clears the status. */
|
|
@@ -1902,8 +1789,7 @@ var __exports__ = (() => {
|
|
|
1902
1789
|
this._setPipelineNeedsUpdate("bufferLayout");
|
|
1903
1790
|
this.pipeline = this._updatePipeline();
|
|
1904
1791
|
this.vertexArray = this.device.createVertexArray({
|
|
1905
|
-
|
|
1906
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
1792
|
+
renderPipeline: this.pipeline
|
|
1907
1793
|
});
|
|
1908
1794
|
if (this._gpuGeometry) {
|
|
1909
1795
|
this._setGeometryAttributes(this._gpuGeometry);
|
|
@@ -2395,7 +2281,7 @@ var __exports__ = (() => {
|
|
|
2395
2281
|
mipmapFilter: "nearest"
|
|
2396
2282
|
});
|
|
2397
2283
|
this.model = new Model(this.device, {
|
|
2398
|
-
id: props.id ||
|
|
2284
|
+
id: props.id || "texture-transform-model",
|
|
2399
2285
|
fs: props.fs || (0, import_shadertools4.getPassthroughFS)({
|
|
2400
2286
|
input: props.targetTextureVarying,
|
|
2401
2287
|
inputChannels: props.targetTextureChannels,
|