@luma.gl/engine 9.1.0-beta.8 → 9.1.0
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 +57 -157
- 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 +57 -155
- package/dist/index.cjs.map +2 -2
- package/dist/model/model.d.ts +6 -0
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +25 -19
- package/dist/model/model.js.map +1 -1
- package/dist/shader-inputs.d.ts +5 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +13 -6
- package/dist/shader-inputs.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 +28 -20
- package/src/shader-inputs.ts +21 -6
|
@@ -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,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AE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAExB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IA8BxD,OAAO,IAAI,IAAI;IAOf,uCAAuC;IACvC,MAAM,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+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AAC,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9C,CAAC;IACH,CAAC;CACF"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -1016,138 +1016,59 @@ var __exports__ = (() => {
|
|
|
1016
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
|
}
|
|
@@ -1400,11 +1288,14 @@ var __exports__ = (() => {
|
|
|
1400
1288
|
|
|
1401
1289
|
// src/shader-inputs.ts
|
|
1402
1290
|
var ShaderInputs = class {
|
|
1291
|
+
options = {
|
|
1292
|
+
disableWarnings: false
|
|
1293
|
+
};
|
|
1403
1294
|
/**
|
|
1404
1295
|
* The map of modules
|
|
1405
1296
|
* @todo should should this include the resolved dependencies?
|
|
1406
1297
|
*/
|
|
1407
|
-
// @ts-
|
|
1298
|
+
// @ts-ignore Fix typings
|
|
1408
1299
|
modules;
|
|
1409
1300
|
/** Stores the uniform values for each module */
|
|
1410
1301
|
moduleUniforms;
|
|
@@ -1416,8 +1307,8 @@ var __exports__ = (() => {
|
|
|
1416
1307
|
* Create a new UniformStore instance
|
|
1417
1308
|
* @param modules
|
|
1418
1309
|
*/
|
|
1419
|
-
|
|
1420
|
-
|
|
1310
|
+
constructor(modules, options) {
|
|
1311
|
+
Object.assign(this.options, options);
|
|
1421
1312
|
const resolvedModules = (0, import_shadertools.getShaderModuleDependencies)(
|
|
1422
1313
|
Object.values(modules).filter((module) => module.dependencies)
|
|
1423
1314
|
);
|
|
@@ -1430,7 +1321,7 @@ var __exports__ = (() => {
|
|
|
1430
1321
|
this.moduleBindings = {};
|
|
1431
1322
|
for (const [name, module] of Object.entries(modules)) {
|
|
1432
1323
|
this._addModule(module);
|
|
1433
|
-
if (module.name && name !== module.name) {
|
|
1324
|
+
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
1434
1325
|
import_core6.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
1435
1326
|
}
|
|
1436
1327
|
}
|
|
@@ -1447,7 +1338,9 @@ var __exports__ = (() => {
|
|
|
1447
1338
|
const moduleProps = props[moduleName] || {};
|
|
1448
1339
|
const module = this.modules[moduleName];
|
|
1449
1340
|
if (!module) {
|
|
1450
|
-
|
|
1341
|
+
if (!this.options.disableWarnings) {
|
|
1342
|
+
import_core6.log.warn(`Module ${name} not found`)();
|
|
1343
|
+
}
|
|
1451
1344
|
continue;
|
|
1452
1345
|
}
|
|
1453
1346
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -1701,10 +1594,11 @@ var __exports__ = (() => {
|
|
|
1701
1594
|
const moduleMap = Object.fromEntries(
|
|
1702
1595
|
this.props.modules?.map((module) => [module.name, module]) || []
|
|
1703
1596
|
);
|
|
1704
|
-
|
|
1597
|
+
const shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap, { disableWarnings: this.props.disableWarnings });
|
|
1598
|
+
this.setShaderInputs(shaderInputs);
|
|
1705
1599
|
const platformInfo = getPlatformInfo(device);
|
|
1706
1600
|
const modules = (
|
|
1707
|
-
// @ts-
|
|
1601
|
+
// @ts-ignore shaderInputs is assigned in setShaderInputs above.
|
|
1708
1602
|
(this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || []
|
|
1709
1603
|
);
|
|
1710
1604
|
const isWebGPU = this.device.type === "webgpu";
|
|
@@ -1739,8 +1633,7 @@ var __exports__ = (() => {
|
|
|
1739
1633
|
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
1740
1634
|
this.pipeline = this._updatePipeline();
|
|
1741
1635
|
this.vertexArray = device.createVertexArray({
|
|
1742
|
-
|
|
1743
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
1636
|
+
renderPipeline: this.pipeline
|
|
1744
1637
|
});
|
|
1745
1638
|
if (this._gpuGeometry) {
|
|
1746
1639
|
this._setGeometryAttributes(this._gpuGeometry);
|
|
@@ -1778,16 +1671,16 @@ var __exports__ = (() => {
|
|
|
1778
1671
|
Object.seal(this);
|
|
1779
1672
|
}
|
|
1780
1673
|
destroy() {
|
|
1781
|
-
if (
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
this._uniformStore.destroy();
|
|
1788
|
-
this._gpuGeometry?.destroy();
|
|
1789
|
-
this._destroyed = true;
|
|
1674
|
+
if (this._destroyed)
|
|
1675
|
+
return;
|
|
1676
|
+
this.pipelineFactory.release(this.pipeline);
|
|
1677
|
+
this.shaderFactory.release(this.pipeline.vs);
|
|
1678
|
+
if (this.pipeline.fs) {
|
|
1679
|
+
this.shaderFactory.release(this.pipeline.fs);
|
|
1790
1680
|
}
|
|
1681
|
+
this._uniformStore.destroy();
|
|
1682
|
+
this._gpuGeometry?.destroy();
|
|
1683
|
+
this._destroyed = true;
|
|
1791
1684
|
}
|
|
1792
1685
|
// Draw call
|
|
1793
1686
|
/** Query redraw status. Clears the status. */
|
|
@@ -1902,8 +1795,7 @@ var __exports__ = (() => {
|
|
|
1902
1795
|
this._setPipelineNeedsUpdate("bufferLayout");
|
|
1903
1796
|
this.pipeline = this._updatePipeline();
|
|
1904
1797
|
this.vertexArray = this.device.createVertexArray({
|
|
1905
|
-
|
|
1906
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
1798
|
+
renderPipeline: this.pipeline
|
|
1907
1799
|
});
|
|
1908
1800
|
if (this._gpuGeometry) {
|
|
1909
1801
|
this._setGeometryAttributes(this._gpuGeometry);
|
|
@@ -2039,6 +1931,14 @@ var __exports__ = (() => {
|
|
|
2039
1931
|
this.setNeedsRedraw("constants");
|
|
2040
1932
|
}
|
|
2041
1933
|
// DEPRECATED METHODS
|
|
1934
|
+
/**
|
|
1935
|
+
* Sets individual uniforms
|
|
1936
|
+
* @deprecated WebGL only, use uniform buffers for portability
|
|
1937
|
+
* @param uniforms
|
|
1938
|
+
*/
|
|
1939
|
+
setUniforms(uniforms) {
|
|
1940
|
+
this.setUniformsWebGL(uniforms);
|
|
1941
|
+
}
|
|
2042
1942
|
/**
|
|
2043
1943
|
* Sets individual uniforms
|
|
2044
1944
|
* @deprecated WebGL only, use uniform buffers for portability
|
|
@@ -2395,7 +2295,7 @@ var __exports__ = (() => {
|
|
|
2395
2295
|
mipmapFilter: "nearest"
|
|
2396
2296
|
});
|
|
2397
2297
|
this.model = new Model(this.device, {
|
|
2398
|
-
id: props.id ||
|
|
2298
|
+
id: props.id || "texture-transform-model",
|
|
2399
2299
|
fs: props.fs || (0, import_shadertools4.getPassthroughFS)({
|
|
2400
2300
|
input: props.targetTextureVarying,
|
|
2401
2301
|
inputChannels: props.targetTextureChannels,
|