diff --git a/cocos/2d/renderer/batcher-2d.ts b/cocos/2d/renderer/batcher-2d.ts index ed6949672dd..ecce83bf2a5 100644 --- a/cocos/2d/renderer/batcher-2d.ts +++ b/cocos/2d/renderer/batcher-2d.ts @@ -869,6 +869,7 @@ export class Batcher2D implements IBatcher { // by legacyCC.director.root.batcher2D._releaseDescriptorSetCache /** * @engineInternal + * @mangle */ public _releaseDescriptorSetCache (textureHash: number | Texture | null, sampler: Sampler | null = null): void { if (JSB) { @@ -962,6 +963,7 @@ export class Batcher2D implements IBatcher { } } +/** @mangle */ class LocalDescriptorSet { private _descriptorSet: DescriptorSet | null = null; private _transform: Node | null = null; @@ -971,7 +973,11 @@ class LocalDescriptorSet { private _transformUpdate = true; private declare _localData: Float32Array | null; - public get descriptorSet (): DescriptorSet | null { + // NOTE: Internal modules should avoid using getter/setter accessors since we're using babel to convert TS to JS + // and terser minifier could not handle the getter/setter generated JS code correctly. + // See the issue: https://github.com/terser/terser/issues/322 + // Change get descriptorSet() to getDescriptorSet() in v3.8.6. + public getDescriptorSet (): DescriptorSet | null { return this._descriptorSet; } @@ -1063,6 +1069,7 @@ class LocalDescriptorSet { } } +/** @mangle */ class DescriptorSetCache { private _descriptorSetCache = new Map(); private _dsCacheHashByTexture = new Map(); @@ -1080,13 +1087,13 @@ class DescriptorSetCache { for (let i = 0, len = caches.length; i < len; i++) { const cache: LocalDescriptorSet = caches[i]; if (cache.equals(batch.useLocalData, batch.textureHash, batch.samplerHash)) { - return cache.descriptorSet!; + return cache.getDescriptorSet()!; } } const localDs = this._localCachePool.alloc(); localDs.initialize(batch); this._localDescriptorSetCache.push(localDs); - return localDs.descriptorSet!; + return localDs.getDescriptorSet()!; } else { const hash = batch.textureHash ^ batch.samplerHash; if (this._descriptorSetCache.has(hash)) { diff --git a/cocos/2d/renderer/draw-batch.ts b/cocos/2d/renderer/draw-batch.ts index 2c209ea269f..ab572fd66de 100644 --- a/cocos/2d/renderer/draw-batch.ts +++ b/cocos/2d/renderer/draw-batch.ts @@ -33,30 +33,9 @@ import { IBatcher } from './i-batcher'; import type { Root } from '../../root'; const UI_VIS_FLAG = Layers.Enum.NONE | Layers.Enum.UI_3D; -export class DrawBatch2D { - public get inputAssembler (): InputAssembler | null { - return this._inputAssembler; - } - - public set inputAssembler (ia: InputAssembler | null) { - this._inputAssembler = ia; - } - - public get descriptorSet (): DescriptorSet | null { - return this._descriptorSet; - } - - public set descriptorSet (ds: DescriptorSet | null) { - this._descriptorSet = ds; - } - - public get visFlags (): number { - return this._visFlags; - } - public set visFlags (vis) { - this._visFlags = vis; - } +/** @mangle */ +export class DrawBatch2D { get passes (): Pass[] { return this._passes; } @@ -77,9 +56,9 @@ export class DrawBatch2D { public samplerHash = 0; private _passes: Pass[] = []; private _shaders: Shader[] = []; - private _visFlags: number = UI_VIS_FLAG; - private _inputAssembler: InputAssembler | null = null; - private _descriptorSet: DescriptorSet | null = null; + public visFlags: number = UI_VIS_FLAG; + public inputAssembler: InputAssembler | null = null; + public descriptorSet: DescriptorSet | null = null; //private declare _nativeObj: any; public destroy (ui: IBatcher): void { @@ -88,8 +67,8 @@ export class DrawBatch2D { public clear (): void { // this.bufferBatch = null; - this._inputAssembler = null; - this._descriptorSet = null; + this.inputAssembler = null; + this.descriptorSet = null; // this.camera = null; this.texture = null; this.sampler = null;