@galacean/engine-shader-compiler 0.0.0-experimental-2.0-spine.1 → 0.0.0-experimental-2.0-migrate.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/dist/browser.js CHANGED
@@ -362,6 +362,11 @@
362
362
  ShaderCompilerUtils._shaderCompilerObjectPoolSet[i].clear();
363
363
  }
364
364
  };
365
+ /** Release all objects retained by the compiler pools. */ ShaderCompilerUtils.releaseAllShaderCompilerObjectPool = function releaseAllShaderCompilerObjectPool() {
366
+ for(var i = 0, n = ShaderCompilerUtils._shaderCompilerObjectPoolSet.length; i < n; i++){
367
+ ShaderCompilerUtils._shaderCompilerObjectPoolSet[i].garbageCollection();
368
+ }
369
+ };
365
370
  ShaderCompilerUtils.createGSError = function createGSError(message, errorName, source, location, file) {
366
371
  console.error(message);
367
372
  var err = new Error(message);
@@ -6219,6 +6224,10 @@
6219
6224
  this._stateItemPool.set(mapId, newItem);
6220
6225
  return newItem;
6221
6226
  };
6227
+ /** Release the state graph after the action/goto tables have been generated. */ State.clearPool = function clearPool() {
6228
+ this.closureMap.clear();
6229
+ this.pool.clear();
6230
+ };
6222
6231
  State.create = function create(cores) {
6223
6232
  var cacheKey = this.getMapKey(cores);
6224
6233
  var state = this.closureMap.get(cacheKey);
@@ -6353,6 +6362,9 @@
6353
6362
  _proto.generate = function generate() {
6354
6363
  this.computeFirstSet();
6355
6364
  this.buildStateTable();
6365
+ // Runtime parsing only needs the numeric action/goto tables. The state closure graph is
6366
+ // construction-only data and otherwise keeps thousands of StateItem/Set objects alive.
6367
+ State.clearPool();
6356
6368
  };
6357
6369
  _proto.buildStateTable = function buildStateTable() {
6358
6370
  var startStateItemCore = [
@@ -6391,7 +6403,7 @@
6391
6403
  var terminalExist = false;
6392
6404
  // when A :=> a.BC, a; ==》 B :=> .xy, First(Ca)
6393
6405
  // newLookAhead = First(Ca)
6394
- for(var i = 1, nextSymbol = item.symbolByOffset(1); !!nextSymbol; nextSymbol = item.symbolByOffset(++i)){
6406
+ for(var i = 1, nextSymbol = item.symbolByOffset(1); nextSymbol; nextSymbol = item.symbolByOffset(++i)){
6395
6407
  if (GrammarUtils.isTerminal(nextSymbol)) {
6396
6408
  newLookaheadSet.add(nextSymbol);
6397
6409
  terminalExist = true;
@@ -8906,6 +8918,13 @@
8906
8918
  variableMap: renderStates.variableMap
8907
8919
  };
8908
8920
  };
8921
+ /**
8922
+ * Release token and AST pools retained at their compilation-time peak.
8923
+ * Call this after shader warm-up when no further compilation is expected soon.
8924
+ * Later compilation remains supported and will allocate pool entries on demand.
8925
+ */ ShaderCompiler.releaseCompilationCache = function releaseCompilationCache() {
8926
+ ShaderCompilerUtils.releaseAllShaderCompilerObjectPool();
8927
+ };
8909
8928
  ShaderCompiler.createPosition = function createPosition(index, line, column) {
8910
8929
  var position = this._shaderPositionPool.get();
8911
8930
  position.set(index);
@@ -8923,7 +8942,7 @@
8923
8942
  ShaderCompiler._shaderRangePool = ShaderCompilerUtils.createObjectPool(ShaderRange);
8924
8943
 
8925
8944
  //@ts-ignore
8926
- var version = "0.0.0-experimental-2.0-spine.1";
8945
+ var version = "0.0.0-experimental-2.0-migrate.2";
8927
8946
  var mode = "Release";
8928
8947
  console.log("Galacean Engine Shader Compiler Version: " + version + " | Mode: " + mode);
8929
8948