diff --git a/@types/pal/input.d.ts b/@types/pal/input.d.ts index 502622ee940..cc96d0c94b7 100644 --- a/@types/pal/input.d.ts +++ b/@types/pal/input.d.ts @@ -14,6 +14,7 @@ declare module 'pal/input' { * Register the touch event callback. */ public on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: TouchCallback, target?: any); + public dispatchEventsInCache (): void; } type MouseCallback = (res: import('cocos/input/types').EventMouse) => void; @@ -30,6 +31,8 @@ declare module 'pal/input' { public dispatchMouseMoveEvent? (nativeMouseEvent: any); public dispatchMouseUpEvent? (nativeMouseEvent: any); public dispatchScrollEvent? (nativeMouseEvent: any); + + public dispatchEventsInCache (): void } type KeyboardCallback = (res: import('cocos/input/types').EventKeyboard) => void; diff --git a/cocos/asset/asset-manager/asset-manager.ts b/cocos/asset/asset-manager/asset-manager.ts index b84002f1570..1fee8abcf3c 100644 --- a/cocos/asset/asset-manager/asset-manager.ts +++ b/cocos/asset/asset-manager/asset-manager.ts @@ -307,13 +307,13 @@ export class AssetManager { */ public references = references; - private _releaseManager$ = releaseManager; - private _files$ = files; - private _parsed$ = parsed; - private _parsePipeline$ = BUILD ? null : new Pipeline('parse existing json', [this.loadPipe]); - private _projectBundles$: string[] = []; + private _releaseManager = releaseManager; + private _files = files; + private _parsed = parsed; + private _parsePipeline = BUILD ? null : new Pipeline('parse existing json', [this.loadPipe]); + private _projectBundles: string[] = []; private static _instance: AssetManager; - private _eventTarget$ = new EventTarget(); + private _eventTarget = new EventTarget(); /** * @en @@ -335,14 +335,14 @@ export class AssetManager { * @engineInternal */ public get files(): Cache { - return this._files$; + return this._files; } /** * @engineInternal */ public getReleaseManager (): ReleaseManager { - return this._releaseManager$; + return this._releaseManager; } /** @@ -381,7 +381,7 @@ export class AssetManager { * @engineInternal */ public onAssetMissing (func: (parentAsset: Asset, owner: any, propName: string, uuid: string) => void, target?: any): void { - this._eventTarget$.on(EVENT_ASSET_MISSING, func, target); + this._eventTarget.on(EVENT_ASSET_MISSING, func, target); } /** @@ -395,7 +395,7 @@ export class AssetManager { * @engineInternal */ public offAssetMissing (func: (parentAsset: Asset, owner: any, propName: string, uuid: string) => void, target?: any): void { - this._eventTarget$.off(EVENT_ASSET_MISSING, func, target); + this._eventTarget.off(EVENT_ASSET_MISSING, func, target); } /** @@ -411,7 +411,7 @@ export class AssetManager { * @engineInternal */ public dispatchAssetMissing (parentAsset: Asset, owner: any, propName: string, uuid: string): void { - this._eventTarget$.emit(EVENT_ASSET_MISSING, parentAsset, owner, propName, uuid); + this._eventTarget.emit(EVENT_ASSET_MISSING, parentAsset, owner, propName, uuid); } /** @@ -434,9 +434,9 @@ export class AssetManager { this.downloader.maxConcurrency = downloadMaxConcurrency; } - this._files$.clear(); - this._parsed$.clear(); - this._releaseManager$.init(); + this._files.clear(); + this._parsed.clear(); + this._releaseManager.init(); this.assets.clear(); this.bundles.clear(); this.packManager.init(); @@ -453,7 +453,7 @@ export class AssetManager { } this.generalImportBase = importBase; this.generalNativeBase = nativeBase; - this._projectBundles$ = settings.querySettings(SettingsCategory.ASSETS, 'projectBundles') || []; + this._projectBundles = settings.querySettings(SettingsCategory.ASSETS, 'projectBundles') || []; const assetsOverride = settings.querySettings(SettingsCategory.ASSETS, 'assetsOverrides') || {}; for (const key in assetsOverride) { this.assetsOverrideMap.set(key, assetsOverride[key] as string); @@ -827,7 +827,7 @@ export class AssetManager { if (onComp) { onComp(err, data); } }), }); - this._parsePipeline$!.async(task); + this._parsePipeline!.async(task); } } diff --git a/cocos/asset/asset-manager/bundle.ts b/cocos/asset/asset-manager/bundle.ts index cde42eb778e..0eea6f75b5f 100644 --- a/cocos/asset/asset-manager/bundle.ts +++ b/cocos/asset/asset-manager/bundle.ts @@ -42,14 +42,14 @@ import type { AssetManager } from './asset-manager'; * */ export default class Bundle { - private _config$: Config = new Config(); + private _config: Config = new Config(); /** * For internal use. * @engineInternal */ public get config (): Config { - return this._config$; + return this._config; } /** @@ -61,7 +61,7 @@ export default class Bundle { * */ public get name (): string { - return this._config$.name; + return this._config.name; } /** @@ -73,7 +73,7 @@ export default class Bundle { * */ public get deps (): string[] { - return this._config$.deps!; + return this._config.deps!; } /** @@ -85,7 +85,7 @@ export default class Bundle { * */ public get base (): string { - return this._config$.base; + return this._config.base; } /** @@ -104,7 +104,7 @@ export default class Bundle { * */ public getInfoWithPath (path: string, type?: Constructor | null): IAddressableInfo | null { - return this._config$.getInfoWithPath(path, type); + return this._config.getInfoWithPath(path, type); } /** @@ -126,7 +126,7 @@ export default class Bundle { * bundle.getDirWithPath('images', Texture2D, infos); */ public getDirWithPath (path: string, type?: Constructor | null, out?: IAddressableInfo[]): IAddressableInfo[] { - return this._config$.getDirWithPath(path, type, out); + return this._config.getDirWithPath(path, type, out); } /** @@ -144,7 +144,7 @@ export default class Bundle { * */ public getAssetInfo (uuid: string): IAssetInfo | null { - return this._config$.getAssetInfo(uuid); + return this._config.getAssetInfo(uuid); } /** @@ -162,7 +162,7 @@ export default class Bundle { * */ public getSceneInfo (name: string): ISceneInfo | null { - return this._config$.getSceneInfo(name); + return this._config.getSceneInfo(name); } /** @@ -177,7 +177,7 @@ export default class Bundle { * */ public init (options: IConfigOption): void { - this._config$.init(options); + this._config.init(options); bundles.add(options.name, this); } @@ -639,7 +639,7 @@ export default class Bundle { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _destroy (): void { - this._config$.destroy(); + this._config.destroy(); } } diff --git a/cocos/asset/asset-manager/config.ts b/cocos/asset/asset-manager/config.ts index 6b1a8adefb0..1a4a0899332 100644 --- a/cocos/asset/asset-manager/config.ts +++ b/cocos/asset/asset-manager/config.ts @@ -250,12 +250,12 @@ export default class Config { this.name = options.name || ''; this.deps = options.deps || []; // init - this._initUuid$(options.uuids); - this._initPath$(options.paths); - this._initScene$(options.scenes); - this._initPackage$(options.packs); - this._initVersion$(options.versions); - this._initRedirect$(options.redirect); + this._initUuid(options.uuids); + this._initPath(options.paths); + this._initScene(options.scenes); + this._initPackage(options.packs); + this._initVersion(options.versions); + this._initRedirect(options.redirect); for (const ext in options.extensionMap) { if (!Object.prototype.hasOwnProperty.call(options.extensionMap, ext)) { continue; @@ -333,7 +333,7 @@ export default class Config { this.assetInfos.destroy(); } - private _initUuid$ (uuidList: string[]): void { + private _initUuid (uuidList: string[]): void { if (!uuidList) { return; } @@ -344,7 +344,7 @@ export default class Config { } } - private _initPath$ (pathList: Record): void { + private _initPath (pathList: Record): void { if (!pathList) { return; } const paths = this.paths; paths.clear(); @@ -369,7 +369,7 @@ export default class Config { } } - private _initScene$ (sceneList: Record): void { + private _initScene (sceneList: Record): void { if (!sceneList) { return; } const scenes = this.scenes; scenes.clear(); @@ -382,7 +382,7 @@ export default class Config { } } - private _initPackage$ (packageList: Record): void { + private _initPackage (packageList: Record): void { if (!packageList) { return; } const assetInfos = this.assetInfos; for (const packUuid in packageList) { @@ -407,7 +407,7 @@ export default class Config { } } - private _initVersion$ (versions: { import?: string[], native?: string[] }): void { + private _initVersion (versions: { import?: string[], native?: string[] }): void { if (!versions) { return; } const assetInfos = this.assetInfos; let entries = versions.import; @@ -428,7 +428,7 @@ export default class Config { } } - private _initRedirect$ (redirect: string[]): void { + private _initRedirect (redirect: string[]): void { if (!redirect) { return; } const assetInfos = this.assetInfos; for (let i = 0, l = redirect.length; i < l; i += 2) { diff --git a/cocos/asset/asset-manager/depend-util.ts b/cocos/asset/asset-manager/depend-util.ts index dbac4f235d7..8f826676aea 100644 --- a/cocos/asset/asset-manager/depend-util.ts +++ b/cocos/asset/asset-manager/depend-util.ts @@ -143,7 +143,7 @@ export class DependUtil { public getDepsRecursively (uuid: string): string[] { const exclude = Object.create(null); const depends = []; - this._descend$(uuid, exclude, depends); + this._descend(uuid, exclude, depends); return depends; } @@ -184,12 +184,12 @@ export class DependUtil { // issue: https://github.com/cocos/cocos-engine/issues/14642 if (Array.isArray(json) && (!(BUILD || isCompiledJson(json)) || !hasNativeDep(json as any))) { out = { - deps: this._parseDepsFromJson$(json), + deps: this._parseDepsFromJson(json), }; } else { try { const asset = deserialize(json, { __uuid__: uuid }); - out = this._parseDepsFromAsset$(asset); + out = this._parseDepsFromAsset(asset); if (out.nativeDep) { out.nativeDep.uuid = uuid; } @@ -206,14 +206,14 @@ export class DependUtil { return out; } } - out = this._parseDepsFromAsset$(json); + out = this._parseDepsFromAsset(json); } // cache dependency list this._depends.add(uuid, out); return out; } - private _parseDepsFromAsset$ (asset: Asset): IDependencies { + private _parseDepsFromAsset (asset: Asset): IDependencies { const out: IDependencies = { deps: [], parsedFromExistAsset: true, @@ -232,20 +232,20 @@ export class DependUtil { return out; } - private _parseDepsFromJson$ (json: any[]): string[] { + private _parseDepsFromJson (json: any[]): string[] { const depends = parseUuidDependencies(json); depends.forEach((uuid, index): string => depends[index] = decodeUuid(uuid)); return depends; } - private _descend$ (uuid: string, exclude: Record, depends: string[]): void { + private _descend (uuid: string, exclude: Record, depends: string[]): void { const deps = this.getDeps(uuid); for (let i = 0; i < deps.length; i++) { const depend = deps[i]; if (!exclude[depend]) { exclude[depend] = true; depends.push(depend); - this._descend$(depend, exclude, depends); + this._descend(depend, exclude, depends); } } } diff --git a/cocos/asset/asset-manager/deprecated.ts b/cocos/asset/asset-manager/deprecated.ts index 85c2ac29942..4a036e7bb17 100644 --- a/cocos/asset/asset-manager/deprecated.ts +++ b/cocos/asset/asset-manager/deprecated.ts @@ -101,7 +101,7 @@ export class CCLoader { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _autoReleaseSetting: Record = Object.create(null); - private _parseLoadResArgs$ = parseLoadResArgs; + private _parseLoadResArgs = parseLoadResArgs; /** * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. @@ -307,7 +307,7 @@ export class CCLoader { progressCallback?: LoadProgressCallback | LoadCompleteCallback, completeCallback?: LoadCompleteCallback, ): any { - const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$( + const { type: _type, onProgress, onComplete } = this._parseLoadResArgs( type as any, progressCallback as LoadProgressCallback, completeCallback as LoadCompleteCallback, @@ -358,7 +358,7 @@ type as any, progressCallback?: LoadProgressCallback, completeCallback?: LoadCompleteCallback, ): void { - const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$>( + const { type: _type, onProgress, onComplete } = this._parseLoadResArgs>( type as any, progressCallback as LoadProgressCallback, completeCallback as LoadCompleteCallback, @@ -447,7 +447,7 @@ type as any, progressCallback?: LoadProgressCallback | LoadDirCompleteCallback, completeCallback?: LoadDirCompleteCallback, ): any { - const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$>( + const { type: _type, onProgress, onComplete } = this._parseLoadResArgs>( type as any, progressCallback as LoadProgressCallback, completeCallback as LoadDirCompleteCallback, diff --git a/cocos/asset/asset-manager/downloader.ts b/cocos/asset/asset-manager/downloader.ts index 37cdb97dc3e..f127437758a 100644 --- a/cocos/asset/asset-manager/downloader.ts +++ b/cocos/asset/asset-manager/downloader.ts @@ -195,7 +195,7 @@ export class Downloader { * */ public get remoteServerAddress (): string { - return this._remoteServerAddress$; + return this._remoteServerAddress; } /** @@ -274,7 +274,7 @@ export class Downloader { public _downloadJson = downloadJson; // default handler map - private _downloaders$: Record = { + private _downloaders: Record = { // Images '.png': downloadImage, '.jpg': downloadImage, @@ -321,28 +321,28 @@ export class Downloader { default: downloadText, }; - private _downloading$ = new Cache<((err: Error | null, data?: any) => void)[]>(); - private _queue$: IDownloadRequest[] = []; - private _queueDirty$ = false; + private _downloading = new Cache<((err: Error | null, data?: any) => void)[]>(); + private _queue: IDownloadRequest[] = []; + private _queueDirty = false; // the number of loading thread - private _totalNum$ = 0; + private _totalNum = 0; // the number of request that launched in this period - private _totalNumThisPeriod$ = 0; + private _totalNumThisPeriod = 0; // last time, if now - lastTime > period, refresh _totalNumThisPeriod. - private _lastDate$ = -1; + private _lastDate = -1; // if _totalNumThisPeriod equals max, move request to next period using setTimeOut. - private _checkNextPeriod$ = false; - private _remoteServerAddress$ = ''; - private _maxInterval$ = 1 / 30; + private _checkNextPeriod = false; + private _remoteServerAddress = ''; + private _maxInterval = 1 / 30; private static _instance: Downloader; /** * @engineInternal */ public init (remoteServerAddress = '', bundleVers: Record = {}, remoteBundles: string[] = []): void { - this._downloading$.clear(); - this._queue$.length = 0; - this._remoteServerAddress$ = remoteServerAddress; + this._downloading.clear(); + this._queue.length = 0; + this._remoteServerAddress = remoteServerAddress; this.bundleVers = bundleVers; this.remoteBundles = remoteBundles; } @@ -351,7 +351,7 @@ export class Downloader { * @engineInternal */ public get handlers (): Record { - return this._downloaders$; + return this._downloaders; } /** @@ -385,9 +385,9 @@ export class Downloader { handler?: (url: string, options: Record, onComplete: ((err: Error | null, data?: any) => void)) => void, ): void { if (typeof type === 'object') { - js.mixin(this._downloaders$, type); + js.mixin(this._downloaders, type); } else { - this._downloaders$[type] = handler as DownloadHandler; + this._downloaders[type] = handler as DownloadHandler; } } @@ -423,15 +423,15 @@ export class Downloader { return; } - const downloadCallbacks = this._downloading$.get(id); + const downloadCallbacks = this._downloading.get(id); if (downloadCallbacks) { downloadCallbacks.push(onComplete); - const request = this._queue$.find((x): boolean => x.id === id); + const request = this._queue.find((x): boolean => x.id === id); if (!request) { return; } const priority: number = options.priority || 0; if (request.priority < priority) { request.priority = priority; - this._queueDirty$ = true; + this._queueDirty = true; } return; } @@ -440,11 +440,11 @@ export class Downloader { const maxRetryCount = typeof options.maxRetryCount !== 'undefined' ? options.maxRetryCount as number : this.maxRetryCount; const maxConcurrency = typeof options.maxConcurrency !== 'undefined' ? options.maxConcurrency as number : this.maxConcurrency; const maxRequestsPerFrame = typeof options.maxRequestsPerFrame !== 'undefined' ? options.maxRequestsPerFrame as number : this.maxRequestsPerFrame; - const handler = this._downloaders$[type] || this._downloaders$.default; + const handler = this._downloaders[type] || this._downloaders.default; const process: RetryFunction = (index, callback): void => { if (index === 0) { - this._downloading$.add(id, [onComplete]); + this._downloading.add(id, [onComplete]); } if (!this.limited) { @@ -457,28 +457,28 @@ export class Downloader { const done: ((err: Error | null, data?: any) => void) = (err, data): void => { // when finish downloading, update _totalNum - this._totalNum$--; + this._totalNum--; this._handleQueueInNextFrame(maxConcurrency, maxRequestsPerFrame); callback(err, data); }; - if (this._totalNum$ < maxConcurrency && this._totalNumThisPeriod$ < maxRequestsPerFrame) { + if (this._totalNum < maxConcurrency && this._totalNumThisPeriod < maxRequestsPerFrame) { handler(urlAppendTimestamp(url, this.appendTimeStamp), options, done); - this._totalNum$++; - this._totalNumThisPeriod$++; + this._totalNum++; + this._totalNumThisPeriod++; } else { // when number of request up to limitation, cache the rest - this._queue$.push({ id, priority: options.priority || 0, url, options, done, handler }); - this._queueDirty$ = true; + this._queue.push({ id, priority: options.priority || 0, url, options, done, handler }); + this._queueDirty = true; - if (this._totalNum$ < maxConcurrency) { this._handleQueueInNextFrame(maxConcurrency, maxRequestsPerFrame); } + if (this._totalNum < maxConcurrency) { this._handleQueueInNextFrame(maxConcurrency, maxRequestsPerFrame); } } }; // when retry finished, invoke callbacks const finale = (err: Error | null, result: any): void => { if (!err) { files.add(id, result); } - const callbacks = this._downloading$.remove(id) as ((err: Error | null, data?: any) => void)[]; + const callbacks = this._downloading.remove(id) as ((err: Error | null, data?: any) => void)[]; for (let i = 0, l = callbacks.length; i < l; i++) { callbacks[i](err, result); } @@ -506,28 +506,28 @@ export class Downloader { const now = performance.now(); // use deltaTime as interval const deltaTime = cclegacy.game.deltaTime; - const interval = deltaTime > this._maxInterval$ ? this._maxInterval$ : deltaTime; - if (now - this._lastDate$ > interval * 1000) { - this._totalNumThisPeriod$ = 0; - this._lastDate$ = now; + const interval = deltaTime > this._maxInterval ? this._maxInterval : deltaTime; + if (now - this._lastDate > interval * 1000) { + this._totalNumThisPeriod = 0; + this._lastDate = now; } } // handle the rest request in next period private _handleQueue (maxConcurrency: number, maxRequestsPerFrame: number): void { - this._checkNextPeriod$ = false; + this._checkNextPeriod = false; this._updateTime(); - while (this._queue$.length > 0 && this._totalNum$ < maxConcurrency && this._totalNumThisPeriod$ < maxRequestsPerFrame) { - if (this._queueDirty$) { - this._queue$.sort((a, b): number => a.priority - b.priority); - this._queueDirty$ = false; + while (this._queue.length > 0 && this._totalNum < maxConcurrency && this._totalNumThisPeriod < maxRequestsPerFrame) { + if (this._queueDirty) { + this._queue.sort((a, b): number => a.priority - b.priority); + this._queueDirty = false; } - const request = this._queue$.pop(); + const request = this._queue.pop(); if (!request) { break; } - this._totalNum$++; - this._totalNumThisPeriod$++; + this._totalNum++; + this._totalNumThisPeriod++; request.handler(urlAppendTimestamp(request.url, this.appendTimeStamp), request.options, request.done); } @@ -535,9 +535,9 @@ export class Downloader { } private _handleQueueInNextFrame (maxConcurrency: number, maxRequestsPerFrame: number): void { - if (!this._checkNextPeriod$ && this._queue$.length > 0) { + if (!this._checkNextPeriod && this._queue.length > 0) { misc.callInNextTick(this._handleQueue.bind(this), maxConcurrency, maxRequestsPerFrame); - this._checkNextPeriod$ = true; + this._checkNextPeriod = true; } } } diff --git a/cocos/asset/asset-manager/factory.ts b/cocos/asset/asset-manager/factory.ts index bf9df95fe0e..3511ecb5d38 100644 --- a/cocos/asset/asset-manager/factory.ts +++ b/cocos/asset/asset-manager/factory.ts @@ -96,9 +96,9 @@ function createBundle (id: string, data: IConfigOption, options: Record void)[]>(); + private _creating = new Cache<((err: Error | null, data?: any | null) => void)[]>(); - private _producers$: Record = { + private _producers: Record = { // Images '.png': createImageAsset, '.jpg': createImageAsset, @@ -141,32 +141,32 @@ export class Factory { public register (type: string | Record, handler?: CreateHandler): void { if (typeof type === 'object') { - js.mixin(this._producers$, type); + js.mixin(this._producers, type); } else { - this._producers$[type] = handler!; + this._producers[type] = handler!; } } public create (id: string, data: any, type: string, options: Record, onComplete: ((err: Error | null, data?: Asset | Bundle | null) => void)): void { - const handler = this._producers$[type] || this._producers$.default; + const handler = this._producers[type] || this._producers.default; const asset = assets.get(id); if (!options.reloadAsset && asset) { onComplete(null, asset); return; } - const creating = this._creating$.get(id); + const creating = this._creating.get(id); if (creating) { creating.push(onComplete); return; } - this._creating$.add(id, [onComplete]); + this._creating.add(id, [onComplete]); handler(id, data, options, (err, result): void => { if (!err && result instanceof Asset) { result._uuid = id; cache(id, result, options.cacheAsset); } - const callbacks = this._creating$.remove(id); + const callbacks = this._creating.remove(id); for (let i = 0, l = callbacks!.length; i < l; i++) { callbacks![i](err, result); } diff --git a/cocos/asset/asset-manager/pack-manager.ts b/cocos/asset/asset-manager/pack-manager.ts index cb2d88a6209..cab8fbc8aa7 100644 --- a/cocos/asset/asset-manager/pack-manager.ts +++ b/cocos/asset/asset-manager/pack-manager.ts @@ -53,8 +53,8 @@ interface IUnpackRequest { * */ export class PackManager { - private _loading$ = new Cache(); - private _unpackers$: Record = { + private _loading = new Cache(); + private _unpackers: Record = { '.json': this.unpackJson, }; @@ -125,7 +125,7 @@ export class PackManager { } public init (): void { - this._loading$.clear(); + this._loading.clear(); } /** @@ -153,9 +153,9 @@ export class PackManager { public register (map: Record): void; public register (type: string | Record, handler?: Unpacker): void { if (typeof type === 'object') { - js.mixin(this._unpackers$, type); + js.mixin(this._unpackers, type); } else { - this._unpackers$[type] = handler!; + this._unpackers[type] = handler!; } } @@ -192,7 +192,7 @@ export class PackManager { onComplete(new Error('package data is wrong!')); return; } - const unpacker = this._unpackers$[type]; + const unpacker = this._unpackers[type]; unpacker(pack, data, options, onComplete); } @@ -232,10 +232,10 @@ export class PackManager { const packs = item.info.packs; // find a loading package - const loadingPack = packs.find((val): boolean => this._loading$.has(val.uuid)); + const loadingPack = packs.find((val): boolean => this._loading.has(val.uuid)); if (loadingPack) { - const req = this._loading$.get(loadingPack.uuid); + const req = this._loading.get(loadingPack.uuid); assertIsTrue(req); req.push({ onComplete, id: item.id }); return; @@ -243,7 +243,7 @@ export class PackManager { // download a new package const pack = packs[0]; - this._loading$.add(pack.uuid, [{ onComplete, id: item.id }]); + this._loading.add(pack.uuid, [{ onComplete, id: item.id }]); // find the url of pack assertIsTrue(item.config); @@ -261,7 +261,7 @@ export class PackManager { files.add(id, result[id]); } } - const callbacks = this._loading$.remove(pack.uuid); + const callbacks = this._loading.remove(pack.uuid); assertIsTrue(callbacks); for (let i = 0, l = callbacks.length; i < l; i++) { const cb = callbacks[i]; diff --git a/cocos/asset/asset-manager/parser.ts b/cocos/asset/asset-manager/parser.ts index d64dbf3c7b1..fbda8052281 100644 --- a/cocos/asset/asset-manager/parser.ts +++ b/cocos/asset/asset-manager/parser.ts @@ -43,9 +43,9 @@ export type ParseHandler = (file: any, options: Record, onComplete: * */ export class Parser { - private _parsing$ = new Cache<((err: Error | null, data?: any) => void)[]>(); + private _parsing = new Cache<((err: Error | null, data?: any) => void)[]>(); - private _parsers$: Record = { + private _parsers: Record = { '.png': this.parseImage, '.jpg': this.parseImage, '.bmp': this.parseImage, @@ -193,7 +193,7 @@ export class Parser { * @engineInternal */ public init (): void { - this._parsing$.clear(); + this._parsing.clear(); } /** @@ -234,9 +234,9 @@ export class Parser { ) => void, ): void { if (typeof type === 'object') { - js.mixin(this._parsers$, type); + js.mixin(this._parsers, type); } else { - this._parsers$[type] = handler as ParseHandler; + this._parsers[type] = handler as ParseHandler; } } @@ -273,26 +273,26 @@ export class Parser { onComplete(null, parsedAsset); return; } - const parsing = this._parsing$.get(id); + const parsing = this._parsing.get(id); if (parsing) { parsing.push(onComplete); return; } - const parseHandler = this._parsers$[type]; + const parseHandler = this._parsers[type]; if (!parseHandler) { onComplete(null, file); return; } - this._parsing$.add(id, [onComplete]); + this._parsing.add(id, [onComplete]); parseHandler(file, options, (err, data): void => { if (err) { files.remove(id); } else if (!isScene(data)) { parsed.add(id, data); } - const callbacks = this._parsing$.remove(id); + const callbacks = this._parsing.remove(id); for (let i = 0, l = callbacks!.length; i < l; i++) { callbacks![i](err, data); } diff --git a/cocos/asset/asset-manager/plist-parser.ts b/cocos/asset/asset-manager/plist-parser.ts index 42e4866c6a0..a62dcd82177 100644 --- a/cocos/asset/asset-manager/plist-parser.ts +++ b/cocos/asset/asset-manager/plist-parser.ts @@ -32,10 +32,10 @@ import { warnID } from '../../core'; * @class saxParser */ export class SAXParser { - private _parser$: DOMParser | null = null; + private _parser: DOMParser | null = null; constructor () { if (globalThis.DOMParser) { - this._parser$ = new DOMParser(); + this._parser = new DOMParser(); } } @@ -50,8 +50,8 @@ export class SAXParser { protected _parseXML (textxml: string): Document { // get a reference to the requested corresponding xml file - if (this._parser$) { - return this._parser$.parseFromString(textxml, 'text/xml'); + if (this._parser) { + return this._parser.parseFromString(textxml, 'text/xml'); } throw new Error('Dom parser is not supported in this platform!'); } @@ -86,16 +86,16 @@ class PlistParser extends SAXParser { break; } } - return this._parseNode$(node!); + return this._parseNode(node!); } - private _parseNode$ (node: HTMLElement): unknown { + private _parseNode (node: HTMLElement): unknown { let data: any = null; const tagName = node.tagName; if (tagName === 'dict') { - data = this._parseDict$(node); + data = this._parseDict(node); } else if (tagName === 'array') { - data = this._parseArray$(node); + data = this._parseArray(node); } else if (tagName === 'string') { if (node.childNodes.length === 1) { data = node.firstChild!.nodeValue; @@ -118,19 +118,19 @@ class PlistParser extends SAXParser { return data; } - private _parseArray$ (node: HTMLElement): unknown[] { + private _parseArray (node: HTMLElement): unknown[] { const data: any[] = []; for (let i = 0, len = node.childNodes.length; i < len; i++) { const child = node.childNodes[i]; if (child.nodeType !== 1) { continue; } - data.push(this._parseNode$(child as HTMLElement)); + data.push(this._parseNode(child as HTMLElement)); } return data; } - private _parseDict$ (node: HTMLElement): Record { + private _parseDict (node: HTMLElement): Record { const data = {}; let key = ''; for (let i = 0, len = node.childNodes.length; i < len; i++) { @@ -143,7 +143,7 @@ class PlistParser extends SAXParser { if (child.tagName === 'key') { key = child.firstChild!.nodeValue!; } else { - data[key] = this._parseNode$(child); + data[key] = this._parseNode(child); } // Parse the value node } return data; diff --git a/cocos/asset/asset-manager/release-manager.ts b/cocos/asset/asset-manager/release-manager.ts index f6d320f2d5f..b30a90906a4 100644 --- a/cocos/asset/asset-manager/release-manager.ts +++ b/cocos/asset/asset-manager/release-manager.ts @@ -113,18 +113,18 @@ function checkCircularReference (asset: Asset): number { } export class ReleaseManager { - private _persistNodeDeps$ = new Cache(); - private _toDelete$ = new Cache(); - private _eventListener$ = false; - private _dontDestroyAssets$: string[] = []; + private _persistNodeDeps = new Cache(); + private _toDelete = new Cache(); + private _eventListener = false; + private _dontDestroyAssets: string[] = []; public addIgnoredAsset (asset: Asset): void { - this._dontDestroyAssets$.push(asset._uuid); + this._dontDestroyAssets.push(asset._uuid); } public init (): void { - this._persistNodeDeps$.clear(); - this._toDelete$.clear(); + this._persistNodeDeps.clear(); + this._toDelete.clear(); } /** @@ -139,23 +139,23 @@ export class ReleaseManager { dependAsset.addRef(); } } - this._persistNodeDeps$.add(node.uuid, deps); + this._persistNodeDeps.add(node.uuid, deps); } /** * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _removePersistNodeRef (node: Node): void { - if (!this._persistNodeDeps$.has(node.uuid)) { return; } + if (!this._persistNodeDeps.has(node.uuid)) { return; } - const deps = this._persistNodeDeps$.get(node.uuid) as string[]; + const deps = this._persistNodeDeps.get(node.uuid) as string[]; for (let i = 0, l = deps.length; i < l; i++) { const dependAsset = assets.get(deps[i]); if (dependAsset) { dependAsset.decRef(); } } - this._persistNodeDeps$.remove(node.uuid); + this._persistNodeDeps.remove(node.uuid); } // do auto release @@ -193,7 +193,7 @@ export class ReleaseManager { if (sceneDeps) { sceneDeps.persistDeps = []; } for (const key in persistNodes) { const node = persistNodes[key]; - const deps = this._persistNodeDeps$.get(node.uuid) as string[]; + const deps = this._persistNodeDeps.get(node.uuid) as string[]; for (const dep of deps) { const dependAsset = assets.get(dep); if (dependAsset) { @@ -208,31 +208,31 @@ export class ReleaseManager { public tryRelease (asset: Asset, force = false): void { if (!(asset instanceof Asset)) { return; } if (force) { - this._free$(asset, force); + this._free(asset, force); return; } - this._toDelete$.add(asset._uuid, asset); + this._toDelete.add(asset._uuid, asset); if (TEST) return; - if (!this._eventListener$) { - this._eventListener$ = true; - misc.callInNextTick(this._freeAssets$.bind(this)); + if (!this._eventListener) { + this._eventListener = true; + misc.callInNextTick(this._freeAssets.bind(this)); } } - private _freeAssets$ (): void { - this._eventListener$ = false; - this._toDelete$.forEach((asset): void => { - this._free$(asset); + private _freeAssets (): void { + this._eventListener = false; + this._toDelete.forEach((asset): void => { + this._free(asset); }); - this._toDelete$.clear(); + this._toDelete.clear(); } - private _free$ (asset: Asset, force = false): void { + private _free (asset: Asset, force = false): void { const uuid = asset._uuid; - this._toDelete$.remove(uuid); + this._toDelete.remove(uuid); - if (!isValid(asset, true) || this._dontDestroyAssets$.indexOf(uuid) !== -1) { return; } + if (!isValid(asset, true) || this._dontDestroyAssets.indexOf(uuid) !== -1) { return; } if (!force) { if (asset.refCount > 0) { @@ -249,7 +249,7 @@ export class ReleaseManager { dependAsset.decRef(false); // no need to release dependencies recursively in editor if (!EDITOR) { - this._free$(dependAsset, false); + this._free(dependAsset, false); } } } diff --git a/cocos/asset/assets/image-asset.ts b/cocos/asset/assets/image-asset.ts index 73fd7008d82..8bd7aa54a80 100644 --- a/cocos/asset/assets/image-asset.ts +++ b/cocos/asset/assets/image-asset.ts @@ -547,13 +547,13 @@ export class ImageAsset extends Asset { @override get _nativeAsset (): any { // Maybe returned to pool in webgl. - return this._nativeData$; + return this._nativeData; } // TODO: Property 'format' does not exist on type 'ImageBitmap' // set _nativeAsset (value: ImageSource) { set _nativeAsset (value: any) { if (!(value instanceof HTMLElement) && !isImageBitmap(value)) { - value.format = value.format || this._format$; + value.format = value.format || this._format; } this.reset(value as ImageSource); } @@ -563,11 +563,11 @@ export class ImageAsset extends Asset { * @zh 此图像资源的图像数据。 */ get data (): ArrayBufferView | HTMLCanvasElement | HTMLImageElement | ImageBitmap | null { - if (isNativeImage(this._nativeData$)) { - return this._nativeData$; + if (isNativeImage(this._nativeData)) { + return this._nativeData; } - return this._nativeData$ && this._nativeData$._data; + return this._nativeData && this._nativeData._data; } /** @@ -575,7 +575,7 @@ export class ImageAsset extends Asset { * @zh 此图像资源的像素宽度。 */ get width (): number { - return this._nativeData$.width || this._width$; + return this._nativeData.width || this._width; } /** @@ -583,7 +583,7 @@ export class ImageAsset extends Asset { * @zh 此图像资源的像素高度。 */ get height (): number { - return this._nativeData$.height || this._height$; + return this._nativeData.height || this._height; } /** @@ -591,7 +591,7 @@ export class ImageAsset extends Asset { * @zh 此图像资源的像素格式。 */ get format (): PixelFormat { - return this._format$; + return this._format; } /** @@ -599,8 +599,8 @@ export class ImageAsset extends Asset { * @zh 此图像资源是否为压缩像素格式。 */ get isCompressed (): boolean { - return (this._format$ >= PixelFormat.RGB_ETC1 && this._format$ <= PixelFormat.RGBA_ASTC_12x12) - || (this._format$ >= PixelFormat.RGB_A_PVRTC_2BPPV1 && this._format$ <= PixelFormat.RGBA_ETC1); + return (this._format >= PixelFormat.RGB_ETC1 && this._format <= PixelFormat.RGBA_ASTC_12x12) + || (this._format >= PixelFormat.RGB_A_PVRTC_2BPPV1 && this._format <= PixelFormat.RGBA_ETC1); } /** @@ -609,7 +609,7 @@ export class ImageAsset extends Asset { * @engineInternal */ get mipmapLevelDataSize (): number[] | undefined { - return (this._nativeData$ as IMemoryImageSource).mipmapLevelDataSize; + return (this._nativeData as IMemoryImageSource).mipmapLevelDataSize; } /** @@ -623,21 +623,21 @@ export class ImageAsset extends Asset { private static extnames = ['.png', '.jpg', '.jpeg', '.bmp', '.webp', '.pvr', '.pkm', '.astc']; - private _nativeData$: ImageSource; + private _nativeData: ImageSource; //NOTE: _exportedExts is used by editor, should not rename or mangle it. private _exportedExts: string[] | null | undefined = undefined; - private _format$: PixelFormat = PixelFormat.RGBA8888; + private _format: PixelFormat = PixelFormat.RGBA8888; - private _width$ = 0; + private _width = 0; - private _height$ = 0; + private _height = 0; constructor (nativeAsset?: ImageSource) { super(); - this._nativeData$ = { + this._nativeData = { _data: null, width: 0, height: 0, @@ -662,13 +662,13 @@ export class ImageAsset extends Asset { */ public reset (data: ImageSource): void { if (isImageBitmap(data)) { - this._nativeData$ = data; + this._nativeData = data; } else if (!(data instanceof HTMLElement)) { // this._nativeData = Object.create(data); - this._nativeData$ = data; - this._format$ = data.format; + this._nativeData = data; + this._format = data.format; } else { - this._nativeData$ = data; + this._nativeData = data; } } @@ -730,15 +730,15 @@ export class ImageAsset extends Asset { if (typeof data === 'string') { fmtStr = data; } else { - this._width$ = data.w; - this._height$ = data.h; + this._width = data.w; + this._height = data.h; fmtStr = data.fmt; } const device = _getGlobalDevice(); const extensionIDs = fmtStr.split('_'); let preferedExtensionIndex = Number.MAX_VALUE; - let format = this._format$; + let format = this._format; let ext = ''; const SupportTextureFormats = macro.SUPPORT_TEXTURE_FORMATS; for (const extensionID of extensionIDs) { @@ -749,7 +749,7 @@ export class ImageAsset extends Asset { const index = SupportTextureFormats.indexOf(tmpExt); if (index !== -1 && index < preferedExtensionIndex) { - const fmt = extFormat[1] ? parseInt(extFormat[1]) : this._format$; + const fmt = extFormat[1] ? parseInt(extFormat[1]) : this._format; // check whether or not support compressed texture if (tmpExt === '.astc' && (!device || !(device.getFormatFeatures(Format.ASTC_RGBA_4X4) & FormatFeatureBit.SAMPLED_TEXTURE))) { continue; @@ -772,26 +772,26 @@ export class ImageAsset extends Asset { if (ext) { this._setRawAsset(ext); - this._format$ = format; + this._format = format; } else { warnID(3121); } } - private static _sharedPlaceHolderCanvas$: HTMLCanvasElement | null = null; + private static _sharedPlaceHolderCanvas: HTMLCanvasElement | null = null; public initDefault (uuid?: string): void { super.initDefault(uuid); - if (!ImageAsset._sharedPlaceHolderCanvas$) { + if (!ImageAsset._sharedPlaceHolderCanvas) { const canvas = ccwindow.document.createElement('canvas'); const context = canvas.getContext('2d')!; const l = canvas.width = canvas.height = 2; context.fillStyle = '#ff00ff'; context.fillRect(0, 0, l, l); this.reset(canvas); - ImageAsset._sharedPlaceHolderCanvas$ = canvas; + ImageAsset._sharedPlaceHolderCanvas = canvas; } else { - this.reset(ImageAsset._sharedPlaceHolderCanvas$); + this.reset(ImageAsset._sharedPlaceHolderCanvas); } } diff --git a/cocos/asset/assets/render-texture.ts b/cocos/asset/assets/render-texture.ts index 57bbf736f9f..c1e3dc42004 100644 --- a/cocos/asset/assets/render-texture.ts +++ b/cocos/asset/assets/render-texture.ts @@ -60,7 +60,7 @@ const _windowInfo: IRenderWindowInfo = { */ @ccclass('cc.RenderTexture') export class RenderTexture extends TextureBase { - private _window$: RenderWindow | null = null; + private _window: RenderWindow | null = null; constructor () { super(); } @@ -70,7 +70,7 @@ export class RenderTexture extends TextureBase { * @zh 渲染管线所使用的渲染窗口,内部逻辑创建,无法被修改。 */ get window (): RenderWindow | null { - return this._window$; + return this._window; } /** @@ -99,10 +99,10 @@ export class RenderTexture extends TextureBase { * @zh 销毁渲染贴图。 */ public destroy (): boolean { - if (this._window$) { + if (this._window) { const root = cclegacy.director.root as Root; - root?.destroyWindow(this._window$); - this._window$ = null; + root?.destroyWindow(this._window); + this._window = null; } return super.destroy(); @@ -117,10 +117,10 @@ export class RenderTexture extends TextureBase { public resize (width: number, height: number): void { this._width = Math.floor(clamp(width, 1, 2048)); this._height = Math.floor(clamp(height, 1, 2048)); - if (this._window$) { - this._window$.resize(this._width, this._height); + if (this._window) { + this._window.resize(this._width, this._height); } - this.emit('resize', this._window$); + this.emit('resize', this._window); } /** @@ -151,7 +151,7 @@ export class RenderTexture extends TextureBase { * @return @en The low level gfx texture. @zh 底层的 gfx 贴图。 */ public getGFXTexture (): Texture | null { - return this._window$ && this._window$.framebuffer.colorTextures[0]; + return this._window && this._window.framebuffer.colorTextures[0]; } /** @@ -187,11 +187,11 @@ export class RenderTexture extends TextureBase { AccessFlagBit.FRAGMENT_SHADER_READ_TEXTURE, )); - if (this._window$) { - this._window$.destroy(); - this._window$.initialize(deviceManager.gfxDevice, _windowInfo); + if (this._window) { + this._window.destroy(); + this._window.initialize(deviceManager.gfxDevice, _windowInfo); } else { - this._window$ = root.createWindow(_windowInfo); + this._window = root.createWindow(_windowInfo); } } diff --git a/cocos/asset/assets/rendering-sub-mesh.ts b/cocos/asset/assets/rendering-sub-mesh.ts index 5657d237bd3..8a8752c6c00 100644 --- a/cocos/asset/assets/rendering-sub-mesh.ts +++ b/cocos/asset/assets/rendering-sub-mesh.ts @@ -104,31 +104,31 @@ export class RenderingSubMesh { */ public subMeshIdx?: number; - private _flatBuffers$: IFlatBuffer[] = []; + private _flatBuffers: IFlatBuffer[] = []; - private _jointMappedBuffers$?: Buffer[]; + private _jointMappedBuffers?: Buffer[]; - private _jointMappedBufferIndices$?: number[]; + private _jointMappedBufferIndices?: number[]; - private _vertexIdChannel$?: { stream: number; index: number }; + private _vertexIdChannel?: { stream: number; index: number }; - private _geometricInfo$?: IGeometricInfo; + private _geometricInfo?: IGeometricInfo; - private _vertexBuffers$: Buffer[]; + private _vertexBuffers: Buffer[]; - private declare _attributes$: Attribute[]; + private declare _attributes: Attribute[]; - private declare _indexBuffer$: Buffer | null; + private declare _indexBuffer: Buffer | null; - private declare _indirectBuffer$: Buffer | null; + private declare _indirectBuffer: Buffer | null; - private declare _primitiveMode$: PrimitiveMode; + private declare _primitiveMode: PrimitiveMode; - private declare _iaInfo$: InputAssemblerInfo; + private declare _iaInfo: InputAssemblerInfo; - private declare _isOwnerOfIndexBuffer$: boolean; + private declare _isOwnerOfIndexBuffer: boolean; - private _drawInfo$?: DrawInfo | null = null; + private _drawInfo?: DrawInfo | null = null; /** * @en @@ -149,52 +149,52 @@ export class RenderingSubMesh { indirectBuffer: Buffer | null = null, isOwnerOfIndexBuffer = true, ) { - this._attributes$ = attributes; - this._vertexBuffers$ = vertexBuffers; - this._indexBuffer$ = indexBuffer; - this._indirectBuffer$ = indirectBuffer; - this._primitiveMode$ = primitiveMode; - this._iaInfo$ = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer); - this._isOwnerOfIndexBuffer$ = isOwnerOfIndexBuffer; + this._attributes = attributes; + this._vertexBuffers = vertexBuffers; + this._indexBuffer = indexBuffer; + this._indirectBuffer = indirectBuffer; + this._primitiveMode = primitiveMode; + this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer); + this._isOwnerOfIndexBuffer = isOwnerOfIndexBuffer; } /** * @en All vertex attributes used by the sub mesh. * @zh 所有顶点属性。 */ - get attributes (): Attribute[] { return this._attributes$; } + get attributes (): Attribute[] { return this._attributes; } /** * @en All vertex buffers used by the sub mesh. * @zh 使用的所有顶点缓冲区。 */ - get vertexBuffers (): Buffer[] { return this._vertexBuffers$; } + get vertexBuffers (): Buffer[] { return this._vertexBuffers; } /** * @en Index buffer used by the sub mesh. * @zh 使用的索引缓冲区,若未使用则无需指定。 */ - get indexBuffer (): Buffer | null { return this._indexBuffer$; } + get indexBuffer (): Buffer | null { return this._indexBuffer; } /** * @en Indirect buffer used by the sub mesh. * @zh 间接绘制缓冲区。 */ - get indirectBuffer (): Buffer | null { return this._indirectBuffer$; } + get indirectBuffer (): Buffer | null { return this._indirectBuffer; } /** * @en Primitive mode used by the sub mesh. * @zh 图元类型。 */ - get primitiveMode (): PrimitiveMode { return this._primitiveMode$; } + get primitiveMode (): PrimitiveMode { return this._primitiveMode; } /** * @en The geometric info of the sub mesh, used for raycast. * @zh (用于射线检测的)几何信息。 */ get geometricInfo (): IGeometricInfo { - if (this._geometricInfo$) { - return this._geometricInfo$; + if (this._geometricInfo) { + return this._geometricInfo; } if (this.mesh === undefined) { return EMPTY_GEOMETRIC_INFO; @@ -298,40 +298,40 @@ export class RenderingSubMesh { min.z = positions[i + 2] < min.z ? positions[i + 2] : min.z; } } - this._geometricInfo$ = { positions, indices, boundingBox: { max, min } }; - return this._geometricInfo$; + this._geometricInfo = { positions, indices, boundingBox: { max, min } }; + return this._geometricInfo; } /** * @en Invalidate the geometric info of the sub mesh after geometry changed. * @zh 网格更新后,设置(用于射线检测的)几何信息为无效,需要重新计算。 */ - public invalidateGeometricInfo (): void { this._geometricInfo$ = undefined; } + public invalidateGeometricInfo (): void { this._geometricInfo = undefined; } /** * @en the draw range. * @zh 渲染范围。 */ set drawInfo (info: DrawInfo | null | undefined) { - this._drawInfo$ = info; + this._drawInfo = info; } get drawInfo (): DrawInfo | null | undefined { - return this._drawInfo$; + return this._drawInfo; } /** * @en Flatted vertex buffers. * @zh 扁平化的顶点缓冲区。 */ - get flatBuffers (): IFlatBuffer[] { return this._flatBuffers$; } + get flatBuffers (): IFlatBuffer[] { return this._flatBuffers; } /** * @en generate flatted vertex buffers. * @zh 生成扁平化的顶点缓冲区。 */ public genFlatBuffers (): void { - if (this._flatBuffers$.length || !this.mesh || this.subMeshIdx === undefined) { return; } + if (this._flatBuffers.length || !this.mesh || this.subMeshIdx === undefined) { return; } const { mesh } = this; let idxCount = 0; @@ -348,7 +348,7 @@ export class RenderingSubMesh { if (!prim.indexView) { sharedView.set(mesh.data.subarray(vertexBundle.view.offset, vertexBundle.view.offset + vertexBundle.view.length)); - this._flatBuffers$.push({ stride: vbStride, count: vbCount, buffer: sharedView }); + this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: sharedView }); continue; } @@ -362,7 +362,7 @@ export class RenderingSubMesh { sharedView[offset + m] = view[srcOffset + m]; } } - this._flatBuffers$.push({ stride: vbStride, count: vbCount, buffer: sharedView }); + this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: sharedView }); } } @@ -371,14 +371,14 @@ export class RenderingSubMesh { * @zh 骨骼索引按映射表处理后的顶点缓冲。 */ get jointMappedBuffers (): Buffer[] { - if (this._jointMappedBuffers$) { return this._jointMappedBuffers$; } - const buffers: Buffer[] = this._jointMappedBuffers$ = []; - const indices: number[] = this._jointMappedBufferIndices$ = []; - if (!this.mesh || this.subMeshIdx === undefined) { return this._jointMappedBuffers$ = this.vertexBuffers; } + if (this._jointMappedBuffers) { return this._jointMappedBuffers; } + const buffers: Buffer[] = this._jointMappedBuffers = []; + const indices: number[] = this._jointMappedBufferIndices = []; + if (!this.mesh || this.subMeshIdx === undefined) { return this._jointMappedBuffers = this.vertexBuffers; } const { struct } = this.mesh; const prim = struct.primitives[this.subMeshIdx]; if (!struct.jointMaps || prim.jointMapIndex === undefined || !struct.jointMaps[prim.jointMapIndex]) { - return this._jointMappedBuffers$ = this.vertexBuffers; + return this._jointMappedBuffers = this.vertexBuffers; } let jointFormat: Format; let jointOffset: number; @@ -419,7 +419,7 @@ export class RenderingSubMesh { buffers.push(this.vertexBuffers[prim.vertexBundelIndices[i]]); } } - if (this._vertexIdChannel$) { + if (this._vertexIdChannel) { buffers.push(this._allocVertexIdBuffer(device)); } return buffers; @@ -429,7 +429,7 @@ export class RenderingSubMesh { * @en The input assembler info. * @zh 输入汇集器信息。 */ - get iaInfo (): InputAssemblerInfo { return this._iaInfo$; } + get iaInfo (): InputAssemblerInfo { return this._iaInfo; } /** * @en Destroys sub mesh. @@ -440,22 +440,22 @@ export class RenderingSubMesh { this.vertexBuffers[i].destroy(); } this.vertexBuffers.length = 0; - if (this._indexBuffer$) { - if (this._isOwnerOfIndexBuffer$) { - this._indexBuffer$.destroy(); + if (this._indexBuffer) { + if (this._isOwnerOfIndexBuffer) { + this._indexBuffer.destroy(); } - this._indexBuffer$ = null; + this._indexBuffer = null; } - if (this._jointMappedBuffers$ && this._jointMappedBufferIndices$) { - for (let i = 0; i < this._jointMappedBufferIndices$.length; i++) { - this._jointMappedBuffers$[this._jointMappedBufferIndices$[i]].destroy(); + if (this._jointMappedBuffers && this._jointMappedBufferIndices) { + for (let i = 0; i < this._jointMappedBufferIndices.length; i++) { + this._jointMappedBuffers[this._jointMappedBufferIndices[i]].destroy(); } - this._jointMappedBuffers$ = undefined; - this._jointMappedBufferIndices$ = undefined; + this._jointMappedBuffers = undefined; + this._jointMappedBufferIndices = undefined; } - if (this._indirectBuffer$) { - this._indirectBuffer$.destroy(); - this._indirectBuffer$ = null; + if (this._indirectBuffer) { + this._indirectBuffer.destroy(); + this._indirectBuffer = null; } } @@ -469,7 +469,7 @@ export class RenderingSubMesh { * @param device @en Device used to create related rendering resources @zh 用于创建相关渲染资源的设备对象 */ public enableVertexIdChannel (device: Device): void { - if (this._vertexIdChannel$) { + if (this._vertexIdChannel) { return; } @@ -477,13 +477,13 @@ export class RenderingSubMesh { const attributeIndex = this.attributes.length; const vertexIdBuffer = this._allocVertexIdBuffer(device); - this._vertexBuffers$.push(vertexIdBuffer); - this._attributes$.push(new Attribute('a_vertexId', Format.R32F, false, streamIndex)); + this._vertexBuffers.push(vertexIdBuffer); + this._attributes.push(new Attribute('a_vertexId', Format.R32F, false, streamIndex)); - this._iaInfo$.attributes = this._attributes$; - this._iaInfo$.vertexBuffers = this._vertexBuffers$; + this._iaInfo.attributes = this._attributes; + this._iaInfo.vertexBuffers = this._vertexBuffers; - this._vertexIdChannel$ = { + this._vertexIdChannel = { stream: streamIndex, index: attributeIndex, }; diff --git a/cocos/asset/assets/simple-texture.ts b/cocos/asset/assets/simple-texture.ts index 2d099dc9511..434e0731568 100644 --- a/cocos/asset/assets/simple-texture.ts +++ b/cocos/asset/assets/simple-texture.ts @@ -67,10 +67,10 @@ export class SimpleTexture extends TextureBase { * @engineInternal */ protected _gfxTextureView: Texture | null = null; - private _mipmapLevel$ = 1; + private _mipmapLevel = 1; // Cache these data to reduce JSB invoking. - private _textureWidth$ = 0; - private _textureHeight$ = 0; + private _textureWidth = 0; + private _textureHeight = 0; /** * @engineInternal @@ -90,7 +90,7 @@ export class SimpleTexture extends TextureBase { * @zh 贴图中的 Mipmap 层级数量。 */ get mipmapLevel (): number { - return this._mipmapLevel$; + return this._mipmapLevel; } /** @@ -145,7 +145,7 @@ export class SimpleTexture extends TextureBase { * @param arrayIndex @en The array index. @zh 要上传的数组索引。 */ public uploadData (source: HTMLCanvasElement | HTMLImageElement | ArrayBufferView | ImageBitmap, level = 0, arrayIndex = 0): void { - if (!this._gfxTexture || this._mipmapLevel$ <= level) { + if (!this._gfxTexture || this._mipmapLevel <= level) { return; } @@ -155,8 +155,8 @@ export class SimpleTexture extends TextureBase { } const region = _regions[0]; - region.texExtent.width = this._textureWidth$ >> level; - region.texExtent.height = this._textureHeight$ >> level; + region.texExtent.width = this._textureWidth >> level; + region.texExtent.height = this._textureHeight >> level; region.texSubres.mipLevel = level; region.texSubres.baseArrayLayer = arrayIndex; @@ -223,7 +223,7 @@ export class SimpleTexture extends TextureBase { * */ protected _setMipmapLevel (value: number): void { - this._mipmapLevel$ = value < 1 ? 1 : value; + this._mipmapLevel = value < 1 ? 1 : value; } /** @@ -282,7 +282,7 @@ export class SimpleTexture extends TextureBase { protected _tryReset (): void { this._tryDestroyTextureView(); this._tryDestroyTexture(); - if (this._mipmapLevel$ === 0) { + if (this._mipmapLevel === 0) { return; } const device = this._getGFXDevice(); @@ -308,7 +308,7 @@ export class SimpleTexture extends TextureBase { if (this._width === 0 || this._height === 0) { return; } let flags = TextureFlagBit.NONE; if (this._mipFilter !== Filter.NONE && canGenerateMipmap(device, this._width, this._height)) { - this._mipmapLevel$ = getMipLevel(this._width, this._height); + this._mipmapLevel = getMipLevel(this._width, this._height); if (!this.isUsingOfflineMipmaps() && !this.isCompressed) { flags = TextureFlagBit.GEN_MIPMAP; } @@ -316,7 +316,7 @@ export class SimpleTexture extends TextureBase { const textureCreateInfo = this._getGfxTextureCreateInfo({ usage: TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST | TextureUsageBit.COLOR_ATTACHMENT, format: this._getGFXFormat(), - levelCount: this._mipmapLevel$, + levelCount: this._mipmapLevel, flags, }); if (!textureCreateInfo) { @@ -324,8 +324,8 @@ export class SimpleTexture extends TextureBase { } const texture = device.createTexture(textureCreateInfo); - this._textureWidth$ = textureCreateInfo.width; - this._textureHeight$ = textureCreateInfo.height; + this._textureWidth = textureCreateInfo.width; + this._textureHeight = textureCreateInfo.height; this._gfxTexture = texture; } @@ -337,7 +337,7 @@ export class SimpleTexture extends TextureBase { if (!this._gfxTexture) { return null; } - const maxLevel = this._maxLevel < this._mipmapLevel$ ? this._maxLevel : this._mipmapLevel$ - 1; + const maxLevel = this._maxLevel < this._mipmapLevel ? this._maxLevel : this._mipmapLevel - 1; const textureViewCreateInfo = this._getGfxTextureViewCreateInfo({ texture: this._gfxTexture, format: this._getGFXFormat(), diff --git a/cocos/asset/assets/texture-2d.ts b/cocos/asset/assets/texture-2d.ts index a5cc835ede5..6454b04a599 100644 --- a/cocos/asset/assets/texture-2d.ts +++ b/cocos/asset/assets/texture-2d.ts @@ -112,26 +112,26 @@ export class Texture2D extends SimpleTexture { } } - this._setMipmapParams$(mipmaps); + this._setMipmapParams(mipmaps); } /** * TODO: See: cocos/cocos-engine#15305 */ - private _setMipmapParams$ (value: ImageAsset[]): void { - this._generatedMipmaps$ = value; - this._setMipmapLevel(this._generatedMipmaps$.length); - if (this._generatedMipmaps$.length > 0) { - const imageAsset: ImageAsset = this._generatedMipmaps$[0]; + private _setMipmapParams (value: ImageAsset[]): void { + this._generatedMipmaps = value; + this._setMipmapLevel(this._generatedMipmaps.length); + if (this._generatedMipmaps.length > 0) { + const imageAsset: ImageAsset = this._generatedMipmaps[0]; this.reset({ width: imageAsset.width, height: imageAsset.height, format: imageAsset.format, - mipmapLevel: this._generatedMipmaps$.length, + mipmapLevel: this._generatedMipmaps.length, baseLevel: this._baseLevel, maxLevel: this._maxLevel, }); - this._generatedMipmaps$.forEach((mipmap, level) => { + this._generatedMipmaps.forEach((mipmap, level) => { this._assignImage(mipmap, level); }); // @@ -139,7 +139,7 @@ export class Texture2D extends SimpleTexture { this.reset({ width: 0, height: 0, - mipmapLevel: this._generatedMipmaps$.length, + mipmapLevel: this._generatedMipmaps.length, baseLevel: this._baseLevel, maxLevel: this._maxLevel, }); @@ -168,7 +168,7 @@ export class Texture2D extends SimpleTexture { @type([ImageAsset]) public _mipmaps: ImageAsset[] = []; - private _generatedMipmaps$: ImageAsset[] = []; + private _generatedMipmaps: ImageAsset[] = []; /** * @engineInternal @@ -229,18 +229,18 @@ export class Texture2D extends SimpleTexture { } public updateMipmaps (firstLevel = 0, count: number | undefined = undefined): void { - if (firstLevel >= this._generatedMipmaps$.length) { + if (firstLevel >= this._generatedMipmaps.length) { return; } const nUpdate = Math.min( - count === undefined ? this._generatedMipmaps$.length : count, - this._generatedMipmaps$.length - firstLevel, + count === undefined ? this._generatedMipmaps.length : count, + this._generatedMipmaps.length - firstLevel, ); for (let i = 0; i < nUpdate; ++i) { const level = firstLevel + i; - this._assignImage(this._generatedMipmaps$[level], level); + this._assignImage(this._generatedMipmaps[level], level); } } @@ -260,7 +260,7 @@ export class Texture2D extends SimpleTexture { */ public destroy (): boolean { this._mipmaps = []; - this._generatedMipmaps$ = []; + this._generatedMipmaps = []; return super.destroy(); } diff --git a/cocos/asset/assets/texture-base.ts b/cocos/asset/assets/texture-base.ts index d7e6bb8b943..be7004007cf 100644 --- a/cocos/asset/assets/texture-base.ts +++ b/cocos/asset/assets/texture-base.ts @@ -141,19 +141,19 @@ export class TextureBase extends Asset { protected _height = 1; private declare _id: string; - private _samplerInfo$ = new SamplerInfo(); - private _gfxSampler$: Sampler | null = null; - private _gfxDevice$: Device | null = null; + private _samplerInfo = new SamplerInfo(); + private _gfxSampler: Sampler | null = null; + private _gfxDevice: Device | null = null; - private _textureHash$ = 0; + private _textureHash = 0; constructor () { super(); // Id for generate hash in material this._id = idGenerator.getNewId(); - this._gfxDevice$ = this._getGFXDevice(); - this._textureHash$ = murmurhash2_32_gc(this._id, 666); + this._gfxDevice = this._getGFXDevice(); + this._textureHash = murmurhash2_32_gc(this._id, 666); } /** @@ -196,14 +196,14 @@ export class TextureBase extends Asset { if (wrapR === undefined) wrapR = wrapS; // wrap modes should be as consistent as possible for performance this._wrapS = wrapS; - this._samplerInfo$.addressU = wrapS as unknown as Address; + this._samplerInfo.addressU = wrapS as unknown as Address; this._wrapT = wrapT; - this._samplerInfo$.addressV = wrapT as unknown as Address; + this._samplerInfo.addressV = wrapT as unknown as Address; this._wrapR = wrapR; - this._samplerInfo$.addressW = wrapR as unknown as Address; + this._samplerInfo.addressW = wrapR as unknown as Address; - if (this._gfxDevice$) { - this._gfxSampler$ = this._gfxDevice$.getSampler(this._samplerInfo$); + if (this._gfxDevice) { + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -215,12 +215,12 @@ export class TextureBase extends Asset { */ public setFilters (minFilter: Filter, magFilter: Filter): void { this._minFilter = minFilter; - this._samplerInfo$.minFilter = minFilter as unknown as GFXFilter; + this._samplerInfo.minFilter = minFilter as unknown as GFXFilter; this._magFilter = magFilter; - this._samplerInfo$.magFilter = magFilter as unknown as GFXFilter; + this._samplerInfo.magFilter = magFilter as unknown as GFXFilter; - if (this._gfxDevice$) { - this._gfxSampler$ = this._gfxDevice$.getSampler(this._samplerInfo$); + if (this._gfxDevice) { + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -231,10 +231,10 @@ export class TextureBase extends Asset { */ public setMipFilter (mipFilter: Filter): void { this._mipFilter = mipFilter; - this._samplerInfo$.mipFilter = mipFilter as unknown as GFXFilter; + this._samplerInfo.mipFilter = mipFilter as unknown as GFXFilter; - if (this._gfxDevice$) { - this._gfxSampler$ = this._gfxDevice$.getSampler(this._samplerInfo$); + if (this._gfxDevice) { + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -246,10 +246,10 @@ export class TextureBase extends Asset { public setAnisotropy (anisotropy: number): void { anisotropy = Math.min(anisotropy, 16); this._anisotropy = anisotropy; - this._samplerInfo$.maxAnisotropy = anisotropy; + this._samplerInfo.maxAnisotropy = anisotropy; - if (this._gfxDevice$) { - this._gfxSampler$ = this._gfxDevice$.getSampler(this._samplerInfo$); + if (this._gfxDevice) { + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -260,7 +260,7 @@ export class TextureBase extends Asset { public destroy (): boolean { const destroyed = super.destroy(); if (destroyed && cclegacy.director.root?.batcher2D) { - (cclegacy.director.root.batcher2D as Batcher2D)._releaseDescriptorSetCache(this._textureHash$); + (cclegacy.director.root.batcher2D as Batcher2D)._releaseDescriptorSetCache(this._textureHash); } return destroyed; } @@ -270,7 +270,7 @@ export class TextureBase extends Asset { * @zh 获取此贴图的哈希值。 */ public getHash (): number { - return this._textureHash$; + return this._textureHash; } /** @@ -287,7 +287,7 @@ export class TextureBase extends Asset { * @private */ public getSamplerInfo (): Readonly { - return this._samplerInfo$; + return this._samplerInfo; } /** @@ -295,14 +295,14 @@ export class TextureBase extends Asset { * @zh 获取此贴图底层的 GFX 采样信息。 */ public getGFXSampler (): Sampler { - if (!this._gfxSampler$) { - if (this._gfxDevice$) { - this._gfxSampler$ = this._gfxDevice$.getSampler(this._samplerInfo$); + if (!this._gfxSampler) { + if (this._gfxDevice) { + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } else { errorID(9302); } } - return this._gfxSampler$!; + return this._gfxSampler!; } // SERIALIZATION diff --git a/cocos/asset/assets/texture-cube.ts b/cocos/asset/assets/texture-cube.ts index 734446cfd36..c7db6870a7f 100644 --- a/cocos/asset/assets/texture-cube.ts +++ b/cocos/asset/assets/texture-cube.ts @@ -161,7 +161,7 @@ export class TextureCube extends SimpleTexture { || front.length !== top.length || front.length !== bottom.length) { errorID(16347); - this._setMipmapParams$([]); + this._setMipmapParams([]); return; } @@ -191,23 +191,23 @@ export class TextureCube extends SimpleTexture { }); } - this._setMipmapParams$(cubeMaps); + this._setMipmapParams(cubeMaps); } - private _setMipmapParams$ (value: ITextureCubeMipmap[]): void { - this._generatedMipmaps$ = value; - this._setMipmapLevel(this._generatedMipmaps$.length); - if (this._generatedMipmaps$.length > 0) { - const imageAsset: ImageAsset = this._generatedMipmaps$[0].front; + private _setMipmapParams (value: ITextureCubeMipmap[]): void { + this._generatedMipmaps = value; + this._setMipmapLevel(this._generatedMipmaps.length); + if (this._generatedMipmaps.length > 0) { + const imageAsset: ImageAsset = this._generatedMipmaps[0].front; this.reset({ width: imageAsset.width, height: imageAsset.height, format: imageAsset.format, - mipmapLevel: this._generatedMipmaps$.length, + mipmapLevel: this._generatedMipmaps.length, baseLevel: this._baseLevel, maxLevel: this._maxLevel, }); - this._generatedMipmaps$.forEach((mipmap, level): void => { + this._generatedMipmaps.forEach((mipmap, level): void => { _forEachFace(mipmap, (face, faceIndex): void => { this._assignImage(face, level, faceIndex); }); @@ -216,7 +216,7 @@ export class TextureCube extends SimpleTexture { this.reset({ width: 0, height: 0, - mipmapLevel: this._generatedMipmaps$.length, + mipmapLevel: this._generatedMipmaps.length, baseLevel: this._baseLevel, maxLevel: this._maxLevel, }); @@ -359,7 +359,7 @@ export class TextureCube extends SimpleTexture { @serializable public _mipmaps: ITextureCubeMipmap[] = []; - private _generatedMipmaps$: ITextureCubeMipmap[] = []; + private _generatedMipmaps: ITextureCubeMipmap[] = []; public onLoaded (): void { if (this._mipmapMode === MipmapMode.BAKED_CONVOLUTION_MAP) { @@ -396,18 +396,18 @@ export class TextureCube extends SimpleTexture { * @param count @en Mipmap level count to be updated。 @zh 指定要更新层的数量。 */ public updateMipmaps (firstLevel = 0, count: number | undefined = undefined): void { - if (firstLevel >= this._generatedMipmaps$.length) { + if (firstLevel >= this._generatedMipmaps.length) { return; } const nUpdate = Math.min( - count === undefined ? this._generatedMipmaps$.length : count, - this._generatedMipmaps$.length - firstLevel, + count === undefined ? this._generatedMipmaps.length : count, + this._generatedMipmaps.length - firstLevel, ); for (let i = 0; i < nUpdate; ++i) { const level = firstLevel + i; - _forEachFace(this._generatedMipmaps$[level], (face, faceIndex): void => { + _forEachFace(this._generatedMipmaps[level], (face, faceIndex): void => { this._assignImage(face, level, faceIndex); }); } @@ -419,7 +419,7 @@ export class TextureCube extends SimpleTexture { */ public destroy (): boolean { this._mipmaps = []; - this._generatedMipmaps$ = []; + this._generatedMipmaps = []; this._mipmapAtlas = null; return super.destroy(); } diff --git a/cocos/core/data/garbage-collection.ts b/cocos/core/data/garbage-collection.ts index 0b0e7c798a5..5447cb48e2e 100644 --- a/cocos/core/data/garbage-collection.ts +++ b/cocos/core/data/garbage-collection.ts @@ -31,11 +31,11 @@ declare class FinalizationRegistry { const targetSymbol = Symbol('[[target]]'); class GarbageCollectionManager { - private _finalizationRegistry$: FinalizationRegistry | null = EDITOR && typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry(this.finalizationRegistryCallback$.bind(this)) : null; - private _gcObjects$: WeakMap = new WeakMap(); + private _finalizationRegistry: FinalizationRegistry | null = EDITOR && typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry(this.finalizationRegistryCallback.bind(this)) : null; + private _gcObjects: WeakMap = new WeakMap(); public registerGCObject (gcObject: GCObject): GCObject { - if (EDITOR && this._finalizationRegistry$) { + if (EDITOR && this._finalizationRegistry) { const token = {}; const proxy = new Proxy(gcObject, { get (target, property, receiver): unknown { @@ -57,8 +57,8 @@ class GarbageCollectionManager { return true; }, }); - this._gcObjects$.set(token, gcObject); - this._finalizationRegistry$.register(proxy, token, token); + this._gcObjects.set(token, gcObject); + this._finalizationRegistry.register(proxy, token, token); return proxy; } else { return gcObject; @@ -68,13 +68,13 @@ class GarbageCollectionManager { public init (): void { } - private finalizationRegistryCallback$ (token: any): void { - const gcObject = this._gcObjects$.get(token); + private finalizationRegistryCallback (token: any): void { + const gcObject = this._gcObjects.get(token); if (gcObject) { - this._gcObjects$.delete(token); + this._gcObjects.delete(token); gcObject.destroy(); } - this._finalizationRegistry$!.unregister(token); + this._finalizationRegistry!.unregister(token); } public destroy (): void { diff --git a/cocos/core/event/async-delegate.ts b/cocos/core/event/async-delegate.ts index dd0445b960b..f1d31bd1567 100644 --- a/cocos/core/event/async-delegate.ts +++ b/cocos/core/event/async-delegate.ts @@ -47,7 +47,7 @@ import { array } from '../utils/js'; * ``` */ export class AsyncDelegate (Promise | void) = () => (Promise | void)> { - private _delegates$: T[] = []; + private _delegates: T[] = []; /** * @en @@ -61,8 +61,8 @@ export class AsyncDelegate (Promise | void) = * @zh 要添加的回调,并将在该委托调度时被调用。 */ public add (callback: T): void { - if (!this._delegates$.includes(callback)) { - this._delegates$.push(callback); + if (!this._delegates.includes(callback)) { + this._delegates.push(callback); } } @@ -76,7 +76,7 @@ export class AsyncDelegate (Promise | void) = * @returns @en Whether the callback has been added. @zh 是否已经添加了回调。 */ public hasListener (callback: T): boolean { - return this._delegates$.includes(callback); + return this._delegates.includes(callback); } /** @@ -89,7 +89,7 @@ export class AsyncDelegate (Promise | void) = * @param callback @en The callback to remove. @zh 要移除的某个回调。 */ public remove (callback: T): void { - array.fastRemove(this._delegates$, callback); + array.fastRemove(this._delegates, callback); } /** @@ -103,6 +103,6 @@ export class AsyncDelegate (Promise | void) = * @returns @en The promise awaiting all async callback resolved. @zh 等待所有异步回调结束的 Promise 对象。 */ public dispatch (...args: Parameters): Promise { - return Promise.all(this._delegates$.map((func) => func(...arguments)).filter(Boolean)); + return Promise.all(this._delegates.map((func) => func(...arguments)).filter(Boolean)); } } diff --git a/cocos/core/event/callbacks-invoker.ts b/cocos/core/event/callbacks-invoker.ts index 7a46e931b14..a5f137f734c 100644 --- a/cocos/core/event/callbacks-invoker.ts +++ b/cocos/core/event/callbacks-invoker.ts @@ -184,7 +184,7 @@ export class CallbacksInvoker { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _callbackTable: ICallbackTable = createMap(true); - private _offCallback$?: () => void; + private _offCallback?: () => void; /** * @zh 向一个事件名注册一个新的事件监听器,包含回调函数和调用者 @@ -307,7 +307,7 @@ export class CallbacksInvoker { this.removeAll(key); } } - this._offCallback$?.(); + this._offCallback?.(); } /** @@ -375,7 +375,7 @@ export class CallbacksInvoker { * @engineInternal */ public _registerOffCallback (cb: () => void): void { - this._offCallback$ = cb; + this._offCallback = cb; } } diff --git a/cocos/core/geometry/curve.ts b/cocos/core/geometry/curve.ts index 519e9036dda..9580e510722 100644 --- a/cocos/core/geometry/curve.ts +++ b/cocos/core/geometry/curve.ts @@ -271,7 +271,7 @@ export class AnimationCurve { if (wrappedTime >= cachedKey.time && wrappedTime < cachedKey.endTime) { return cachedKey.evaluate(wrappedTime); } - const leftIndex = this.findIndex$(cachedKey, wrappedTime); + const leftIndex = this.findIndex(cachedKey, wrappedTime); const rightIndex = Math.min(leftIndex + 1, lastKeyframeIndex); this.calcOptimizedKey(cachedKey, leftIndex, rightIndex); return cachedKey.evaluate(wrappedTime); @@ -309,7 +309,7 @@ export class AnimationCurve { * @param optKey * @param t */ - private findIndex$ (optKey: OptimizedKey, t: number): number { + private findIndex (optKey: OptimizedKey, t: number): number { const { _curve: curve } = this; const nKeyframes = curve.keyFramesCount; const cachedIndex = optKey.index; diff --git a/cocos/core/geometry/spline.ts b/cocos/core/geometry/spline.ts index c8d1815259b..e4b928fc5fa 100644 --- a/cocos/core/geometry/spline.ts +++ b/cocos/core/geometry/spline.ts @@ -90,28 +90,16 @@ const _v3 = new Vec3(); */ export class Spline { - private readonly _type$: number; - private declare _mode$: SplineMode; - private _knots$: Vec3[] = []; - - // The private properties '_mode' and '_knots' are used in 'jsb_conversions_spec.cpp' for native platforms. - // bool sevalue_to_native(const se::Value &from, cc::geometry::Spline *to, se::Object * /*unused*/) - // So declare them here and add references in constructor. + private readonly _type: number; private declare _mode: SplineMode; - private declare _knots: Vec3[]; - // + private _knots: Vec3[] = []; private constructor (mode: SplineMode = SplineMode.CATMULL_ROM, knots: Readonly = []) { - this._type$ = ShapeType.SHAPE_SPLINE; - this._mode$ = mode; + this._type = ShapeType.SHAPE_SPLINE; + this._mode = mode; for (let i = 0; i < knots.length; i++) { - this._knots$[i] = new Vec3(knots[i]); - } - - if (JSB) { - this._mode = this._mode$; - this._knots = this._knots$; + this._knots[i] = new Vec3(knots[i]); } } @@ -150,13 +138,13 @@ export class Spline { * @returns @en The target Spline instance to copy to, same as the `out` parameter. @zh 拷贝目标 Spline 实例,值与 `out` 参数相同。 */ public static copy (out: Spline, s: Spline): Spline { - out._mode$ = s.mode; - out._knots$.length = 0; + out._mode = s.mode; + out._knots.length = 0; const knots = s.knots; const length = knots.length; for (let i = 0; i < length; i++) { - out._knots$[i] = new Vec3(knots[i]); + out._knots[i] = new Vec3(knots[i]); } return out; @@ -169,7 +157,7 @@ export class Spline { * 获取此 Spline 的类型,固定返回 `ShapeType.SHAPE_SPLINE` */ get type (): number { - return this._type$; + return this._type; } /** @@ -179,7 +167,7 @@ export class Spline { * 获取当前 Spline 实例的模式。 */ get mode (): SplineMode { - return this._mode$; + return this._mode; } /** @@ -189,7 +177,7 @@ export class Spline { * 获取当前 Spline 实例的所有结点。 */ get knots (): Readonly { - return this._knots$; + return this._knots; } /** @@ -201,11 +189,11 @@ export class Spline { * @param knots @en The knots to be set to this spline instance. @zh 要设置到当前 Spline 实例的结点列表。 */ public setModeAndKnots (mode: SplineMode, knots: Vec3[]): void { - this._mode$ = mode; - this._knots$.length = 0; + this._mode = mode; + this._knots.length = 0; for (let i = 0; i < knots.length; i++) { - this._knots$[i] = new Vec3(knots[i]); + this._knots[i] = new Vec3(knots[i]); } } @@ -216,7 +204,7 @@ export class Spline { * 清空当前 Spline 实例的所有结点。 */ public clearKnots (): void { - this._knots$.length = 0; + this._knots.length = 0; } /** @@ -227,7 +215,7 @@ export class Spline { * @returns @en The knot count of this Spline instance. @zh 当前 Spline 实例的结点数量。 */ public getKnotCount (): number { - return this._knots$.length; + return this._knots.length; } /** @@ -238,7 +226,7 @@ export class Spline { * @param knot @en The knot to add to this Spline instance. @zh 要添加到当前 Spline 实例的结点。 */ public addKnot (knot: Vec3): void { - this._knots$.push(new Vec3(knot)); + this._knots.push(new Vec3(knot)); } /** @@ -251,12 +239,12 @@ export class Spline { */ public insertKnot (index: number, knot: Vec3): void { const item = new Vec3(knot); - if (index >= this._knots$.length) { - this._knots$.push(item); + if (index >= this._knots.length) { + this._knots.push(item); return; } - this._knots$.splice(index, 0, item); + this._knots.splice(index, 0, item); } /** @@ -267,9 +255,9 @@ export class Spline { * @param index */ public removeKnot (index: number): void { - assertsArrayIndex(this._knots$, index); + assertsArrayIndex(this._knots, index); - this._knots$.splice(index, 1); + this._knots.splice(index, 1); } /** @@ -281,9 +269,9 @@ export class Spline { * @param knot @en The knot to be set to the specified position. @zh 要设置的结点。 */ public setKnot (index: number, knot: Vec3): void { - assertsArrayIndex(this._knots$, index); + assertsArrayIndex(this._knots, index); - this._knots$[index].set(knot); + this._knots[index].set(knot); } /** @@ -295,9 +283,9 @@ export class Spline { * @returns @en The knot of the specified position of this Spline instance. @zh 当前 Spline 实例指定位置的结点。 */ public getKnot (index: number): Readonly { - assertsArrayIndex(this._knots$, index); + assertsArrayIndex(this._knots, index); - return this._knots$[index]; + return this._knots[index]; } /** @@ -324,23 +312,23 @@ export class Spline { t = (t % deltaT) / deltaT; } - const knots = this._knots$; + const knots = this._knots; if (index >= segments) { return new Vec3(knots[knots.length - 1]); } - switch (this._mode$) { + switch (this._mode) { case SplineMode.LINEAR: - return Spline.calcLinear$(knots[index], knots[index + 1], t); + return Spline.calcLinear(knots[index], knots[index + 1], t); case SplineMode.BEZIER: { const start = index * 4; - return Spline.calcBezier$(knots[start], knots[start + 1], knots[start + 2], knots[start + 3], t); + return Spline.calcBezier(knots[start], knots[start + 1], knots[start + 2], knots[start + 3], t); } case SplineMode.CATMULL_ROM: { const v0 = index > 0 ? knots[index - 1] : knots[index]; const v3 = index + 2 < knots.length ? knots[index + 2] : knots[index + 1]; - return Spline.calcCatmullRom$(v0, knots[index], knots[index + 1], v3, t); + return Spline.calcCatmullRom(v0, knots[index], knots[index + 1], v3, t); } default: return new Vec3(); @@ -381,8 +369,8 @@ export class Spline { // eslint-disable-next-line consistent-return private getSegments (): number { - const count = this._knots$.length; - switch (this._mode$) { + const count = this._knots.length; + switch (this._mode) { case SplineMode.LINEAR: case SplineMode.CATMULL_ROM: if (count < 2) { @@ -404,7 +392,7 @@ export class Spline { } } - private static calcLinear$ (v0: Vec3, v1: Vec3, t: number): Vec3 { + private static calcLinear (v0: Vec3, v1: Vec3, t: number): Vec3 { const result = new Vec3(); Vec3.multiplyScalar(_v0, v0, (1.0 - t)); Vec3.multiplyScalar(_v1, v1, t); @@ -413,7 +401,7 @@ export class Spline { return result; } - private static calcBezier$ (v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3, t: number): Vec3 { + private static calcBezier (v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3, t: number): Vec3 { const result = new Vec3(); const s = 1.0 - t; Vec3.multiplyScalar(_v0, v0, s * s * s); @@ -426,7 +414,7 @@ export class Spline { return result; } - private static calcCatmullRom$ (v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3, t: number): Vec3 { + private static calcCatmullRom (v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3, t: number): Vec3 { const result = new Vec3(); const t2 = t * t; const t3 = t2 * t; diff --git a/cocos/core/memop/cached-array.ts b/cocos/core/memop/cached-array.ts index f66b3bc5a87..80457ba76f6 100644 --- a/cocos/core/memop/cached-array.ts +++ b/cocos/core/memop/cached-array.ts @@ -49,8 +49,8 @@ export class CachedArray extends ScalableContainer { */ public length = 0; - private declare _compareFn$?: (a: T, b: T) => number; - private _initSize$ = 0; + private declare _compareFn?: (a: T, b: T) => number; + private _initSize = 0; /** * @en Constructor. @zh 构造函数。 @@ -64,8 +64,8 @@ export class CachedArray extends ScalableContainer { constructor (length: number, compareFn?: (a: T, b: T) => number) { super(); this.array = new Array(length); - this._initSize$ = length; - this._compareFn$ = compareFn; + this._initSize = length; + this._compareFn = compareFn; } /** @@ -132,7 +132,7 @@ export class CachedArray extends ScalableContainer { */ public tryShrink (): void { if (this.array.length >> 2 > this.length) { - this.array.length = Math.max(this._initSize$, this.array.length >> 1); + this.array.length = Math.max(this._initSize, this.array.length >> 1); } } @@ -145,7 +145,7 @@ export class CachedArray extends ScalableContainer { */ public sort (): void { this.array.length = this.length; - this.array.sort(this._compareFn$); + this.array.sort(this._compareFn); } /** diff --git a/cocos/core/memop/pool.ts b/cocos/core/memop/pool.ts index eb29e7ae410..ee9c538e908 100644 --- a/cocos/core/memop/pool.ts +++ b/cocos/core/memop/pool.ts @@ -33,12 +33,12 @@ import { ScalableContainer } from './scalable-container'; * @see [[RecyclePool]] */ export class Pool extends ScalableContainer { - private declare _ctor$: () => T; - private declare _elementsPerBatch$: number; - private declare _shrinkThreshold$: number; - private declare _nextAvail$: number; - private _freePool$: T[] = []; - private declare _dtor$: ((obj: T) => void) | null; + private declare _ctor: () => T; + private declare _elementsPerBatch: number; + private declare _shrinkThreshold: number; + private declare _nextAvail: number; + private _freePool: T[] = []; + private declare _dtor: ((obj: T) => void) | null; /** * @en Constructor with the allocator of elements and initial pool size. @@ -58,14 +58,14 @@ export class Pool extends ScalableContainer { */ constructor (ctor: () => T, elementsPerBatch: number, dtor?: (obj: T) => void, shrinkThreshold?: number) { super(); - this._ctor$ = ctor; - this._dtor$ = dtor || null; - this._elementsPerBatch$ = Math.max(elementsPerBatch, 1); - this._shrinkThreshold$ = shrinkThreshold ? max(shrinkThreshold, 1) : this._elementsPerBatch$; - this._nextAvail$ = this._elementsPerBatch$ - 1; - - for (let i = 0; i < this._elementsPerBatch$; ++i) { - this._freePool$.push(ctor()); + this._ctor = ctor; + this._dtor = dtor || null; + this._elementsPerBatch = Math.max(elementsPerBatch, 1); + this._shrinkThreshold = shrinkThreshold ? max(shrinkThreshold, 1) : this._elementsPerBatch; + this._nextAvail = this._elementsPerBatch - 1; + + for (let i = 0; i < this._elementsPerBatch; ++i) { + this._freePool.push(ctor()); } } @@ -76,15 +76,15 @@ export class Pool extends ScalableContainer { * @zh 该函数总是返回一个可用的对象。 */ public alloc (): T { - if (this._nextAvail$ < 0) { - this._freePool$.length = this._elementsPerBatch$; - for (let i = 0; i < this._elementsPerBatch$; i++) { - this._freePool$[i] = this._ctor$(); + if (this._nextAvail < 0) { + this._freePool.length = this._elementsPerBatch; + for (let i = 0; i < this._elementsPerBatch; i++) { + this._freePool[i] = this._ctor(); } - this._nextAvail$ = this._elementsPerBatch$ - 1; + this._nextAvail = this._elementsPerBatch - 1; } - return this._freePool$[this._nextAvail$--]; + return this._freePool[this._nextAvail--]; } /** @@ -94,7 +94,7 @@ export class Pool extends ScalableContainer { * @zh 放回对象池中的对象。 */ public free (obj: T): void { - this._freePool$[++this._nextAvail$] = obj; + this._freePool[++this._nextAvail] = obj; } /** @@ -104,9 +104,9 @@ export class Pool extends ScalableContainer { * @zh 放回对象池中的一组对象。 */ public freeArray (objs: T[]): void { - this._freePool$.length = this._nextAvail$ + 1; - Array.prototype.push.apply(this._freePool$, objs); - this._nextAvail$ += objs.length; + this._freePool.length = this._nextAvail + 1; + Array.prototype.push.apply(this._freePool, objs); + this._nextAvail += objs.length; } /** @@ -114,25 +114,25 @@ export class Pool extends ScalableContainer { * @zh 尝试缩容对象池,以释放内存。 */ public tryShrink (): void { - const freeObjectNumber = this._nextAvail$ + 1; - if (freeObjectNumber <= this._shrinkThreshold$) { + const freeObjectNumber = this._nextAvail + 1; + if (freeObjectNumber <= this._shrinkThreshold) { return; } let objectNumberToShrink = 0; - if (freeObjectNumber >> 1 >= this._shrinkThreshold$) { + if (freeObjectNumber >> 1 >= this._shrinkThreshold) { objectNumberToShrink = freeObjectNumber >> 1; } else { - objectNumberToShrink = Math.floor((freeObjectNumber - this._shrinkThreshold$ + 1) / 2); + objectNumberToShrink = Math.floor((freeObjectNumber - this._shrinkThreshold + 1) / 2); } - if (this._dtor$) { - for (let i = this._nextAvail$ - objectNumberToShrink + 1; i <= this._nextAvail$; ++i) { - this._dtor$(this._freePool$[i]); + if (this._dtor) { + for (let i = this._nextAvail - objectNumberToShrink + 1; i <= this._nextAvail; ++i) { + this._dtor(this._freePool[i]); } } - this._nextAvail$ -= objectNumberToShrink; - this._freePool$.length = this._nextAvail$ + 1; + this._nextAvail -= objectNumberToShrink; + this._freePool.length = this._nextAvail + 1; } /** @@ -142,14 +142,14 @@ export class Pool extends ScalableContainer { public destroy (): void { const dtor = arguments.length > 0 ? arguments[0] : null; if (dtor) { warnID(14100); } - const readDtor = dtor || this._dtor$; + const readDtor = dtor || this._dtor; if (readDtor) { - for (let i = 0; i <= this._nextAvail$; i++) { - readDtor(this._freePool$[i]); + for (let i = 0; i <= this._nextAvail; i++) { + readDtor(this._freePool[i]); } } - this._freePool$.length = 0; - this._nextAvail$ = -1; + this._freePool.length = 0; + this._nextAvail = -1; super.destroy(); } } diff --git a/cocos/core/memop/recycle-pool.ts b/cocos/core/memop/recycle-pool.ts index 0ff73643ce6..6b8cb1d243e 100644 --- a/cocos/core/memop/recycle-pool.ts +++ b/cocos/core/memop/recycle-pool.ts @@ -38,9 +38,9 @@ import { ScalableContainer } from './scalable-container'; export class RecyclePool extends ScalableContainer { private declare _fn: () => T; private declare _dtor: ((obj: T) => void) | null; - private _count$ = 0; - private declare _data$: T[]; - private declare _initSize$: number; + private _count = 0; + private declare _data: T[]; + private declare _initSize: number; /** * @en Constructor with the allocator of elements and initial pool size, all elements will be pre-allocated. @@ -53,11 +53,11 @@ export class RecyclePool extends ScalableContainer { super(); this._fn = fn; this._dtor = dtor || null; - this._data$ = new Array(size); - this._initSize$ = size; + this._data = new Array(size); + this._initSize = size; for (let i = 0; i < size; ++i) { - this._data$[i] = fn(); + this._data[i] = fn(); } } @@ -66,7 +66,7 @@ export class RecyclePool extends ScalableContainer { * @zh 对象池大小。 */ get length (): number { - return this._count$; + return this._count; } /** @@ -74,7 +74,7 @@ export class RecyclePool extends ScalableContainer { * @zh 实际对象池数组。 */ get data (): T[] { - return this._data$; + return this._data; } /** @@ -82,7 +82,7 @@ export class RecyclePool extends ScalableContainer { * @zh 清空对象池。目前仅仅会设置尺寸为 0。 */ public reset (): void { - this._count$ = 0; + this._count = 0; } /** @@ -91,9 +91,9 @@ export class RecyclePool extends ScalableContainer { * @param size @en The new size of the pool. @zh 新的对象池大小。 */ public resize (size: number): void { - if (size > this._data$.length) { - for (let i = this._data$.length; i < size; ++i) { - this._data$[i] = this._fn(); + if (size > this._data.length) { + for (let i = this._data.length; i < size; ++i) { + this._data[i] = this._fn(); } } } @@ -103,11 +103,11 @@ export class RecyclePool extends ScalableContainer { * @zh 添加一个新元素,如果容量不足,会自动扩充尺寸到原来的 2 倍。 */ public add (): T { - if (this._count$ >= this._data$.length) { - this.resize(this._data$.length << 1); + if (this._count >= this._data.length) { + this.resize(this._data.length << 1); } - return this._data$[this._count$++]; + return this._data[this._count++]; } /** @@ -116,12 +116,12 @@ export class RecyclePool extends ScalableContainer { */ public destroy (): void { if (this._dtor) { - for (let i = 0; i < this._data$.length; i++) { - this._dtor(this._data$[i]); + for (let i = 0; i < this._data.length; i++) { + this._dtor(this._data[i]); } } - this._data$.length = 0; - this._count$ = 0; + this._data.length = 0; + this._count = 0; super.destroy(); } @@ -130,14 +130,14 @@ export class RecyclePool extends ScalableContainer { * @zh 尝试回收没用的对象,释放内存。 */ public tryShrink (): void { - if (this._data$.length >> 2 > this._count$) { - const length = Math.max(this._initSize$, this._data$.length >> 1); + if (this._data.length >> 2 > this._count) { + const length = Math.max(this._initSize, this._data.length >> 1); if (this._dtor) { - for (let i = length; i < this._data$.length; i++) { - this._dtor(this._data$[i]); + for (let i = length; i < this._data.length; i++) { + this._dtor(this._data[i]); } } - this._data$.length = length; + this._data.length = length; } } @@ -147,14 +147,14 @@ export class RecyclePool extends ScalableContainer { * @param idx @en The index of the element to remove. @zh 被移除的元素的索引。 */ public removeAt (idx: number): void { - if (idx >= this._count$) { + if (idx >= this._count) { return; } - const last = this._count$ - 1; - const tmp = this._data$[idx]; - this._data$[idx] = this._data$[last]; - this._data$[last] = tmp; - this._count$ -= 1; + const last = this._count - 1; + const tmp = this._data[idx]; + this._data[idx] = this._data[last]; + this._data[last] = tmp; + this._count -= 1; } } diff --git a/cocos/core/memop/scalable-container.ts b/cocos/core/memop/scalable-container.ts index 52be6d1d3ee..63a8ef89055 100644 --- a/cocos/core/memop/scalable-container.ts +++ b/cocos/core/memop/scalable-container.ts @@ -44,8 +44,8 @@ export abstract class ScalableContainer { * It will shrink all managed ScalableContainer in a fixed interval. */ class ScalableContainerManager { - private _pools$: ScalableContainer[] = []; - private _lastShrinkPassed$ = 0; + private _pools: ScalableContainer[] = []; + private _lastShrinkPassed = 0; /** * @en Shrink interval in seconds. */ @@ -57,8 +57,8 @@ class ScalableContainerManager { */ addContainer (pool: ScalableContainer): void { if (pool._poolHandle !== -1) return; - pool._poolHandle = this._pools$.length; - this._pools$.push(pool); + pool._poolHandle = this._pools.length; + this._pools.push(pool); } /** @@ -67,8 +67,8 @@ class ScalableContainerManager { */ removeContainer (pool: ScalableContainer): void { if (pool._poolHandle === -1) return; - this._pools$[this._pools$.length - 1]._poolHandle = pool._poolHandle; - fastRemoveAt(this._pools$, pool._poolHandle); + this._pools[this._pools.length - 1]._poolHandle = pool._poolHandle; + fastRemoveAt(this._pools, pool._poolHandle); pool._poolHandle = -1; } @@ -76,8 +76,8 @@ class ScalableContainerManager { * @en Try to shrink all managed ScalableContainers. */ tryShrink (): void { - for (let i = 0; i < this._pools$.length; i++) { - this._pools$[i].tryShrink(); + for (let i = 0; i < this._pools.length; i++) { + this._pools[i].tryShrink(); } } @@ -86,10 +86,10 @@ class ScalableContainerManager { * @param dt @en Delta time of frame interval in secondes. */ update (dt: number): void { - this._lastShrinkPassed$ += dt; - if (this._lastShrinkPassed$ > this.shrinkTimeSpan) { + this._lastShrinkPassed += dt; + if (this._lastShrinkPassed > this.shrinkTimeSpan) { this.tryShrink(); - this._lastShrinkPassed$ -= this.shrinkTimeSpan; + this._lastShrinkPassed -= this.shrinkTimeSpan; } } } diff --git a/cocos/core/scheduler.ts b/cocos/core/scheduler.ts index 100708198d8..3cf3733075f 100644 --- a/cocos/core/scheduler.ts +++ b/cocos/core/scheduler.ts @@ -47,12 +47,12 @@ export interface ISchedulable { */ class ListEntry { public static get (target: ISchedulable, priority: number, paused: boolean, markedForDeletion: boolean): ListEntry { - let result = ListEntry._listEntries$.pop(); + let result = ListEntry._listEntries.pop(); if (result) { - result.target$ = target; - result.priority$ = priority; - result.paused$ = paused; - result.markedForDeletion$ = markedForDeletion; + result.target = target; + result.priority = priority; + result.paused = paused; + result.markedForDeletion = markedForDeletion; } else { result = new ListEntry(target, priority, paused, markedForDeletion); } @@ -60,18 +60,18 @@ class ListEntry { } public static put (entry: ListEntry): void { - if (ListEntry._listEntries$.length < MAX_POOL_SIZE) { - entry.target$ = null; - ListEntry._listEntries$.push(entry); + if (ListEntry._listEntries.length < MAX_POOL_SIZE) { + entry.target = null; + ListEntry._listEntries.push(entry); } } - private static _listEntries$: ListEntry[] = []; + private static _listEntries: ListEntry[] = []; - public target$: ISchedulable | null; - public priority$: number; - public paused$: boolean; - public markedForDeletion$: boolean; + public target: ISchedulable | null; + public priority: number; + public paused: boolean; + public markedForDeletion: boolean; /** * @en The constructor of ListEntry. @@ -90,10 +90,10 @@ class ListEntry { * @zh 删除标记, 当为true时, selector 将不再被调用,并且entry将在下一个tick结束时被删除。 */ constructor (target: ISchedulable, priority: number, paused: boolean, markedForDeletion: boolean) { - this.target$ = target; - this.priority$ = priority; - this.paused$ = paused; - this.markedForDeletion$ = markedForDeletion; + this.target = target; + this.priority = priority; + this.paused = paused; + this.markedForDeletion = markedForDeletion; } } @@ -110,10 +110,10 @@ class HashUpdateEntry { public static get (list: ListEntry[], entry: ListEntry, target: ISchedulable, callback: AnyFunction | null): HashUpdateEntry { let result = HashUpdateEntry._hashUpdateEntries.pop(); if (result) { - result.list$ = list; - result.entry$ = entry; - result.target$ = target; - result.callback$ = callback; + result.list = list; + result.entry = entry; + result.target = target; + result.callback = callback; } else { result = new HashUpdateEntry(list, entry, target, callback); } @@ -122,23 +122,23 @@ class HashUpdateEntry { public static put (entry: HashUpdateEntry): void { if (HashUpdateEntry._hashUpdateEntries.length < MAX_POOL_SIZE) { - entry.list$ = entry.entry$ = entry.target$ = entry.callback$ = null; + entry.list = entry.entry = entry.target = entry.callback = null; HashUpdateEntry._hashUpdateEntries.push(entry); } } private static _hashUpdateEntries: HashUpdateEntry[] = []; - public list$: ListEntry[] | null; - public entry$: ListEntry | null; - public target$: ISchedulable | null; - public callback$: AnyFunction | null; + public list: ListEntry[] | null; + public entry: ListEntry | null; + public target: ISchedulable | null; + public callback: AnyFunction | null; constructor (list: ListEntry[], entry: ListEntry, target: ISchedulable, callback: AnyFunction | null) { - this.list$ = list; - this.entry$ = entry; - this.target$ = target; - this.callback$ = callback; + this.list = list; + this.entry = entry; + this.target = target; + this.callback = callback; } } @@ -154,14 +154,14 @@ class HashUpdateEntry { */ class HashTimerEntry { public static get (timers: CallbackTimer[] | null, target: ISchedulable, timerIndex: number, currentTimer: CallbackTimer | null, currentTimerSalvaged: boolean, paused: boolean): HashTimerEntry { - let result = HashTimerEntry._hashTimerEntries$.pop(); + let result = HashTimerEntry._hashTimerEntries.pop(); if (result) { - result.timers$ = timers; - result.target$ = target; - result.timerIndex$ = timerIndex; - result.currentTimer$ = currentTimer; - result.currentTimerSalvaged$ = currentTimerSalvaged; - result.paused$ = paused; + result.timers = timers; + result.target = target; + result.timerIndex = timerIndex; + result.currentTimer = currentTimer; + result.currentTimerSalvaged = currentTimerSalvaged; + result.paused = paused; } else { result = new HashTimerEntry(timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused); } @@ -169,28 +169,28 @@ class HashTimerEntry { } public static put (entry: HashTimerEntry): void { - if (HashTimerEntry._hashTimerEntries$.length < MAX_POOL_SIZE) { - entry.timers$ = entry.target$ = entry.currentTimer$ = null; - HashTimerEntry._hashTimerEntries$.push(entry); + if (HashTimerEntry._hashTimerEntries.length < MAX_POOL_SIZE) { + entry.timers = entry.target = entry.currentTimer = null; + HashTimerEntry._hashTimerEntries.push(entry); } } - private static _hashTimerEntries$: HashTimerEntry[] = []; + private static _hashTimerEntries: HashTimerEntry[] = []; - public timers$: CallbackTimer[] | null; - public target$: ISchedulable | null; - public timerIndex$: number; - public currentTimer$: CallbackTimer | null; - public currentTimerSalvaged$: boolean; - public paused$: boolean; + public timers: CallbackTimer[] | null; + public target: ISchedulable | null; + public timerIndex: number; + public currentTimer: CallbackTimer | null; + public currentTimerSalvaged: boolean; + public paused: boolean; constructor (timers: CallbackTimer[] | null, target: ISchedulable, timerIndex: number, currentTimer: CallbackTimer | null, currentTimerSalvaged: boolean, paused: boolean) { - this.timers$ = timers; - this.target$ = target; - this.timerIndex$ = timerIndex; - this.currentTimer$ = currentTimer; - this.currentTimerSalvaged$ = currentTimerSalvaged; - this.paused$ = paused; + this.timers = timers; + this.target = target; + this.timerIndex = timerIndex; + this.currentTimer = currentTimer; + this.currentTimerSalvaged = currentTimerSalvaged; + this.paused = paused; } } @@ -200,54 +200,54 @@ type CallbackType = (dt?: number) => void; * Light weight timer */ class CallbackTimer { - public static _timers$: CallbackTimer[] = []; - public static get (): CallbackTimer { return CallbackTimer._timers$.pop() || new CallbackTimer(); } + public static _timers: CallbackTimer[] = []; + public static get (): CallbackTimer { return CallbackTimer._timers.pop() || new CallbackTimer(); } public static put (timer: CallbackTimer): void { - if (CallbackTimer._timers$.length < MAX_POOL_SIZE && !timer._lock$) { - timer._scheduler$ = timer._target$ = timer._callback$ = null; - CallbackTimer._timers$.push(timer); + if (CallbackTimer._timers.length < MAX_POOL_SIZE && !timer._lock) { + timer._scheduler = timer._target = timer._callback = null; + CallbackTimer._timers.push(timer); } } - private _lock$: boolean; - private _scheduler$: Scheduler | null; - private _elapsed$: number; - private _runForever$: boolean; - private _useDelay$: boolean; - private _timesExecuted$: number; - private _repeat$: number; - private _delay$: number; - private _interval$: number; - private _target$: ISchedulable | null; - private _callback$?: CallbackType | null; + private _lock: boolean; + private _scheduler: Scheduler | null; + private _elapsed: number; + private _runForever: boolean; + private _useDelay: boolean; + private _timesExecuted: number; + private _repeat: number; + private _delay: number; + private _interval: number; + private _target: ISchedulable | null; + private _callback?: CallbackType | null; constructor () { - this._lock$ = false; - this._scheduler$ = null; - this._elapsed$ = -1; - this._runForever$ = false; - this._useDelay$ = false; - this._timesExecuted$ = 0; - this._repeat$ = 0; - this._delay$ = 0; - this._interval$ = 0; - - this._target$ = null; + this._lock = false; + this._scheduler = null; + this._elapsed = -1; + this._runForever = false; + this._useDelay = false; + this._timesExecuted = 0; + this._repeat = 0; + this._delay = 0; + this._interval = 0; + + this._target = null; } public initWithCallback (scheduler: Scheduler, callback: CallbackType, target: ISchedulable, seconds: number, repeat: number, delay: number): boolean { - this._lock$ = false; - this._scheduler$ = scheduler; - this._target$ = target; - this._callback$ = callback; - this._timesExecuted$ = 0; - - this._elapsed$ = -1; - this._interval$ = seconds; - this._delay$ = delay; - this._useDelay$ = (this._delay$ > 0); - this._repeat$ = repeat; - this._runForever$ = (this._repeat$ === legacyCC.macro.REPEAT_FOREVER); + this._lock = false; + this._scheduler = scheduler; + this._target = target; + this._callback = callback; + this._timesExecuted = 0; + + this._elapsed = -1; + this._interval = seconds; + this._delay = delay; + this._useDelay = (this._delay > 0); + this._repeat = repeat; + this._runForever = (this._repeat === legacyCC.macro.REPEAT_FOREVER); return true; } /** @@ -258,14 +258,14 @@ class CallbackTimer { * @zh 返回计时器的时间间隔, 以秒为单位。 */ public getInterval (): number { - return this._interval$; + return this._interval; } /** * @en Set interval in seconds. * @zh 以秒为单位设置时间间隔。 */ public setInterval (interval: number): void { - this._interval$ = interval; + this._interval = interval; } /** @@ -276,33 +276,33 @@ class CallbackTimer { * @zh 更新间隔时间, 单位是秒。 */ public update (dt: number): void { - if (this._elapsed$ === -1) { - this._elapsed$ = 0; - this._timesExecuted$ = 0; + if (this._elapsed === -1) { + this._elapsed = 0; + this._timesExecuted = 0; } else { - this._elapsed$ += dt; - if (this._runForever$ && !this._useDelay$) { // standard timer usage - if (this._elapsed$ >= this._interval$) { + this._elapsed += dt; + if (this._runForever && !this._useDelay) { // standard timer usage + if (this._elapsed >= this._interval) { this.trigger(); - this._elapsed$ = 0; + this._elapsed = 0; } } else { // advanced usage - if (this._useDelay$) { - if (this._elapsed$ >= this._delay$) { + if (this._useDelay) { + if (this._elapsed >= this._delay) { this.trigger(); - this._elapsed$ -= this._delay$; - this._timesExecuted$ += 1; - this._useDelay$ = false; + this._elapsed -= this._delay; + this._timesExecuted += 1; + this._useDelay = false; } - } else if (this._elapsed$ >= this._interval$) { + } else if (this._elapsed >= this._interval) { this.trigger(); - this._elapsed$ = 0; - this._timesExecuted$ += 1; + this._elapsed = 0; + this._timesExecuted += 1; } - if (this._callback$ && !this._runForever$ && this._timesExecuted$ > this._repeat$) { + if (this._callback && !this._runForever && this._timesExecuted > this._repeat) { this.cancel(); } } @@ -310,20 +310,20 @@ class CallbackTimer { } public getCallback (): CallbackType | null | undefined { - return this._callback$; + return this._callback; } public trigger (): void { - if (this._target$ && this._callback$) { - this._lock$ = true; - this._callback$.call(this._target$, this._elapsed$); - this._lock$ = false; + if (this._target && this._callback) { + this._lock = true; + this._callback.call(this._target, this._elapsed); + this._lock = false; } } public cancel (): void { - if (this._scheduler$ && this._callback$ && this._target$) { - this._scheduler$.unscheduleForTimer(this, this._target$); + if (this._scheduler && this._callback && this._target) { + this._scheduler.unscheduleForTimer(this, this._target); } } } @@ -350,16 +350,16 @@ class CallbackTimer { export class Scheduler extends System { public static ID = 'scheduler'; - private _timeScale$: number; - private _updatesNegList$: ListEntry[]; - private _updates0List$: ListEntry[]; - private _updatesPosList$: ListEntry[]; - private _hashForUpdates$: Record; - private _hashForTimers$: Record; - private _currentTarget$: HashTimerEntry | null; - private _currentTargetSalvaged$: boolean; - private _updateHashLocked$: boolean; - private _arrayForTimers$: HashTimerEntry[]; + private _timeScale: number; + private _updatesNegList: ListEntry[]; + private _updates0List: ListEntry[]; + private _updatesPosList: ListEntry[]; + private _hashForUpdates: Record; + private _hashForTimers: Record; + private _currentTarget: HashTimerEntry | null; + private _currentTargetSalvaged: boolean; + private _updateHashLocked: boolean; + private _arrayForTimers: HashTimerEntry[]; /** * @en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. @@ -384,17 +384,17 @@ export class Scheduler extends System { constructor () { super(); - this._timeScale$ = 1.0; - this._updatesNegList$ = []; // list of priority < 0 - this._updates0List$ = []; // list of priority == 0 - this._updatesPosList$ = []; // list of priority > 0 - this._hashForUpdates$ = createMap(true) as Record; // hash used to fetch quickly the list entries for pause, delete, etc - this._hashForTimers$ = createMap(true) as Record; // Used for "selectors with interval" - this._currentTarget$ = null; - this._currentTargetSalvaged$ = false; - this._updateHashLocked$ = false; // If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. - - this._arrayForTimers$ = []; // Speed up indexing + this._timeScale = 1.0; + this._updatesNegList = []; // list of priority < 0 + this._updates0List = []; // list of priority == 0 + this._updatesPosList = []; // list of priority > 0 + this._hashForUpdates = createMap(true) as Record; // hash used to fetch quickly the list entries for pause, delete, etc + this._hashForTimers = createMap(true) as Record; // Used for "selectors with interval" + this._currentTarget = null; + this._currentTargetSalvaged = false; + this._updateHashLocked = false; // If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. + + this._arrayForTimers = []; // Speed up indexing // this._arrayForUpdates = []; // Speed up indexing } @@ -416,7 +416,7 @@ export class Scheduler extends System { * @param timeScale */ public setTimeScale (timeScale: number): void { - this._timeScale$ = timeScale; + this._timeScale = timeScale; } /** @@ -424,7 +424,7 @@ export class Scheduler extends System { * @zh 获取时间间隔的缩放比例。 */ public getTimeScale (): number { - return this._timeScale$; + return this._timeScale; } /** @@ -435,9 +435,9 @@ export class Scheduler extends System { * @zh 更新间隔时间, 单位是秒。 */ public update (dt: number): void { - this._updateHashLocked$ = true; - if (this._timeScale$ !== 1) { - dt *= this._timeScale$; + this._updateHashLocked = true; + if (this._timeScale !== 1) { + dt *= this._timeScale; } let i: number; @@ -445,84 +445,84 @@ export class Scheduler extends System { let len: number; let entry: ListEntry; - for (i = 0, list = this._updatesNegList$, len = list.length; i < len; i++) { + for (i = 0, list = this._updatesNegList, len = list.length; i < len; i++) { entry = list[i]; - if (!entry.paused$ && !entry.markedForDeletion$ && entry.target$) { - entry.target$.update?.(dt); + if (!entry.paused && !entry.markedForDeletion && entry.target) { + entry.target.update?.(dt); } } - for (i = 0, list = this._updates0List$, len = list.length; i < len; i++) { + for (i = 0, list = this._updates0List, len = list.length; i < len; i++) { entry = list[i]; - if (!entry.paused$ && !entry.markedForDeletion$ && entry.target$) { - entry.target$.update?.(dt); + if (!entry.paused && !entry.markedForDeletion && entry.target) { + entry.target.update?.(dt); } } - for (i = 0, list = this._updatesPosList$, len = list.length; i < len; i++) { + for (i = 0, list = this._updatesPosList, len = list.length; i < len; i++) { entry = list[i]; - if (!entry.paused$ && !entry.markedForDeletion$ && entry.target$) { - entry.target$.update?.(dt); + if (!entry.paused && !entry.markedForDeletion && entry.target) { + entry.target.update?.(dt); } } // Iterate over all the custom selectors let elt: HashTimerEntry; - const arr = this._arrayForTimers$; + const arr = this._arrayForTimers; for (i = 0; i < arr.length; i++) { elt = arr[i]; - this._currentTarget$ = elt; - this._currentTargetSalvaged$ = false; + this._currentTarget = elt; + this._currentTargetSalvaged = false; - if (!elt.paused$ && elt.timers$) { + if (!elt.paused && elt.timers) { // The 'timers' array may change while inside this loop - for (elt.timerIndex$ = 0; elt.timerIndex$ < elt.timers$.length; ++(elt.timerIndex$)) { - elt.currentTimer$ = elt.timers$[elt.timerIndex$]; - elt.currentTimerSalvaged$ = false; + for (elt.timerIndex = 0; elt.timerIndex < elt.timers.length; ++(elt.timerIndex)) { + elt.currentTimer = elt.timers[elt.timerIndex]; + elt.currentTimerSalvaged = false; - elt.currentTimer$.update(dt); - elt.currentTimer$ = null; + elt.currentTimer.update(dt); + elt.currentTimer = null; } } // only delete currentTarget if no actions were scheduled during the cycle (issue #481) - if (this._currentTargetSalvaged$ && this._currentTarget$.timers$?.length === 0) { - this._removeHashElement$(this._currentTarget$); + if (this._currentTargetSalvaged && this._currentTarget.timers?.length === 0) { + this._removeHashElement(this._currentTarget); --i; } } // delete all updates that are marked for deletion // updates with priority < 0 - for (i = 0, list = this._updatesNegList$; i < list.length;) { + for (i = 0, list = this._updatesNegList; i < list.length;) { entry = list[i]; - if (entry.markedForDeletion$) { - this._removeUpdateFromHash$(entry); + if (entry.markedForDeletion) { + this._removeUpdateFromHash(entry); } else { i++; } } - for (i = 0, list = this._updates0List$; i < list.length;) { + for (i = 0, list = this._updates0List; i < list.length;) { entry = list[i]; - if (entry.markedForDeletion$) { - this._removeUpdateFromHash$(entry); + if (entry.markedForDeletion) { + this._removeUpdateFromHash(entry); } else { i++; } } - for (i = 0, list = this._updatesPosList$; i < list.length;) { + for (i = 0, list = this._updatesPosList; i < list.length;) { entry = list[i]; - if (entry.markedForDeletion$) { - this._removeUpdateFromHash$(entry); + if (entry.markedForDeletion) { + this._removeUpdateFromHash(entry); } else { i++; } } - this._updateHashLocked$ = false; - this._currentTarget$ = null; + this._updateHashLocked = false; + this._currentTarget = null; } /** @@ -603,23 +603,23 @@ export class Scheduler extends System { errorID(1510); return; } - let element = this._hashForTimers$[targetId]; + let element = this._hashForTimers[targetId]; if (!element) { // Is this the 1st element ? Then set the pause level to all the callback_fns of this target element = HashTimerEntry.get(null, target, 0, null, false, Boolean(paused)); - this._arrayForTimers$.push(element); - this._hashForTimers$[targetId] = element; - } else if (element.paused$ !== paused) { + this._arrayForTimers.push(element); + this._hashForTimers[targetId] = element; + } else if (element.paused !== paused) { warnID(1511); } let timer: CallbackTimer; let i; - if (element.timers$ == null) { - element.timers$ = []; + if (element.timers == null) { + element.timers = []; } else { - for (i = 0; i < element.timers$.length; ++i) { - timer = element.timers$[i]; + for (i = 0; i < element.timers.length; ++i) { + timer = element.timers[i]; if (timer && callback === timer.getCallback()) { logID(1507, timer.getInterval(), interval); timer.setInterval(interval); @@ -630,10 +630,10 @@ export class Scheduler extends System { timer = CallbackTimer.get(); timer.initWithCallback(this, callback, target, interval, repeat ?? 0, delay ?? 0); - element.timers$.push(timer); + element.timers.push(timer); - if (this._currentTarget$ === element && this._currentTargetSalvaged$) { - this._currentTargetSalvaged$ = false; + if (this._currentTarget === element && this._currentTargetSalvaged) { + this._currentTargetSalvaged = false; } } @@ -658,22 +658,22 @@ export class Scheduler extends System { errorID(1510); return; } - const hashElement = this._hashForUpdates$[targetId]; - if (hashElement && hashElement.entry$) { + const hashElement = this._hashForUpdates[targetId]; + if (hashElement && hashElement.entry) { // check if priority has changed - if (hashElement.entry$.priority$ !== priority) { - if (this._updateHashLocked$) { + if (hashElement.entry.priority !== priority) { + if (this._updateHashLocked) { logID(1506); - hashElement.entry$.markedForDeletion$ = false; - hashElement.entry$.paused$ = paused; + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; return; } else { // will be added again outside if (hashElement). this.unscheduleUpdate(target); } } else { - hashElement.entry$.markedForDeletion$ = false; - hashElement.entry$.paused$ = paused; + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; return; } } @@ -684,15 +684,15 @@ export class Scheduler extends System { // most of the updates are going to be 0, that's way there // is an special list for updates with priority 0 if (priority === 0) { - ppList = this._updates0List$; - this._appendIn$(ppList, listElement); + ppList = this._updates0List; + this._appendIn(ppList, listElement); } else { - ppList = priority < 0 ? this._updatesNegList$ : this._updatesPosList$; - this._priorityIn$(ppList, listElement, priority); + ppList = priority < 0 ? this._updatesNegList : this._updatesPosList; + this._priorityIn(ppList, listElement, priority); } // update hash entry for quick access - this._hashForUpdates$[targetId] = HashUpdateEntry.get(ppList, listElement, target, null); + this._hashForUpdates[targetId] = HashUpdateEntry.get(ppList, listElement, target, null); } /** @@ -718,30 +718,30 @@ export class Scheduler extends System { return; } - const element = this._hashForTimers$[targetId]; + const element = this._hashForTimers[targetId]; if (element) { - const timers = element.timers$; + const timers = element.timers; if (!timers) { return; } for (let i = 0, li = timers.length; i < li; i++) { const timer = timers[i]; if (callback === timer.getCallback()) { - if ((timer === element.currentTimer$) && (!element.currentTimerSalvaged$)) { - element.currentTimerSalvaged$ = true; + if ((timer === element.currentTimer) && (!element.currentTimerSalvaged)) { + element.currentTimerSalvaged = true; } timers.splice(i, 1); CallbackTimer.put(timer); // update timerIndex in case we are in tick;, looping over the actions - if (element.timerIndex$ >= i) { - element.timerIndex$--; + if (element.timerIndex >= i) { + element.timerIndex--; } if (timers.length === 0) { - if (this._currentTarget$ === element) { - this._currentTargetSalvaged$ = true; + if (this._currentTarget === element) { + this._currentTargetSalvaged = true; } else { - this._removeHashElement$(element); + this._removeHashElement(element); } } return; @@ -758,8 +758,8 @@ export class Scheduler extends System { */ public unscheduleForTimer (timerToUnschedule: CallbackTimer, target: ISchedulable): void { const targetId = (target.uuid || target.id) as string; - const element = this._hashForTimers$[targetId]; - const timers = element.timers$; + const element = this._hashForTimers[targetId]; + const timers = element.timers; if (!timers || timers.length === 0) { return; } @@ -771,12 +771,12 @@ export class Scheduler extends System { CallbackTimer.put(timer); // update timerIndex in case we are in tick;, looping over the actions - if (element.timerIndex$ >= i) { - element.timerIndex$--; + if (element.timerIndex >= i) { + element.timerIndex--; } if (timers.length === 0) { - this._currentTargetSalvaged$ = true; + this._currentTargetSalvaged = true; } return; } @@ -798,12 +798,12 @@ export class Scheduler extends System { return; } - const element = this._hashForUpdates$[targetId]; - if (element?.entry$) { - if (this._updateHashLocked$) { - element.entry$.markedForDeletion$ = true; + const element = this._hashForUpdates[targetId]; + if (element?.entry) { + if (this._updateHashLocked) { + element.entry.markedForDeletion = true; } else { - this._removeUpdateFromHash$(element.entry$); + this._removeUpdateFromHash(element.entry); } } } @@ -827,22 +827,22 @@ export class Scheduler extends System { } // Custom Selectors - const element = this._hashForTimers$[targetId]; - if (element?.timers$) { - const timers = element.timers$; - if (element.currentTimer$ && timers.indexOf(element.currentTimer$) > -1 - && (!element.currentTimerSalvaged$)) { - element.currentTimerSalvaged$ = true; + const element = this._hashForTimers[targetId]; + if (element?.timers) { + const timers = element.timers; + if (element.currentTimer && timers.indexOf(element.currentTimer) > -1 + && (!element.currentTimerSalvaged)) { + element.currentTimerSalvaged = true; } for (let i = 0, l = timers.length; i < l; i++) { CallbackTimer.put(timers[i]); } timers.length = 0; - if (this._currentTarget$ === element) { - this._currentTargetSalvaged$ = true; + if (this._currentTarget === element) { + this._currentTargetSalvaged = true; } else { - this._removeHashElement$(element); + this._removeHashElement(element); } } @@ -879,11 +879,11 @@ export class Scheduler extends System { // Custom Selectors let i: number; let element: HashTimerEntry; - const arr = this._arrayForTimers$; + const arr = this._arrayForTimers; for (i = arr.length - 1; i >= 0; i--) { element = arr[i]; - if (element.target$) { - this.unscheduleAllForTarget(element.target$); + if (element.target) { + this.unscheduleAllForTarget(element.target); } } @@ -891,38 +891,38 @@ export class Scheduler extends System { let entry: ListEntry; let temp_length = 0; if (minPriority < 0) { - for (i = 0; i < this._updatesNegList$.length;) { - temp_length = this._updatesNegList$.length; - entry = this._updatesNegList$[i]; - if (entry?.target$ && entry.priority$ >= minPriority) { - this.unscheduleUpdate(entry.target$); + for (i = 0; i < this._updatesNegList.length;) { + temp_length = this._updatesNegList.length; + entry = this._updatesNegList[i]; + if (entry?.target && entry.priority >= minPriority) { + this.unscheduleUpdate(entry.target); } - if (temp_length === this._updatesNegList$.length) { + if (temp_length === this._updatesNegList.length) { i++; } } } if (minPriority <= 0) { - for (i = 0; i < this._updates0List$.length;) { - temp_length = this._updates0List$.length; - entry = this._updates0List$[i]; - if (entry?.target$) { - this.unscheduleUpdate(entry.target$); + for (i = 0; i < this._updates0List.length;) { + temp_length = this._updates0List.length; + entry = this._updates0List[i]; + if (entry?.target) { + this.unscheduleUpdate(entry.target); } - if (temp_length === this._updates0List$.length) { + if (temp_length === this._updates0List.length) { i++; } } } - for (i = 0; i < this._updatesPosList$.length;) { - temp_length = this._updatesPosList$.length; - entry = this._updatesPosList$[i]; - if (entry?.target$ && entry.priority$ >= minPriority) { - this.unscheduleUpdate(entry.target$); + for (i = 0; i < this._updatesPosList.length;) { + temp_length = this._updatesPosList.length; + entry = this._updatesPosList[i]; + if (entry?.target && entry.priority >= minPriority) { + this.unscheduleUpdate(entry.target); } - if (temp_length === this._updatesPosList$.length) { + if (temp_length === this._updatesPosList.length) { i++; } } @@ -946,16 +946,16 @@ export class Scheduler extends System { return false; } - const element = this._hashForTimers$[targetId]; + const element = this._hashForTimers[targetId]; if (!element) { return false; } - if (element.timers$ == null) { + if (element.timers == null) { return false; } else { - const timers = element.timers$; + const timers = element.timers; for (let i = 0; i < timers.length; ++i) { const timer = timers[i]; @@ -992,47 +992,47 @@ export class Scheduler extends System { const idsWithSelectors: ISchedulable[] = []; let element: HashTimerEntry; - const locArrayForTimers = this._arrayForTimers$; + const locArrayForTimers = this._arrayForTimers; let i; let li; // Custom Selectors for (i = 0, li = locArrayForTimers.length; i < li; i++) { element = locArrayForTimers[i]; - if (element?.target$) { - element.paused$ = true; - idsWithSelectors.push(element.target$); + if (element?.target) { + element.paused = true; + idsWithSelectors.push(element.target); } } let entry: ListEntry; if (minPriority < 0) { - for (i = 0; i < this._updatesNegList$.length; i++) { - entry = this._updatesNegList$[i]; - if (entry?.target$) { - if (entry.priority$ >= minPriority) { - entry.paused$ = true; - idsWithSelectors.push(entry.target$); + for (i = 0; i < this._updatesNegList.length; i++) { + entry = this._updatesNegList[i]; + if (entry?.target) { + if (entry.priority >= minPriority) { + entry.paused = true; + idsWithSelectors.push(entry.target); } } } } if (minPriority <= 0) { - for (i = 0; i < this._updates0List$.length; i++) { - entry = this._updates0List$[i]; - if (entry?.target$) { - entry.paused$ = true; - idsWithSelectors.push(entry.target$); + for (i = 0; i < this._updates0List.length; i++) { + entry = this._updates0List[i]; + if (entry?.target) { + entry.paused = true; + idsWithSelectors.push(entry.target); } } } - for (i = 0; i < this._updatesPosList$.length; i++) { - entry = this._updatesPosList$[i]; - if (entry?.target$) { - if (entry.priority$ >= minPriority) { - entry.paused$ = true; - idsWithSelectors.push(entry.target$); + for (i = 0; i < this._updatesPosList.length; i++) { + entry = this._updatesPosList[i]; + if (entry?.target) { + if (entry.priority >= minPriority) { + entry.paused = true; + idsWithSelectors.push(entry.target); } } } @@ -1079,15 +1079,15 @@ export class Scheduler extends System { } // customer selectors - const element = this._hashForTimers$[targetId]; + const element = this._hashForTimers[targetId]; if (element) { - element.paused$ = true; + element.paused = true; } // update callback - const elementUpdate = this._hashForUpdates$[targetId]; - if (elementUpdate?.entry$) { - elementUpdate.entry$.paused$ = true; + const elementUpdate = this._hashForUpdates[targetId]; + if (elementUpdate?.entry) { + elementUpdate.entry.paused = true; } } @@ -1111,15 +1111,15 @@ export class Scheduler extends System { } // custom selectors - const element = this._hashForTimers$[targetId]; + const element = this._hashForTimers[targetId]; if (element) { - element.paused$ = false; + element.paused = false; } // update callback - const elementUpdate = this._hashForUpdates$[targetId]; - if (elementUpdate?.entry$) { - elementUpdate.entry$.paused$ = false; + const elementUpdate = this._hashForUpdates[targetId]; + if (elementUpdate?.entry) { + elementUpdate.entry.paused = false; } } @@ -1137,28 +1137,28 @@ export class Scheduler extends System { } // Custom selectors - const element = this._hashForTimers$[targetId]; + const element = this._hashForTimers[targetId]; if (element) { - return element.paused$; + return element.paused; } - const elementUpdate = this._hashForUpdates$[targetId]; - if (elementUpdate?.entry$) { - return elementUpdate.entry$.paused$; + const elementUpdate = this._hashForUpdates[targetId]; + if (elementUpdate?.entry) { + return elementUpdate.entry.paused; } return false; } // -----------------------private method---------------------- - private _removeHashElement$ (element: HashTimerEntry): void { - if (!element.target$) { + private _removeHashElement (element: HashTimerEntry): void { + if (!element.target) { return; } - const targetId = element.target$.uuid || element.target$.id; + const targetId = element.target.uuid || element.target.id; if (typeof targetId === 'undefined') { return; } - delete this._hashForTimers$[targetId]; - const arr = this._arrayForTimers$; + delete this._hashForTimers[targetId]; + const arr = this._arrayForTimers; for (let i = 0, l = arr.length; i < l; i++) { if (arr[i] === element) { arr.splice(i, 1); @@ -1168,19 +1168,19 @@ export class Scheduler extends System { HashTimerEntry.put(element); } - private _removeUpdateFromHash$ (entry: ListEntry): void { - if (!entry.target$) { + private _removeUpdateFromHash (entry: ListEntry): void { + if (!entry.target) { return; } - const targetId = entry.target$.uuid || entry.target$.id; + const targetId = entry.target.uuid || entry.target.id; if (typeof targetId === 'undefined') { return; } - const element = this._hashForUpdates$[targetId]; + const element = this._hashForUpdates[targetId]; if (element) { // Remove list entry from list - const list = element.list$; - const listEntry = element.entry$; + const list = element.list; + const listEntry = element.entry; if (list) { for (let i = 0, l = list.length; i < l; i++) { if (list[i] === listEntry) { @@ -1190,7 +1190,7 @@ export class Scheduler extends System { } } - delete this._hashForUpdates$[targetId]; + delete this._hashForUpdates[targetId]; if (listEntry) { ListEntry.put(listEntry); } @@ -1198,9 +1198,9 @@ export class Scheduler extends System { } } - private _priorityIn$ (ppList: ListEntry[], listElement: ListEntry, priority: number): void { + private _priorityIn (ppList: ListEntry[], listElement: ListEntry, priority: number): void { for (let i = 0; i < ppList.length; i++) { - if (priority < ppList[i].priority$) { + if (priority < ppList[i].priority) { ppList.splice(i, 0, listElement); return; } @@ -1208,7 +1208,7 @@ export class Scheduler extends System { ppList.push(listElement); } - private _appendIn$ (ppList: ListEntry[], listElement: ListEntry): void { + private _appendIn (ppList: ListEntry[], listElement: ListEntry): void { ppList.push(listElement); } } diff --git a/cocos/core/settings.ts b/cocos/core/settings.ts index 5bd293eb4e6..c7ec7a431a2 100644 --- a/cocos/core/settings.ts +++ b/cocos/core/settings.ts @@ -83,7 +83,7 @@ export class Settings { // For now, we use a system module context to dynamically import the relative path of module. const settingsModule = '../settings.js'; import(settingsModule).then((res): void => { - this._settings$ = res.default; + this._settings = res.default; resolve(); }).catch((e): void => reject(e)); }); @@ -98,7 +98,7 @@ export class Settings { reject(err); return; } - this._settings$ = result; + this._settings = result; resolve(); }); } else { @@ -106,7 +106,7 @@ export class Settings { if (result instanceof Error) { reject(result); } else { - this._settings$ = result; + this._settings = result; resolve(); } } @@ -115,7 +115,7 @@ export class Settings { xhr.open('GET', path); xhr.responseType = 'text'; xhr.onload = (): void => { - this._settings$ = JSON.parse(xhr.response as string); + this._settings = JSON.parse(xhr.response as string); resolve(); }; xhr.onerror = (): void => { @@ -145,10 +145,10 @@ export class Settings { * ``` */ overrideSettings (category: SettingsCategory | string, name: string, value: T): void { - if (!(category in this._override$)) { - this._override$[category] = {}; + if (!(category in this._override)) { + this._override[category] = {}; } - this._override$[category][name] = value; + this._override[category][name] = value; } /** @@ -168,14 +168,14 @@ export class Settings { * ``` */ querySettings (category: SettingsCategory | string, name: string): T | null { - if (category in this._override$) { - const categorySettings = this._override$[category]; + if (category in this._override) { + const categorySettings = this._override[category]; if (categorySettings && name in categorySettings) { return categorySettings[name] as T; } } - if (category in this._settings$) { - const categorySettings = this._settings$[category]; + if (category in this._settings) { + const categorySettings = this._settings[category]; if (categorySettings && name in categorySettings) { return categorySettings[name] as T; } @@ -183,8 +183,8 @@ export class Settings { return null; } - private _settings$: Record = {}; - private _override$: Record = {}; + private _settings: Record = {}; + private _override: Record = {}; } export declare namespace Settings { diff --git a/cocos/core/utils/pool.ts b/cocos/core/utils/pool.ts index 4ca9c07febc..13cbc03c254 100644 --- a/cocos/core/utils/pool.ts +++ b/cocos/core/utils/pool.ts @@ -98,8 +98,8 @@ export class Pool { return this._get(); } - private declare _pool$: Array; - private declare _cleanup$: CleanUpFunction | null; + private declare _pool: Array; + private declare _cleanup: CleanUpFunction | null; /** * @en Constructor. @zh 构造函数。 @@ -125,8 +125,8 @@ export class Pool { constructor (_0: CleanUpFunction | number, _1?: number) { const size = (_1 === undefined) ? (_0 as number) : _1; const cleanupFunc = (_1 === undefined) ? null : (_0 as CleanUpFunction); - this._pool$ = new Array(size); - this._cleanup$ = cleanupFunc; + this._pool = new Array(size); + this._cleanup = cleanupFunc; } /** @@ -140,8 +140,8 @@ export class Pool { public _get (): T | null { if (this.count > 0) { --this.count; - const cache = this._pool$[this.count]; - this._pool$[this.count] = null; + const cache = this._pool[this.count]; + this._pool[this.count] = null; return cache; } return null; @@ -152,9 +152,9 @@ export class Pool { * @zh 向对象池返还一个不再需要的对象。 */ public put (obj: T): void { - const pool = this._pool$; + const pool = this._pool; if (this.count < pool.length) { - if (this._cleanup$ && this._cleanup$(obj) === false) { + if (this._cleanup && this._cleanup(obj) === false) { return; } pool[this.count] = obj; @@ -170,7 +170,7 @@ export class Pool { */ public resize (length: number): void { if (length >= 0) { - this._pool$.length = length; + this._pool.length = length; if (this.count > length) { this.count = length; } diff --git a/cocos/game/director.ts b/cocos/game/director.ts index 66f9f6d7753..510d59b0f80 100644 --- a/cocos/game/director.ts +++ b/cocos/game/director.ts @@ -298,15 +298,15 @@ export class Director extends EventTarget { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _nodeActivator: NodeActivator = new NodeActivator(); - private _invalid$: boolean = false; - private _paused$: boolean = false; - private _root$: Root | null = null; - private _loadingScene$: string = ''; - private _scene$: Scene | null = null; - private _totalFrames$: number = 0; // FPS - private _scheduler$: Scheduler = new Scheduler(); // Scheduler for user registration update - private _systems$: System[] = []; - private _persistRootNodes$: Record = {}; + private _invalid: boolean = false; + private _paused: boolean = false; + private _root: Root | null = null; + private _loadingScene: string = ''; + private _scene: Scene | null = null; + private _totalFrames: number = 0; // FPS + private _scheduler: Scheduler = new Scheduler(); // Scheduler for user registration update + private _systems: System[] = []; + private _persistRootNodes: Record = {}; constructor () { super(); @@ -331,7 +331,7 @@ export class Director extends EventTarget { * 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 `game.pause` 。 */ public pause (): void { - this._paused$ = true; + this._paused = true; } /** @@ -342,16 +342,16 @@ export class Director extends EventTarget { */ public purgeDirector (): void { // cleanup scheduler - this._scheduler$.unscheduleAll(); + this._scheduler.unscheduleAll(); this._compScheduler.unscheduleAll(); this._nodeActivator.reset(); if (!EDITOR) { - if (isValid(this._scene$)) { - this._scene$!.destroy(); + if (isValid(this._scene)) { + this._scene!.destroy(); } - this._scene$ = null; + this._scene = null; } this.stopAnimation(); @@ -367,8 +367,8 @@ export class Director extends EventTarget { public reset (): void { this.purgeDirector(); - for (const id in this._persistRootNodes$) { - this.removePersistRootNode(this._persistRootNodes$[id]); + for (const id in this._persistRootNodes) { + this.removePersistRootNode(this._persistRootNodes[id]); } // Clear scene @@ -410,7 +410,7 @@ export class Director extends EventTarget { // eslint-disable-next-line no-console console.time('AttachPersist'); } - const persistNodeList = Object.keys(this._persistRootNodes$).map((x): Node => this._persistRootNodes$[x]); + const persistNodeList = Object.keys(this._persistRootNodes).map((x): Node => this._persistRootNodes[x]); for (let i = 0; i < persistNodeList.length; i++) { const node = persistNodeList[i]; node.emit(NodeEventType.SCENE_CHANGED_FOR_PERSISTS, scene.renderScene); @@ -432,7 +432,7 @@ export class Director extends EventTarget { // eslint-disable-next-line no-console console.timeEnd('AttachPersist'); } - const oldScene = this._scene$; + const oldScene = this._scene; // unload scene if (BUILD && DEBUG) { @@ -448,14 +448,14 @@ export class Director extends EventTarget { // eslint-disable-next-line no-console console.time('AutoRelease'); } - releaseManager._autoRelease(oldScene!, scene, this._persistRootNodes$); + releaseManager._autoRelease(oldScene!, scene, this._persistRootNodes); if (BUILD && DEBUG) { // eslint-disable-next-line no-console console.timeEnd('AutoRelease'); } } - this._scene$ = null; + this._scene = null; // purge destroyed nodes belongs to old scene CCObject._deferredDestroy(); @@ -468,7 +468,7 @@ export class Director extends EventTarget { this.emit(DirectorEvent.BEFORE_SCENE_LAUNCH, scene); // Run an Entity Scene - this._scene$ = scene; + this._scene = scene; if (BUILD && DEBUG) { // eslint-disable-next-line no-console @@ -480,8 +480,8 @@ export class Director extends EventTarget { console.timeEnd('Activate'); } // start scene - if (this._root$) { - this._root$.resetCumulativeTime(); + if (this._root) { + this._root.resetCumulativeTime(); } this.startAnimation(); if (onLaunched) { @@ -520,20 +520,20 @@ export class Director extends EventTarget { * @return if error, return false */ public loadScene (sceneName: string, onLaunched?: Director.OnSceneLaunched, onUnloaded?: Director.OnUnload): boolean { - if (this._loadingScene$) { - warnID(1208, sceneName, this._loadingScene$); + if (this._loadingScene) { + warnID(1208, sceneName, this._loadingScene); return false; } const bundle = assetManager.bundles.find((bundle): boolean => !!bundle.getSceneInfo(sceneName)); if (bundle) { this.emit(DirectorEvent.BEFORE_SCENE_LOADING, sceneName); - this._loadingScene$ = sceneName; + this._loadingScene = sceneName; // eslint-disable-next-line no-console console.time(`LoadScene ${sceneName}`); bundle.loadScene(sceneName, (err, scene): void => { // eslint-disable-next-line no-console console.timeEnd(`LoadScene ${sceneName}`); - this._loadingScene$ = ''; + this._loadingScene = ''; if (err) { error(err); if (onLaunched) { @@ -607,11 +607,11 @@ export class Director extends EventTarget { * @zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。 */ public resume (): void { - this._paused$ = false; + this._paused = false; } get root (): Root | null { - return this._root$; + return this._root; } /** @@ -625,7 +625,7 @@ export class Director extends EventTarget { * ``` */ public getScene (): Scene | null { - return this._scene$; + return this._scene; } /** @@ -660,7 +660,7 @@ export class Director extends EventTarget { * @zh 获取 director 启动以来游戏运行的总帧数。 */ public getTotalFrames (): number { - return this._totalFrames$; + return this._totalFrames; } /** @@ -668,7 +668,7 @@ export class Director extends EventTarget { * @zh 是否处于暂停状态。 */ public isPaused (): boolean { - return this._paused$; + return this._paused; } /** @@ -676,7 +676,7 @@ export class Director extends EventTarget { * @zh 获取和 director 相关联的调度器。 */ public getScheduler (): Scheduler { - return this._scheduler$; + return this._scheduler; } /** @@ -684,9 +684,9 @@ export class Director extends EventTarget { * @zh 设置和 director 相关联的调度器。 */ public setScheduler (scheduler: Scheduler): void { - if (this._scheduler$ !== scheduler) { - this.unregisterSystem(this._scheduler$); - this._scheduler$ = scheduler; + if (this._scheduler !== scheduler) { + this.unregisterSystem(this._scheduler); + this._scheduler = scheduler; this.registerSystem(Scheduler.ID, scheduler, 200); } } @@ -698,13 +698,13 @@ export class Director extends EventTarget { public registerSystem (name: string, sys: System, priority: number): void { sys.id = name; sys.priority = priority; - this._systems$.push(sys); - this._systems$.sort(System.sortByPriority); + this._systems.push(sys); + this._systems.sort(System.sortByPriority); } public unregisterSystem (sys: System): void { - js.array.fastRemove(this._systems$, sys); - this._systems$.sort(System.sortByPriority); + js.array.fastRemove(this._systems, sys); + this._systems.sort(System.sortByPriority); } /** @@ -712,7 +712,7 @@ export class Director extends EventTarget { * @zh 获取一个 system。 */ public getSystem (name: string): System | undefined { - return this._systems$.find((sys): boolean => sys.id === name); + return this._systems.find((sys): boolean => sys.id === name); } /** @@ -730,7 +730,7 @@ export class Director extends EventTarget { * @zh 开始执行游戏逻辑 */ public startAnimation (): void { - this._invalid$ = false; + this._invalid = false; } /** @@ -738,7 +738,7 @@ export class Director extends EventTarget { * @zh 停止执行游戏逻辑,每帧渲染会继续执行 */ public stopAnimation (): void { - this._invalid$ = true; + this._invalid = true; } /** @@ -762,22 +762,22 @@ export class Director extends EventTarget { * @param dt Delta time in seconds */ public tick (dt: number): void { - if (!this._invalid$) { + if (!this._invalid) { this.emit(DirectorEvent.BEGIN_FRAME); if (!EDITOR_NOT_IN_PREVIEW) { input._frameDispatchEvents(); } // Update - if (!this._paused$) { + if (!this._paused) { this.emit(DirectorEvent.BEFORE_UPDATE); // Call start for new added components this._compScheduler.startPhase(); // Update for components this._compScheduler.updatePhase(dt); // Update systems - for (let i = 0; i < this._systems$.length; ++i) { - this._systems$[i].update(dt); + for (let i = 0; i < this._systems.length; ++i) { + this._systems[i].update(dt); } // Late update for components this._compScheduler.lateUpdatePhase(dt); @@ -787,21 +787,21 @@ export class Director extends EventTarget { CCObject._deferredDestroy(); // Post update systems - for (let i = 0; i < this._systems$.length; ++i) { - this._systems$[i].postUpdate(dt); + for (let i = 0; i < this._systems.length; ++i) { + this._systems[i].postUpdate(dt); } } this.emit(DirectorEvent.BEFORE_DRAW); uiRendererManager.updateAllDirtyRenderers(); - this._root$!.frameMove(dt); + this._root!.frameMove(dt); this.emit(DirectorEvent.AFTER_DRAW); Node.resetHasChangedFlags(); Node.clearNodeArray(); scalableContainerManager.update(dt); this.emit(DirectorEvent.END_FRAME); - this._totalFrames$++; + this._totalFrames++; } } @@ -810,12 +810,12 @@ export class Director extends EventTarget { * @zh 构建自定义渲染管线 */ private buildRenderPipeline (): void { - if (!this._root$) { + if (!this._root) { return; } // Here we should build the render pipeline. - const ppl = this._root$.customPipeline; - const cameras = this._root$.cameraList; + const ppl = this._root.customPipeline; + const cameras = this._root.cameraList; ppl.beginSetup(); const builder = cclegacy.rendering.getCustomPipeline(macro.CUSTOM_PIPELINE_NAME); @@ -830,7 +830,7 @@ export class Director extends EventTarget { // (in CocosCreator/Project/Project Settings/Engine Manager/Macro Configuration/CUSTOM_PIPELINE_NAME) // 2. cclegacy.rendering is available // 3. The root node is created and uses custom pipeline - if (macro.CUSTOM_PIPELINE_NAME !== '' && cclegacy.rendering && this._root$ && this._root$.usesCustomPipeline) { + if (macro.CUSTOM_PIPELINE_NAME !== '' && cclegacy.rendering && this._root && this._root.usesCustomPipeline) { this.on( DirectorEvent.BEFORE_RENDER, this.buildRenderPipeline, @@ -848,19 +848,19 @@ export class Director extends EventTarget { * @internal */ public init (): void { - this._totalFrames$ = 0; - this._paused$ = false; + this._totalFrames = 0; + this._paused = false; // Scheduler // TODO: have a solid organization of priority and expose to user - this.registerSystem(Scheduler.ID, this._scheduler$, 200); - this._root$ = new Root(deviceManager.gfxDevice); + this.registerSystem(Scheduler.ID, this._scheduler, 200); + this._root = new Root(deviceManager.gfxDevice); const rootInfo = {}; - this._root$.initialize(rootInfo); + this._root.initialize(rootInfo); this.setupRenderPipelineBuilder(); - for (let i = 0; i < this._systems$.length; i++) { - this._systems$[i].init(); + for (let i = 0; i < this._systems.length; i++) { + this._systems[i].init(); } this.emit(DirectorEvent.INIT); @@ -882,8 +882,8 @@ export class Director extends EventTarget { return; } const id = node.uuid; - if (!this._persistRootNodes$[id]) { - const scene = this._scene$ as any; + if (!this._persistRootNodes[id]) { + const scene = this._scene as any; if (isValid(scene)) { if (!node.parent) { node.parent = scene; @@ -898,7 +898,7 @@ export class Director extends EventTarget { node._originalSceneId = scene.uuid; } } - this._persistRootNodes$[id] = node; + this._persistRootNodes[id] = node; node._persistNode = true; releaseManager._addPersistNodeRef(node); } @@ -911,8 +911,8 @@ export class Director extends EventTarget { */ public removePersistRootNode (node: Node): void { const id = node.uuid || ''; - if (node === this._persistRootNodes$[id]) { - delete this._persistRootNodes$[id]; + if (node === this._persistRootNodes[id]) { + delete this._persistRootNodes[id]; node._persistNode = false; node._originalSceneId = ''; releaseManager._removePersistNodeRef(node); diff --git a/cocos/game/game.ts b/cocos/game/game.ts index c8e5c80bc9a..daab108f06f 100644 --- a/cocos/game/game.ts +++ b/cocos/game/game.ts @@ -400,7 +400,7 @@ export class Game extends EventTarget { * @zh 引擎和渲染器是否以完成初始化 */ public get inited (): boolean { - return this._inited$; + return this._inited; } /** @@ -408,7 +408,7 @@ export class Game extends EventTarget { * @zh 游戏的设定帧率。 */ public get frameRate (): string | number { - return this._frameRate$; + return this._frameRate; } public set frameRate (frameRate: number | string) { if (typeof frameRate !== 'number') { @@ -417,9 +417,9 @@ export class Game extends EventTarget { frameRate = 60; } } - this._frameRate$ = frameRate; + this._frameRate = frameRate; this.frameTime = 1000 / frameRate; - if (this._pacer$) this._pacer$.targetFrameRate = this._frameRate$; + if (this._pacer) this._pacer.targetFrameRate = this._frameRate; } /** @@ -427,7 +427,7 @@ export class Game extends EventTarget { * @zh 获取上一帧的增量时间,以秒为单位。 */ public get deltaTime (): number { - return this._useFixedDeltaTime$ ? this.frameTime / 1000 : this._deltaTime$; + return this._useFixedDeltaTime ? this.frameTime / 1000 : this._deltaTime; } /** @@ -435,7 +435,7 @@ export class Game extends EventTarget { * @zh 获取从游戏开始到现在总共经过的时间,以毫秒为单位 */ public get totalTime (): number { - return performance.now() - this._initTime$; + return performance.now() - this._initTime; } /** @@ -443,7 +443,7 @@ export class Game extends EventTarget { * @zh 获取当前帧开始的时间(以 ms 为单位)。 */ public get frameStartTime (): number { - return this._startTime$; + return this._startTime; } /** @@ -457,19 +457,19 @@ export class Game extends EventTarget { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _isCloning = false; // deserializing or instantiating - private _inited$ = false; - private _engineInited$ = false; // whether the engine has inited - private _rendererInitialized$ = false; - private _paused$ = true; - private _pausedByEngine$ = false; + private _inited = false; + private _engineInited = false; // whether the engine has inited + private _rendererInitialized = false; + private _paused = true; + private _pausedByEngine = false; // frame control - private _frameRate$ = 60; - private _pacer$: Pacer | null = null; - private _initTime$ = 0; - private _startTime$ = 0; - private _deltaTime$ = 0.0; - private _useFixedDeltaTime$ = false; - private _shouldLoadLaunchScene$ = true; + private _frameRate = 60; + private _pacer: Pacer | null = null; + private _initTime = 0; + private _startTime = 0; + private _deltaTime = 0.0; + private _useFixedDeltaTime = false; + private _shouldLoadLaunchScene = true; /** * @en The event delegate pre base module initialization. At this point you can not use pal/logging/sys/settings API. @@ -553,9 +553,9 @@ export class Game extends EventTarget { * @en Called by the engine to pause the game. * @zh 提供给引擎调用暂停游戏接口。 */ - private pauseByEngine$ (): void { - if (this._paused$) { return; } - this._pausedByEngine$ = true; + private pauseByEngine (): void { + if (this._paused) { return; } + this._pausedByEngine = true; this.pause(); } @@ -563,10 +563,10 @@ export class Game extends EventTarget { * @en Resume paused game by engine call. * @zh 提供给引擎调用恢复暂停游戏接口。 */ - private resumeByEngine$ (): void { - if (this._pausedByEngine$) { + private resumeByEngine (): void { + if (this._pausedByEngine) { this.resume(); - this._pausedByEngine$ = false; + this._pausedByEngine = false; } } @@ -586,9 +586,9 @@ export class Game extends EventTarget { * 这点和只暂停游戏逻辑的 `director.pause()` 不同。 */ public pause (): void { - if (this._paused$) { return; } - this._paused$ = true; - this._pacer$?.stop(); + if (this._paused) { return; } + this._paused = true; + this._pacer?.stop(); this.emit(Game.EVENT_PAUSE); } @@ -598,10 +598,10 @@ export class Game extends EventTarget { * @zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。 */ public resume (): void { - if (!this._paused$) { return; } + if (!this._paused) { return; } input._clearEvents(); - this._paused$ = false; - this._pacer$?.start(); + this._paused = false; + this._pacer?.start(); this.emit(Game.EVENT_RESUME); } @@ -610,7 +610,7 @@ export class Game extends EventTarget { * @zh 判断游戏是否暂停。 */ public isPaused (): boolean { - return this._paused$; + return this._paused; } /** @@ -626,7 +626,7 @@ export class Game extends EventTarget { cclegacy.Object._deferredDestroy(); this.pause(); this.resume(); - this._shouldLoadLaunchScene$ = true; + this._shouldLoadLaunchScene = true; }).then((): Promise => { if (WECHAT) { return Promise.resolve([]); @@ -634,7 +634,7 @@ export class Game extends EventTarget { return SplashScreen.createInstance().init(); } }).then((): void => { - this._safeEmit$(Game.EVENT_RESTART); + this._safeEmit(Game.EVENT_RESTART); }); } @@ -662,7 +662,7 @@ export class Game extends EventTarget { */ public on (type: string, callback: () => void, target?: any, once?: boolean): any { // Make sure EVENT_ENGINE_INITED callbacks to be invoked - if (this.canRegisterEvent$(type)) { + if (this.canRegisterEvent(type)) { callback.call(target); } return this.eventTargetOn(type, callback, target, once); @@ -682,16 +682,16 @@ export class Game extends EventTarget { */ public once (type: string, callback: () => void, target?: any): any { // Make sure EVENT_ENGINE_INITED callbacks to be invoked - if (this.canRegisterEvent$(type)) { + if (this.canRegisterEvent(type)) { return callback.call(target); } return this.eventTargetOnce(type, callback, target); } - private canRegisterEvent$ (type: string): boolean { - return this._engineInited$ && type === Game.EVENT_ENGINE_INITED - || this._inited$ && type === Game.EVENT_GAME_INITED - || this._rendererInitialized$ && type === Game.EVENT_RENDERER_INITED; + private canRegisterEvent (type: string): boolean { + return this._engineInited && type === Game.EVENT_ENGINE_INITED + || this._inited && type === Game.EVENT_GAME_INITED + || this._rendererInitialized && type === Game.EVENT_RENDERER_INITED; } /** @@ -729,7 +729,7 @@ export class Game extends EventTarget { * @param config - Pass configuration object */ public init (config: IGameConfig): Promise { - this._compatibleWithOldParams$(config); + this._compatibleWithOldParams(config); // DONT change the order unless you know what's you doing return Promise.resolve() // #region Base @@ -747,7 +747,7 @@ export class Game extends EventTarget { }) .then((): Promise => sys.init()) .then((): void => { - this._initEvents$(); + this._initEvents(); }) .then((): Promise => settings.init(config.settingsPath, config.overrideSettings)) .then((): Promise => { @@ -771,7 +771,7 @@ export class Game extends EventTarget { console.time('Init Infrastructure'); } macro.init(); - this._initXR$(); + this._initXR(); const adapter = findCanvas(); if (adapter) { this.canvas = adapter.canvas; @@ -803,7 +803,7 @@ export class Game extends EventTarget { assetManager.init(); builtinResMgr.init(); Layers.init(); - this.initPacer$(); + this.initPacer(); if (DEBUG) { // eslint-disable-next-line no-console console.timeEnd('Init Infrastructure'); @@ -863,7 +863,7 @@ export class Game extends EventTarget { .then((): void => { log(`Cocos Creator v${VERSION}`); this.emit(Game.EVENT_ENGINE_INITED); - this._engineInited$ = true; + this._engineInited = true; }) // #endregion Subsystem // #region Project @@ -886,9 +886,9 @@ export class Game extends EventTarget { return promise; }) .then((): Promise => this._loadProjectBundles()) - .then((): Promise => this._loadCCEScripts$()) - .then((): void | Promise => this._setupRenderPipeline$()) - .then((): Promise => this._loadPreloadAssets$()) + .then((): Promise => this._loadCCEScripts()) + .then((): void | Promise => this._setupRenderPipeline()) + .then((): Promise => this._loadPreloadAssets()) .then((): Promise => { builtinResMgr.compileBuiltinMaterial(); if (WECHAT) { @@ -906,12 +906,12 @@ export class Game extends EventTarget { }) // #endregion Project .then((): void => { - this._inited$ = true; - this._safeEmit$(Game.EVENT_GAME_INITED); + this._inited = true; + this._safeEmit(Game.EVENT_GAME_INITED); }); } - private _initXR$ (): void { + private _initXR (): void { if (typeof globalThis.__globalXR === 'undefined') { globalThis.__globalXR = {}; } @@ -929,7 +929,7 @@ export class Game extends EventTarget { } } - private _compatibleWithOldParams$ (config: IGameConfig): void { + private _compatibleWithOldParams (config: IGameConfig): void { const overrideSettings = config.overrideSettings = config.overrideSettings || {}; if ('showFPS' in config) { overrideSettings.profiling = overrideSettings.profiling || {}; @@ -969,7 +969,7 @@ export class Game extends EventTarget { } } - private _loadPreloadAssets$ (): Promise { + private _loadPreloadAssets (): Promise { const preloadAssets = settings.querySettings(SettingsCategory.ASSETS, 'preloadAssets'); if (!preloadAssets) return Promise.resolve([]); return Promise.all(preloadAssets.map((uuid): Promise => new Promise((resolve, reject): void => { @@ -986,7 +986,7 @@ export class Game extends EventTarget { /** * @internal only for browser preview */ - private _loadCCEScripts$ (): Promise { + private _loadCCEScripts (): Promise { return new Promise((resolve, reject): void => { // Since there is no script in the bundle during preview, we need to load the user's script in the following way if (PREVIEW && !TEST && !EDITOR && !NATIVE) { @@ -1026,7 +1026,7 @@ export class Game extends EventTarget { if (onStart) { this.onStart = onStart; } - if (!this._inited$ || EDITOR_NOT_IN_PREVIEW) { + if (!this._inited || EDITOR_NOT_IN_PREVIEW) { return; } this.resume(); @@ -1037,42 +1037,42 @@ export class Game extends EventTarget { * @engineInternal */ public _calculateDT (useFixedDeltaTime: boolean): number { - this._useFixedDeltaTime$ = useFixedDeltaTime; + this._useFixedDeltaTime = useFixedDeltaTime; if (useFixedDeltaTime) { - this._startTime$ = performance.now(); + this._startTime = performance.now(); return this.frameTime / 1000; } const now = performance.now(); - this._deltaTime$ = now > this._startTime$ ? (now - this._startTime$) / 1000 : 0; - if (this._deltaTime$ > Game.DEBUG_DT_THRESHOLD) { - this._deltaTime$ = this.frameTime / 1000; + this._deltaTime = now > this._startTime ? (now - this._startTime) / 1000 : 0; + if (this._deltaTime > Game.DEBUG_DT_THRESHOLD) { + this._deltaTime = this.frameTime / 1000; } - this._startTime$ = now; - return this._deltaTime$; + this._startTime = now; + return this._deltaTime; } - private _updateCallback$ (): void { - if (!this._inited$) return; + private _updateCallback (): void { + if (!this._inited) return; if (!WECHAT && SplashScreen.instance && !SplashScreen.instance.isFinished) { SplashScreen.instance.update(this._calculateDT(false)); - } else if (this._shouldLoadLaunchScene$) { + } else if (this._shouldLoadLaunchScene) { if (!WECHAT) { SplashScreen.releaseInstance(); } - this._shouldLoadLaunchScene$ = false; + this._shouldLoadLaunchScene = false; const launchScene = settings.querySettings(SettingsCategory.LAUNCH, 'launchScene') as string; if (launchScene) { // load scene director.loadScene(launchScene, (): void => { logID(1103, launchScene); - this._initTime$ = performance.now(); + this._initTime = performance.now(); director.startAnimation(); this.onStart?.(); }); } else { - this._initTime$ = performance.now(); + this._initTime = performance.now(); director.startAnimation(); this.onStart?.(); } @@ -1081,31 +1081,31 @@ export class Game extends EventTarget { } } - private initPacer$ (): void { + private initPacer (): void { const frameRate = settings.querySettings(SettingsCategory.SCREEN, 'frameRate') ?? 60; assert(typeof frameRate === 'number'); - this._pacer$ = new Pacer(); - this._pacer$.onTick = this._updateCallback$.bind(this); + this._pacer = new Pacer(); + this._pacer.onTick = this._updateCallback.bind(this); this.frameRate = frameRate; } - private _initEvents$ (): void { - systemInfo.on('show', this._onShow$, this); - systemInfo.on('hide', this._onHide$, this); - systemInfo.on('close', this._onClose$, this); + private _initEvents (): void { + systemInfo.on('show', this._onShow, this); + systemInfo.on('hide', this._onHide, this); + systemInfo.on('close', this._onClose, this); } - private _onHide$ (): void { + private _onHide (): void { this.emit(Game.EVENT_HIDE); - this.pauseByEngine$(); + this.pauseByEngine(); } - private _onShow$ (): void { + private _onShow (): void { this.emit(Game.EVENT_SHOW); - this.resumeByEngine$(); + this.resumeByEngine(); } - private _onClose$ (): void { + private _onClose (): void { this.emit(Game.EVENT_CLOSE); // TODO : Release Resources. systemInfo.exit(); @@ -1146,26 +1146,26 @@ export class Game extends EventTarget { return director.isPersistRootNode(node); } - private _setupRenderPipeline$ (): void | Promise { + private _setupRenderPipeline (): void | Promise { const usesCustomPipeline = settings.querySettings( SettingsCategory.RENDERING, 'customPipeline', ); - return this._setRenderPipeline$(!!usesCustomPipeline); + return this._setRenderPipeline(!!usesCustomPipeline); } - private _setRenderPipeline$ (customPipeline: boolean): void { + private _setRenderPipeline (customPipeline: boolean): void { if (!director.root!.setRenderPipeline(customPipeline)) { errorID(1222); return; } - this._rendererInitialized$ = true; - this._safeEmit$(Game.EVENT_RENDERER_INITED); + this._rendererInitialized = true; + this._safeEmit(Game.EVENT_RENDERER_INITED); } - private _safeEmit$ (event: string | number): void { + private _safeEmit (event: string | number): void { if (EDITOR) { try { this.emit(event); diff --git a/cocos/game/splash-screen.ts b/cocos/game/splash-screen.ts index 8d75bb9d3d6..aa9b004f7d0 100644 --- a/cocos/game/splash-screen.ts +++ b/cocos/game/splash-screen.ts @@ -68,61 +68,61 @@ interface SplashLogo { } export class SplashScreen { - private settings$!: ISplashSetting; - private _curTime$ = 0; - - private device$!: Device; - private swapchain$!: Swapchain; - private shader$!: Shader; - private sampler$!: Sampler; - private cmdBuff$!: CommandBuffer; - private quadAssmebler$!: InputAssembler; - private vertexBuffers$!: Buffer; - private indicesBuffers$!: Buffer; - private renderArea$!: Rect; - private clearColors$!: Color[]; - private projection$!: Mat4; - private isMobile$ = false; - - private bgMat$!: Material; - private bgImage$!: HTMLImageElement; - private bgTexture$!: Texture; - - private logoMat$!: Material; - private logoImage$!: HTMLImageElement; - private logoTexture$!: Texture; - - private watermarkMat$!: Material; - private watermarkTexture$!: Texture; + private settings!: ISplashSetting; + private _curTime = 0; + + private device!: Device; + private swapchain!: Swapchain; + private shader!: Shader; + private sampler!: Sampler; + private cmdBuff!: CommandBuffer; + private quadAssmebler!: InputAssembler; + private vertexBuffers!: Buffer; + private indicesBuffers!: Buffer; + private renderArea!: Rect; + private clearColors!: Color[]; + private projection!: Mat4; + private isMobile = false; + + private bgMat!: Material; + private bgImage!: HTMLImageElement; + private bgTexture!: Texture; + + private logoMat!: Material; + private logoImage!: HTMLImageElement; + private logoTexture!: Texture; + + private watermarkMat!: Material; + private watermarkTexture!: Texture; // layout - private bgWidth$ = 1920; - private bgHeight$ = 1080; - private logoWidthTemp$ = 140; - private logoHeightTemp$ = 200; - private logoWidth$ = 0; - private logoHeight$ = 0; - private logoXTrans$ = 1 / 2;// Percent - private logoYTrans$ = 1 / 6 + 2.5 / 6;// Percent - - private textSize$ = 24; // font size - private textHeight$ = 24; // line height - private textXTrans$ = 1 / 2;// Percent - private textYExtraTrans$ = 32;// px - private textExpandSize$ = 4;// px - - private scaleSize$ = 1; + private bgWidth = 1920; + private bgHeight = 1080; + private logoWidthTemp = 140; + private logoHeightTemp = 200; + private logoWidth = 0; + private logoHeight = 0; + private logoXTrans = 1 / 2;// Percent + private logoYTrans = 1 / 6 + 2.5 / 6;// Percent + + private textSize = 24; // font size + private textHeight = 24; // line height + private textXTrans = 1 / 2;// Percent + private textYExtraTrans = 32;// px + private textExpandSize = 4;// px + + private scaleSize = 1; public get isFinished (): boolean { - return this._curTime$ >= this.settings$.totalTime; + return this._curTime >= this.settings.totalTime; } set curTime (val) { - this._curTime$ = val; + this._curTime = val; } get curTime (): number { - return this._curTime$; + return this._curTime; } public init (): Promise { @@ -133,7 +133,7 @@ export class SplashScreen { policy = designResolution.policy as number; } } - this.settings$ = { + this.settings = { policy: (policy) ?? ResolutionPolicy.SHOW_ALL, displayRatio: settings.querySettings(SettingsCategory.SPLASH_SCREEN, 'displayRatio') ?? 0.4, totalTime: settings.querySettings(SettingsCategory.SPLASH_SCREEN, 'totalTime') ?? 3000, @@ -142,46 +142,46 @@ export class SplashScreen { logo: settings.querySettings(SettingsCategory.SPLASH_SCREEN, 'logo') ?? undefined, background: settings.querySettings(SettingsCategory.SPLASH_SCREEN, 'background') ?? undefined, }; - this._curTime$ = 0; + this._curTime = 0; - if (EDITOR || this.settings$.totalTime <= 0 || this.settings$.logo === undefined || this.settings$.background === undefined) { - this.settings$.totalTime = 0; + if (EDITOR || this.settings.totalTime <= 0 || this.settings.logo === undefined || this.settings.background === undefined) { + this.settings.totalTime = 0; } else { - this.device$ = cclegacy.director.root!.device; - this.swapchain$ = cclegacy.director.root!.mainWindow!.swapchain; + this.device = cclegacy.director.root!.device; + this.swapchain = cclegacy.director.root!.mainWindow!.swapchain; - this.preInit$(); - this.initLayout$(); + this.preInit(); + this.initLayout(); - if (this.settings$.logo.type === 'default') { - this.initWaterMark$(); + if (this.settings.logo.type === 'default') { + this.initWaterMark(); } let bgPromise = Promise.resolve(); let logoPromise = Promise.resolve(); - if (this.settings$.background.type === 'custom') { + if (this.settings.background.type === 'custom') { bgPromise = new Promise((resolve, reject): void => { - this.bgImage$ = new ccwindow.Image(); - this.bgImage$.onload = (): void => { - this.initBG$(); + this.bgImage = new ccwindow.Image(); + this.bgImage.onload = (): void => { + this.initBG(); resolve(); }; - this.bgImage$.onerror = (): void => { + this.bgImage.onerror = (): void => { reject(); }; - this.bgImage$.src = this.settings$.background!.base64!; + this.bgImage.src = this.settings.background!.base64!; }); } - if (this.settings$.logo.type !== 'none') { + if (this.settings.logo.type !== 'none') { logoPromise = new Promise((resolve, reject): void => { - this.logoImage$ = new ccwindow.Image(); - this.logoImage$.onload = (): void => { - this.initLogo$(); + this.logoImage = new ccwindow.Image(); + this.logoImage.onload = (): void => { + this.initLogo(); resolve(); }; - this.logoImage$.onerror = (): void => { + this.logoImage.onerror = (): void => { reject(); }; - this.logoImage$.src = this.settings$.logo!.base64!; + this.logoImage.src = this.settings.logo!.base64!; }); } return Promise.all([bgPromise, logoPromise]); @@ -189,48 +189,48 @@ export class SplashScreen { return Promise.resolve([]); } - private preInit$ (): void { - const clearColor = this.settings$.background?.color; - this.clearColors$ = clearColor ? [new Color(clearColor.x, clearColor.y, clearColor.z, clearColor.w)] : [new Color(0, 0, 0, 1)]; - const { device$: device, swapchain$: swapchain } = this; - this.renderArea$ = new Rect(0, 0, swapchain.width, swapchain.height); - this.cmdBuff$ = device.commandBuffer; + private preInit (): void { + const clearColor = this.settings.background?.color; + this.clearColors = clearColor ? [new Color(clearColor.x, clearColor.y, clearColor.z, clearColor.w)] : [new Color(0, 0, 0, 1)]; + const { device, swapchain } = this; + this.renderArea = new Rect(0, 0, swapchain.width, swapchain.height); + this.cmdBuff = device.commandBuffer; // create input assembler // create vertex buffer const verts = new Float32Array([0.5, 0.5, 1, 0, -0.5, 0.5, 0, 0, 0.5, -0.5, 1, 1, -0.5, -0.5, 0, 1]); const vbStride = Float32Array.BYTES_PER_ELEMENT * 4; const vbSize = vbStride * 4; - this.vertexBuffers$ = device.createBuffer(new BufferInfo( + this.vertexBuffers = device.createBuffer(new BufferInfo( BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST, MemoryUsageBit.DEVICE, vbSize, vbStride, )); - this.vertexBuffers$.update(verts); + this.vertexBuffers.update(verts); // create index buffer const indices = new Uint16Array([0, 1, 2, 1, 3, 2]); const ibStride = Uint16Array.BYTES_PER_ELEMENT; const ibSize = ibStride * 6; - this.indicesBuffers$ = device.createBuffer(new BufferInfo( + this.indicesBuffers = device.createBuffer(new BufferInfo( BufferUsageBit.INDEX | BufferUsageBit.TRANSFER_DST, MemoryUsageBit.DEVICE, ibSize, ibStride, )); - this.indicesBuffers$.update(indices); + this.indicesBuffers.update(indices); const attributes: Attribute[] = [ new Attribute('a_position', Format.RG32F), new Attribute('a_texCoord', Format.RG32F), ]; - const IAInfo = new InputAssemblerInfo(attributes, [this.vertexBuffers$], this.indicesBuffers$); - this.quadAssmebler$ = device.createInputAssembler(IAInfo); + const IAInfo = new InputAssemblerInfo(attributes, [this.vertexBuffers], this.indicesBuffers); + this.quadAssmebler = device.createInputAssembler(IAInfo); - this.projection$ = new Mat4(); + this.projection = new Mat4(); Mat4.ortho( - this.projection$, + this.projection, -1, 1, -1, @@ -242,59 +242,59 @@ export class SplashScreen { swapchain.surfaceTransform, ); - this.isMobile$ = sys.isMobile; + this.isMobile = sys.isMobile; } - private initLayout$ (): void { - if (this.isMobile$) { - this.bgWidth$ = 812; - this.bgHeight$ = 375; + private initLayout (): void { + if (this.isMobile) { + this.bgWidth = 812; + this.bgHeight = 375; - this.logoWidthTemp$ = 70; - this.logoHeightTemp$ = 100; + this.logoWidthTemp = 70; + this.logoHeightTemp = 100; - this.textSize$ = 12; // font size - this.textHeight$ = this.textSize$ + this.textExpandSize$; // line height - this.textXTrans$ = 1 / 2;// Percent - this.textYExtraTrans$ = 16;// px + this.textSize = 12; // font size + this.textHeight = this.textSize + this.textExpandSize; // line height + this.textXTrans = 1 / 2;// Percent + this.textYExtraTrans = 16;// px } else { - this.bgWidth$ = 1920; - this.bgHeight$ = 1080; + this.bgWidth = 1920; + this.bgHeight = 1080; - this.logoWidthTemp$ = 140; - this.logoHeightTemp$ = 200; + this.logoWidthTemp = 140; + this.logoHeightTemp = 200; - this.textSize$ = 24; // font size - this.textHeight$ = this.textSize$ + this.textExpandSize$; // line height - this.textXTrans$ = 1 / 2;// Percent - this.textYExtraTrans$ = 32;// px + this.textSize = 24; // font size + this.textHeight = this.textSize + this.textExpandSize; // line height + this.textXTrans = 1 / 2;// Percent + this.textYExtraTrans = 32;// px } - this.logoXTrans$ = 1 / 2;// Percent - this.logoYTrans$ = 1 / 6 + 2.5 / 6;// Percent - this.initScale$(); + this.logoXTrans = 1 / 2;// Percent + this.logoYTrans = 1 / 6 + 2.5 / 6;// Percent + this.initScale(); } - private initScale$ (): void { - const dw = this.swapchain$.width; const dh = this.swapchain$.height; - let desiredWidth = this.isMobile$ ? 375 : 1080; - let desiredHeight = this.isMobile$ ? 812 : 1920; + private initScale (): void { + const dw = this.swapchain.width; const dh = this.swapchain.height; + let desiredWidth = this.isMobile ? 375 : 1080; + let desiredHeight = this.isMobile ? 812 : 1920; if (dw > dh) { const temp = desiredHeight; desiredHeight = desiredWidth; desiredWidth = temp; } if (dw / dh > 16 / 9) { - this.scaleSize$ = dh / desiredHeight; + this.scaleSize = dh / desiredHeight; } else { - this.scaleSize$ = dw / desiredWidth; + this.scaleSize = dw / desiredWidth; } } public update (deltaTime: number): void { - const settings = this.settings$; - const { device$: device, swapchain$: swapchain } = this; + const settings = this.settings; + const { device, swapchain } = this; Mat4.ortho( - this.projection$, + this.projection, -1, 1, -1, @@ -306,195 +306,195 @@ export class SplashScreen { swapchain.surfaceTransform, ); const dw = swapchain.width; const dh = swapchain.height; - this.initScale$(); + this.initScale(); - this._curTime$ += deltaTime * 1000; - const percent = clamp01(this._curTime$ / settings.totalTime); + this._curTime += deltaTime * 1000; + const percent = clamp01(this._curTime / settings.totalTime); const u_p = easing.cubicOut(percent); let scaleX = 1; let scaleY = 1; // update bg uniform - if (this.settings$.background!.type === 'custom') { - if (this.settings$.policy === ResolutionPolicy.FIXED_WIDTH) { + if (this.settings.background!.type === 'custom') { + if (this.settings.policy === ResolutionPolicy.FIXED_WIDTH) { scaleX = dw; - scaleY = (dw / this.bgImage$.width) * this.bgImage$.height; - } else if (this.settings$.policy === ResolutionPolicy.FIXED_HEIGHT) { - scaleX = (dh / this.bgImage$.height) * this.bgImage$.width; + scaleY = (dw / this.bgImage.width) * this.bgImage.height; + } else if (this.settings.policy === ResolutionPolicy.FIXED_HEIGHT) { + scaleX = (dh / this.bgImage.height) * this.bgImage.width; scaleY = dh; - } else if (this.settings$.policy === ResolutionPolicy.SHOW_ALL) { - if ((this.bgImage$.width / this.bgHeight$) > (dw / dh)) { + } else if (this.settings.policy === ResolutionPolicy.SHOW_ALL) { + if ((this.bgImage.width / this.bgHeight) > (dw / dh)) { scaleX = dw; - scaleY = (dw / this.bgImage$.width) * this.bgImage$.height; + scaleY = (dw / this.bgImage.width) * this.bgImage.height; } else { - scaleX = (dh / this.bgImage$.height) * this.bgImage$.width; + scaleX = (dh / this.bgImage.height) * this.bgImage.width; scaleY = dh; } - } else if (this.settings$.policy === ResolutionPolicy.NO_BORDER) { - if ((this.bgImage$.width / this.bgImage$.height) > (dw / dh)) { - scaleX = (dh / this.bgImage$.height) * this.bgImage$.width; + } else if (this.settings.policy === ResolutionPolicy.NO_BORDER) { + if ((this.bgImage.width / this.bgImage.height) > (dw / dh)) { + scaleX = (dh / this.bgImage.height) * this.bgImage.width; scaleY = dh; } else { scaleX = dw; - scaleY = (dw / this.bgImage$.width) * this.bgImage$.height; + scaleY = (dw / this.bgImage.width) * this.bgImage.height; } } else { scaleX = dw; scaleY = dh; } - this.bgMat$.setProperty('resolution', v2_0.set(dw, dh), 0); - this.bgMat$.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.bgMat$.setProperty('translate', v2_0.set(dw * 0.5, dh * 0.5), 0); - this.bgMat$.setProperty('percent', 1.0); - this.bgMat$.setProperty('u_projection', this.projection$); - this.bgMat$.passes[0].update(); + this.bgMat.setProperty('resolution', v2_0.set(dw, dh), 0); + this.bgMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); + this.bgMat.setProperty('translate', v2_0.set(dw * 0.5, dh * 0.5), 0); + this.bgMat.setProperty('percent', 1.0); + this.bgMat.setProperty('u_projection', this.projection); + this.bgMat.passes[0].update(); } // update logo uniform - const logoYTrans = dh * this.logoYTrans$; - if (this.settings$.logo!.type !== 'none') { + const logoYTrans = dh * this.logoYTrans; + if (this.settings.logo!.type !== 'none') { // Product design is 0.185 of the height of the screen resolution as the display height of the logo. scaleY = dh * 0.185 * settings.displayRatio; - scaleX = this.logoWidth$ * (dh * 0.185 / this.logoHeight$) * settings.displayRatio; - this.logoMat$.setProperty('resolution', v2_0.set(dw, dh), 0); - this.logoMat$.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.logoMat$.setProperty('translate', v2_0.set(dw * this.logoXTrans$, logoYTrans), 0); - this.logoMat$.setProperty('percent', u_p); - this.logoMat$.setProperty('u_projection', this.projection$); - this.logoMat$.passes[0].update(); + scaleX = this.logoWidth * (dh * 0.185 / this.logoHeight) * settings.displayRatio; + this.logoMat.setProperty('resolution', v2_0.set(dw, dh), 0); + this.logoMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); + this.logoMat.setProperty('translate', v2_0.set(dw * this.logoXTrans, logoYTrans), 0); + this.logoMat.setProperty('percent', u_p); + this.logoMat.setProperty('u_projection', this.projection); + this.logoMat.passes[0].update(); } // update watermark uniform - if (this.settings$.logo!.type === 'default' && this.watermarkMat$) { - const watermarkTW = this.watermarkTexture$.width; const watermarkTH = this.watermarkTexture$.height; + if (this.settings.logo!.type === 'default' && this.watermarkMat) { + const watermarkTW = this.watermarkTexture.width; const watermarkTH = this.watermarkTexture.height; scaleX = watermarkTW; scaleY = watermarkTH; - const textYTrans = logoYTrans - (this.logoHeight$ * 0.5 * settings.displayRatio + this.textYExtraTrans$) - * this.scaleSize$ - watermarkTH * 0.5; - this.watermarkMat$.setProperty('resolution', v2_0.set(dw, dh), 0); - this.watermarkMat$.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.watermarkMat$.setProperty('translate', v2_0.set(dw * this.textXTrans$, textYTrans), 0); - this.watermarkMat$.setProperty('percent', u_p); - this.watermarkMat$.setProperty('u_projection', this.projection$); - this.watermarkMat$.passes[0].update(); + const textYTrans = logoYTrans - (this.logoHeight * 0.5 * settings.displayRatio + this.textYExtraTrans) + * this.scaleSize - watermarkTH * 0.5; + this.watermarkMat.setProperty('resolution', v2_0.set(dw, dh), 0); + this.watermarkMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); + this.watermarkMat.setProperty('translate', v2_0.set(dw * this.textXTrans, textYTrans), 0); + this.watermarkMat.setProperty('percent', u_p); + this.watermarkMat.setProperty('u_projection', this.projection); + this.watermarkMat.passes[0].update(); } - this.frame$(); + this.frame(); } - private initBG$ (): void { - const device = this.device$; + private initBG (): void { + const device = this.device; - this.bgMat$ = new Material(); - this.bgMat$.initialize({ effectName: 'util/splash-screen' }); + this.bgMat = new Material(); + this.bgMat.initialize({ effectName: 'util/splash-screen' }); const samplerInfo = new SamplerInfo(); samplerInfo.addressU = Address.CLAMP; samplerInfo.addressV = Address.CLAMP; samplerInfo.addressW = Address.CLAMP; - this.sampler$ = device.getSampler(samplerInfo); + this.sampler = device.getSampler(samplerInfo); - this.bgTexture$ = device.createTexture(new TextureInfo( + this.bgTexture = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST, Format.RGBA8, - this.bgImage$.width, - this.bgImage$.height, + this.bgImage.width, + this.bgImage.height, )); - const pass = this.bgMat$.passes[0]; + const pass = this.bgMat.passes[0]; const binding = pass.getBinding('mainTexture'); - pass.bindTexture(binding, this.bgTexture$); - this.shader$ = pass.getShaderVariant()!; + pass.bindTexture(binding, this.bgTexture); + this.shader = pass.getShaderVariant()!; const descriptorSet = pass.descriptorSet; - descriptorSet.bindSampler(binding, this.sampler$); + descriptorSet.bindSampler(binding, this.sampler); descriptorSet.update(); const region = new BufferTextureCopy(); - region.texExtent.width = this.bgImage$.width; - region.texExtent.height = this.bgImage$.height; + region.texExtent.width = this.bgImage.width; + region.texExtent.height = this.bgImage.height; region.texExtent.depth = 1; - device.copyTexImagesToTexture([this.bgImage$], this.bgTexture$, [region]); + device.copyTexImagesToTexture([this.bgImage], this.bgTexture, [region]); } - private initLogo$ (): void { - const device = this.device$; + private initLogo (): void { + const device = this.device; - this.logoMat$ = new Material(); - this.logoMat$.initialize({ effectName: 'util/splash-screen' }); + this.logoMat = new Material(); + this.logoMat.initialize({ effectName: 'util/splash-screen' }); const samplerInfo = new SamplerInfo(); samplerInfo.addressU = Address.CLAMP; samplerInfo.addressV = Address.CLAMP; samplerInfo.addressW = Address.CLAMP; - this.sampler$ = device.getSampler(samplerInfo); + this.sampler = device.getSampler(samplerInfo); - this.logoTexture$ = device.createTexture(new TextureInfo( + this.logoTexture = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST, Format.RGBA8, - this.logoImage$.width, - this.logoImage$.height, + this.logoImage.width, + this.logoImage.height, )); - const pass = this.logoMat$.passes[0]; + const pass = this.logoMat.passes[0]; const binding = pass.getBinding('mainTexture'); - pass.bindTexture(binding, this.logoTexture$); - this.shader$ = pass.getShaderVariant()!; + pass.bindTexture(binding, this.logoTexture); + this.shader = pass.getShaderVariant()!; const descriptorSet = pass.descriptorSet; - descriptorSet.bindSampler(binding, this.sampler$); + descriptorSet.bindSampler(binding, this.sampler); descriptorSet.update(); const region = new BufferTextureCopy(); - region.texExtent.width = this.logoImage$.width; - region.texExtent.height = this.logoImage$.height; + region.texExtent.width = this.logoImage.width; + region.texExtent.height = this.logoImage.height; region.texExtent.depth = 1; - device.copyTexImagesToTexture([this.logoImage$], this.logoTexture$, [region]); + device.copyTexImagesToTexture([this.logoImage], this.logoTexture, [region]); - const logoRatio = this.logoImage$.width / this.logoImage$.height; + const logoRatio = this.logoImage.width / this.logoImage.height; if (logoRatio < 1) { - this.logoWidth$ = this.logoWidthTemp$; - this.logoHeight$ = this.logoWidthTemp$ / logoRatio; + this.logoWidth = this.logoWidthTemp; + this.logoHeight = this.logoWidthTemp / logoRatio; } else { - this.logoWidth$ = this.logoHeightTemp$ * logoRatio; - this.logoHeight$ = this.logoHeightTemp$; + this.logoWidth = this.logoHeightTemp * logoRatio; + this.logoHeight = this.logoHeightTemp; } } - private initWaterMark$ (): void { + private initWaterMark (): void { // create texture from image const watermarkImg = ccwindow.document.createElement('canvas'); - watermarkImg.height = this.textHeight$ * this.scaleSize$; + watermarkImg.height = this.textHeight * this.scaleSize; watermarkImg.style.width = `${watermarkImg.width}`; watermarkImg.style.height = `${watermarkImg.height}`; const text = 'Created with Cocos'; const ctx = watermarkImg.getContext('2d')!; - ctx.font = `${this.textSize$ * this.scaleSize$}px Arial`; ctx.textBaseline = 'top'; ctx.textAlign = 'center'; ctx.fillStyle = '#707070'; + ctx.font = `${this.textSize * this.scaleSize}px Arial`; ctx.textBaseline = 'top'; ctx.textAlign = 'center'; ctx.fillStyle = '#707070'; const textLength = ctx.measureText(text).width + 10; watermarkImg.width = textLength; // Tips: Set canvas width will clean context style - ctx.font = `${this.textSize$ * this.scaleSize$}px Arial`; ctx.textBaseline = 'top'; ctx.textAlign = 'center'; ctx.fillStyle = '#707070'; + ctx.font = `${this.textSize * this.scaleSize}px Arial`; ctx.textBaseline = 'top'; ctx.textAlign = 'center'; ctx.fillStyle = '#707070'; ctx.fillText(text, watermarkImg.width / 2, 0); const region = new BufferTextureCopy(); region.texExtent.width = watermarkImg.width; region.texExtent.height = watermarkImg.height; region.texExtent.depth = 1; - this.watermarkTexture$ = this.device$.createTexture(new TextureInfo( + this.watermarkTexture = this.device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST, Format.RGBA8, watermarkImg.width, watermarkImg.height, )); - this.device$.copyTexImagesToTexture([watermarkImg], this.watermarkTexture$, [region]); + this.device.copyTexImagesToTexture([watermarkImg], this.watermarkTexture, [region]); // create material - this.watermarkMat$ = new Material(); - this.watermarkMat$.initialize({ effectName: 'util/splash-screen' }); - const pass = this.watermarkMat$.passes[0]; + this.watermarkMat = new Material(); + this.watermarkMat.initialize({ effectName: 'util/splash-screen' }); + const pass = this.watermarkMat.passes[0]; const binding = pass.getBinding('mainTexture'); - pass.bindTexture(binding, this.watermarkTexture$); + pass.bindTexture(binding, this.watermarkTexture); pass.descriptorSet.update(); } - private frame$ (): void { - const { device$: device, swapchain$: swapchain } = this; + private frame (): void { + const { device, swapchain } = this; if (!sys.isXR || xr.entry.isRenderAllowable()) { const renderSize = sys.isXR ? 2 : 1; @@ -511,7 +511,7 @@ export class SplashScreen { radioRight = Math.abs(Math.tan(xrFov[1] as number)) / Math.abs(Math.tan(xrFov[0] as number)); } Mat4.ortho( - this.projection$, + this.projection, -radioLeft, radioRight, -1, @@ -523,19 +523,19 @@ export class SplashScreen { swapchain.surfaceTransform, ); // keep scale to [-1, 1] only use offset - this.projection$.m00 = preTransforms[swapchain.surfaceTransform][0]; - this.projection$.m05 = preTransforms[swapchain.surfaceTransform][3] * device.capabilities.clipSpaceSignY; - if (this.settings$.background!.type === 'custom') { - this.bgMat$.setProperty('u_projection', this.projection$); - this.bgMat$.passes[0].update(); + this.projection.m00 = preTransforms[swapchain.surfaceTransform][0]; + this.projection.m05 = preTransforms[swapchain.surfaceTransform][3] * device.capabilities.clipSpaceSignY; + if (this.settings.background!.type === 'custom') { + this.bgMat.setProperty('u_projection', this.projection); + this.bgMat.passes[0].update(); } - if (this.settings$.logo!.type !== 'none') { - this.logoMat$.setProperty('u_projection', this.projection$); - this.logoMat$.passes[0].update(); + if (this.settings.logo!.type !== 'none') { + this.logoMat.setProperty('u_projection', this.projection); + this.logoMat.passes[0].update(); } - if (this.settings$.logo!.type === 'default' && this.watermarkMat$) { - this.watermarkMat$.setProperty('u_projection', this.projection$); - this.watermarkMat$.passes[0].update(); + if (this.settings.logo!.type === 'default' && this.watermarkMat) { + this.watermarkMat.setProperty('u_projection', this.projection); + this.watermarkMat.passes[0].update(); } } @@ -544,65 +544,65 @@ export class SplashScreen { device.acquire([swapchain]); // record command - const cmdBuff = this.cmdBuff$; + const cmdBuff = this.cmdBuff; const framebuffer = cclegacy.director.root!.mainWindow!.framebuffer as Framebuffer; - const renderArea = this.renderArea$; + const renderArea = this.renderArea; renderArea.width = swapchain.width; renderArea.height = swapchain.height; cmdBuff.begin(); - cmdBuff.beginRenderPass(framebuffer.renderPass, framebuffer, renderArea, this.clearColors$, 1.0, 0); + cmdBuff.beginRenderPass(framebuffer.renderPass, framebuffer, renderArea, this.clearColors, 1.0, 0); const pipeline = cclegacy.director.root.pipeline as PipelineRuntime; - if (this.settings$.background!.type === 'custom') { - const bgPass = this.bgMat$.passes[0]; + if (this.settings.background!.type === 'custom') { + const bgPass = this.bgMat.passes[0]; const bgPso = PipelineStateManager.getOrCreatePipelineState( device, bgPass, - this.shader$, + this.shader, framebuffer.renderPass, - this.quadAssmebler$, + this.quadAssmebler, ); cmdBuff.bindPipelineState(bgPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, bgPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler$); - cmdBuff.draw(this.quadAssmebler$); + cmdBuff.bindInputAssembler(this.quadAssmebler); + cmdBuff.draw(this.quadAssmebler); } - if (this.settings$.logo!.type !== 'none') { - const logoPass = this.logoMat$.passes[0]; + if (this.settings.logo!.type !== 'none') { + const logoPass = this.logoMat.passes[0]; const logoPso = PipelineStateManager.getOrCreatePipelineState( device, logoPass, - this.shader$, + this.shader, framebuffer.renderPass, - this.quadAssmebler$, + this.quadAssmebler, ); cmdBuff.bindPipelineState(logoPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, logoPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler$); - cmdBuff.draw(this.quadAssmebler$); + cmdBuff.bindInputAssembler(this.quadAssmebler); + cmdBuff.draw(this.quadAssmebler); } - if (this.settings$.logo!.type === 'default' && this.watermarkMat$) { - const wartermarkPass = this.watermarkMat$.passes[0]; + if (this.settings.logo!.type === 'default' && this.watermarkMat) { + const wartermarkPass = this.watermarkMat.passes[0]; const watermarkPso = PipelineStateManager.getOrCreatePipelineState( device, wartermarkPass, - this.shader$, + this.shader, framebuffer.renderPass, - this.quadAssmebler$, + this.quadAssmebler, ); cmdBuff.bindPipelineState(watermarkPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, wartermarkPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler$); - cmdBuff.draw(this.quadAssmebler$); + cmdBuff.bindInputAssembler(this.quadAssmebler); + cmdBuff.draw(this.quadAssmebler); } cmdBuff.endRenderPass(); @@ -619,73 +619,73 @@ export class SplashScreen { } } - private destroy$ (): void { - this.device$ = null!; - this.swapchain$ = null!; - this.clearColors$ = null!; + private destroy (): void { + this.device = null!; + this.swapchain = null!; + this.clearColors = null!; - if (this.bgImage$) { - if ((this.bgImage$ as any).destroy) (this.bgImage$ as any).destroy(); - this.bgImage$ = null!; + if (this.bgImage) { + if ((this.bgImage as any).destroy) (this.bgImage as any).destroy(); + this.bgImage = null!; } - if (this.bgMat$) { - this.bgMat$.destroy(); - this.bgMat$ = null!; + if (this.bgMat) { + this.bgMat.destroy(); + this.bgMat = null!; } - if (this.bgTexture$) { - this.bgTexture$.destroy(); - this.bgTexture$ = null!; + if (this.bgTexture) { + this.bgTexture.destroy(); + this.bgTexture = null!; } - if (this.logoImage$) { - if ((this.logoImage$ as any).destroy) (this.logoImage$ as any).destroy(); - this.logoImage$ = null!; + if (this.logoImage) { + if ((this.logoImage as any).destroy) (this.logoImage as any).destroy(); + this.logoImage = null!; } - if (this.logoMat$) { - this.logoMat$.destroy(); - this.logoMat$ = null!; + if (this.logoMat) { + this.logoMat.destroy(); + this.logoMat = null!; } - if (this.logoTexture$) { - this.logoTexture$.destroy(); - this.logoTexture$ = null!; + if (this.logoTexture) { + this.logoTexture.destroy(); + this.logoTexture = null!; } - this.renderArea$ = null!; - this.cmdBuff$ = null!; - this.shader$ = null!; + this.renderArea = null!; + this.cmdBuff = null!; + this.shader = null!; - if (this.quadAssmebler$) { - this.quadAssmebler$.destroy(); - this.quadAssmebler$ = null!; + if (this.quadAssmebler) { + this.quadAssmebler.destroy(); + this.quadAssmebler = null!; } - if (this.vertexBuffers$) { - this.vertexBuffers$.destroy(); - this.vertexBuffers$ = null!; + if (this.vertexBuffers) { + this.vertexBuffers.destroy(); + this.vertexBuffers = null!; } - if (this.indicesBuffers$) { - this.indicesBuffers$.destroy(); - this.indicesBuffers$ = null!; + if (this.indicesBuffers) { + this.indicesBuffers.destroy(); + this.indicesBuffers = null!; } - this.sampler$ = null!; + this.sampler = null!; /** text */ - if (this.watermarkMat$) { - this.watermarkMat$.destroy(); - this.watermarkMat$ = null!; + if (this.watermarkMat) { + this.watermarkMat.destroy(); + this.watermarkMat = null!; } - if (this.watermarkTexture$) { - this.watermarkTexture$.destroy(); - this.watermarkTexture$ = null!; + if (this.watermarkTexture) { + this.watermarkTexture.destroy(); + this.watermarkTexture = null!; } - this.settings$ = null!; + this.settings = null!; } private static _ins: SplashScreen | null = null; @@ -701,7 +701,7 @@ export class SplashScreen { public static releaseInstance (): void { if (SplashScreen._ins) { - SplashScreen._ins.destroy$(); + SplashScreen._ins.destroy(); SplashScreen._ins = null; } } diff --git a/cocos/gfx/base/buffer.ts b/cocos/gfx/base/buffer.ts index 26d8caf00b2..88e8a435a1f 100644 --- a/cocos/gfx/base/buffer.ts +++ b/cocos/gfx/base/buffer.ts @@ -46,7 +46,7 @@ export abstract class Buffer extends GFXObject { * @zh 缓冲使用方式。 */ get usage (): BufferUsage { - return this._usage$; + return this._usage; } /** @@ -54,7 +54,7 @@ export abstract class Buffer extends GFXObject { * @zh 缓冲的内存使用方式。 */ get memUsage (): MemoryUsage { - return this._memUsage$; + return this._memUsage; } /** @@ -62,7 +62,7 @@ export abstract class Buffer extends GFXObject { * @zh 缓冲大小。 */ get size (): number { - return this._size$; + return this._size; } /** @@ -70,7 +70,7 @@ export abstract class Buffer extends GFXObject { * @zh 缓冲步长。 */ get stride (): number { - return this._stride$; + return this._stride; } /** @@ -78,20 +78,20 @@ export abstract class Buffer extends GFXObject { * @zh 缓冲条目数量。 */ get count (): number { - return this._count$; + return this._count; } get flags (): BufferFlags { - return this._flags$; + return this._flags; } - protected _usage$: BufferUsage = BufferUsageBit.NONE; - protected _memUsage$: MemoryUsage = MemoryUsageBit.NONE; - protected _size$ = 0; - protected _stride$ = 1; - protected _count$ = 0; - protected _flags$: BufferFlags = BufferFlagBit.NONE; - protected _isBufferView$ = false; + protected _usage: BufferUsage = BufferUsageBit.NONE; + protected _memUsage: MemoryUsage = MemoryUsageBit.NONE; + protected _size = 0; + protected _stride = 1; + protected _count = 0; + protected _flags: BufferFlags = BufferFlagBit.NONE; + protected _isBufferView = false; constructor () { super(ObjectType.BUFFER); diff --git a/cocos/gfx/base/command-buffer.ts b/cocos/gfx/base/command-buffer.ts index 292a0d6e1db..332e0da1e83 100644 --- a/cocos/gfx/base/command-buffer.ts +++ b/cocos/gfx/base/command-buffer.ts @@ -53,7 +53,7 @@ export abstract class CommandBuffer extends GFXObject { * @zh 命令缓冲类型。 */ get type (): CommandBufferType { - return this._type$; + return this._type; } /** @@ -61,7 +61,7 @@ export abstract class CommandBuffer extends GFXObject { * @zh 命令缓冲类型。 */ get queue (): Queue { - return this._queue$!; + return this._queue!; } /** @@ -69,7 +69,7 @@ export abstract class CommandBuffer extends GFXObject { * @zh 绘制调用次数。 */ get numDrawCalls (): number { - return this._numDrawCalls$; + return this._numDrawCalls; } /** @@ -77,7 +77,7 @@ export abstract class CommandBuffer extends GFXObject { * @zh 绘制 Instance 数量。 */ get numInstances (): number { - return this._numInstances$; + return this._numInstances; } /** @@ -85,14 +85,14 @@ export abstract class CommandBuffer extends GFXObject { * @zh 绘制三角形数量。 */ get numTris (): number { - return this._numTris$; + return this._numTris; } - protected _queue$: Queue | null = null; - protected _type$: CommandBufferType = CommandBufferType.PRIMARY; - protected _numDrawCalls$ = 0; - protected _numInstances$ = 0; - protected _numTris$ = 0; + protected _queue: Queue | null = null; + protected _type: CommandBufferType = CommandBufferType.PRIMARY; + protected _numDrawCalls = 0; + protected _numInstances = 0; + protected _numTris = 0; constructor () { super(ObjectType.COMMAND_BUFFER); diff --git a/cocos/gfx/base/define.ts b/cocos/gfx/base/define.ts index e2f95ea09d5..1d8b60a3b8b 100644 --- a/cocos/gfx/base/define.ts +++ b/cocos/gfx/base/define.ts @@ -2006,28 +2006,28 @@ export class DynamicStates { */ export class GFXObject extends GCObject { public get objectType (): ObjectType { - return this._objectType$; + return this._objectType; } public get objectID (): number { - return this._objectID$; + return this._objectID; } public get typedID (): number { - return this._typedID$; + return this._typedID; } - protected _objectType$ = ObjectType.UNKNOWN; - protected _objectID$ = 0; - protected _typedID$ = 0; + protected _objectType = ObjectType.UNKNOWN; + protected _objectID = 0; + protected _typedID = 0; private static _idTable = Array(ObjectType.COUNT).fill(1 << 16); constructor (objectType: ObjectType) { super(); - this._objectType$ = objectType; - this._objectID$ = GFXObject._idTable[ObjectType.UNKNOWN]++; - this._typedID$ = GFXObject._idTable[objectType]++; + this._objectType = objectType; + this._objectID = GFXObject._idTable[ObjectType.UNKNOWN]++; + this._typedID = GFXObject._idTable[objectType]++; } } diff --git a/cocos/gfx/base/descriptor-set-layout.ts b/cocos/gfx/base/descriptor-set-layout.ts index 9ff9063500a..46eb21613a3 100644 --- a/cocos/gfx/base/descriptor-set-layout.ts +++ b/cocos/gfx/base/descriptor-set-layout.ts @@ -30,20 +30,20 @@ import { GFXObject, ObjectType, DescriptorSetLayoutBinding, DescriptorSetLayoutI */ export abstract class DescriptorSetLayout extends GFXObject { get bindings (): DescriptorSetLayoutBinding[] { - return this._bindings$; + return this._bindings; } get bindingIndices (): number[] { - return this._bindingIndices$; + return this._bindingIndices; } get descriptorIndices (): number[] { - return this._descriptorIndices$; + return this._descriptorIndices; } - protected _bindings$: DescriptorSetLayoutBinding[] = []; - protected _bindingIndices$: number[] = []; - protected _descriptorIndices$: number[] = []; + protected _bindings: DescriptorSetLayoutBinding[] = []; + protected _bindingIndices: number[] = []; + protected _descriptorIndices: number[] = []; constructor () { super(ObjectType.DESCRIPTOR_SET_LAYOUT); diff --git a/cocos/gfx/base/descriptor-set.ts b/cocos/gfx/base/descriptor-set.ts index 3860bd47b16..3896f7bb8f6 100644 --- a/cocos/gfx/base/descriptor-set.ts +++ b/cocos/gfx/base/descriptor-set.ts @@ -34,15 +34,15 @@ import { GFXObject, ObjectType, DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCR */ export abstract class DescriptorSet extends GFXObject { get layout (): DescriptorSetLayout { - return this._layout$!; + return this._layout!; } - protected _layout$: DescriptorSetLayout | null = null; - protected _buffers$: Buffer[] = []; - protected _textures$: Texture[] = []; - protected _samplers$: Sampler[] = []; + protected _layout: DescriptorSetLayout | null = null; + protected _buffers: Buffer[] = []; + protected _textures: Texture[] = []; + protected _samplers: Sampler[] = []; - protected _isDirty$ = false; + protected _isDirty = false; constructor () { super(ObjectType.DESCRIPTOR_SET); @@ -61,13 +61,13 @@ export abstract class DescriptorSet extends GFXObject { * @param buffer The buffer to be bound. */ public bindBuffer (binding: number, buffer: Buffer, index = 0): void { - const bindingIndex = this._layout$!.bindingIndices[binding]; - const info = this._layout$!.bindings[bindingIndex]; if (!info) { return; } + const bindingIndex = this._layout!.bindingIndices[binding]; + const info = this._layout!.bindings[bindingIndex]; if (!info) { return; } if (info.descriptorType & DESCRIPTOR_BUFFER_TYPE) { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - if (this._buffers$[descriptorIndex + index] !== buffer) { - this._buffers$[descriptorIndex + index] = buffer; - this._isDirty$ = true; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + if (this._buffers[descriptorIndex + index] !== buffer) { + this._buffers[descriptorIndex + index] = buffer; + this._isDirty = true; } } } @@ -79,13 +79,13 @@ export abstract class DescriptorSet extends GFXObject { * @param sampler The sampler to be bound. */ public bindSampler (binding: number, sampler: Sampler, index = 0): void { - const bindingIndex = this._layout$!.bindingIndices[binding]; - const info = this._layout$!.bindings[bindingIndex]; if (!info) { return; } + const bindingIndex = this._layout!.bindingIndices[binding]; + const info = this._layout!.bindings[bindingIndex]; if (!info) { return; } if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - if (this._samplers$[descriptorIndex + index] !== sampler) { - this._samplers$[descriptorIndex + index] = sampler; - this._isDirty$ = true; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + if (this._samplers[descriptorIndex + index] !== sampler) { + this._samplers[descriptorIndex + index] = sampler; + this._isDirty = true; } } } @@ -97,13 +97,13 @@ export abstract class DescriptorSet extends GFXObject { * @param texture The texture to be bound. */ public bindTexture (binding: number, texture: Texture, index = 0, flags = AccessFlagBit.NONE): void { - const bindingIndex = this._layout$!.bindingIndices[binding]; - const info = this._layout$!.bindings[bindingIndex]; if (!info) { return; } + const bindingIndex = this._layout!.bindingIndices[binding]; + const info = this._layout!.bindings[bindingIndex]; if (!info) { return; } if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - if (this._textures$[descriptorIndex + index] !== texture) { - this._textures$[descriptorIndex + index] = texture; - this._isDirty$ = true; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + if (this._textures[descriptorIndex + index] !== texture) { + this._textures[descriptorIndex + index] = texture; + this._isDirty = true; } } } @@ -114,8 +114,8 @@ export abstract class DescriptorSet extends GFXObject { * @param binding The target binding. */ public getBuffer (binding: number, index = 0): Buffer { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - return this._buffers$[descriptorIndex + index]; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + return this._buffers[descriptorIndex + index]; } /** @@ -124,8 +124,8 @@ export abstract class DescriptorSet extends GFXObject { * @param binding The target binding. */ public getSampler (binding: number, index = 0): Sampler { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - return this._samplers$[descriptorIndex + index]; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + return this._samplers[descriptorIndex + index]; } /** @@ -134,7 +134,7 @@ export abstract class DescriptorSet extends GFXObject { * @param binding The target binding. */ public getTexture (binding: number, index = 0): Texture { - const descriptorIndex = this._layout$!.descriptorIndices[binding]; - return this._textures$[descriptorIndex + index]; + const descriptorIndex = this._layout!.descriptorIndices[binding]; + return this._textures[descriptorIndex + index]; } } diff --git a/cocos/gfx/base/device.ts b/cocos/gfx/base/device.ts index 21f15b34ce4..b0d87c2c26c 100644 --- a/cocos/gfx/base/device.ts +++ b/cocos/gfx/base/device.ts @@ -58,7 +58,7 @@ export abstract class Device { * @zh 当前 GFX 使用的渲染 API。 */ get gfxAPI (): API { - return this._gfxAPI$; + return this._gfxAPI; } /** @@ -66,7 +66,7 @@ export abstract class Device { * @zh GFX 默认队列。 */ get queue (): Queue { - return this._queue$ as Queue; + return this._queue as Queue; } /** @@ -74,7 +74,7 @@ export abstract class Device { * @zh GFX 默认命令缓冲。 */ get commandBuffer (): CommandBuffer { - return this._cmdBuff$ as CommandBuffer; + return this._cmdBuff as CommandBuffer; } /** @@ -82,7 +82,7 @@ export abstract class Device { * @zh 当前使用的swapchain的格式。 */ get swapchainFormat (): Format { - return this._swapchainFormat$; + return this._swapchainFormat; } /** @@ -90,7 +90,7 @@ export abstract class Device { * @zh 渲染器描述。 */ get renderer (): string { - return this._renderer$; + return this._renderer; } /** @@ -98,7 +98,7 @@ export abstract class Device { * @zh 厂商描述。 */ get vendor (): string { - return this._vendor$; + return this._vendor; } /** @@ -106,7 +106,7 @@ export abstract class Device { * @zh 绘制调用次数。 */ get numDrawCalls (): number { - return this._numDrawCalls$; + return this._numDrawCalls; } /** @@ -114,7 +114,7 @@ export abstract class Device { * @zh 绘制 Instance 数量。 */ get numInstances (): number { - return this._numInstances$; + return this._numInstances; } /** @@ -122,7 +122,7 @@ export abstract class Device { * @zh 渲染三角形数量。 */ get numTris (): number { - return this._numTris$; + return this._numTris; } /** @@ -130,7 +130,7 @@ export abstract class Device { * @zh 内存状态。 */ get memoryStatus (): MemoryStatus { - return this._memoryStatus$; + return this._memoryStatus; } /** @@ -138,7 +138,7 @@ export abstract class Device { * @zh 当前设备能力数据。 */ get capabilities (): DeviceCaps { - return this._caps$; + return this._caps; } /** @@ -146,27 +146,27 @@ export abstract class Device { * @zh 当前设备的绑定槽位映射关系。 */ get bindingMappingInfo (): BindingMappingInfo { - return this._bindingMappingInfo$; + return this._bindingMappingInfo; } - protected _gfxAPI$ = API.UNKNOWN; - protected _renderer$ = ''; - protected _vendor$ = ''; - protected _features$ = new Array(Feature.COUNT); - protected _formatFeatures$ = new Array(Format.COUNT); - protected _queue$: Queue | null = null; - protected _cmdBuff$: CommandBuffer | null = null; - protected _numDrawCalls$ = 0; - protected _numInstances$ = 0; - protected _numTris$ = 0; - protected _memoryStatus$ = new MemoryStatus(); - protected _caps$ = new DeviceCaps(); - protected _bindingMappingInfo$: BindingMappingInfo = new BindingMappingInfo(); - protected _samplers$ = new Map(); - protected _generalBarrierss$ = new Map(); - protected _textureBarriers$ = new Map(); - protected _bufferBarriers$ = new Map(); - protected _swapchainFormat$ = Format.RGBA8; + protected _gfxAPI = API.UNKNOWN; + protected _renderer = ''; + protected _vendor = ''; + protected _features = new Array(Feature.COUNT); + protected _formatFeatures = new Array(Format.COUNT); + protected _queue: Queue | null = null; + protected _cmdBuff: CommandBuffer | null = null; + protected _numDrawCalls = 0; + protected _numInstances = 0; + protected _numTris = 0; + protected _memoryStatus = new MemoryStatus(); + protected _caps = new DeviceCaps(); + protected _bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(); + protected _samplers = new Map(); + protected _generalBarrierss = new Map(); + protected _textureBarriers = new Map(); + protected _bufferBarriers = new Map(); + protected _swapchainFormat = Format.RGBA8; public static canvas: HTMLCanvasElement; // Hack for WebGL device initialization process @@ -350,7 +350,7 @@ export abstract class Device { * @param feature The GFX feature to be queried. */ public hasFeature (feature: Feature): boolean { - return this._features$[feature]; + return this._features[feature]; } /** @@ -359,7 +359,7 @@ export abstract class Device { * @param format The GFX format to be queried. */ public getFormatFeatures (format: Format): FormatFeature { - return this._formatFeatures$[format]; + return this._formatFeatures[format]; } /** @@ -384,10 +384,10 @@ export abstract class Device { } export class DefaultResource { - private _texture2D$: Texture | null = null; - private _texture3D$: Texture | null = null; - private _textureCube$: Texture | null = null; - private _texture2DArray$: Texture | null = null; + private _texture2D: Texture | null = null; + private _texture3D: Texture | null = null; + private _textureCube: Texture | null = null; + private _texture2DArray: Texture | null = null; constructor (device: Device) { const capabilities = device.capabilities; @@ -396,7 +396,7 @@ export class DefaultResource { const buffer = new Uint8Array(bufferSize); buffer.fill(255); if (capabilities.maxTextureSize >= 2) { - this._texture2D$ = device.createTexture(new TextureInfo( + this._texture2D = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.STORAGE | TextureUsageBit.SAMPLED, Format.RGBA8, @@ -405,10 +405,10 @@ export class DefaultResource { TextureFlagBit.NONE, )); const copyRegion = new BufferTextureCopy(0, 0, 0, new Offset(0, 0, 0), new Extent(2, 2, 1)); - device.copyBuffersToTexture([buffer], this._texture2D$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._texture2D, [copyRegion]); } if (capabilities.maxTextureSize >= 2) { - this._textureCube$ = device.createTexture(new TextureInfo( + this._textureCube = device.createTexture(new TextureInfo( TextureType.CUBE, TextureUsageBit.STORAGE | TextureUsageBit.SAMPLED, Format.RGBA8, @@ -418,20 +418,20 @@ export class DefaultResource { 6, )); const copyRegion = new BufferTextureCopy(0, 0, 0, new Offset(0, 0, 0), new Extent(2, 2, 1)); - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 1; - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 2; - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 3; - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 4; - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 5; - device.copyBuffersToTexture([buffer], this._textureCube$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._textureCube, [copyRegion]); } if (capabilities.max3DTextureSize >= 2) { - this._texture3D$ = device.createTexture(new TextureInfo( + this._texture3D = device.createTexture(new TextureInfo( TextureType.TEX3D, TextureUsageBit.STORAGE | TextureUsageBit.SAMPLED, Format.RGBA8, @@ -444,10 +444,10 @@ export class DefaultResource { 2, )); const copyRegion = new BufferTextureCopy(0, 0, 0, new Offset(0, 0, 0), new Extent(2, 2, 2), new TextureSubresLayers(0, 0, 1)); - device.copyBuffersToTexture([buffer], this._texture3D$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._texture3D, [copyRegion]); } if (capabilities.maxArrayTextureLayers >= 2) { - this._texture2DArray$ = device.createTexture(new TextureInfo( + this._texture2DArray = device.createTexture(new TextureInfo( TextureType.TEX2D_ARRAY, TextureUsageBit.STORAGE | TextureUsageBit.SAMPLED, Format.RGBA8, @@ -457,18 +457,18 @@ export class DefaultResource { 2, )); const copyRegion = new BufferTextureCopy(0, 0, 0, new Offset(0, 0, 0), new Extent(2, 2, 1), new TextureSubresLayers(0, 0, 1)); - device.copyBuffersToTexture([buffer], this._texture2DArray$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._texture2DArray, [copyRegion]); copyRegion.texSubres.baseArrayLayer = 1; - device.copyBuffersToTexture([buffer], this._texture2DArray$, [copyRegion]); + device.copyBuffersToTexture([buffer], this._texture2DArray, [copyRegion]); } } public getTexture (type: TextureType): Texture | null { switch (type) { - case TextureType.TEX2D: return this._texture2D$; - case TextureType.TEX3D: return this._texture3D$; - case TextureType.CUBE: return this._textureCube$; - case TextureType.TEX2D_ARRAY: return this._texture2DArray$; + case TextureType.TEX2D: return this._texture2D; + case TextureType.TEX3D: return this._texture3D; + case TextureType.CUBE: return this._textureCube; + case TextureType.TEX2D_ARRAY: return this._texture2DArray; default: return null; } } diff --git a/cocos/gfx/base/framebuffer.ts b/cocos/gfx/base/framebuffer.ts index e4d622c0ed3..fa6f2c2e99e 100644 --- a/cocos/gfx/base/framebuffer.ts +++ b/cocos/gfx/base/framebuffer.ts @@ -36,7 +36,7 @@ export abstract class Framebuffer extends GFXObject { * @zh GFX 渲染过程。 */ public get renderPass (): RenderPass { - return this._renderPass$!; + return this._renderPass!; } /** @@ -44,7 +44,7 @@ export abstract class Framebuffer extends GFXObject { * @zh 颜色纹理视图数组。 */ public get colorTextures (): (Texture | null)[] { - return this._colorTextures$; + return this._colorTextures; } /** @@ -52,36 +52,36 @@ export abstract class Framebuffer extends GFXObject { * @zh 深度模板纹理视图。 */ public get depthStencilTexture (): Texture | null { - return this._depthStencilTexture$; + return this._depthStencilTexture; } public get width (): number { if (this.colorTextures.length > 0) { - return this.colorTextures[0]?.width ?? this._width$; + return this.colorTextures[0]?.width ?? this._width; } else if (this.depthStencilTexture) { return this.depthStencilTexture.width; } - return this._width$; + return this._width; } public get height (): number { if (this.colorTextures.length > 0) { - return this.colorTextures[0]?.height ?? this._height$; + return this.colorTextures[0]?.height ?? this._height; } else if (this.depthStencilTexture) { return this.depthStencilTexture.height; } - return this._height$; + return this._height; } public get needRebuild (): boolean { return false; } - protected _renderPass$: RenderPass | null = null; - protected _colorTextures$: (Texture | null)[] = []; - protected _depthStencilTexture$: Texture | null = null; - protected _width$: number = 0; - protected _height$: number = 0; + protected _renderPass: RenderPass | null = null; + protected _colorTextures: (Texture | null)[] = []; + protected _depthStencilTexture: Texture | null = null; + protected _width: number = 0; + protected _height: number = 0; constructor () { super(ObjectType.FRAMEBUFFER); diff --git a/cocos/gfx/base/input-assembler.ts b/cocos/gfx/base/input-assembler.ts index c435d8ae9bc..890b8b96477 100644 --- a/cocos/gfx/base/input-assembler.ts +++ b/cocos/gfx/base/input-assembler.ts @@ -36,7 +36,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 顶点属性数组。 */ get attributes (): Attribute[] { - return this._attributes$; + return this._attributes; } /** @@ -44,7 +44,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 顶点缓冲数组。 */ get vertexBuffers (): Buffer[] { - return this._vertexBuffers$; + return this._vertexBuffers; } /** @@ -52,7 +52,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 索引缓冲。 */ get indexBuffer (): Buffer | null { - return this._indexBuffer$; + return this._indexBuffer; } /** @@ -60,7 +60,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 间接绘制缓冲。 */ get indirectBuffer (): Buffer | null { - return this._indirectBuffer$; + return this._indirectBuffer; } /** @@ -68,7 +68,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 获取顶点属性数组的哈希值。 */ get attributesHash (): number { - return this._attributesHash$; + return this._attributesHash; } /** @@ -76,10 +76,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 顶点数量。 */ set vertexCount (count: number) { - this._drawInfo$.vertexCount = count; + this._drawInfo.vertexCount = count; } get vertexCount (): number { - return this._drawInfo$.vertexCount; + return this._drawInfo.vertexCount; } /** @@ -87,10 +87,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 起始顶点。 */ set firstVertex (first: number) { - this._drawInfo$.firstVertex = first; + this._drawInfo.firstVertex = first; } get firstVertex (): number { - return this._drawInfo$.firstVertex; + return this._drawInfo.firstVertex; } /** @@ -98,10 +98,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 索引数量。 */ set indexCount (count: number) { - this._drawInfo$.indexCount = count; + this._drawInfo.indexCount = count; } get indexCount (): number { - return this._drawInfo$.indexCount; + return this._drawInfo.indexCount; } /** @@ -109,10 +109,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 起始索引。 */ set firstIndex (first: number) { - this._drawInfo$.firstIndex = first; + this._drawInfo.firstIndex = first; } get firstIndex (): number { - return this._drawInfo$.firstIndex; + return this._drawInfo.firstIndex; } /** @@ -120,10 +120,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 顶点偏移量。 */ set vertexOffset (offset: number) { - this._drawInfo$.vertexOffset = offset; + this._drawInfo.vertexOffset = offset; } get vertexOffset (): number { - return this._drawInfo$.vertexOffset; + return this._drawInfo.vertexOffset; } /** @@ -131,10 +131,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 实例数量。 */ set instanceCount (count: number) { - this._drawInfo$.instanceCount = count; + this._drawInfo.instanceCount = count; } get instanceCount (): number { - return this._drawInfo$.instanceCount; + return this._drawInfo.instanceCount; } /** @@ -142,10 +142,10 @@ export abstract class InputAssembler extends GFXObject { * @zh 起始实例。 */ set firstInstance (first: number) { - this._drawInfo$.firstInstance = first; + this._drawInfo.firstInstance = first; } get firstInstance (): number { - return this._drawInfo$.firstInstance; + return this._drawInfo.firstInstance; } /** @@ -153,7 +153,7 @@ export abstract class InputAssembler extends GFXObject { * @zh 设置渲染范围 */ set drawInfo (info: DrawInfo) { - this._drawInfo$ = info; + this._drawInfo = info; } /** @@ -161,17 +161,17 @@ export abstract class InputAssembler extends GFXObject { * @zh 获取渲染范围 */ get drawInfo (): DrawInfo { - return this._drawInfo$; + return this._drawInfo; } - protected _attributes$: Attribute[] = []; - protected _attributesHash$ = 0; + protected _attributes: Attribute[] = []; + protected _attributesHash = 0; - protected _vertexBuffers$: Buffer[] = []; - protected _indexBuffer$: Buffer | null = null; - protected _indirectBuffer$: Buffer | null = null; + protected _vertexBuffers: Buffer[] = []; + protected _indexBuffer: Buffer | null = null; + protected _indirectBuffer: Buffer | null = null; - protected _drawInfo$ = new DrawInfo(); + protected _drawInfo = new DrawInfo(); constructor () { super(ObjectType.INPUT_ASSEMBLER); @@ -183,14 +183,14 @@ export abstract class InputAssembler extends GFXObject { * @param stream The stream index of the vertex buffer. */ public getVertexBuffer (stream = 0): Buffer | null { - if (stream < this._vertexBuffers$.length) { - return this._vertexBuffers$[stream]; + if (stream < this._vertexBuffers.length) { + return this._vertexBuffers[stream]; } else { return null; } } - protected computeAttributesHash$ (): number { + protected computeAttributesHash (): number { let res = 'attrs'; for (let i = 0; i < this.attributes.length; ++i) { const at = this.attributes[i]; diff --git a/cocos/gfx/base/pipeline-layout.ts b/cocos/gfx/base/pipeline-layout.ts index cfc649c399b..677c4ac96d1 100644 --- a/cocos/gfx/base/pipeline-layout.ts +++ b/cocos/gfx/base/pipeline-layout.ts @@ -31,10 +31,10 @@ import { GFXObject, ObjectType, PipelineLayoutInfo } from './define'; */ export abstract class PipelineLayout extends GFXObject { get setLayouts (): DescriptorSetLayout[] { - return this._setLayouts$; + return this._setLayouts; } - protected _setLayouts$: DescriptorSetLayout[] = []; + protected _setLayouts: DescriptorSetLayout[] = []; constructor () { super(ObjectType.PIPELINE_LAYOUT); diff --git a/cocos/gfx/base/pipeline-state.ts b/cocos/gfx/base/pipeline-state.ts index 9dbca2e0528..a7f5848b05a 100644 --- a/cocos/gfx/base/pipeline-state.ts +++ b/cocos/gfx/base/pipeline-state.ts @@ -65,7 +65,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 着色器。 */ get shader (): Shader { - return this._shader$!; + return this._shader!; } /** @@ -73,7 +73,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 管线布局。 */ get pipelineLayout (): PipelineLayout { - return this._pipelineLayout$!; + return this._pipelineLayout!; } /** @@ -81,7 +81,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 图元模式。 */ get primitive (): PrimitiveMode { - return this._primitive$; + return this._primitive; } /** @@ -89,7 +89,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 光栅化状态。 */ get rasterizerState (): RasterizerState { - return this._rs$; + return this._rs; } /** @@ -97,7 +97,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 深度模板状态。 */ get depthStencilState (): DepthStencilState { - return this._dss$; + return this._dss; } /** @@ -105,7 +105,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 混合状态。 */ get blendState (): BlendState { - return this._bs$; + return this._bs; } /** @@ -113,7 +113,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 输入状态。 */ get inputState (): InputState { - return this._is$ as InputState; + return this._is as InputState; } /** @@ -121,7 +121,7 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 动态状态数组。 */ get dynamicStates (): DynamicStateFlags { - return this._dynamicStates$; + return this._dynamicStates; } /** @@ -129,18 +129,18 @@ export abstract class PipelineState extends GFXObject { * @zh GFX 渲染过程。 */ get renderPass (): RenderPass { - return this._renderPass$ as RenderPass; + return this._renderPass as RenderPass; } - protected _shader$: Shader | null = null; - protected _pipelineLayout$: PipelineLayout | null = null; - protected _primitive$: PrimitiveMode = PrimitiveMode.TRIANGLE_LIST; - protected _is$: InputState | null = null; - protected _rs$: RasterizerState = new RasterizerState(); - protected _dss$: DepthStencilState = new DepthStencilState(); - protected _bs$: BlendState = new BlendState(); - protected _dynamicStates$: DynamicStateFlags = DynamicStateFlagBit.NONE; - protected _renderPass$: RenderPass | null = null; + protected _shader: Shader | null = null; + protected _pipelineLayout: PipelineLayout | null = null; + protected _primitive: PrimitiveMode = PrimitiveMode.TRIANGLE_LIST; + protected _is: InputState | null = null; + protected _rs: RasterizerState = new RasterizerState(); + protected _dss: DepthStencilState = new DepthStencilState(); + protected _bs: BlendState = new BlendState(); + protected _dynamicStates: DynamicStateFlags = DynamicStateFlagBit.NONE; + protected _renderPass: RenderPass | null = null; constructor () { super(ObjectType.PIPELINE_STATE); diff --git a/cocos/gfx/base/pipeline-sub-state.jsb.ts b/cocos/gfx/base/pipeline-sub-state.jsb.ts index e53d035f168..4ab1af2e558 100644 --- a/cocos/gfx/base/pipeline-sub-state.jsb.ts +++ b/cocos/gfx/base/pipeline-sub-state.jsb.ts @@ -66,19 +66,19 @@ function watchArrayElementsField (self: S, list: T[], eleField: string, ca } export class RasterizerState { - protected _nativeObj$; - protected _isDiscard$: boolean = false; - protected _polygonMode$: PolygonMode = PolygonMode.FILL; - protected _shadeModel$: ShadeModel = ShadeModel.GOURAND; - protected _cullMode$: CullMode = CullMode.BACK; - protected _isFrontFaceCCW$: boolean = true; - protected _depthBiasEnabled$: boolean = false; - protected _depthBias$: number = 0; - protected _depthBiasClamp$: number = 0.0; - protected _depthBiasSlop$: number = 0.0; - protected _isDepthClip$: boolean = true; - protected _isMultisample$: boolean = false; - protected _lineWidth$: number = 1.0; + protected _nativeObj; + protected _isDiscard: boolean = false; + protected _polygonMode: PolygonMode = PolygonMode.FILL; + protected _shadeModel: ShadeModel = ShadeModel.GOURAND; + protected _cullMode: CullMode = CullMode.BACK; + protected _isFrontFaceCCW: boolean = true; + protected _depthBiasEnabled: boolean = false; + protected _depthBias: number = 0; + protected _depthBiasClamp: number = 0.0; + protected _depthBiasSlop: number = 0.0; + protected _isDepthClip: boolean = true; + protected _isMultisample: boolean = false; + protected _lineWidth: number = 1.0; constructor ( isDiscard: boolean = false, polygonMode: PolygonMode = PolygonMode.FILL, @@ -93,84 +93,84 @@ export class RasterizerState { isMultisample: boolean = false, lineWidth: number = 1.0, ) { - this._nativeObj$ = new gfx.RasterizerState(); + this._nativeObj = new gfx.RasterizerState(); this.assignProperties(isDiscard, polygonMode, shadeModel, cullMode, isFrontFaceCCW, depthBiasEnabled, depthBias, depthBiasClamp, depthBiasSlop, isDepthClip, isMultisample, lineWidth); } get native () { - return this._nativeObj$; + return this._nativeObj; } get isDiscard (): boolean { - return this._isDiscard$; + return this._isDiscard; } set isDiscard (val: boolean) { - this._isDiscard$ = val; - this._nativeObj$.isDiscard = val; + this._isDiscard = val; + this._nativeObj.isDiscard = val; } - get polygonMode (): PolygonMode { return this._polygonMode$; } + get polygonMode (): PolygonMode { return this._polygonMode; } set polygonMode (val: PolygonMode) { - this._polygonMode$ = val; - this._nativeObj$.polygonMode = val; + this._polygonMode = val; + this._nativeObj.polygonMode = val; } - get shadeModel (): ShadeModel { return this._shadeModel$; } + get shadeModel (): ShadeModel { return this._shadeModel; } set shadeModel (val: ShadeModel) { - this._shadeModel$ = val; - this._nativeObj$.shadeModel = val; + this._shadeModel = val; + this._nativeObj.shadeModel = val; } - get cullMode (): CullMode { return this._cullMode$; } + get cullMode (): CullMode { return this._cullMode; } set cullMode (val: CullMode) { - this._cullMode$ = val; - this._nativeObj$.cullMode = val; + this._cullMode = val; + this._nativeObj.cullMode = val; } get isFrontFaceCCW (): boolean { - return this._isFrontFaceCCW$; + return this._isFrontFaceCCW; } set isFrontFaceCCW (val: boolean) { - this._isFrontFaceCCW$ = val; - this._nativeObj$.isFrontFaceCCW = val; + this._isFrontFaceCCW = val; + this._nativeObj.isFrontFaceCCW = val; } get depthBiasEnabled (): boolean { - return this._depthBiasEnabled$; + return this._depthBiasEnabled; } set depthBiasEnabled (val: boolean) { - this._depthBiasEnabled$ = val; - this._nativeObj$.depthBiasEnabled = val; + this._depthBiasEnabled = val; + this._nativeObj.depthBiasEnabled = val; } - get depthBias (): number { return this._depthBias$; } + get depthBias (): number { return this._depthBias; } set depthBias (val: number) { - this._depthBias$ = val; - this._nativeObj$.depthBias = val; + this._depthBias = val; + this._nativeObj.depthBias = val; } - get depthBiasClamp (): number { return this._depthBiasClamp$; } + get depthBiasClamp (): number { return this._depthBiasClamp; } set depthBiasClamp (val: number) { - this._depthBiasClamp$ = val; - this._nativeObj$.depthBiasClamp = val; + this._depthBiasClamp = val; + this._nativeObj.depthBiasClamp = val; } - get depthBiasSlop (): number { return this._depthBiasSlop$; } + get depthBiasSlop (): number { return this._depthBiasSlop; } set depthBiasSlop (val: number) { - this._depthBiasSlop$ = val; - this._nativeObj$.depthBiasSlop = val; + this._depthBiasSlop = val; + this._nativeObj.depthBiasSlop = val; } get isDepthClip (): boolean { - return this._isDepthClip$; + return this._isDepthClip; } set isDepthClip (val: boolean) { - this._isDepthClip$ = val; - this._nativeObj$.isDepthClip = val; + this._isDepthClip = val; + this._nativeObj.isDepthClip = val; } get isMultisample (): boolean { - return this._isMultisample$; + return this._isMultisample; } set isMultisample (val: boolean) { - this._isMultisample$ = val; - this._nativeObj$.isMultisample = val; + this._isMultisample = val; + this._nativeObj.isMultisample = val; } - get lineWidth (): number { return this._lineWidth$; } + get lineWidth (): number { return this._lineWidth; } set lineWidth (val: number) { - this._lineWidth$ = val; - this._nativeObj$.lineWidth = val; + this._lineWidth = val; + this._nativeObj.lineWidth = val; } public reset () { @@ -185,7 +185,7 @@ export class RasterizerState { } public destroy () { - this._nativeObj$ = null; + this._nativeObj = null; } private assignProperties ( @@ -222,26 +222,26 @@ export class RasterizerState { * @zh GFX 深度模板状态。 */ export class DepthStencilState { - protected _nativeObj$; - protected _depthTest$: boolean = true; - protected _depthWrite$: boolean = true; - protected _depthFunc$: ComparisonFunc = ComparisonFunc.LESS; - protected _stencilTestFront$: boolean = false; - protected _stencilFuncFront$: ComparisonFunc = ComparisonFunc.ALWAYS; - protected _stencilReadMaskFront$: number = 0xffff; - protected _stencilWriteMaskFront$: number = 0xffff; - protected _stencilFailOpFront$: StencilOp = StencilOp.KEEP; - protected _stencilZFailOpFront$: StencilOp = StencilOp.KEEP; - protected _stencilPassOpFront$: StencilOp = StencilOp.KEEP; - protected _stencilRefFront$: number = 1; - protected _stencilTestBack$: boolean = false; - protected _stencilFuncBack$: ComparisonFunc = ComparisonFunc.ALWAYS; - protected _stencilReadMaskBack$: number = 0xffff; - protected _stencilWriteMaskBack$: number = 0xffff; - protected _stencilFailOpBack$: StencilOp = StencilOp.KEEP; - protected _stencilZFailOpBack$: StencilOp = StencilOp.KEEP; - protected _stencilPassOpBack$: StencilOp = StencilOp.KEEP; - protected _stencilRefBack$: number = 1; + protected _nativeObj; + protected _depthTest: boolean = true; + protected _depthWrite: boolean = true; + protected _depthFunc: ComparisonFunc = ComparisonFunc.LESS; + protected _stencilTestFront: boolean = false; + protected _stencilFuncFront: ComparisonFunc = ComparisonFunc.ALWAYS; + protected _stencilReadMaskFront: number = 0xffff; + protected _stencilWriteMaskFront: number = 0xffff; + protected _stencilFailOpFront: StencilOp = StencilOp.KEEP; + protected _stencilZFailOpFront: StencilOp = StencilOp.KEEP; + protected _stencilPassOpFront: StencilOp = StencilOp.KEEP; + protected _stencilRefFront: number = 1; + protected _stencilTestBack: boolean = false; + protected _stencilFuncBack: ComparisonFunc = ComparisonFunc.ALWAYS; + protected _stencilReadMaskBack: number = 0xffff; + protected _stencilWriteMaskBack: number = 0xffff; + protected _stencilFailOpBack: StencilOp = StencilOp.KEEP; + protected _stencilZFailOpBack: StencilOp = StencilOp.KEEP; + protected _stencilPassOpBack: StencilOp = StencilOp.KEEP; + protected _stencilRefBack: number = 1; constructor ( depthTest: boolean = true, depthWrite: boolean = true, @@ -263,7 +263,7 @@ export class DepthStencilState { stencilPassOpBack: StencilOp = StencilOp.KEEP, stencilRefBack: number = 1, ) { - this._nativeObj$ = new gfx.DepthStencilState(); + this._nativeObj = new gfx.DepthStencilState(); this.assignProperties(depthTest, depthWrite, depthFunc, stencilTestFront, stencilFuncFront, stencilReadMaskFront, stencilWriteMaskFront, stencilFailOpFront, stencilZFailOpFront, stencilPassOpFront, stencilRefFront, stencilTestBack, stencilFuncBack, stencilReadMaskBack, stencilWriteMaskBack, stencilFailOpBack, @@ -271,111 +271,111 @@ export class DepthStencilState { } get native () { - return this._nativeObj$; + return this._nativeObj; } get depthTest (): boolean { - return this._depthTest$; + return this._depthTest; } set depthTest (val: boolean) { - this._depthTest$ = val; - this._nativeObj$.depthTest = val; + this._depthTest = val; + this._nativeObj.depthTest = val; } get depthWrite (): boolean { - return this._depthWrite$; + return this._depthWrite; } set depthWrite (val: boolean) { - this._depthWrite$ = val; - this._nativeObj$.depthWrite = val; + this._depthWrite = val; + this._nativeObj.depthWrite = val; } - get depthFunc (): ComparisonFunc { return this._depthFunc$; } + get depthFunc (): ComparisonFunc { return this._depthFunc; } set depthFunc (val: ComparisonFunc) { - this._depthFunc$ = val; - this._nativeObj$.depthFunc = val; + this._depthFunc = val; + this._nativeObj.depthFunc = val; } get stencilTestFront (): boolean { - return this._stencilTestFront$; + return this._stencilTestFront; } set stencilTestFront (val: boolean) { - this._stencilTestFront$ = val; - this._nativeObj$.stencilTestFront = val; + this._stencilTestFront = val; + this._nativeObj.stencilTestFront = val; } - get stencilFuncFront (): ComparisonFunc { return this._stencilFuncFront$; } + get stencilFuncFront (): ComparisonFunc { return this._stencilFuncFront; } set stencilFuncFront (val: ComparisonFunc) { - this._stencilFuncFront$ = val; - this._nativeObj$.stencilFuncFront = val; + this._stencilFuncFront = val; + this._nativeObj.stencilFuncFront = val; } - get stencilReadMaskFront (): number { return this._stencilReadMaskFront$; } + get stencilReadMaskFront (): number { return this._stencilReadMaskFront; } set stencilReadMaskFront (val: number) { - this._stencilReadMaskFront$ = val; - this._nativeObj$.stencilReadMaskFront = val; + this._stencilReadMaskFront = val; + this._nativeObj.stencilReadMaskFront = val; } - get stencilWriteMaskFront (): number { return this._stencilWriteMaskFront$; } + get stencilWriteMaskFront (): number { return this._stencilWriteMaskFront; } set stencilWriteMaskFront (val: number) { - this._stencilWriteMaskFront$ = val; - this._nativeObj$.stencilWriteMaskFront = val; + this._stencilWriteMaskFront = val; + this._nativeObj.stencilWriteMaskFront = val; } - get stencilFailOpFront (): StencilOp { return this._stencilFailOpFront$; } + get stencilFailOpFront (): StencilOp { return this._stencilFailOpFront; } set stencilFailOpFront (val: StencilOp) { - this._stencilFailOpFront$ = val; - this._nativeObj$.stencilFailOpFront = val; + this._stencilFailOpFront = val; + this._nativeObj.stencilFailOpFront = val; } - get stencilZFailOpFront (): StencilOp { return this._stencilZFailOpFront$; } + get stencilZFailOpFront (): StencilOp { return this._stencilZFailOpFront; } set stencilZFailOpFront (val: StencilOp) { - this._stencilZFailOpFront$ = val; - this._nativeObj$.stencilZFailOpFront = val; + this._stencilZFailOpFront = val; + this._nativeObj.stencilZFailOpFront = val; } - get stencilPassOpFront (): StencilOp { return this._stencilPassOpFront$; } + get stencilPassOpFront (): StencilOp { return this._stencilPassOpFront; } set stencilPassOpFront (val: StencilOp) { - this._stencilPassOpFront$ = val; - this._nativeObj$.stencilPassOpFront = val; + this._stencilPassOpFront = val; + this._nativeObj.stencilPassOpFront = val; } - get stencilRefFront (): number { return this._stencilRefFront$; } + get stencilRefFront (): number { return this._stencilRefFront; } set stencilRefFront (val: number) { - this._stencilRefFront$ = val; - this._nativeObj$.stencilRefFront = val; + this._stencilRefFront = val; + this._nativeObj.stencilRefFront = val; } get stencilTestBack (): boolean { - return this._stencilTestBack$; + return this._stencilTestBack; } set stencilTestBack (val: boolean) { - this._stencilTestBack$ = val; - this._nativeObj$.stencilTestBack = val; + this._stencilTestBack = val; + this._nativeObj.stencilTestBack = val; } - get stencilFuncBack (): ComparisonFunc { return this._stencilFuncBack$; } + get stencilFuncBack (): ComparisonFunc { return this._stencilFuncBack; } set stencilFuncBack (val: ComparisonFunc) { - this._stencilFuncBack$ = val; - this._nativeObj$.stencilFuncBack = val; + this._stencilFuncBack = val; + this._nativeObj.stencilFuncBack = val; } - get stencilReadMaskBack (): number { return this._stencilReadMaskBack$; } + get stencilReadMaskBack (): number { return this._stencilReadMaskBack; } set stencilReadMaskBack (val: number) { - this._stencilReadMaskBack$ = val; - this._nativeObj$.stencilReadMaskBack = val; + this._stencilReadMaskBack = val; + this._nativeObj.stencilReadMaskBack = val; } - get stencilWriteMaskBack (): number { return this._stencilWriteMaskBack$; } + get stencilWriteMaskBack (): number { return this._stencilWriteMaskBack; } set stencilWriteMaskBack (val: number) { - this._stencilWriteMaskBack$ = val; - this._nativeObj$.stencilWriteMaskBack = val; + this._stencilWriteMaskBack = val; + this._nativeObj.stencilWriteMaskBack = val; } - get stencilFailOpBack (): StencilOp { return this._stencilFailOpBack$; } + get stencilFailOpBack (): StencilOp { return this._stencilFailOpBack; } set stencilFailOpBack (val: StencilOp) { - this._stencilFailOpBack$ = val; - this._nativeObj$.stencilFailOpBack = val; + this._stencilFailOpBack = val; + this._nativeObj.stencilFailOpBack = val; } - get stencilZFailOpBack (): StencilOp { return this._stencilZFailOpBack$; } + get stencilZFailOpBack (): StencilOp { return this._stencilZFailOpBack; } set stencilZFailOpBack (val: StencilOp) { - this._stencilZFailOpBack$ = val; - this._nativeObj$.stencilZFailOpBack = val; + this._stencilZFailOpBack = val; + this._nativeObj.stencilZFailOpBack = val; } - get stencilPassOpBack (): StencilOp { return this._stencilPassOpBack$; } + get stencilPassOpBack (): StencilOp { return this._stencilPassOpBack; } set stencilPassOpBack (val: StencilOp) { - this._stencilPassOpBack$ = val; - this._nativeObj$.stencilPassOpBack = val; + this._stencilPassOpBack = val; + this._nativeObj.stencilPassOpBack = val; } - get stencilRefBack (): number { return this._stencilRefBack$; } + get stencilRefBack (): number { return this._stencilRefBack; } set stencilRefBack (val: number) { - this._stencilRefBack$ = val; - this._nativeObj$.stencilRefBack = val; + this._stencilRefBack = val; + this._nativeObj.stencilRefBack = val; } public reset () { @@ -392,7 +392,7 @@ export class DepthStencilState { } public destroy () { - this._nativeObj$ = null; + this._nativeObj = null; } private assignProperties ( @@ -443,17 +443,17 @@ export class DepthStencilState { * @zh GFX 混合目标。 */ export class BlendTarget { - protected _nativeObj$; - protected _blend$: boolean = false; - protected _blendSrc$: BlendFactor = BlendFactor.ONE; - protected _blendDst$: BlendFactor = BlendFactor.ZERO; - protected _blendEq$: BlendOp = BlendOp.ADD; - protected _blendSrcAlpha$: BlendFactor = BlendFactor.ONE; - protected _blendDstAlpha$: BlendFactor = BlendFactor.ZERO; - protected _blendAlphaEq$: BlendOp = BlendOp.ADD; - protected _blendColorMask$: ColorMask = ColorMask.ALL; + protected _nativeObj; + protected _blend: boolean = false; + protected _blendSrc: BlendFactor = BlendFactor.ONE; + protected _blendDst: BlendFactor = BlendFactor.ZERO; + protected _blendEq: BlendOp = BlendOp.ADD; + protected _blendSrcAlpha: BlendFactor = BlendFactor.ONE; + protected _blendDstAlpha: BlendFactor = BlendFactor.ZERO; + protected _blendAlphaEq: BlendOp = BlendOp.ADD; + protected _blendColorMask: ColorMask = ColorMask.ALL; get native () { - return this._nativeObj$; + return this._nativeObj; } constructor ( @@ -466,52 +466,52 @@ export class BlendTarget { blendAlphaEq: BlendOp = BlendOp.ADD, blendColorMask: ColorMask = ColorMask.ALL, ) { - this._nativeObj$ = new gfx.BlendTarget(); + this._nativeObj = new gfx.BlendTarget(); this.assignProperties(blend, blendSrc, blendDst, blendEq, blendSrcAlpha, blendDstAlpha, blendAlphaEq, blendColorMask); } get blend (): boolean { - return this._blend$; + return this._blend; } set blend (val: boolean) { - this._blend$ = val; - this._nativeObj$.blend = val; + this._blend = val; + this._nativeObj.blend = val; } - get blendSrc (): BlendFactor { return this._blendSrc$; } + get blendSrc (): BlendFactor { return this._blendSrc; } set blendSrc (val: BlendFactor) { - this._blendSrc$ = val; - this._nativeObj$.blendSrc = val; + this._blendSrc = val; + this._nativeObj.blendSrc = val; } - get blendDst () { return this._blendDst$; } + get blendDst () { return this._blendDst; } set blendDst (val: BlendFactor) { - this._blendDst$ = val; - this._nativeObj$.blendDst = val; + this._blendDst = val; + this._nativeObj.blendDst = val; } - get blendEq (): BlendOp { return this._blendEq$; } + get blendEq (): BlendOp { return this._blendEq; } set blendEq (val: BlendOp) { - this._blendEq$ = val; - this._nativeObj$.blendEq = val; + this._blendEq = val; + this._nativeObj.blendEq = val; } - get blendSrcAlpha (): BlendFactor { return this._blendSrcAlpha$; } + get blendSrcAlpha (): BlendFactor { return this._blendSrcAlpha; } set blendSrcAlpha (val: BlendFactor) { - this._blendSrcAlpha$ = val; - this._nativeObj$.blendSrcAlpha = val; + this._blendSrcAlpha = val; + this._nativeObj.blendSrcAlpha = val; } - get blendDstAlpha (): BlendFactor { return this._blendDstAlpha$; } + get blendDstAlpha (): BlendFactor { return this._blendDstAlpha; } set blendDstAlpha (val: BlendFactor) { - this._blendDstAlpha$ = val; - this._nativeObj$.blendDstAlpha = val; + this._blendDstAlpha = val; + this._nativeObj.blendDstAlpha = val; } - get blendAlphaEq (): BlendOp { return this._blendAlphaEq$; } + get blendAlphaEq (): BlendOp { return this._blendAlphaEq; } set blendAlphaEq (val: BlendOp) { - this._blendAlphaEq$ = val; - this._nativeObj$.blendAlphaEq = val; + this._blendAlphaEq = val; + this._nativeObj.blendAlphaEq = val; } - get blendColorMask (): ColorMask { return this._blendColorMask$; } + get blendColorMask (): ColorMask { return this._blendColorMask; } set blendColorMask (val: ColorMask) { - this._blendColorMask$ = val; - this._nativeObj$.blendColorMask = val; + this._blendColorMask = val; + this._nativeObj.blendColorMask = val; } public reset () { @@ -520,7 +520,7 @@ export class BlendTarget { } public destroy () { - this._nativeObj$ = null; + this._nativeObj = null; } public assign (target: RecursivePartial) { @@ -555,9 +555,9 @@ export class BlendState { public targets!: BlendTarget[]; // NOTE: not initialize in constructor private _blendColor!: Color; - protected _nativeObj$; - protected _isA2C$: boolean = false; - protected _isIndepend$: boolean = false; + protected _nativeObj; + protected _isA2C: boolean = false; + protected _isIndepend: boolean = false; private _setTargets (targets: BlendTarget[]) { this.targets = targets; @@ -573,11 +573,11 @@ export class BlendState { private _syncTargetsToNativeObj (cachedFieldName: string) { const nativeTars = this.targets.map(target => { return target.native[cachedFieldName] || target.native; }); - this._nativeObj$.targets = nativeTars; + this._nativeObj.targets = nativeTars; } get native () { - return this._nativeObj$; + return this._nativeObj; } constructor ( @@ -586,7 +586,7 @@ export class BlendState { blendColor: Color = new Color(), targets: BlendTarget[] = [new BlendTarget()], ) { - this._nativeObj$ = new gfx.BlendState(); + this._nativeObj = new gfx.BlendState(); this._setTargets(targets); this.blendColor = blendColor; this.isA2C = isA2C; @@ -594,23 +594,23 @@ export class BlendState { } get isA2C (): boolean { - return this._isA2C$; + return this._isA2C; } set isA2C (val: boolean) { - this._isA2C$ = val; - this._nativeObj$.isA2C = val; + this._isA2C = val; + this._nativeObj.isA2C = val; } get isIndepend (): boolean { - return this._isIndepend$; + return this._isIndepend; } set isIndepend (val: boolean) { - this._isIndepend$ = val; - this._nativeObj$.isIndepend = val; + this._isIndepend = val; + this._nativeObj.isIndepend = val; } get blendColor (): Color { return this._blendColor; } set blendColor (color: Color) { this._blendColor = color; - this._nativeObj$.blendColor = color; + this._nativeObj.blendColor = color; } /** @@ -651,6 +651,6 @@ export class BlendState { } // NOTE: Type 'null' is not assignable to type 'BlendTarget[]'. this.targets = null as any; - this._nativeObj$ = null; + this._nativeObj = null; } } \ No newline at end of file diff --git a/cocos/gfx/base/queue.ts b/cocos/gfx/base/queue.ts index d03a00deab1..d80c02ed35a 100644 --- a/cocos/gfx/base/queue.ts +++ b/cocos/gfx/base/queue.ts @@ -35,10 +35,10 @@ export abstract class Queue extends GFXObject { * @zh 队列类型。 */ get type (): number { - return this._type$; + return this._type; } - protected _type$: QueueType = QueueType.GRAPHICS; + protected _type: QueueType = QueueType.GRAPHICS; constructor () { super(ObjectType.QUEUE); diff --git a/cocos/gfx/base/render-pass.ts b/cocos/gfx/base/render-pass.ts index f215f04c376..567a4061c0d 100644 --- a/cocos/gfx/base/render-pass.ts +++ b/cocos/gfx/base/render-pass.ts @@ -37,15 +37,15 @@ import { * @zh GFX 渲染过程。 */ export abstract class RenderPass extends GFXObject { - protected _colorInfos$: ColorAttachment[] = []; - protected _depthStencilInfo$: DepthStencilAttachment | null = null; - protected _subpasses$: SubpassInfo[] = []; - protected _hash$ = 0; + protected _colorInfos: ColorAttachment[] = []; + protected _depthStencilInfo: DepthStencilAttachment | null = null; + protected _subpasses: SubpassInfo[] = []; + protected _hash = 0; - get colorAttachments (): Readonly { return this._colorInfos$; } - get depthStencilAttachment (): Readonly | null { return this._depthStencilInfo$; } - get subPasses (): Readonly { return this._subpasses$; } - get hash (): number { return this._hash$; } + get colorAttachments (): Readonly { return this._colorInfos; } + get depthStencilAttachment (): Readonly | null { return this._depthStencilInfo; } + get subPasses (): Readonly { return this._subpasses; } + get hash (): number { return this._hash; } constructor () { super(ObjectType.RENDER_PASS); @@ -54,35 +54,35 @@ export abstract class RenderPass extends GFXObject { // Based on render pass compatibility protected computeHash (): number { let res = ''; - if (this._subpasses$.length) { - for (let i = 0; i < this._subpasses$.length; ++i) { - const subpass = this._subpasses$[i]; + if (this._subpasses.length) { + for (let i = 0; i < this._subpasses.length; ++i) { + const subpass = this._subpasses[i]; if (subpass.inputs.length) { res += 'ia'; for (let j = 0; j < subpass.inputs.length; ++j) { - const ia = this._colorInfos$[subpass.inputs[j]]; + const ia = this._colorInfos[subpass.inputs[j]]; res += `,${ia.format},${ia.sampleCount}`; } } if (subpass.colors.length) { res += 'ca'; for (let j = 0; j < subpass.inputs.length; ++j) { - const ca = this._colorInfos$[subpass.inputs[j]]; + const ca = this._colorInfos[subpass.inputs[j]]; res += `,${ca.format},${ca.sampleCount}`; } } if (subpass.depthStencil >= 0) { - const ds = this._colorInfos$[subpass.depthStencil]; + const ds = this._colorInfos[subpass.depthStencil]; res += `ds,${ds.format},${ds.sampleCount}`; } } } else { res += 'ca'; - for (let i = 0; i < this._colorInfos$.length; ++i) { - const ca = this._colorInfos$[i]; + for (let i = 0; i < this._colorInfos.length; ++i) { + const ca = this._colorInfos[i]; res += `,${ca.format},${ca.sampleCount}`; } - const ds = this._depthStencilInfo$; + const ds = this._depthStencilInfo; if (ds) { res += `ds,${ds.format},${ds.sampleCount}`; } diff --git a/cocos/gfx/base/shader.ts b/cocos/gfx/base/shader.ts index 03f28c9c6b1..23554d40d22 100644 --- a/cocos/gfx/base/shader.ts +++ b/cocos/gfx/base/shader.ts @@ -30,30 +30,30 @@ import { GFXObject, ObjectType, ShaderInfo, ShaderStage, UniformBlock, UniformSa */ export abstract class Shader extends GFXObject { get name (): string { - return this._name$; + return this._name; } get attributes (): Attribute[] { - return this._attributes$; + return this._attributes; } get blocks (): UniformBlock[] { - return this._blocks$; + return this._blocks; } get samplers (): UniformSampler[] { - return this._samplers$; + return this._samplers; } get stages (): ShaderStage[] { - return this._stages$; + return this._stages; } - protected _name$ = ''; - protected _stages$: ShaderStage[] = []; - protected _attributes$: Attribute[] = []; - protected _blocks$: UniformBlock[] = []; - protected _samplers$: UniformSampler[] = []; + protected _name = ''; + protected _stages: ShaderStage[] = []; + protected _attributes: Attribute[] = []; + protected _blocks: UniformBlock[] = []; + protected _samplers: UniformSampler[] = []; constructor () { super(ObjectType.SHADER); diff --git a/cocos/gfx/base/states/buffer-barrier.ts b/cocos/gfx/base/states/buffer-barrier.ts index 43475b3074c..9e236c2ee1c 100644 --- a/cocos/gfx/base/states/buffer-barrier.ts +++ b/cocos/gfx/base/states/buffer-barrier.ts @@ -30,16 +30,16 @@ import { GFXObject, ObjectType, BufferBarrierInfo } from '../define'; * @zh GFX buffer内存屏障。 */ export class BufferBarrier extends GFXObject { - get info (): Readonly { return this._info$; } - get hash (): number { return this._hash$; } + get info (): Readonly { return this._info; } + get hash (): number { return this._hash; } - protected _info$: BufferBarrierInfo = new BufferBarrierInfo(); - protected _hash$ = 0; + protected _info: BufferBarrierInfo = new BufferBarrierInfo(); + protected _hash = 0; constructor (info: Readonly, hash: number) { super(ObjectType.BUFFER_BARRIER); - this._info$.copy(info); - this._hash$ = hash; + this._info.copy(info); + this._hash = hash; } static computeHash (info: Readonly): number { diff --git a/cocos/gfx/base/states/general-barrier.ts b/cocos/gfx/base/states/general-barrier.ts index bf0f7c2c6ca..2c0505fc958 100644 --- a/cocos/gfx/base/states/general-barrier.ts +++ b/cocos/gfx/base/states/general-barrier.ts @@ -30,16 +30,16 @@ import { GFXObject, ObjectType, GeneralBarrierInfo } from '../define'; * @zh GFX 全局内存屏障。 */ export class GeneralBarrier extends GFXObject { - get info (): Readonly { return this._info$; } - get hash (): number { return this._hash$; } + get info (): Readonly { return this._info; } + get hash (): number { return this._hash; } - protected _info$: GeneralBarrierInfo = new GeneralBarrierInfo(); - protected _hash$ = 0; + protected _info: GeneralBarrierInfo = new GeneralBarrierInfo(); + protected _hash = 0; constructor (info: Readonly, hash: number) { super(ObjectType.GLOBAL_BARRIER); - this._info$.copy(info); - this._hash$ = hash; + this._info.copy(info); + this._hash = hash; } static computeHash (info: Readonly): number { diff --git a/cocos/gfx/base/states/sampler.ts b/cocos/gfx/base/states/sampler.ts index f9c7f8ddf2c..056699ac0be 100644 --- a/cocos/gfx/base/states/sampler.ts +++ b/cocos/gfx/base/states/sampler.ts @@ -29,16 +29,16 @@ import { Filter, GFXObject, ObjectType, SamplerInfo } from '../define'; * @zh GFX 采样器。 */ export class Sampler extends GFXObject { - get info (): Readonly { return this._info$; } - get hash (): number { return this._hash$; } + get info (): Readonly { return this._info; } + get hash (): number { return this._hash; } - protected _info$: SamplerInfo = new SamplerInfo(); - protected _hash$ = 0; + protected _info: SamplerInfo = new SamplerInfo(); + protected _hash = 0; constructor (info: Readonly, hash: number) { super(ObjectType.SAMPLER); - this._info$.copy(info); - this._hash$ = hash; + this._info.copy(info); + this._hash = hash; } static computeHash (info: Readonly): number { diff --git a/cocos/gfx/base/states/texture-barrier.ts b/cocos/gfx/base/states/texture-barrier.ts index 9f3f8282404..c2fafb876ff 100644 --- a/cocos/gfx/base/states/texture-barrier.ts +++ b/cocos/gfx/base/states/texture-barrier.ts @@ -30,16 +30,16 @@ import { GFXObject, ObjectType, TextureBarrierInfo } from '../define'; * @zh GFX 贴图内存屏障。 */ export class TextureBarrier extends GFXObject { - get info (): Readonly { return this._info$; } - get hash (): number { return this._hash$; } + get info (): Readonly { return this._info; } + get hash (): number { return this._hash; } - protected _info$: TextureBarrierInfo = new TextureBarrierInfo(); - protected _hash$ = 0; + protected _info: TextureBarrierInfo = new TextureBarrierInfo(); + protected _hash = 0; constructor (info: Readonly, hash: number) { super(ObjectType.TEXTURE_BARRIER); - this._info$.copy(info); - this._hash$ = hash; + this._info.copy(info); + this._hash = hash; } static computeHash (info: Readonly): number { diff --git a/cocos/gfx/base/swapchain.ts b/cocos/gfx/base/swapchain.ts index ca7d6397367..1be61edf23a 100644 --- a/cocos/gfx/base/swapchain.ts +++ b/cocos/gfx/base/swapchain.ts @@ -35,7 +35,7 @@ export abstract class Swapchain extends GFXObject { * @zh 当前交换链的颜色缓冲。 */ get colorTexture (): Texture { - return this._colorTexture$; + return this._colorTexture; } /** @@ -43,7 +43,7 @@ export abstract class Swapchain extends GFXObject { * @zh 当前交换链的深度模板缓冲。 */ get depthStencilTexture (): Texture { - return this._depthStencilTexture$; + return this._depthStencilTexture; } /** @@ -51,20 +51,20 @@ export abstract class Swapchain extends GFXObject { * @zh 需要在投影矩阵中应用的表面变换。 */ get surfaceTransform (): SurfaceTransform { - return this._transform$; + return this._transform; } get width (): number { - return this._colorTexture$.width; + return this._colorTexture.width; } get height (): number { - return this._colorTexture$.height; + return this._colorTexture.height; } - protected _transform$ = SurfaceTransform.IDENTITY; - protected _colorTexture$: Texture = null!; - protected _depthStencilTexture$: Texture = null!; + protected _transform = SurfaceTransform.IDENTITY; + protected _colorTexture: Texture = null!; + protected _depthStencilTexture: Texture = null!; constructor () { super(ObjectType.SWAPCHAIN); diff --git a/cocos/gfx/base/texture.ts b/cocos/gfx/base/texture.ts index 18e9598e8f3..81d4e10a792 100644 --- a/cocos/gfx/base/texture.ts +++ b/cocos/gfx/base/texture.ts @@ -46,7 +46,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理类型。 */ get type (): TextureType { - return this._info$.type; + return this._info.type; } /** @@ -54,7 +54,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理使用方式。 */ get usage (): TextureUsage { - return this._info$.usage; + return this._info.usage; } /** @@ -62,7 +62,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理格式。 */ get format (): Format { - return this._info$.format; + return this._info.format; } /** @@ -70,7 +70,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理宽度。 */ get width (): number { - return this._info$.width; + return this._info.width; } /** @@ -78,7 +78,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理高度。 */ get height (): number { - return this._info$.height; + return this._info.height; } /** @@ -86,7 +86,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理深度。 */ get depth (): number { - return this._info$.depth; + return this._info.depth; } /** @@ -94,7 +94,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理数组层数。 */ get layerCount (): number { - return this._info$.layerCount; + return this._info.layerCount; } /** @@ -102,7 +102,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理 mip 层级数。 */ get levelCount (): number { - return this._info$.levelCount; + return this._info.levelCount; } /** @@ -110,7 +110,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理采样数。 */ get samples (): SampleCount { - return this._info$.samples; + return this._info.samples; } /** @@ -118,7 +118,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理标识位。 */ get flags (): TextureFlags { - return this._info$.flags; + return this._info.flags; } /** @@ -126,7 +126,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理大小。 */ get size (): number { - return this._size$; + return this._size; } /** @@ -134,7 +134,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理信息。 */ get info (): Readonly { - return this._info$; + return this._info; } /** @@ -142,7 +142,7 @@ export abstract class Texture extends GFXObject { * @zh 纹理视图信息。 */ get viewInfo (): Readonly { - return this._viewInfo$; + return this._viewInfo; } /** @@ -150,15 +150,15 @@ export abstract class Texture extends GFXObject { * @zh 是否为纹理视图。 */ get isTextureView (): boolean { - return this._isTextureView$; + return this._isTextureView; } - protected _info$: TextureInfo = new TextureInfo(); - protected _viewInfo$: TextureViewInfo = new TextureViewInfo(); + protected _info: TextureInfo = new TextureInfo(); + protected _viewInfo: TextureViewInfo = new TextureViewInfo(); - protected _isPowerOf2$ = false; - protected _isTextureView$ = false; - protected _size$ = 0; + protected _isPowerOf2 = false; + protected _isTextureView = false; + protected _size = 0; constructor () { super(ObjectType.TEXTURE); diff --git a/cocos/gfx/empty/empty-buffer.ts b/cocos/gfx/empty/empty-buffer.ts index 91d3af39665..798d3a77b1d 100644 --- a/cocos/gfx/empty/empty-buffer.ts +++ b/cocos/gfx/empty/empty-buffer.ts @@ -28,22 +28,22 @@ import { Buffer } from '../base/buffer'; export class EmptyBuffer extends Buffer { public initialize (info: Readonly | Readonly): void { if ('buffer' in info) { // buffer view - this._isBufferView$ = true; + this._isBufferView = true; const buffer = info.buffer as EmptyBuffer; - this._usage$ = buffer.usage; - this._memUsage$ = buffer.memUsage; - this._size$ = this._stride$ = info.range; - this._count$ = 1; - this._flags$ = buffer.flags; + this._usage = buffer.usage; + this._memUsage = buffer.memUsage; + this._size = this._stride = info.range; + this._count = 1; + this._flags = buffer.flags; } else { // native buffer - this._usage$ = info.usage; - this._memUsage$ = info.memUsage; - this._size$ = info.size; - this._stride$ = Math.max(info.stride || this._size$, 1); - this._count$ = this._size$ / this._stride$; - this._flags$ = info.flags; + this._usage = info.usage; + this._memUsage = info.memUsage; + this._size = info.size; + this._stride = Math.max(info.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = info.flags; } } public destroy (): void {} diff --git a/cocos/gfx/empty/empty-command-buffer.ts b/cocos/gfx/empty/empty-command-buffer.ts index 67e1943574e..4355538a03b 100644 --- a/cocos/gfx/empty/empty-command-buffer.ts +++ b/cocos/gfx/empty/empty-command-buffer.ts @@ -39,8 +39,8 @@ import { StencilFace, BufferSource, CommandBufferInfo, BufferTextureCopy, Color, export class EmptyCommandBuffer extends CommandBuffer { public initialize (info: Readonly): void { - this._type$ = info.type; - this._queue$ = info.queue; + this._type = info.type; + this._queue = info.queue; } public destroy (): void {} public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void {} diff --git a/cocos/gfx/empty/empty-descriptor-set-layout.ts b/cocos/gfx/empty/empty-descriptor-set-layout.ts index 17dbaa9ab83..3e6c96b2923 100644 --- a/cocos/gfx/empty/empty-descriptor-set-layout.ts +++ b/cocos/gfx/empty/empty-descriptor-set-layout.ts @@ -27,7 +27,7 @@ import { DescriptorSetLayout } from '../base/descriptor-set-layout'; export class EmptyDescriptorSetLayout extends DescriptorSetLayout { public initialize (info: Readonly): void { - Array.prototype.push.apply(this._bindings$, info.bindings); + Array.prototype.push.apply(this._bindings, info.bindings); } public destroy (): void {} } diff --git a/cocos/gfx/empty/empty-descriptor-set.ts b/cocos/gfx/empty/empty-descriptor-set.ts index bb0bb52a6c1..4f39ec49961 100644 --- a/cocos/gfx/empty/empty-descriptor-set.ts +++ b/cocos/gfx/empty/empty-descriptor-set.ts @@ -27,7 +27,7 @@ import { DescriptorSetInfo } from '../base/define'; export class EmptyDescriptorSet extends DescriptorSet { public initialize (info: Readonly): void { - this._layout$ = info.layout; + this._layout = info.layout; } public destroy (): void {} public update (): void {} diff --git a/cocos/gfx/empty/empty-device.ts b/cocos/gfx/empty/empty-device.ts index 3f28d3bd68f..7da46c3210d 100644 --- a/cocos/gfx/empty/empty-device.ts +++ b/cocos/gfx/empty/empty-device.ts @@ -65,12 +65,12 @@ export class EmptyDevice extends Device { private _swapchain: EmptySwapchain | null = null; public initialize (info: DeviceInfo): boolean { - this._gfxAPI$ = API.UNKNOWN; + this._gfxAPI = API.UNKNOWN; - this._bindingMappingInfo$ = info.bindingMappingInfo; + this._bindingMappingInfo = info.bindingMappingInfo; - this._queue$ = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff$ = this.createCommandBuffer(new CommandBufferInfo(this._queue$)); + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); debug('Empty device initialized.'); @@ -78,14 +78,14 @@ export class EmptyDevice extends Device { } public destroy (): void { - if (this._queue$) { - this._queue$.destroy(); - this._queue$ = null; + if (this._queue) { + this._queue.destroy(); + this._queue = null; } - if (this._cmdBuff$) { - this._cmdBuff$.destroy(); - this._cmdBuff$ = null; + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; } this._swapchain = null; @@ -182,10 +182,10 @@ export class EmptyDevice extends Device { public getSampler (info: Readonly): Sampler { const hash = Sampler.computeHash(info); - if (!this._samplers$.has(hash)) { - this._samplers$.set(hash, new Sampler(info, hash)); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new Sampler(info, hash)); } - return this._samplers$.get(hash)!; + return this._samplers.get(hash)!; } public getSwapchains (): Readonly { @@ -194,26 +194,26 @@ export class EmptyDevice extends Device { public getGeneralBarrier (info: Readonly): GeneralBarrier { const hash = GeneralBarrier.computeHash(info); - if (!this._generalBarrierss$.has(hash)) { - this._generalBarrierss$.set(hash, new GeneralBarrier(info, hash)); + if (!this._generalBarrierss.has(hash)) { + this._generalBarrierss.set(hash, new GeneralBarrier(info, hash)); } - return this._generalBarrierss$.get(hash)!; + return this._generalBarrierss.get(hash)!; } public getTextureBarrier (info: Readonly): TextureBarrier { const hash = TextureBarrier.computeHash(info); - if (!this._textureBarriers$.has(hash)) { - this._textureBarriers$.set(hash, new TextureBarrier(info, hash)); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info, hash)); } - return this._textureBarriers$.get(hash)!; + return this._textureBarriers.get(hash)!; } public getBufferBarrier (info: Readonly): BufferBarrier { const hash = BufferBarrier.computeHash(info); - if (!this._bufferBarriers$.has(hash)) { - this._bufferBarriers$.set(hash, new BufferBarrier(info, hash)); + if (!this._bufferBarriers.has(hash)) { + this._bufferBarriers.set(hash, new BufferBarrier(info, hash)); } - return this._bufferBarriers$.get(hash)!; + return this._bufferBarriers.get(hash)!; } public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { diff --git a/cocos/gfx/empty/empty-framebuffer.ts b/cocos/gfx/empty/empty-framebuffer.ts index 32200917415..da61ec0f129 100644 --- a/cocos/gfx/empty/empty-framebuffer.ts +++ b/cocos/gfx/empty/empty-framebuffer.ts @@ -27,9 +27,9 @@ import { Framebuffer } from '../base/framebuffer'; export class EmptyFramebuffer extends Framebuffer { public initialize (info: Readonly): void { - this._renderPass$ = info.renderPass; - this._colorTextures$ = info.colorTextures || []; - this._depthStencilTexture$ = info.depthStencilTexture || null; + this._renderPass = info.renderPass; + this._colorTextures = info.colorTextures || []; + this._depthStencilTexture = info.depthStencilTexture || null; } public destroy (): void {} } diff --git a/cocos/gfx/empty/empty-input-assembler.ts b/cocos/gfx/empty/empty-input-assembler.ts index e673cfc94e1..3d9df167a46 100644 --- a/cocos/gfx/empty/empty-input-assembler.ts +++ b/cocos/gfx/empty/empty-input-assembler.ts @@ -27,19 +27,19 @@ import { InputAssembler } from '../base/input-assembler'; export class EmptyInputAssembler extends InputAssembler { public initialize (info: Readonly): void { - this._attributes$ = info.attributes; - this._attributesHash$ = this.computeAttributesHash$(); - this._vertexBuffers$ = info.vertexBuffers; + this._attributes = info.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = info.vertexBuffers; if (info.indexBuffer) { - this._indexBuffer$ = info.indexBuffer; - this._drawInfo$.indexCount = this._indexBuffer$.size / this._indexBuffer$.stride; - this._drawInfo$.firstIndex = 0; + this._indexBuffer = info.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; } else { - const vertBuff = this._vertexBuffers$[0]; - this._drawInfo$.vertexCount = vertBuff.size / vertBuff.stride; - this._drawInfo$.firstVertex = 0; - this._drawInfo$.vertexOffset = 0; + const vertBuff = this._vertexBuffers[0]; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; } } public destroy (): void {} diff --git a/cocos/gfx/empty/empty-pipeline-layout.ts b/cocos/gfx/empty/empty-pipeline-layout.ts index 5b05015765f..93eda468e2a 100644 --- a/cocos/gfx/empty/empty-pipeline-layout.ts +++ b/cocos/gfx/empty/empty-pipeline-layout.ts @@ -27,7 +27,7 @@ import { PipelineLayoutInfo } from '../base/define'; export class EmptyPipelineLayout extends PipelineLayout { public initialize (info: Readonly): void { - Array.prototype.push.apply(this._setLayouts$, info.setLayouts); + Array.prototype.push.apply(this._setLayouts, info.setLayouts); } public destroy (): void {} } diff --git a/cocos/gfx/empty/empty-pipeline-state.ts b/cocos/gfx/empty/empty-pipeline-state.ts index 76aab079acb..8f32ccf4716 100644 --- a/cocos/gfx/empty/empty-pipeline-state.ts +++ b/cocos/gfx/empty/empty-pipeline-state.ts @@ -26,10 +26,10 @@ import { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; export class EmptyPipelineState extends PipelineState { public initialize (info: Readonly): void { - this._primitive$ = info.primitive; - this._shader$ = info.shader; - this._pipelineLayout$ = info.pipelineLayout; - const bs = this._bs$; + this._primitive = info.primitive; + this._shader = info.shader; + this._pipelineLayout = info.pipelineLayout; + const bs = this._bs; if (info.blendState) { const bsInfo = info.blendState; const { targets } = bsInfo; @@ -43,11 +43,11 @@ export class EmptyPipelineState extends PipelineState { if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; } if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor; } } - Object.assign(this._rs$, info.rasterizerState); - Object.assign(this._dss$, info.depthStencilState); - this._is$ = info.inputState; - this._renderPass$ = info.renderPass; - this._dynamicStates$ = info.dynamicStates; + Object.assign(this._rs, info.rasterizerState); + Object.assign(this._dss, info.depthStencilState); + this._is = info.inputState; + this._renderPass = info.renderPass; + this._dynamicStates = info.dynamicStates; } public destroy (): void {} } diff --git a/cocos/gfx/empty/empty-queue.ts b/cocos/gfx/empty/empty-queue.ts index 121dbc4bd80..cee42522c64 100644 --- a/cocos/gfx/empty/empty-queue.ts +++ b/cocos/gfx/empty/empty-queue.ts @@ -28,7 +28,7 @@ import { Queue } from '../base/queue'; export class EmptyQueue extends Queue { public initialize (info: Readonly): void { - this._type$ = info.type; + this._type = info.type; } public destroy (): void {} public submit (cmdBuffs: Readonly): void {} diff --git a/cocos/gfx/empty/empty-render-pass.ts b/cocos/gfx/empty/empty-render-pass.ts index 22dc0a0a292..c7b4b500609 100644 --- a/cocos/gfx/empty/empty-render-pass.ts +++ b/cocos/gfx/empty/empty-render-pass.ts @@ -27,10 +27,10 @@ import { RenderPass } from '../base/render-pass'; export class EmptyRenderPass extends RenderPass { public initialize (info: Readonly): void { - this._colorInfos$ = info.colorAttachments; - this._depthStencilInfo$ = info.depthStencilAttachment; - this._subpasses$ = info.subpasses; - this._hash$ = this.computeHash(); + this._colorInfos = info.colorAttachments; + this._depthStencilInfo = info.depthStencilAttachment; + this._subpasses = info.subpasses; + this._hash = this.computeHash(); } public destroy (): void {} } diff --git a/cocos/gfx/empty/empty-swapchain.ts b/cocos/gfx/empty/empty-swapchain.ts index 7dbfb706b94..b3cc0e84475 100644 --- a/cocos/gfx/empty/empty-swapchain.ts +++ b/cocos/gfx/empty/empty-swapchain.ts @@ -28,16 +28,16 @@ import { EmptyTexture } from './empty-texture'; export class EmptySwapchain extends Swapchain { public initialize (info: Readonly): void { - this._colorTexture$ = new EmptyTexture(); - this._colorTexture$.initAsSwapchainTexture({ + this._colorTexture = new EmptyTexture(); + this._colorTexture.initAsSwapchainTexture({ swapchain: this, format: Format.RGBA8, width: info.width, height: info.height, }); - this._depthStencilTexture$ = new EmptyTexture(); - this._depthStencilTexture$.initAsSwapchainTexture({ + this._depthStencilTexture = new EmptyTexture(); + this._depthStencilTexture.initAsSwapchainTexture({ swapchain: this, format: Format.DEPTH_STENCIL, width: info.width, diff --git a/cocos/gfx/empty/empty-texture.ts b/cocos/gfx/empty/empty-texture.ts index 955a94a71b6..fc802637c5e 100644 --- a/cocos/gfx/empty/empty-texture.ts +++ b/cocos/gfx/empty/empty-texture.ts @@ -31,23 +31,23 @@ export class EmptyTexture extends Texture { if ('texture' in info) { texInfo = info.texture.info; - this._isTextureView$ = true; - this._viewInfo$.copy(info); + this._isTextureView = true; + this._viewInfo.copy(info); } else { - this._viewInfo$.texture = this; - this._viewInfo$.type = info.type; - this._viewInfo$.format = info.format; - this._viewInfo$.baseLevel = 0; - this._viewInfo$.levelCount = 1; - this._viewInfo$.baseLayer = 0; - this._viewInfo$.layerCount = 1; + this._viewInfo.texture = this; + this._viewInfo.type = info.type; + this._viewInfo.format = info.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = 1; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = 1; } - this._info$.copy(texInfo); + this._info.copy(texInfo); - this._isPowerOf2$ = IsPowerOf2(this._info$.width) && IsPowerOf2(this._info$.height); - this._size$ = FormatSurfaceSize(this._info$.format, this.width, this.height, - this.depth, this._info$.levelCount) * this._info$.layerCount; + this._isPowerOf2 = IsPowerOf2(this._info.width) && IsPowerOf2(this._info.height); + this._size = FormatSurfaceSize(this._info.format, this.width, this.height, + this.depth, this._info.levelCount) * this._info.layerCount; } public destroy (): void {} @@ -56,8 +56,8 @@ export class EmptyTexture extends Texture { } public resize (width: number, height: number): void { - this._info$.width = width; - this._info$.height = height; + this._info.width = width; + this._info.height = height; } /** * @engineInternal diff --git a/cocos/gfx/webgl/states/webgl-sampler.ts b/cocos/gfx/webgl/states/webgl-sampler.ts index 14fa0127c4f..ec15cdbdeeb 100644 --- a/cocos/gfx/webgl/states/webgl-sampler.ts +++ b/cocos/gfx/webgl/states/webgl-sampler.ts @@ -36,10 +36,10 @@ const WebGLWraps: GLenum[] = [ export class WebGLSampler extends Sampler { public get gpuSampler (): IWebGLGPUSampler { - return this._gpuSampler$!; + return this._gpuSampler!; } - private _gpuSampler$: IWebGLGPUSampler | null = null; + private _gpuSampler: IWebGLGPUSampler | null = null; constructor (info: Readonly, hash: number) { super(info, hash); @@ -47,9 +47,9 @@ export class WebGLSampler extends Sampler { let glMinFilter = 0; let glMagFilter = 0; - const minFilter = this._info$.minFilter; - const magFilter = this._info$.magFilter; - const mipFilter = this._info$.mipFilter; + const minFilter = this._info.minFilter; + const magFilter = this._info.magFilter; + const mipFilter = this._info.mipFilter; if (minFilter === Filter.LINEAR || minFilter === Filter.ANISOTROPIC) { if (mipFilter === Filter.LINEAR || mipFilter === Filter.ANISOTROPIC) { @@ -73,16 +73,16 @@ export class WebGLSampler extends Sampler { glMagFilter = WebGLConstants.NEAREST; } - const glWrapS = WebGLWraps[this._info$.addressU]; - const glWrapT = WebGLWraps[this._info$.addressV]; - const glWrapR = WebGLWraps[this._info$.addressW]; + const glWrapS = WebGLWraps[this._info.addressU]; + const glWrapT = WebGLWraps[this._info.addressV]; + const glWrapR = WebGLWraps[this._info.addressW]; - this._gpuSampler$ = { - glMinFilter$: glMinFilter, - glMagFilter$: glMagFilter, - glWrapS$: glWrapS, - glWrapT$: glWrapT, - glWrapR$: glWrapR, + this._gpuSampler = { + glMinFilter, + glMagFilter, + glWrapS, + glWrapT, + glWrapR, }; } } diff --git a/cocos/gfx/webgl/webgl-buffer.ts b/cocos/gfx/webgl/webgl-buffer.ts index bba23b20280..c8fef5abdcc 100644 --- a/cocos/gfx/webgl/webgl-buffer.ts +++ b/cocos/gfx/webgl/webgl-buffer.ts @@ -37,16 +37,16 @@ import { warnID } from '../../core/platform/debug'; export class WebGLBuffer extends Buffer { get gpuBuffer (): IWebGLGPUBuffer { - return this._gpuBuffer$!; + return this._gpuBuffer!; } get gpuBufferView (): IWebGLGPUBufferView { - return this._gpuBufferView$!; + return this._gpuBufferView!; } - private _gpuBuffer$: IWebGLGPUBuffer | null = null; - private _gpuBufferView$: IWebGLGPUBufferView | null = null; - private _uniformBuffer$: Uint8Array | null = null; + private _gpuBuffer: IWebGLGPUBuffer | null = null; + private _gpuBufferView: IWebGLGPUBufferView | null = null; + private _uniformBuffer: Uint8Array | null = null; constructor () { super(); @@ -54,91 +54,91 @@ export class WebGLBuffer extends Buffer { public initialize (info: Readonly | Readonly): void { if ('buffer' in info) { // buffer view - this._isBufferView$ = true; + this._isBufferView = true; const buffer = info.buffer as WebGLBuffer; - this._usage$ = buffer.usage; - this._memUsage$ = buffer.memUsage; - this._size$ = this._stride$ = info.range; - this._count$ = 1; - this._flags$ = buffer.flags; + this._usage = buffer.usage; + this._memUsage = buffer.memUsage; + this._size = this._stride = info.range; + this._count = 1; + this._flags = buffer.flags; - this._gpuBufferView$ = { - gpuBuffer$: buffer.gpuBuffer, - offset$: info.offset, - range$: info.range, + this._gpuBufferView = { + gpuBuffer: buffer.gpuBuffer, + offset: info.offset, + range: info.range, }; } else { // native buffer - this._usage$ = info.usage; - this._memUsage$ = info.memUsage; - this._size$ = info.size; - this._stride$ = Math.max(info.stride || this._size$, 1); - this._count$ = this._size$ / this._stride$; - this._flags$ = info.flags; - - if ((this._usage$ & BufferUsageBit.UNIFORM) && this._size$ > 0) { - this._uniformBuffer$ = new Uint8Array(this._size$); + this._usage = info.usage; + this._memUsage = info.memUsage; + this._size = info.size; + this._stride = Math.max(info.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = info.flags; + + if ((this._usage & BufferUsageBit.UNIFORM) && this._size > 0) { + this._uniformBuffer = new Uint8Array(this._size); } - this._gpuBuffer$ = { - usage$: this._usage$, - memUsage$: this._memUsage$, - size$: this._size$, - stride$: this._stride$, - buffer$: null, + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, vf32: null, - indirects$: new WebGLIndirectDrawInfos(), - glTarget$: 0, - glBuffer$: null, + indirects: new WebGLIndirectDrawInfos(), + glTarget: 0, + glBuffer: null, }; - if (this._usage$ & BufferUsageBit.UNIFORM) { - this._gpuBuffer$.buffer$ = this._uniformBuffer$; + if (this._usage & BufferUsageBit.UNIFORM) { + this._gpuBuffer.buffer = this._uniformBuffer; } - WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuBuffer$); + WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuBuffer); - WebGLDeviceManager.instance.memoryStatus.bufferSize += this._size$; + WebGLDeviceManager.instance.memoryStatus.bufferSize += this._size; } } public destroy (): void { - if (this._gpuBuffer$) { - WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuBuffer$); - WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._size$; - this._gpuBuffer$ = null; + if (this._gpuBuffer) { + WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuBuffer); + WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._size; + this._gpuBuffer = null; } - if (this._gpuBufferView$) { - this._gpuBufferView$ = null; + if (this._gpuBufferView) { + this._gpuBufferView = null; } } public resize (size: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16379); return; } - const oldSize = this._size$; + const oldSize = this._size; if (oldSize === size) { return; } - this._size$ = size; - this._count$ = this._size$ / this._stride$; + this._size = size; + this._count = this._size / this._stride; - if (this._uniformBuffer$) { - this._uniformBuffer$ = new Uint8Array(size); + if (this._uniformBuffer) { + this._uniformBuffer = new Uint8Array(size); } - if (this._gpuBuffer$) { - if (this._uniformBuffer$) { - this._gpuBuffer$.buffer$ = this._uniformBuffer$; + if (this._gpuBuffer) { + if (this._uniformBuffer) { + this._gpuBuffer.buffer = this._uniformBuffer; } - this._gpuBuffer$.size$ = size; + this._gpuBuffer.size = size; if (size > 0) { - WebGLCmdFuncResizeBuffer(WebGLDeviceManager.instance, this._gpuBuffer$); + WebGLCmdFuncResizeBuffer(WebGLDeviceManager.instance, this._gpuBuffer); WebGLDeviceManager.instance.memoryStatus.bufferSize -= oldSize; WebGLDeviceManager.instance.memoryStatus.bufferSize += size; } @@ -146,7 +146,7 @@ export class WebGLBuffer extends Buffer { } public update (buffer: Readonly, size?: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16380); return; } @@ -154,7 +154,7 @@ export class WebGLBuffer extends Buffer { let buffSize: number; if (size !== undefined) { buffSize = size; - } else if (this._usage$ & BufferUsageBit.INDIRECT) { + } else if (this._usage & BufferUsageBit.INDIRECT) { buffSize = 0; } else { buffSize = (buffer as ArrayBuffer).byteLength; @@ -162,7 +162,7 @@ export class WebGLBuffer extends Buffer { WebGLCmdFuncUpdateBuffer( WebGLDeviceManager.instance, - this._gpuBuffer$!, + this._gpuBuffer!, buffer as BufferSource, 0, buffSize, diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index 74604f95e43..c4557640c63 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -43,25 +43,25 @@ import { WebGLDeviceManager } from './webgl-define'; import { errorID } from '../../core/platform/debug'; export class WebGLCommandBuffer extends CommandBuffer { - protected _isInRenderPass$ = false; - protected _curGPUPipelineState$: IWebGLGPUPipelineState | null = null; - protected _curGPUInputAssembler$: IWebGLGPUInputAssembler | null = null; - protected _curGPUDescriptorSets$: IWebGLGPUDescriptorSet[] = []; - protected _curDynamicOffsets$: number[] = Array(8).fill(0); - protected _curDynamicStates$: DynamicStates = new DynamicStates(); - protected _isStateInvalied$ = false; + protected _isInRenderPass = false; + protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null; + protected _curGPUInputAssembler: IWebGLGPUInputAssembler | null = null; + protected _curGPUDescriptorSets: IWebGLGPUDescriptorSet[] = []; + protected _curDynamicOffsets: number[] = Array(8).fill(0); + protected _curDynamicStates: DynamicStates = new DynamicStates(); + protected _isStateInvalied = false; constructor () { super(); } public initialize (info: Readonly): void { - this._type$ = info.type; - this._queue$ = info.queue; + this._type = info.type; + this._queue = info.queue; - const setCount = WebGLDeviceManager.instance.bindingMappings.blockOffsets$.length; + const setCount = WebGLDeviceManager.instance.bindingMappings.blockOffsets.length; for (let i = 0; i < setCount; i++) { - this._curGPUDescriptorSets$.push(null!); + this._curGPUDescriptorSets.push(null!); } } @@ -69,20 +69,20 @@ export class WebGLCommandBuffer extends CommandBuffer { } public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { - this._curGPUPipelineState$ = null; - this._curGPUInputAssembler$ = null; - this._curGPUDescriptorSets$.length = 0; - this._numDrawCalls$ = 0; - this._numInstances$ = 0; - this._numTris$ = 0; + this._curGPUPipelineState = null; + this._curGPUInputAssembler = null; + this._curGPUDescriptorSets.length = 0; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; } public end (): void { - if (this._isStateInvalied$) { + if (this._isStateInvalied) { this.bindStates(); } - this._isInRenderPass$ = false; + this._isInRenderPass = false; } public beginRenderPass ( @@ -94,46 +94,46 @@ export class WebGLCommandBuffer extends CommandBuffer { clearStencil: number, ): void { errorID(16401); - this._isInRenderPass$ = true; + this._isInRenderPass = true; } public endRenderPass (): void { - this._isInRenderPass$ = false; + this._isInRenderPass = false; } public bindPipelineState (pipelineState: PipelineState): void { const gpuPipelineState = (pipelineState as WebGLPipelineState).gpuPipelineState; - if (gpuPipelineState !== this._curGPUPipelineState$) { - this._curGPUPipelineState$ = gpuPipelineState; - this._isStateInvalied$ = true; + if (gpuPipelineState !== this._curGPUPipelineState) { + this._curGPUPipelineState = gpuPipelineState; + this._isStateInvalied = true; } } public bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: Readonly): void { const gpuDescriptorSet = (descriptorSet as WebGLDescriptorSet).gpuDescriptorSet; - if (gpuDescriptorSet !== this._curGPUDescriptorSets$[set]) { - this._curGPUDescriptorSets$[set] = gpuDescriptorSet; - this._isStateInvalied$ = true; + if (gpuDescriptorSet !== this._curGPUDescriptorSets[set]) { + this._curGPUDescriptorSets[set] = gpuDescriptorSet; + this._isStateInvalied = true; } if (dynamicOffsets) { - const gpuPipelineLayout = this._curGPUPipelineState$?.gpuPipelineLayout$; + const gpuPipelineLayout = this._curGPUPipelineState?.gpuPipelineLayout; if (gpuPipelineLayout) { - const offsets = this._curDynamicOffsets$; - const idx = gpuPipelineLayout.dynamicOffsetOffsets$[set]; + const offsets = this._curDynamicOffsets; + const idx = gpuPipelineLayout.dynamicOffsetOffsets[set]; for (let i = 0; i < dynamicOffsets.length; i++) offsets[idx + i] = dynamicOffsets[i]; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } } public bindInputAssembler (inputAssembler: InputAssembler): void { const gpuInputAssembler = (inputAssembler as WebGLInputAssembler).gpuInputAssembler; - this._curGPUInputAssembler$ = gpuInputAssembler; - this._isStateInvalied$ = true; + this._curGPUInputAssembler = gpuInputAssembler; + this._isStateInvalied = true; } public setViewport (viewport: Readonly): void { - const cache = this._curDynamicStates$.viewport; + const cache = this._curDynamicStates.viewport; if (cache.left !== viewport.left || cache.top !== viewport.top || cache.width !== viewport.width @@ -146,12 +146,12 @@ export class WebGLCommandBuffer extends CommandBuffer { cache.height = viewport.height; cache.minDepth = viewport.minDepth; cache.maxDepth = viewport.maxDepth; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } public setScissor (scissor: Readonly): void { - const cache = this._curDynamicStates$.scissor; + const cache = this._curDynamicStates.scissor; if (cache.x !== scissor.x || cache.y !== scissor.y || cache.width !== scissor.width @@ -160,76 +160,76 @@ export class WebGLCommandBuffer extends CommandBuffer { cache.y = scissor.y; cache.width = scissor.width; cache.height = scissor.height; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } public setLineWidth (lineWidth: number): void { - if (this._curDynamicStates$.lineWidth !== lineWidth) { - this._curDynamicStates$.lineWidth = lineWidth; - this._isStateInvalied$ = true; + if (this._curDynamicStates.lineWidth !== lineWidth) { + this._curDynamicStates.lineWidth = lineWidth; + this._isStateInvalied = true; } } public setDepthBias (depthBiasConstantFactor: number, depthBiasClamp: number, depthBiasSlopeFactor: number): void { - const cache = this._curDynamicStates$; + const cache = this._curDynamicStates; if (cache.depthBiasConstant !== depthBiasConstantFactor || cache.depthBiasClamp !== depthBiasClamp || cache.depthBiasSlope !== depthBiasSlopeFactor) { cache.depthBiasConstant = depthBiasConstantFactor; cache.depthBiasClamp = depthBiasClamp; cache.depthBiasSlope = depthBiasSlopeFactor; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } public setBlendConstants (blendConstants: Readonly): void { - const cache = this._curDynamicStates$.blendConstant; + const cache = this._curDynamicStates.blendConstant; if (cache.x !== blendConstants.x || cache.y !== blendConstants.y || cache.z !== blendConstants.z || cache.w !== blendConstants.w) { cache.copy(blendConstants); - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } public setDepthBound (minDepthBounds: number, maxDepthBounds: number): void { - const cache = this._curDynamicStates$; + const cache = this._curDynamicStates; if (cache.depthMinBounds !== minDepthBounds || cache.depthMaxBounds !== maxDepthBounds) { cache.depthMinBounds = minDepthBounds; cache.depthMaxBounds = maxDepthBounds; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } public setStencilWriteMask (face: StencilFace, writeMask: number): void { - const front = this._curDynamicStates$.stencilStatesFront; - const back = this._curDynamicStates$.stencilStatesBack; + const front = this._curDynamicStates.stencilStatesFront; + const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { if (front.writeMask !== writeMask) { front.writeMask = writeMask; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } if (face & StencilFace.BACK) { if (back.writeMask !== writeMask) { back.writeMask = writeMask; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } } public setStencilCompareMask (face: StencilFace, reference: number, compareMask: number): void { - const front = this._curDynamicStates$.stencilStatesFront; - const back = this._curDynamicStates$.stencilStatesBack; + const front = this._curDynamicStates.stencilStatesFront; + const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { if (front.compareMask !== compareMask || front.reference !== reference) { front.reference = reference; front.compareMask = compareMask; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } if (face & StencilFace.BACK) { @@ -237,7 +237,7 @@ export class WebGLCommandBuffer extends CommandBuffer { || back.reference !== reference) { back.reference = reference; back.compareMask = compareMask; - this._isStateInvalied$ = true; + this._isStateInvalied = true; } } } diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index 86f0da42393..9d0fe3d1bcb 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -443,72 +443,72 @@ const WebGLBlendFactors: GLenum[] = [ export function WebGLCmdFuncCreateBuffer (device: WebGLDevice, gpuBuffer: IWebGLGPUBuffer): void { const { gl, stateCache } = device; - const glUsage: GLenum = gpuBuffer.memUsage$ & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; + const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; - if (gpuBuffer.usage$ & BufferUsageBit.VERTEX) { - gpuBuffer.glTarget$ = WebGLConstants.ARRAY_BUFFER; + if (gpuBuffer.usage & BufferUsageBit.VERTEX) { + gpuBuffer.glTarget = WebGLConstants.ARRAY_BUFFER; const glBuffer = gl.createBuffer(); if (glBuffer) { - gpuBuffer.glBuffer$ = glBuffer; - if (gpuBuffer.size$ > 0) { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + gpuBuffer.glBuffer = glBuffer; + if (gpuBuffer.size > 0) { + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); - stateCache.glArrayBuffer$ = gpuBuffer.glBuffer$; + if (stateCache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); + stateCache.glArrayBuffer = gpuBuffer.glBuffer; } - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - stateCache.glArrayBuffer$ = null; + stateCache.glArrayBuffer = null; } } - } else if (gpuBuffer.usage$ & BufferUsageBit.INDEX) { - gpuBuffer.glTarget$ = WebGLConstants.ELEMENT_ARRAY_BUFFER; + } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { + gpuBuffer.glTarget = WebGLConstants.ELEMENT_ARRAY_BUFFER; const glBuffer = gl.createBuffer(); if (glBuffer) { - gpuBuffer.glBuffer$ = glBuffer; - if (gpuBuffer.size$ > 0) { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + gpuBuffer.glBuffer = glBuffer; + if (gpuBuffer.size > 0) { + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - stateCache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (stateCache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + stateCache.glElementArrayBuffer = gpuBuffer.glBuffer; } - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - stateCache.glElementArrayBuffer$ = null; + stateCache.glElementArrayBuffer = null; } } - } else if (gpuBuffer.usage$ & BufferUsageBit.UNIFORM) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { + gpuBuffer.glTarget = WebGLConstants.NONE; - if (gpuBuffer.buffer$) { - gpuBuffer.vf32 = new Float32Array(gpuBuffer.buffer$.buffer); + if (gpuBuffer.buffer) { + gpuBuffer.vf32 = new Float32Array(gpuBuffer.buffer.buffer); } - } else if (gpuBuffer.usage$ & BufferUsageBit.INDIRECT) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; - } else if (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_DST) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; - } else if (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_SRC) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { + gpuBuffer.glTarget = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.TRANSFER_DST) { + gpuBuffer.glTarget = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC) { + gpuBuffer.glTarget = WebGLConstants.NONE; } else { errorID(16315); - gpuBuffer.glTarget$ = WebGLConstants.NONE; + gpuBuffer.glTarget = WebGLConstants.NONE; } } @@ -516,97 +516,97 @@ export function WebGLCmdFuncDestroyBuffer (device: WebGLDevice, gpuBuffer: IWebG const { gl } = device; const cache = device.stateCache; - if (gpuBuffer.glBuffer$) { + if (gpuBuffer.glBuffer) { // Firefox 75+ implicitly unbind whatever buffer there was on the slot sometimes // can be reproduced in the static batching scene at https://github.com/cocos-creator/test-cases-3d - switch (gpuBuffer.glTarget$) { + switch (gpuBuffer.glTarget) { case WebGLConstants.ARRAY_BUFFER: - if (device.extensions.useVAO$) { - if (cache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - cache.glVAO$ = null; + if (device.extensions.useVAO) { + if (cache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + cache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; + cache.glArrayBuffer = null; break; case WebGLConstants.ELEMENT_ARRAY_BUFFER: - if (device.extensions.useVAO$) { - if (cache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - cache.glVAO$ = null; + if (device.extensions.useVAO) { + if (cache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + cache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glElementArrayBuffer$ = null; + cache.glElementArrayBuffer = null; break; default: } - gl.deleteBuffer(gpuBuffer.glBuffer$); - gpuBuffer.glBuffer$ = null; + gl.deleteBuffer(gpuBuffer.glBuffer); + gpuBuffer.glBuffer = null; } } export function WebGLCmdFuncResizeBuffer (device: WebGLDevice, gpuBuffer: IWebGLGPUBuffer): void { const { gl, stateCache } = device; - const glUsage: GLenum = gpuBuffer.memUsage$ & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; + const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; - if (gpuBuffer.usage$ & BufferUsageBit.VERTEX) { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + if (gpuBuffer.usage & BufferUsageBit.VERTEX) { + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); + if (stateCache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); } - if (gpuBuffer.buffer$) { - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.buffer$, glUsage); + if (gpuBuffer.buffer) { + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.buffer, glUsage); } else { - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size, glUsage); } gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - stateCache.glArrayBuffer$ = null; - } else if (gpuBuffer.usage$ & BufferUsageBit.INDEX) { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + stateCache.glArrayBuffer = null; + } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); + if (stateCache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); } - if (gpuBuffer.buffer$) { - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.buffer$, glUsage); + if (gpuBuffer.buffer) { + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.buffer, glUsage); } else { - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size, glUsage); } gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - stateCache.glElementArrayBuffer$ = null; - } else if (gpuBuffer.usage$ & BufferUsageBit.UNIFORM) { - if (gpuBuffer.buffer$) { - gpuBuffer.vf32 = new Float32Array(gpuBuffer.buffer$.buffer); - } - } else if ((gpuBuffer.usage$ & BufferUsageBit.INDIRECT) - || (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_DST) - || (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_SRC)) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; + stateCache.glElementArrayBuffer = null; + } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { + if (gpuBuffer.buffer) { + gpuBuffer.vf32 = new Float32Array(gpuBuffer.buffer.buffer); + } + } else if ((gpuBuffer.usage & BufferUsageBit.INDIRECT) + || (gpuBuffer.usage & BufferUsageBit.TRANSFER_DST) + || (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC)) { + gpuBuffer.glTarget = WebGLConstants.NONE; } else { errorID(16315); - gpuBuffer.glTarget$ = WebGLConstants.NONE; + gpuBuffer.glTarget = WebGLConstants.NONE; } } @@ -617,50 +617,50 @@ export function WebGLCmdFuncUpdateBuffer ( offset: number, size: number, ): void { - if (gpuBuffer.usage$ & BufferUsageBit.UNIFORM) { + if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { if (ArrayBuffer.isView(buffer)) { gpuBuffer.vf32!.set(buffer as Float32Array, offset / Float32Array.BYTES_PER_ELEMENT); } else { gpuBuffer.vf32!.set(new Float32Array(buffer as ArrayBuffer), offset / Float32Array.BYTES_PER_ELEMENT); } - } else if (gpuBuffer.usage$ & BufferUsageBit.INDIRECT) { - gpuBuffer.indirects$.clearDraws$(); + } else if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { + gpuBuffer.indirects.clearDraws(); const drawInfos = (buffer as IndirectBuffer).drawInfos; for (let i = 0; i < drawInfos.length; ++i) { - gpuBuffer.indirects$.setDrawInfo$(offset + i, drawInfos[i]); + gpuBuffer.indirects.setDrawInfo(offset + i, drawInfos[i]); } } else { const buff = buffer as ArrayBuffer; const { gl, stateCache } = device; - switch (gpuBuffer.glTarget$) { + switch (gpuBuffer.glTarget) { case WebGLConstants.ARRAY_BUFFER: { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); - stateCache.glArrayBuffer$ = gpuBuffer.glBuffer$; + if (stateCache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); + stateCache.glArrayBuffer = gpuBuffer.glBuffer; } break; } case WebGLConstants.ELEMENT_ARRAY_BUFFER: { - if (device.extensions.useVAO$) { - if (stateCache.glVAO$) { - device.extensions.OES_vertex_array_object$!.bindVertexArrayOES(null); - stateCache.glVAO$ = null; + if (device.extensions.useVAO) { + if (stateCache.glVAO) { + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); + stateCache.glVAO = null; } } - gfxStateCache.gpuInputAssembler$ = null; + gfxStateCache.gpuInputAssembler = null; - if (stateCache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - stateCache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (stateCache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + stateCache.glElementArrayBuffer = gpuBuffer.glBuffer; } break; } @@ -670,16 +670,16 @@ export function WebGLCmdFuncUpdateBuffer ( } } - if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage$ & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { + if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { // Fix performance issue on iOS. // TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases. // We should use multiple buffers to avoid stall (cpu write conflicts with gpu read). // Before that, we will use glBufferData instead of glBufferSubData. - gl.bufferData(gpuBuffer.glTarget$, buff, gl.DYNAMIC_DRAW); + gl.bufferData(gpuBuffer.glTarget, buff, gl.DYNAMIC_DRAW); } else if (size === buff.byteLength) { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff); } else { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff.slice(0, size)); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff.slice(0, size)); } } } @@ -687,120 +687,120 @@ export function WebGLCmdFuncUpdateBuffer ( export function WebGLCmdFuncCreateTexture (device: WebGLDevice, gpuTexture: IWebGLGPUTexture): void { const { gl, stateCache } = device; - gpuTexture.glFormat$ = gpuTexture.glInternalFmt$ = GFXFormatToWebGLFormat(gpuTexture.format$, gl); - gpuTexture.glType$ = GFXFormatToWebGLType(gpuTexture.format$, gl); + gpuTexture.glFormat = gpuTexture.glInternalFmt = GFXFormatToWebGLFormat(gpuTexture.format, gl); + gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl); - let w = gpuTexture.width$; - let h = gpuTexture.height$; + let w = gpuTexture.width; + let h = gpuTexture.height; - switch (gpuTexture.type$) { + switch (gpuTexture.type) { case TextureType.TEX2D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; const maxSize = max(w, h); if (maxSize > device.capabilities.maxTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } // TODO: The system bug in the TikTok mini-game; once they fix it, a rollback will be necessary. - if (!device.textureExclusive[gpuTexture.format$] - && ((!device.extensions.WEBGL_depth_texture$ || BYTEDANCE) && FormatInfos[gpuTexture.format$].hasDepth)) { - gpuTexture.glInternalFmt$ = GFXFormatToWebGLInternalFormat(gpuTexture.format$, gl); - gpuTexture.glRenderbuffer$ = gl.createRenderbuffer(); - if (gpuTexture.size$ > 0) { - if (stateCache.glRenderbuffer$ !== gpuTexture.glRenderbuffer$) { - gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer$); - stateCache.glRenderbuffer$ = gpuTexture.glRenderbuffer$; + if (!device.textureExclusive[gpuTexture.format] + && ((!device.extensions.WEBGL_depth_texture || BYTEDANCE) && FormatInfos[gpuTexture.format].hasDepth)) { + gpuTexture.glInternalFmt = GFXFormatToWebGLInternalFormat(gpuTexture.format, gl); + gpuTexture.glRenderbuffer = gl.createRenderbuffer(); + if (gpuTexture.size > 0) { + if (stateCache.glRenderbuffer !== gpuTexture.glRenderbuffer) { + gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer); + stateCache.glRenderbuffer = gpuTexture.glRenderbuffer; } - gl.renderbufferStorage(WebGLConstants.RENDERBUFFER, gpuTexture.glInternalFmt$, w, h); + gl.renderbufferStorage(WebGLConstants.RENDERBUFFER, gpuTexture.glInternalFmt, w, h); } } else { - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - gl.texImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, gpuTexture.glFormat$, gpuTexture.glType$, null); + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + gl.texImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); w = max(1, w >> 1); h = max(1, h >> 1); } } - if (gpuTexture.isPowerOf2$) { - gpuTexture.glWrapS$ = WebGLConstants.REPEAT; - gpuTexture.glWrapT$ = WebGLConstants.REPEAT; + if (gpuTexture.isPowerOf2) { + gpuTexture.glWrapS = WebGLConstants.REPEAT; + gpuTexture.glWrapT = WebGLConstants.REPEAT; } else { - gpuTexture.glWrapS$ = WebGLConstants.CLAMP_TO_EDGE; - gpuTexture.glWrapT$ = WebGLConstants.CLAMP_TO_EDGE; + gpuTexture.glWrapS = WebGLConstants.CLAMP_TO_EDGE; + gpuTexture.glWrapT = WebGLConstants.CLAMP_TO_EDGE; } - gpuTexture.glMinFilter$ = WebGLConstants.LINEAR; - gpuTexture.glMagFilter$ = WebGLConstants.LINEAR; + gpuTexture.glMinFilter = WebGLConstants.LINEAR; + gpuTexture.glMagFilter = WebGLConstants.LINEAR; - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_S, gpuTexture.glWrapS$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_T, gpuTexture.glWrapT$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter$); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_S, gpuTexture.glWrapS); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_T, gpuTexture.glWrapT); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter); } } break; } case TextureType.CUBE: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_CUBE_MAP; + gpuTexture.glTarget = WebGLConstants.TEXTURE_CUBE_MAP; const maxSize = max(w, h); if (maxSize > device.capabilities.maxCubeMapTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { + if (FormatInfos[gpuTexture.format].isCompressed) { for (let f = 0; f < 6; ++f) { - w = gpuTexture.width$; - h = gpuTexture.height$; - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + w = gpuTexture.width; + h = gpuTexture.height; + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } } else { for (let f = 0; f < 6; ++f) { - w = gpuTexture.width$; - h = gpuTexture.height$; - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { + w = gpuTexture.width; + h = gpuTexture.height; + for (let i = 0; i < gpuTexture.mipLevel; ++i) { gl.texImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, w, h, 0, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, null, ); w = max(1, w >> 1); @@ -809,103 +809,103 @@ export function WebGLCmdFuncCreateTexture (device: WebGLDevice, gpuTexture: IWeb } } - if (gpuTexture.isPowerOf2$) { - gpuTexture.glWrapS$ = WebGLConstants.REPEAT; - gpuTexture.glWrapT$ = WebGLConstants.REPEAT; + if (gpuTexture.isPowerOf2) { + gpuTexture.glWrapS = WebGLConstants.REPEAT; + gpuTexture.glWrapT = WebGLConstants.REPEAT; } else { - gpuTexture.glWrapS$ = WebGLConstants.CLAMP_TO_EDGE; - gpuTexture.glWrapT$ = WebGLConstants.CLAMP_TO_EDGE; + gpuTexture.glWrapS = WebGLConstants.CLAMP_TO_EDGE; + gpuTexture.glWrapT = WebGLConstants.CLAMP_TO_EDGE; } - gpuTexture.glMinFilter$ = WebGLConstants.LINEAR; - gpuTexture.glMagFilter$ = WebGLConstants.LINEAR; + gpuTexture.glMinFilter = WebGLConstants.LINEAR; + gpuTexture.glMagFilter = WebGLConstants.LINEAR; - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_S, gpuTexture.glWrapS$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_T, gpuTexture.glWrapT$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter$); - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter$); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_S, gpuTexture.glWrapS); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_T, gpuTexture.glWrapT); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MIN_FILTER, gpuTexture.glMinFilter); + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MAG_FILTER, gpuTexture.glMagFilter); } break; } default: { errorID(16317); - gpuTexture.type$ = TextureType.TEX2D; - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.type = TextureType.TEX2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; } } } export function WebGLCmdFuncDestroyTexture (device: WebGLDevice, gpuTexture: IWebGLGPUTexture): void { const { gl, stateCache } = device; - if (gpuTexture.glTexture$) { - const glTexUnits = stateCache.glTexUnits$; - let texUnit = stateCache.texUnit$; - gl.deleteTexture(gpuTexture.glTexture$); + if (gpuTexture.glTexture) { + const glTexUnits = stateCache.glTexUnits; + let texUnit = stateCache.texUnit; + gl.deleteTexture(gpuTexture.glTexture); for (let i = 0; i < glTexUnits.length; i++) { - if (glTexUnits[i].glTexture$ === gpuTexture.glTexture$) { + if (glTexUnits[i].glTexture === gpuTexture.glTexture) { gl.activeTexture(WebGLConstants.TEXTURE0 + i); texUnit = i; - gl.bindTexture(gpuTexture.glTarget$, null); - glTexUnits[i].glTexture$ = null; + gl.bindTexture(gpuTexture.glTarget, null); + glTexUnits[i].glTexture = null; } } - stateCache.texUnit$ = texUnit; - gpuTexture.glTexture$ = null; + stateCache.texUnit = texUnit; + gpuTexture.glTexture = null; } - if (gpuTexture.glRenderbuffer$) { - const glRenderbuffer = stateCache.glRenderbuffer$; - gl.deleteRenderbuffer(gpuTexture.glRenderbuffer$); - if (glRenderbuffer === gpuTexture.glRenderbuffer$) { + if (gpuTexture.glRenderbuffer) { + const glRenderbuffer = stateCache.glRenderbuffer; + gl.deleteRenderbuffer(gpuTexture.glRenderbuffer); + if (glRenderbuffer === gpuTexture.glRenderbuffer) { gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, null); - stateCache.glRenderbuffer$ = null; + stateCache.glRenderbuffer = null; } - gpuTexture.glRenderbuffer$ = null; + gpuTexture.glRenderbuffer = null; } } export function WebGLCmdFuncResizeTexture (device: WebGLDevice, gpuTexture: IWebGLGPUTexture): void { - if (!gpuTexture.size$) return; + if (!gpuTexture.size) return; const { gl, stateCache } = device; - let w = gpuTexture.width$; - let h = gpuTexture.height$; + let w = gpuTexture.width; + let h = gpuTexture.height; - switch (gpuTexture.type$) { + switch (gpuTexture.type) { case TextureType.TEX2D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; const maxSize = max(w, h); if (maxSize > device.capabilities.maxTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } - if (gpuTexture.glRenderbuffer$) { - if (stateCache.glRenderbuffer$ !== gpuTexture.glRenderbuffer$) { - gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer$); - stateCache.glRenderbuffer$ = gpuTexture.glRenderbuffer$; + if (gpuTexture.glRenderbuffer) { + if (stateCache.glRenderbuffer !== gpuTexture.glRenderbuffer) { + gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer); + stateCache.glRenderbuffer = gpuTexture.glRenderbuffer; } - gl.renderbufferStorage(WebGLConstants.RENDERBUFFER, gpuTexture.glInternalFmt$, w, h); - } else if (gpuTexture.glTexture$) { - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; + gl.renderbufferStorage(WebGLConstants.RENDERBUFFER, gpuTexture.glInternalFmt, w, h); + } else if (gpuTexture.glTexture) { + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - gl.texImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, gpuTexture.glFormat$, gpuTexture.glType$, null); + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + gl.texImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); w = max(1, w >> 1); h = max(1, h >> 1); } @@ -914,46 +914,46 @@ export function WebGLCmdFuncResizeTexture (device: WebGLDevice, gpuTexture: IWeb break; } case TextureType.CUBE: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_CUBE_MAP; + gpuTexture.glTarget = WebGLConstants.TEXTURE_CUBE_MAP; const maxSize = max(w, h); if (maxSize > device.capabilities.maxCubeMapTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { + if (FormatInfos[gpuTexture.format].isCompressed) { for (let f = 0; f < 6; ++f) { - w = gpuTexture.width$; - h = gpuTexture.height$; - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + w = gpuTexture.width; + h = gpuTexture.height; + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } } else { for (let f = 0; f < 6; ++f) { - w = gpuTexture.width$; - h = gpuTexture.height$; - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { + w = gpuTexture.width; + h = gpuTexture.height; + for (let i = 0; i < gpuTexture.mipLevel; ++i) { gl.texImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, w, h, 0, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, null, ); w = max(1, w >> 1); @@ -965,17 +965,17 @@ export function WebGLCmdFuncResizeTexture (device: WebGLDevice, gpuTexture: IWeb } default: { errorID(16317); - gpuTexture.type$ = TextureType.TEX2D; - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.type = TextureType.TEX2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; } } } export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuffer: IWebGLGPUFramebuffer): void { - for (let i = 0; i < gpuFramebuffer.gpuColorTextures$.length; ++i) { - const tex = gpuFramebuffer.gpuColorTextures$[i]; - if (tex.isSwapchainTexture$) { - gpuFramebuffer.isOffscreen$ = false; + for (let i = 0; i < gpuFramebuffer.gpuColorTextures.length; ++i) { + const tex = gpuFramebuffer.gpuColorTextures[i]; + if (tex.isSwapchainTexture) { + gpuFramebuffer.isOffscreen = false; return; } } @@ -985,21 +985,21 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff const glFramebuffer = gl.createFramebuffer(); if (glFramebuffer) { - gpuFramebuffer.glFramebuffer$ = glFramebuffer; + gpuFramebuffer.glFramebuffer = glFramebuffer; - if (stateCache.glFramebuffer$ !== gpuFramebuffer.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer$); + if (stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer); } - for (let i = 0; i < gpuFramebuffer.gpuColorTextures$.length; ++i) { - const gpuTexture = gpuFramebuffer.gpuColorTextures$[i]; + for (let i = 0; i < gpuFramebuffer.gpuColorTextures.length; ++i) { + const gpuTexture = gpuFramebuffer.gpuColorTextures[i]; if (gpuTexture) { - if (gpuTexture.glTexture$) { + if (gpuTexture.glTexture) { gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0 + i, - gpuTexture.glTarget$, - gpuTexture.glTexture$, + gpuTexture.glTarget, + gpuTexture.glTexture, 0, ); // level must be 0 } else { @@ -1007,25 +1007,25 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0 + i, WebGLConstants.RENDERBUFFER, - gpuTexture.glRenderbuffer$, + gpuTexture.glRenderbuffer, ); } attachments.push(WebGLConstants.COLOR_ATTACHMENT0 + i); - gpuFramebuffer.width = min(gpuFramebuffer.width, gpuTexture.width$); - gpuFramebuffer.height = min(gpuFramebuffer.height, gpuTexture.height$); + gpuFramebuffer.width = min(gpuFramebuffer.width, gpuTexture.width); + gpuFramebuffer.height = min(gpuFramebuffer.height, gpuTexture.height); } } - const dst = gpuFramebuffer.gpuDepthStencilTexture$; + const dst = gpuFramebuffer.gpuDepthStencilTexture; if (dst) { - const glAttachment = FormatInfos[dst.format$].hasStencil ? WebGLConstants.DEPTH_STENCIL_ATTACHMENT : WebGLConstants.DEPTH_ATTACHMENT; - if (dst.glTexture$) { + const glAttachment = FormatInfos[dst.format].hasStencil ? WebGLConstants.DEPTH_STENCIL_ATTACHMENT : WebGLConstants.DEPTH_ATTACHMENT; + if (dst.glTexture) { gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, glAttachment, - dst.glTarget$, - dst.glTexture$, + dst.glTarget, + dst.glTexture, 0, ); // level must be 0 } else { @@ -1033,15 +1033,15 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff WebGLConstants.FRAMEBUFFER, glAttachment, WebGLConstants.RENDERBUFFER, - dst.glRenderbuffer$, + dst.glRenderbuffer, ); } - gpuFramebuffer.width = min(gpuFramebuffer.width, dst.width$); - gpuFramebuffer.height = min(gpuFramebuffer.height, dst.height$); + gpuFramebuffer.width = min(gpuFramebuffer.width, dst.width); + gpuFramebuffer.height = min(gpuFramebuffer.height, dst.height); } - if (device.extensions.WEBGL_draw_buffers$) { - device.extensions.WEBGL_draw_buffers$.drawBuffersWEBGL(attachments); + if (device.extensions.WEBGL_draw_buffers) { + device.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(attachments); } const status = gl.checkFramebufferStatus(WebGLConstants.FRAMEBUFFER); @@ -1067,35 +1067,35 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff } } - if (stateCache.glFramebuffer$ !== gpuFramebuffer.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, stateCache.glFramebuffer$); + if (stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, stateCache.glFramebuffer); } } } export function WebGLCmdFuncDestroyFramebuffer (device: WebGLDevice, gpuFramebuffer: IWebGLGPUFramebuffer): void { const { gl, stateCache } = device; - if (gpuFramebuffer.glFramebuffer$) { - gl.deleteFramebuffer(gpuFramebuffer.glFramebuffer$); - if (stateCache.glFramebuffer$ === gpuFramebuffer.glFramebuffer$) { + if (gpuFramebuffer.glFramebuffer) { + gl.deleteFramebuffer(gpuFramebuffer.glFramebuffer); + if (stateCache.glFramebuffer === gpuFramebuffer.glFramebuffer) { gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, null); - stateCache.glFramebuffer$ = null; + stateCache.glFramebuffer = null; } - gpuFramebuffer.glFramebuffer$ = null; + gpuFramebuffer.glFramebuffer = null; } } export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGLGPUShader): void { const { gl, stateCache } = device; - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; let glShaderType: GLenum = 0; let shaderTypeStr = ''; let lineNumber = 1; - switch (gpuStage.type$) { + switch (gpuStage.type) { case ShaderStageFlagBit.VERTEX: { shaderTypeStr = 'VertexShader'; glShaderType = WebGLConstants.VERTEX_SHADER; @@ -1114,20 +1114,20 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL const glShader = gl.createShader(glShaderType); if (glShader) { - gpuStage.glShader$ = glShader; - gl.shaderSource(gpuStage.glShader$, gpuStage.source$); - gl.compileShader(gpuStage.glShader$); - - if (!gl.getShaderParameter(gpuStage.glShader$, WebGLConstants.COMPILE_STATUS)) { - errorID(16323, shaderTypeStr, gpuShader.name$); - errorID(16324, gpuStage.source$.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); - error(gl.getShaderInfoLog(gpuStage.glShader$)); - - for (let l = 0; l < gpuShader.gpuStages$.length; l++) { - const stage = gpuShader.gpuStages$[k]; - if (stage.glShader$) { - gl.deleteShader(stage.glShader$); - stage.glShader$ = null; + gpuStage.glShader = glShader; + gl.shaderSource(gpuStage.glShader, gpuStage.source); + gl.compileShader(gpuStage.glShader); + + if (!gl.getShaderParameter(gpuStage.glShader, WebGLConstants.COMPILE_STATUS)) { + errorID(16323, shaderTypeStr, gpuShader.name); + errorID(16324, gpuStage.source.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); + error(gl.getShaderInfoLog(gpuStage.glShader)); + + for (let l = 0; l < gpuShader.gpuStages.length; l++) { + const stage = gpuShader.gpuStages[k]; + if (stage.glShader) { + gl.deleteShader(stage.glShader); + stage.glShader = null; } } return; @@ -1140,42 +1140,42 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL return; } - gpuShader.glProgram$ = glProgram; + gpuShader.glProgram = glProgram; // link program - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; - gl.attachShader(gpuShader.glProgram$, gpuStage.glShader$!); + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; + gl.attachShader(gpuShader.glProgram, gpuStage.glShader!); } - gl.linkProgram(gpuShader.glProgram$); + gl.linkProgram(gpuShader.glProgram); // detach & delete immediately - if (device.extensions.destroyShadersImmediately$) { - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; - if (gpuStage.glShader$) { - gl.detachShader(gpuShader.glProgram$, gpuStage.glShader$); - gl.deleteShader(gpuStage.glShader$); - gpuStage.glShader$ = null; + if (device.extensions.destroyShadersImmediately) { + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; + if (gpuStage.glShader) { + gl.detachShader(gpuShader.glProgram, gpuStage.glShader); + gl.deleteShader(gpuStage.glShader); + gpuStage.glShader = null; } } } - if (gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.LINK_STATUS)) { - debugID(16325, gpuShader.name$); + if (gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.LINK_STATUS)) { + debugID(16325, gpuShader.name); } else { - errorID(16326, gpuShader.name$); - error(gl.getProgramInfoLog(gpuShader.glProgram$)); + errorID(16326, gpuShader.name); + error(gl.getProgramInfoLog(gpuShader.glProgram)); return; } // parse inputs - const activeAttribCount: number = gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.ACTIVE_ATTRIBUTES); - gpuShader.glInputs$ = new Array(activeAttribCount); + const activeAttribCount: number = gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.ACTIVE_ATTRIBUTES); + gpuShader.glInputs = new Array(activeAttribCount); for (let i = 0; i < activeAttribCount; ++i) { - const attribInfo = gl.getActiveAttrib(gpuShader.glProgram$, i); + const attribInfo = gl.getActiveAttrib(gpuShader.glProgram, i); if (attribInfo) { const { type: attribType, name: attribName, size: attribSize } = attribInfo; let varName: string; @@ -1186,40 +1186,40 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL varName = attribName; } - const glLoc = gl.getAttribLocation(gpuShader.glProgram$, varName); + const glLoc = gl.getAttribLocation(gpuShader.glProgram, varName); const gfxType = WebGLTypeToGFXType(attribType, gl); const stride = WebGLGetTypeSize(attribType, gl); - gpuShader.glInputs$[i] = { - binding$: glLoc, - name$: varName, - type$: gfxType, - stride$: stride, - count$: attribSize, - size$: stride * attribSize, + gpuShader.glInputs[i] = { + binding: glLoc, + name: varName, + type: gfxType, + stride: stride, + count: attribSize, + size: stride * attribSize, - glType$: attribType, - glLoc$: glLoc, + glType: attribType, + glLoc: glLoc, }; } } // create uniform blocks - if (gpuShader.blocks$.length > 0) { - gpuShader.glBlocks$ = new Array(gpuShader.blocks$.length); - for (let i = 0; i < gpuShader.blocks$.length; ++i) { - const block = gpuShader.blocks$[i]; + if (gpuShader.blocks.length > 0) { + gpuShader.glBlocks = new Array(gpuShader.blocks.length); + for (let i = 0; i < gpuShader.blocks.length; ++i) { + const block = gpuShader.blocks[i]; const glBlock: IWebGLGPUUniformBlock = { - set$: block.set, - binding$: block.binding, - name$: block.name, - size$: 0, - glUniforms$: new Array(block.members.length), - glActiveUniforms$: [], + set: block.set, + binding: block.binding, + name: block.name, + size: 0, + glUniforms: new Array(block.members.length), + glActiveUniforms: [], }; - gpuShader.glBlocks$[i] = glBlock; + gpuShader.glBlocks[i] = glBlock; for (let u = 0; u < block.members.length; ++u) { const uniform = block.members[u]; @@ -1227,63 +1227,63 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL const stride = WebGLGetTypeSize(glType, gl); const size = stride * uniform.count; - glBlock.glUniforms$[u] = { - binding$: -1, - name$: uniform.name, - type$: uniform.type, - stride$: stride, - count$: uniform.count, - size$: size, - offset$: 0, - - glType$: glType, - glLoc$: null!, - array$: null!, + glBlock.glUniforms[u] = { + binding: -1, + name: uniform.name, + type: uniform.type, + stride: stride, + count: uniform.count, + size: size, + offset: 0, + + glType: glType, + glLoc: null!, + array: null!, }; } } } // WebGL doesn't support Framebuffer Fetch - for (let i = 0; i < gpuShader.subpassInputs$.length; ++i) { - const subpassInput = gpuShader.subpassInputs$[i]; - gpuShader.samplerTextures$.push( + for (let i = 0; i < gpuShader.subpassInputs.length; ++i) { + const subpassInput = gpuShader.subpassInputs[i]; + gpuShader.samplerTextures.push( new UniformSamplerTexture(subpassInput.set, subpassInput.binding, subpassInput.name, Type.SAMPLER2D, subpassInput.count), ); } // create uniform sampler textures - if (gpuShader.samplerTextures$.length > 0) { - gpuShader.glSamplerTextures$ = new Array(gpuShader.samplerTextures$.length); - - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - gpuShader.glSamplerTextures$[i] = { - set$: sampler.set, - binding$: sampler.binding, - name$: sampler.name, - type$: sampler.type, - count$: sampler.count, - units$: [], - glUnits$: null!, - glType$: GFXTypeToWebGLType(sampler.type, gl), - glLoc$: null!, + if (gpuShader.samplerTextures.length > 0) { + gpuShader.glSamplerTextures = new Array(gpuShader.samplerTextures.length); + + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + gpuShader.glSamplerTextures[i] = { + set: sampler.set, + binding: sampler.binding, + name: sampler.name, + type: sampler.type, + count: sampler.count, + units: [], + glUnits: null!, + glType: GFXTypeToWebGLType(sampler.type, gl), + glLoc: null!, }; } } // parse uniforms - const activeUniformCount = gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.ACTIVE_UNIFORMS); + const activeUniformCount = gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.ACTIVE_UNIFORMS); for (let i = 0; i < activeUniformCount; ++i) { - const uniformInfo = gl.getActiveUniform(gpuShader.glProgram$, i); + const uniformInfo = gl.getActiveUniform(gpuShader.glProgram, i); if (uniformInfo) { const isSampler = (uniformInfo.type === WebGLConstants.SAMPLER_2D) || (uniformInfo.type === WebGLConstants.SAMPLER_CUBE); if (!isSampler) { - const glLoc = gl.getUniformLocation(gpuShader.glProgram$, uniformInfo.name); - if (device.extensions.isLocationActive$(glLoc)) { + const glLoc = gl.getUniformLocation(gpuShader.glProgram, uniformInfo.name); + if (device.extensions.isLocationActive(glLoc)) { let varName: string; const nameOffset = uniformInfo.name.indexOf('['); if (nameOffset !== -1) { @@ -1293,18 +1293,18 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL } // build uniform block mapping - for (let j = 0; j < gpuShader.glBlocks$.length; j++) { - const glBlock = gpuShader.glBlocks$[j]; - - for (let k = 0; k < glBlock.glUniforms$.length; k++) { - const glUniform = glBlock.glUniforms$[k]; - if (glUniform.name$ === varName) { - glUniform.glLoc$ = glLoc; - glUniform.count$ = uniformInfo.size; - glUniform.size$ = glUniform.stride$ * glUniform.count$; - glUniform.array$ = new (GFXTypeToTypedArrayCtor(glUniform.type$))(glUniform.size$ / 4); - - glBlock.glActiveUniforms$.push(glUniform); + for (let j = 0; j < gpuShader.glBlocks.length; j++) { + const glBlock = gpuShader.glBlocks[j]; + + for (let k = 0; k < glBlock.glUniforms.length; k++) { + const glUniform = glBlock.glUniforms[k]; + if (glUniform.name === varName) { + glUniform.glLoc = glLoc; + glUniform.count = uniformInfo.size; + glUniform.size = glUniform.stride * glUniform.count; + glUniform.array = new (GFXTypeToTypedArrayCtor(glUniform.type))(glUniform.size / 4); + + glBlock.glActiveUniforms.push(glUniform); break; } } @@ -1317,12 +1317,12 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL // calculate offset & size // WARNING: we can't handle inactive uniform arrays with wrong input sizes // and there is no way to detect that for now - for (let j = 0; j < gpuShader.glBlocks$.length; j++) { - const glBlock = gpuShader.glBlocks$[j]; - for (let k = 0; k < glBlock.glUniforms$.length; k++) { - const glUniform = glBlock.glUniforms$[k]; - glUniform.offset$ = glBlock.size$ / 4; - glBlock.size$ += glUniform.size$; + for (let j = 0; j < gpuShader.glBlocks.length; j++) { + const glBlock = gpuShader.glBlocks[j]; + for (let k = 0; k < glBlock.glUniforms.length; k++) { + const glUniform = glBlock.glUniforms[k]; + glUniform.offset = glBlock.size / 4; + glBlock.size += glUniform.size; } } @@ -1330,38 +1330,38 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL const glActiveSamplers: IWebGLGPUUniformSamplerTexture[] = []; const glActiveSamplerLocations: WebGLUniformLocation[] = []; const { bindingMappings, capabilities } = device; - const { texUnitCacheMap$: texUnitCacheMap } = device.stateCache; + const { texUnitCacheMap } = device.stateCache; const { maxTextureUnits } = capabilities; if (!(cclegacy.rendering && cclegacy.rendering.enableEffectImport)) { let flexibleSetBaseOffset = 0; - for (let i = 0; i < gpuShader.blocks$.length; ++i) { - if (gpuShader.blocks$[i].set === bindingMappings.flexibleSet$) { + for (let i = 0; i < gpuShader.blocks.length; ++i) { + if (gpuShader.blocks[i].set === bindingMappings.flexibleSet) { flexibleSetBaseOffset++; } } let arrayOffset = 0; - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - const glLoc = gl.getUniformLocation(gpuShader.glProgram$, sampler.name); - if (device.extensions.isLocationActive$(glLoc)) { - glActiveSamplers.push(gpuShader.glSamplerTextures$[i]); + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); + if (device.extensions.isLocationActive(glLoc)) { + glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } if (texUnitCacheMap[sampler.name] === undefined) { - let binding = sampler.binding + bindingMappings.samplerTextureOffsets$[sampler.set] + arrayOffset; - if (sampler.set === bindingMappings.flexibleSet$) { binding -= flexibleSetBaseOffset; } + let binding = sampler.binding + bindingMappings.samplerTextureOffsets[sampler.set] + arrayOffset; + if (sampler.set === bindingMappings.flexibleSet) { binding -= flexibleSetBaseOffset; } texUnitCacheMap[sampler.name] = binding % maxTextureUnits; arrayOffset += sampler.count - 1; } } } else { - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - const glLoc = gl.getUniformLocation(gpuShader.glProgram$, sampler.name); - if (device.extensions.isLocationActive$(glLoc)) { - glActiveSamplers.push(gpuShader.glSamplerTextures$[i]); + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); + if (device.extensions.isLocationActive(glLoc)) { + glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } if (texUnitCacheMap[sampler.name] === undefined) { @@ -1376,14 +1376,14 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL for (let i = 0; i < glActiveSamplers.length; ++i) { const glSampler = glActiveSamplers[i]; - let cachedUnit = texUnitCacheMap[glSampler.name$]; + let cachedUnit = texUnitCacheMap[glSampler.name]; if (cachedUnit !== undefined) { - glSampler.glLoc$ = glActiveSamplerLocations[i]; - for (let t = 0; t < glSampler.count$; ++t) { + glSampler.glLoc = glActiveSamplerLocations[i]; + for (let t = 0; t < glSampler.count; ++t) { while (usedTexUnits[cachedUnit]) { cachedUnit = (cachedUnit + 1) % maxTextureUnits; } - glSampler.units$.push(cachedUnit); + glSampler.units.push(cachedUnit); usedTexUnits[cachedUnit] = true; } } @@ -1393,100 +1393,100 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL for (let i = 0; i < glActiveSamplers.length; ++i) { const glSampler = glActiveSamplers[i]; - if (!device.extensions.isLocationActive$(glSampler.glLoc$)) { - glSampler.glLoc$ = glActiveSamplerLocations[i]; - for (let t = 0; t < glSampler.count$; ++t) { + if (!device.extensions.isLocationActive(glSampler.glLoc)) { + glSampler.glLoc = glActiveSamplerLocations[i]; + for (let t = 0; t < glSampler.count; ++t) { while (usedTexUnits[unitIdx]) { unitIdx = (unitIdx + 1) % maxTextureUnits; } - if (texUnitCacheMap[glSampler.name$] === undefined) { - texUnitCacheMap[glSampler.name$] = unitIdx; + if (texUnitCacheMap[glSampler.name] === undefined) { + texUnitCacheMap[glSampler.name] = unitIdx; } - glSampler.units$.push(unitIdx); + glSampler.units.push(unitIdx); usedTexUnits[unitIdx] = true; } } } - if (stateCache.glProgram$ !== gpuShader.glProgram$) { - gl.useProgram(gpuShader.glProgram$); + if (stateCache.glProgram !== gpuShader.glProgram) { + gl.useProgram(gpuShader.glProgram); } for (let i = 0; i < glActiveSamplers.length; i++) { const glSampler = glActiveSamplers[i]; - glSampler.glUnits$ = new Int32Array(glSampler.units$); - gl.uniform1iv(glSampler.glLoc$, glSampler.glUnits$); + glSampler.glUnits = new Int32Array(glSampler.units); + gl.uniform1iv(glSampler.glLoc, glSampler.glUnits); } - if (stateCache.glProgram$ !== gpuShader.glProgram$) { - gl.useProgram(stateCache.glProgram$); + if (stateCache.glProgram !== gpuShader.glProgram) { + gl.useProgram(stateCache.glProgram); } } // strip out the inactive ones - for (let i = 0; i < gpuShader.glBlocks$.length;) { - if (gpuShader.glBlocks$[i].glActiveUniforms$.length) { + for (let i = 0; i < gpuShader.glBlocks.length;) { + if (gpuShader.glBlocks[i].glActiveUniforms.length) { i++; } else { - gpuShader.glBlocks$[i] = gpuShader.glBlocks$[gpuShader.glBlocks$.length - 1]; - gpuShader.glBlocks$.length--; + gpuShader.glBlocks[i] = gpuShader.glBlocks[gpuShader.glBlocks.length - 1]; + gpuShader.glBlocks.length--; } } - gpuShader.glSamplerTextures$ = glActiveSamplers; + gpuShader.glSamplerTextures = glActiveSamplers; } export function WebGLCmdFuncDestroyShader (device: WebGLDevice, gpuShader: IWebGLGPUShader): void { - if (gpuShader.glProgram$) { + if (gpuShader.glProgram) { const { gl, stateCache } = device; - if (!device.extensions.destroyShadersImmediately$) { - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; - if (gpuStage.glShader$) { - gl.detachShader(gpuShader.glProgram$, gpuStage.glShader$); - gl.deleteShader(gpuStage.glShader$); - gpuStage.glShader$ = null; + if (!device.extensions.destroyShadersImmediately) { + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; + if (gpuStage.glShader) { + gl.detachShader(gpuShader.glProgram, gpuStage.glShader); + gl.deleteShader(gpuStage.glShader); + gpuStage.glShader = null; } } } - gl.deleteProgram(gpuShader.glProgram$); - if (stateCache.glProgram$ === gpuShader.glProgram$) { + gl.deleteProgram(gpuShader.glProgram); + if (stateCache.glProgram === gpuShader.glProgram) { gl.useProgram(null); - stateCache.glProgram$ = null; + stateCache.glProgram = null; } - gpuShader.glProgram$ = null; + gpuShader.glProgram = null; } } export function WebGLCmdFuncCreateInputAssember (device: WebGLDevice, gpuInputAssembler: IWebGLGPUInputAssembler): void { const { gl } = device; - gpuInputAssembler.glAttribs$ = new Array(gpuInputAssembler.attributes$.length); + gpuInputAssembler.glAttribs = new Array(gpuInputAssembler.attributes.length); const offsets = [0, 0, 0, 0, 0, 0, 0, 0]; - for (let i = 0; i < gpuInputAssembler.attributes$.length; ++i) { - const attrib = gpuInputAssembler.attributes$[i]; + for (let i = 0; i < gpuInputAssembler.attributes.length; ++i) { + const attrib = gpuInputAssembler.attributes[i]; const { format: attribFormat, isNormalized: attribIsNormalized, isInstanced: attribIsInstanced } = attrib; const stream = attrib.stream !== undefined ? attrib.stream : 0; - const gpuBuffer = gpuInputAssembler.gpuVertexBuffers$[stream]; + const gpuBuffer = gpuInputAssembler.gpuVertexBuffers[stream]; const glType = GFXFormatToWebGLType(attribFormat, gl); const { size } = FormatInfos[attribFormat]; - gpuInputAssembler.glAttribs$[i] = { - name$: attrib.name, - glBuffer$: gpuBuffer.glBuffer$, - glType$: glType, - size$: size, - count$: FormatInfos[attribFormat].count, - stride$: gpuBuffer.stride$, - componentCount$: WebGLGetComponentCount(glType, gl), - isNormalized$: (attribIsNormalized !== undefined ? attribIsNormalized : false), - isInstanced$: (attribIsInstanced !== undefined ? attribIsInstanced : false), - offset$: offsets[stream], + gpuInputAssembler.glAttribs[i] = { + name: attrib.name, + glBuffer: gpuBuffer.glBuffer, + glType: glType, + size: size, + count: FormatInfos[attribFormat].count, + stride: gpuBuffer.stride, + componentCount: WebGLGetComponentCount(glType, gl), + isNormalized: (attribIsNormalized !== undefined ? attribIsNormalized : false), + isInstanced: (attribIsInstanced !== undefined ? attribIsInstanced : false), + offset: offsets[stream], }; offsets[stream] += size; @@ -1495,10 +1495,10 @@ export function WebGLCmdFuncCreateInputAssember (device: WebGLDevice, gpuInputAs export function WebGLCmdFuncDestroyInputAssembler (device: WebGLDevice, gpuInputAssembler: IWebGLGPUInputAssembler): void { const { stateCache } = device; - const it = gpuInputAssembler.glVAOs$.values(); + const it = gpuInputAssembler.glVAOs.values(); let res = it.next(); - const OES_vertex_array_object = device.extensions.OES_vertex_array_object$!; - let glVAO = stateCache.glVAO$; + const OES_vertex_array_object = device.extensions.OES_vertex_array_object!; + let glVAO = stateCache.glVAO; while (!res.done) { OES_vertex_array_object.deleteVertexArrayOES(res.value); if (glVAO === res.value) { @@ -1507,19 +1507,19 @@ export function WebGLCmdFuncDestroyInputAssembler (device: WebGLDevice, gpuInput } res = it.next(); } - stateCache.glVAO$ = glVAO; - gpuInputAssembler.glVAOs$.clear(); + stateCache.glVAO = glVAO; + gpuInputAssembler.glVAOs.clear(); } interface IWebGLStateCache { - gpuPipelineState$: IWebGLGPUPipelineState | null; - gpuInputAssembler$: IWebGLGPUInputAssembler | null; - glPrimitive$: number; + gpuPipelineState: IWebGLGPUPipelineState | null; + gpuInputAssembler: IWebGLGPUInputAssembler | null; + glPrimitive: number; } const gfxStateCache: IWebGLStateCache = { - gpuPipelineState$: null, - gpuInputAssembler$: null, - glPrimitive$: 0, + gpuPipelineState: null, + gpuInputAssembler: null, + glPrimitive: 0, }; const realRenderArea = new Rect(); @@ -1537,7 +1537,7 @@ export function WebGLCmdFuncBeginRenderPass ( let clears: GLbitfield = 0; if (gpuFramebuffer) { - const lodLevel = gpuFramebuffer.lodLevel$; + const lodLevel = gpuFramebuffer.lodLevel; realRenderArea.x = renderArea.x << lodLevel; realRenderArea.y = renderArea.y << lodLevel; realRenderArea.width = renderArea.width << lodLevel; @@ -1545,14 +1545,14 @@ export function WebGLCmdFuncBeginRenderPass ( } if (gpuFramebuffer && gpuRenderPass) { - const curGPUFrameBuffer = gpuFramebuffer.glFramebuffer$; + const curGPUFrameBuffer = gpuFramebuffer.glFramebuffer; const { x: realRenderAreaX, y: realRenderAreaY, width: realRenderAreaWidth, height: realRenderAreaHeight } = realRenderArea; - if (cache.glFramebuffer$ !== curGPUFrameBuffer) { + if (cache.glFramebuffer !== curGPUFrameBuffer) { gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, curGPUFrameBuffer); - cache.glFramebuffer$ = curGPUFrameBuffer; + cache.glFramebuffer = curGPUFrameBuffer; } - const cacheViewport = cache.viewport$; + const cacheViewport = cache.viewport; if (cacheViewport.left !== realRenderAreaX || cacheViewport.top !== realRenderAreaY || cacheViewport.width !== realRenderAreaWidth @@ -1565,7 +1565,7 @@ export function WebGLCmdFuncBeginRenderPass ( cacheViewport.height = realRenderAreaHeight; } - const cacheScissorRect = cache.scissorRect$; + const cacheScissorRect = cache.scissorRect; if (cacheScissorRect.x !== realRenderAreaX || cacheScissorRect.y !== realRenderAreaY || cacheScissorRect.width !== realRenderAreaWidth @@ -1581,20 +1581,20 @@ export function WebGLCmdFuncBeginRenderPass ( // const invalidateAttachments: GLenum[] = []; let clearCount = clearColors.length; - if (!device.extensions.WEBGL_draw_buffers$) { + if (!device.extensions.WEBGL_draw_buffers) { clearCount = 1; } - const cacheDSS = cache.dss$; + const cacheDSS = cache.dss; for (let j = 0; j < clearCount; ++j) { - const colorAttachment = gpuRenderPass.colorAttachments$[j]; + const colorAttachment = gpuRenderPass.colorAttachments[j]; if (colorAttachment.format !== Format.UNKNOWN) { switch (colorAttachment.loadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { - if (cache.bs$.targets[0].blendColorMask !== ColorMask.ALL) { + if (cache.bs.targets[0].blendColorMask !== ColorMask.ALL) { gl.colorMask(true, true, true, true); } @@ -1613,9 +1613,9 @@ export function WebGLCmdFuncBeginRenderPass ( } } // if (curGPURenderPass) - if (gpuRenderPass.depthStencilAttachment$) { - if (gpuRenderPass.depthStencilAttachment$.format !== Format.UNKNOWN) { - switch (gpuRenderPass.depthStencilAttachment$.depthLoadOp) { + if (gpuRenderPass.depthStencilAttachment) { + if (gpuRenderPass.depthStencilAttachment.format !== Format.UNKNOWN) { + switch (gpuRenderPass.depthStencilAttachment.depthLoadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { if (!cacheDSS.depthWrite) { @@ -1635,8 +1635,8 @@ export function WebGLCmdFuncBeginRenderPass ( default: } - if (FormatInfos[gpuRenderPass.depthStencilAttachment$.format].hasStencil) { - switch (gpuRenderPass.depthStencilAttachment$.stencilLoadOp) { + if (FormatInfos[gpuRenderPass.depthStencilAttachment.format].hasStencil) { + switch (gpuRenderPass.depthStencilAttachment.stencilLoadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { if (!cacheDSS.stencilWriteMaskFront) { @@ -1674,7 +1674,7 @@ export function WebGLCmdFuncBeginRenderPass ( // restore states if (clears & WebGLConstants.COLOR_BUFFER_BIT) { - const colorMask = cache.bs$.targets[0].blendColorMask; + const colorMask = cache.bs.targets[0].blendColorMask; if (colorMask !== ColorMask.ALL) { const r = (colorMask & ColorMask.R) !== ColorMask.NONE; const g = (colorMask & ColorMask.G) !== ColorMask.NONE; @@ -1711,9 +1711,9 @@ export function WebGLCmdFuncBindStates ( ): void { const { gl } = device; const cache = device.stateCache; - const cacheDSS = cache.dss$; - const cacheBS = cache.bs$; - const gpuShader = gpuPipelineState && gpuPipelineState.gpuShader$; + const cacheDSS = cache.dss; + const cacheBS = cache.bs; + const gpuShader = gpuPipelineState && gpuPipelineState.gpuShader; let isShaderChanged = false; let glWrapS: number; @@ -1721,22 +1721,22 @@ export function WebGLCmdFuncBindStates ( let glMinFilter: number; // bind pipeline - if (gpuPipelineState && gfxStateCache.gpuPipelineState$ !== gpuPipelineState) { - gfxStateCache.gpuPipelineState$ = gpuPipelineState; - gfxStateCache.glPrimitive$ = gpuPipelineState.glPrimitive$; + if (gpuPipelineState && gfxStateCache.gpuPipelineState !== gpuPipelineState) { + gfxStateCache.gpuPipelineState = gpuPipelineState; + gfxStateCache.glPrimitive = gpuPipelineState.glPrimitive; - if (gpuPipelineState.gpuShader$) { - const { glProgram$: glProgram } = gpuPipelineState.gpuShader$; - if (cache.glProgram$ !== glProgram) { + if (gpuPipelineState.gpuShader) { + const { glProgram } = gpuPipelineState.gpuShader; + if (cache.glProgram !== glProgram) { gl.useProgram(glProgram); - cache.glProgram$ = glProgram; + cache.glProgram = glProgram; isShaderChanged = true; } } // rasterizer state - const { rs$: rs } = gpuPipelineState; - const cacheRS = cache.rs$; + const { rs } = gpuPipelineState; + const cacheRS = cache.rs; if (rs) { if (cacheRS.cullMode !== rs.cullMode) { switch (rs.cullMode) { @@ -1780,7 +1780,7 @@ export function WebGLCmdFuncBindStates ( } // rasterizater state // depth-stencil state - const { dss$: dss } = gpuPipelineState; + const { dss } = gpuPipelineState; if (dss) { if (cacheDSS.depthTest !== dss.depthTest) { @@ -1887,7 +1887,7 @@ export function WebGLCmdFuncBindStates ( } // depth-stencil state // blend state - const { bs$: bs } = gpuPipelineState; + const { bs } = gpuPipelineState; if (bs) { if (cacheBS.isA2C !== bs.isA2C) { @@ -1961,28 +1961,28 @@ export function WebGLCmdFuncBindStates ( } // bind pipeline // bind descriptor sets - if (gpuPipelineState && gpuPipelineState.gpuPipelineLayout$ && gpuShader) { - const blockLen = gpuShader.glBlocks$.length; - const { dynamicOffsetIndices$: dynamicOffsetIndices } = gpuPipelineState.gpuPipelineLayout$; + if (gpuPipelineState && gpuPipelineState.gpuPipelineLayout && gpuShader) { + const blockLen = gpuShader.glBlocks.length; + const { dynamicOffsetIndices } = gpuPipelineState.gpuPipelineLayout; for (let j = 0; j < blockLen; j++) { - const glBlock = gpuShader.glBlocks$[j]; - const gpuDescriptorSet = gpuDescriptorSets[glBlock.set$]; - const descriptorIdx = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices$[glBlock.binding$]; - const gpuDescriptor = descriptorIdx >= 0 && gpuDescriptorSet.gpuDescriptors$[descriptorIdx]; + const glBlock = gpuShader.glBlocks[j]; + const gpuDescriptorSet = gpuDescriptorSets[glBlock.set]; + const descriptorIdx = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices[glBlock.binding]; + const gpuDescriptor = descriptorIdx >= 0 && gpuDescriptorSet.gpuDescriptors[descriptorIdx]; let vf32: Float32Array | null = null; let offset = 0; - if (gpuDescriptor && gpuDescriptor.gpuBuffer$) { - const { gpuBuffer$: gpuBuffer } = gpuDescriptor; - const dynamicOffsetIndexSet = dynamicOffsetIndices[glBlock.set$]; - const dynamicOffsetIndex = dynamicOffsetIndexSet && dynamicOffsetIndexSet[glBlock.binding$]; + if (gpuDescriptor && gpuDescriptor.gpuBuffer) { + const { gpuBuffer } = gpuDescriptor; + const dynamicOffsetIndexSet = dynamicOffsetIndices[glBlock.set]; + const dynamicOffsetIndex = dynamicOffsetIndexSet && dynamicOffsetIndexSet[glBlock.binding]; if (dynamicOffsetIndex >= 0) { offset = dynamicOffsets[dynamicOffsetIndex]; } if ('vf32' in gpuBuffer) { vf32 = gpuBuffer.vf32; } else { - offset += gpuBuffer.offset$; - vf32 = gpuBuffer.gpuBuffer$.vf32; + offset += gpuBuffer.offset; + vf32 = gpuBuffer.gpuBuffer.vf32; } offset >>= 2; } @@ -1992,19 +1992,19 @@ export function WebGLCmdFuncBindStates ( continue; } - const uniformLen = glBlock.glActiveUniforms$.length; + const uniformLen = glBlock.glActiveUniforms.length; for (let l = 0; l < uniformLen; l++) { - const glUniform = glBlock.glActiveUniforms$[l]; - switch (glUniform.glType$) { + const glUniform = glBlock.glActiveUniforms[l]; + switch (glUniform.glType) { case WebGLConstants.BOOL: case WebGLConstants.INT: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform1iv(glUniform.glLoc$, glUniform.array$ as Int32Array); + gl.uniform1iv(glUniform.glLoc, glUniform.array as Int32Array); break; } } @@ -2012,13 +2012,13 @@ export function WebGLCmdFuncBindStates ( } case WebGLConstants.BOOL_VEC2: case WebGLConstants.INT_VEC2: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform2iv(glUniform.glLoc$, glUniform.array$ as Int32Array); + gl.uniform2iv(glUniform.glLoc, glUniform.array as Int32Array); break; } } @@ -2026,13 +2026,13 @@ export function WebGLCmdFuncBindStates ( } case WebGLConstants.BOOL_VEC3: case WebGLConstants.INT_VEC3: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform3iv(glUniform.glLoc$, glUniform.array$ as Int32Array); + gl.uniform3iv(glUniform.glLoc, glUniform.array as Int32Array); break; } } @@ -2040,104 +2040,104 @@ export function WebGLCmdFuncBindStates ( } case WebGLConstants.BOOL_VEC4: case WebGLConstants.INT_VEC4: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform4iv(glUniform.glLoc$, glUniform.array$ as Int32Array); + gl.uniform4iv(glUniform.glLoc, glUniform.array as Int32Array); break; } } break; } case WebGLConstants.FLOAT: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform1fv(glUniform.glLoc$, glUniform.array$ as Float32Array); + gl.uniform1fv(glUniform.glLoc, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_VEC2: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform2fv(glUniform.glLoc$, glUniform.array$ as Float32Array); + gl.uniform2fv(glUniform.glLoc, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_VEC3: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform3fv(glUniform.glLoc$, glUniform.array$ as Float32Array); + gl.uniform3fv(glUniform.glLoc, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_VEC4: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniform4fv(glUniform.glLoc$, glUniform.array$ as Float32Array); + gl.uniform4fv(glUniform.glLoc, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_MAT2: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniformMatrix2fv(glUniform.glLoc$, false, glUniform.array$ as Float32Array); + gl.uniformMatrix2fv(glUniform.glLoc, false, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_MAT3: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniformMatrix3fv(glUniform.glLoc$, false, glUniform.array$ as Float32Array); + gl.uniformMatrix3fv(glUniform.glLoc, false, glUniform.array as Float32Array); break; } } break; } case WebGLConstants.FLOAT_MAT4: { - for (let u = 0; u < glUniform.array$.length; ++u) { - const idx = glUniform.offset$ + offset + u; - if (vf32[idx] !== glUniform.array$[u]) { - for (let n = u, m = idx; n < glUniform.array$.length; ++n, ++m) { - glUniform.array$[n] = vf32[m]; + for (let u = 0; u < glUniform.array.length; ++u) { + const idx = glUniform.offset + offset + u; + if (vf32[idx] !== glUniform.array[u]) { + for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) { + glUniform.array[n] = vf32[m]; } - gl.uniformMatrix4fv(glUniform.glLoc$, false, glUniform.array$ as Float32Array); + gl.uniformMatrix4fv(glUniform.glLoc, false, glUniform.array as Float32Array); break; } } @@ -2149,254 +2149,254 @@ export function WebGLCmdFuncBindStates ( continue; } - const samplerLen = gpuShader.glSamplerTextures$.length; + const samplerLen = gpuShader.glSamplerTextures.length; for (let i = 0; i < samplerLen; i++) { - const glSampler = gpuShader.glSamplerTextures$[i]; - const gpuDescriptorSet = gpuDescriptorSets[glSampler.set$]; - let descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices$[glSampler.binding$]; - let gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors$[descriptorIndex]; + const glSampler = gpuShader.glSamplerTextures[i]; + const gpuDescriptorSet = gpuDescriptorSets[glSampler.set]; + let descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices[glSampler.binding]; + let gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors[descriptorIndex]; - const texUnitLen = glSampler.units$.length; + const texUnitLen = glSampler.units.length; for (let l = 0; l < texUnitLen; l++) { - const texUnit = glSampler.units$[l]; + const texUnit = glSampler.units[l]; - if (!gpuDescriptor || !gpuDescriptor.gpuSampler$) { + if (!gpuDescriptor || !gpuDescriptor.gpuSampler) { // error(`Sampler binding '${glSampler.name}' at set ${glSampler.set} binding ${glSampler.binding} index ${l} is not bounded`); continue; } - if (gpuDescriptor.gpuTexture$ && gpuDescriptor.gpuTexture$.size$ > 0) { - const { gpuTexture$: gpuTexture } = gpuDescriptor; - const glTexUnit = cache.glTexUnits$[texUnit]; + if (gpuDescriptor.gpuTexture && gpuDescriptor.gpuTexture.size > 0) { + const { gpuTexture } = gpuDescriptor; + const glTexUnit = cache.glTexUnits[texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - if (cache.texUnit$ !== texUnit) { + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - if (gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); + if (gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); } else { - gl.bindTexture(gpuTexture.glTarget$, device.nullTex2D.gpuTexture.glTexture$); + gl.bindTexture(gpuTexture.glTarget, device.nullTex2D.gpuTexture.glTexture); } - glTexUnit.glTexture$ = gpuTexture.glTexture$; + glTexUnit.glTexture = gpuTexture.glTexture; } - const { gpuSampler$: gpuSampler } = gpuDescriptor; - if (gpuTexture.isPowerOf2$) { - glWrapS = gpuSampler.glWrapS$; - glWrapT = gpuSampler.glWrapT$; + const { gpuSampler } = gpuDescriptor; + if (gpuTexture.isPowerOf2) { + glWrapS = gpuSampler.glWrapS; + glWrapT = gpuSampler.glWrapT; } else { glWrapS = WebGLConstants.CLAMP_TO_EDGE; glWrapT = WebGLConstants.CLAMP_TO_EDGE; } - if (gpuTexture.isPowerOf2$) { - if (gpuTexture.mipLevel$ <= 1 - && (gpuSampler.glMinFilter$ === WebGLConstants.LINEAR_MIPMAP_NEAREST - || gpuSampler.glMinFilter$ === WebGLConstants.LINEAR_MIPMAP_LINEAR)) { + if (gpuTexture.isPowerOf2) { + if (gpuTexture.mipLevel <= 1 + && (gpuSampler.glMinFilter === WebGLConstants.LINEAR_MIPMAP_NEAREST + || gpuSampler.glMinFilter === WebGLConstants.LINEAR_MIPMAP_LINEAR)) { glMinFilter = WebGLConstants.LINEAR; } else { - glMinFilter = gpuSampler.glMinFilter$; + glMinFilter = gpuSampler.glMinFilter; } - } else if (gpuSampler.glMinFilter$ === WebGLConstants.LINEAR - || gpuSampler.glMinFilter$ === WebGLConstants.LINEAR_MIPMAP_NEAREST - || gpuSampler.glMinFilter$ === WebGLConstants.LINEAR_MIPMAP_LINEAR) { + } else if (gpuSampler.glMinFilter === WebGLConstants.LINEAR + || gpuSampler.glMinFilter === WebGLConstants.LINEAR_MIPMAP_NEAREST + || gpuSampler.glMinFilter === WebGLConstants.LINEAR_MIPMAP_LINEAR) { glMinFilter = WebGLConstants.LINEAR; } else { glMinFilter = WebGLConstants.NEAREST; } - if (gpuTexture.glWrapS$ !== glWrapS) { - if (cache.texUnit$ !== texUnit) { + if (gpuTexture.glWrapS !== glWrapS) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_S, glWrapS); - gpuTexture.glWrapS$ = glWrapS; + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_S, glWrapS); + gpuTexture.glWrapS = glWrapS; } - if (gpuTexture.glWrapT$ !== glWrapT) { - if (cache.texUnit$ !== texUnit) { + if (gpuTexture.glWrapT !== glWrapT) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_WRAP_T, glWrapT); - gpuTexture.glWrapT$ = glWrapT; + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_WRAP_T, glWrapT); + gpuTexture.glWrapT = glWrapT; } - if (gpuTexture.glMinFilter$ !== glMinFilter) { - if (cache.texUnit$ !== texUnit) { + if (gpuTexture.glMinFilter !== glMinFilter) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MIN_FILTER, glMinFilter); - gpuTexture.glMinFilter$ = glMinFilter; + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MIN_FILTER, glMinFilter); + gpuTexture.glMinFilter = glMinFilter; } - if (gpuTexture.glMagFilter$ !== gpuSampler.glMagFilter$) { - if (cache.texUnit$ !== texUnit) { + if (gpuTexture.glMagFilter !== gpuSampler.glMagFilter) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - gl.texParameteri(gpuTexture.glTarget$, WebGLConstants.TEXTURE_MAG_FILTER, gpuSampler.glMagFilter$); - gpuTexture.glMagFilter$ = gpuSampler.glMagFilter$; + gl.texParameteri(gpuTexture.glTarget, WebGLConstants.TEXTURE_MAG_FILTER, gpuSampler.glMagFilter); + gpuTexture.glMagFilter = gpuSampler.glMagFilter; } } - gpuDescriptor = gpuDescriptorSet.gpuDescriptors$[++descriptorIndex]; + gpuDescriptor = gpuDescriptorSet.gpuDescriptors[++descriptorIndex]; } } } // bind descriptor sets // bind vertex/index buffer if (gpuInputAssembler && gpuShader - && (isShaderChanged || gfxStateCache.gpuInputAssembler$ !== gpuInputAssembler)) { - gfxStateCache.gpuInputAssembler$ = gpuInputAssembler; - const ia = device.extensions.ANGLE_instanced_arrays$; + && (isShaderChanged || gfxStateCache.gpuInputAssembler !== gpuInputAssembler)) { + gfxStateCache.gpuInputAssembler = gpuInputAssembler; + const ia = device.extensions.ANGLE_instanced_arrays; - if (device.extensions.useVAO$) { - const vao = device.extensions.OES_vertex_array_object$!; + if (device.extensions.useVAO) { + const vao = device.extensions.OES_vertex_array_object!; // check vao - let glVAO = gpuInputAssembler.glVAOs$.get(gpuShader.glProgram$!); + let glVAO = gpuInputAssembler.glVAOs.get(gpuShader.glProgram!); if (!glVAO) { glVAO = vao.createVertexArrayOES()!; - gpuInputAssembler.glVAOs$.set(gpuShader.glProgram$!, glVAO); + gpuInputAssembler.glVAOs.set(gpuShader.glProgram!, glVAO); vao.bindVertexArrayOES(glVAO); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; - cache.glElementArrayBuffer$ = null; + cache.glArrayBuffer = null; + cache.glElementArrayBuffer = null; let glAttrib: IWebGLAttrib | null; - const inputLen = gpuShader.glInputs$.length; + const inputLen = gpuShader.glInputs.length; for (let j = 0; j < inputLen; j++) { - const glInput = gpuShader.glInputs$[j]; + const glInput = gpuShader.glInputs[j]; glAttrib = null; - const attribLen = gpuInputAssembler.glAttribs$.length; + const attribLen = gpuInputAssembler.glAttribs.length; for (let k = 0; k < attribLen; k++) { - const attrib = gpuInputAssembler.glAttribs$[k]; - if (attrib.name$ === glInput.name$) { + const attrib = gpuInputAssembler.glAttribs[k]; + if (attrib.name === glInput.name) { glAttrib = attrib; break; } } if (glAttrib) { - if (cache.glArrayBuffer$ !== glAttrib.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer$); - cache.glArrayBuffer$ = glAttrib.glBuffer$; + if (cache.glArrayBuffer !== glAttrib.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer); + cache.glArrayBuffer = glAttrib.glBuffer; } - for (let c = 0; c < glAttrib.componentCount$; ++c) { - const glLoc = glInput.glLoc$ + c; - const attribOffset = glAttrib.offset$ + glAttrib.size$ * c; + for (let c = 0; c < glAttrib.componentCount; ++c) { + const glLoc = glInput.glLoc + c; + const attribOffset = glAttrib.offset + glAttrib.size * c; gl.enableVertexAttribArray(glLoc); - cache.glCurrentAttribLocs$[glLoc] = true; + cache.glCurrentAttribLocs[glLoc] = true; - gl.vertexAttribPointer(glLoc, glAttrib.count$, glAttrib.glType$, glAttrib.isNormalized$, glAttrib.stride$, attribOffset); - if (ia) { ia.vertexAttribDivisorANGLE(glLoc, glAttrib.isInstanced$ ? 1 : 0); } + gl.vertexAttribPointer(glLoc, glAttrib.count, glAttrib.glType, glAttrib.isNormalized, glAttrib.stride, attribOffset); + if (ia) { ia.vertexAttribDivisorANGLE(glLoc, glAttrib.isInstanced ? 1 : 0); } } } } - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer$; + const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuBuffer) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); } vao.bindVertexArrayOES(null); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; - cache.glElementArrayBuffer$ = null; + cache.glArrayBuffer = null; + cache.glElementArrayBuffer = null; } - if (cache.glVAO$ !== glVAO) { + if (cache.glVAO !== glVAO) { vao.bindVertexArrayOES(glVAO); - cache.glVAO$ = glVAO; + cache.glVAO = glVAO; } } else { for (let a = 0; a < device.capabilities.maxVertexAttributes; ++a) { - cache.glCurrentAttribLocs$[a] = false; + cache.glCurrentAttribLocs[a] = false; } - const inputLen = gpuShader.glInputs$.length; + const inputLen = gpuShader.glInputs.length; for (let j = 0; j < inputLen; j++) { - const glInput = gpuShader.glInputs$[j]; + const glInput = gpuShader.glInputs[j]; let glAttrib: IWebGLAttrib | null = null; - const attribLen = gpuInputAssembler.glAttribs$.length; + const attribLen = gpuInputAssembler.glAttribs.length; for (let k = 0; k < attribLen; k++) { - const attrib = gpuInputAssembler.glAttribs$[k]; - if (attrib.name$ === glInput.name$) { + const attrib = gpuInputAssembler.glAttribs[k]; + if (attrib.name === glInput.name) { glAttrib = attrib; break; } } if (glAttrib) { - if (cache.glArrayBuffer$ !== glAttrib.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer$); - cache.glArrayBuffer$ = glAttrib.glBuffer$; + if (cache.glArrayBuffer !== glAttrib.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer); + cache.glArrayBuffer = glAttrib.glBuffer; } - for (let c = 0; c < glAttrib.componentCount$; ++c) { - const glLoc = glInput.glLoc$ + c; - const attribOffset = glAttrib.offset$ + glAttrib.size$ * c; + for (let c = 0; c < glAttrib.componentCount; ++c) { + const glLoc = glInput.glLoc + c; + const attribOffset = glAttrib.offset + glAttrib.size * c; - if (!cache.glEnabledAttribLocs$[glLoc] && glLoc >= 0) { + if (!cache.glEnabledAttribLocs[glLoc] && glLoc >= 0) { gl.enableVertexAttribArray(glLoc); - cache.glEnabledAttribLocs$[glLoc] = true; + cache.glEnabledAttribLocs[glLoc] = true; } - cache.glCurrentAttribLocs$[glLoc] = true; + cache.glCurrentAttribLocs[glLoc] = true; - gl.vertexAttribPointer(glLoc, glAttrib.count$, glAttrib.glType$, glAttrib.isNormalized$, glAttrib.stride$, attribOffset); - if (ia) { ia.vertexAttribDivisorANGLE(glLoc, glAttrib.isInstanced$ ? 1 : 0); } + gl.vertexAttribPointer(glLoc, glAttrib.count, glAttrib.glType, glAttrib.isNormalized, glAttrib.stride, attribOffset); + if (ia) { ia.vertexAttribDivisorANGLE(glLoc, glAttrib.isInstanced ? 1 : 0); } } } } // for - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer$; + const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuBuffer) { - if (cache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glElementArrayBuffer = gpuBuffer.glBuffer; } } for (let a = 0; a < device.capabilities.maxVertexAttributes; ++a) { - if (cache.glEnabledAttribLocs$[a] !== cache.glCurrentAttribLocs$[a]) { + if (cache.glEnabledAttribLocs[a] !== cache.glCurrentAttribLocs[a]) { gl.disableVertexAttribArray(a); - cache.glEnabledAttribLocs$[a] = false; + cache.glEnabledAttribLocs[a] = false; } } } } // bind vertex/index buffer // update dynamic states - if (gpuPipelineState && gpuPipelineState.dynamicStates$.length) { - const dsLen = gpuPipelineState.dynamicStates$.length; + if (gpuPipelineState && gpuPipelineState.dynamicStates.length) { + const dsLen = gpuPipelineState.dynamicStates.length; for (let j = 0; j < dsLen; j++) { - const dynamicState = gpuPipelineState.dynamicStates$[j]; + const dynamicState = gpuPipelineState.dynamicStates[j]; switch (dynamicState) { case DynamicStateFlagBit.LINE_WIDTH: { - if (cache.rs$.lineWidth !== dynamicStates.lineWidth) { + if (cache.rs.lineWidth !== dynamicStates.lineWidth) { gl.lineWidth(dynamicStates.lineWidth); - cache.rs$.lineWidth = dynamicStates.lineWidth; + cache.rs.lineWidth = dynamicStates.lineWidth; } break; } case DynamicStateFlagBit.DEPTH_BIAS: { - if (cache.rs$.depthBias !== dynamicStates.depthBiasConstant - || cache.rs$.depthBiasSlop !== dynamicStates.depthBiasSlope) { + if (cache.rs.depthBias !== dynamicStates.depthBiasConstant + || cache.rs.depthBiasSlop !== dynamicStates.depthBiasSlope) { gl.polygonOffset(dynamicStates.depthBiasConstant, dynamicStates.depthBiasSlope); - cache.rs$.depthBias = dynamicStates.depthBiasConstant; - cache.rs$.depthBiasSlop = dynamicStates.depthBiasSlope; + cache.rs.depthBias = dynamicStates.depthBiasConstant; + cache.rs.depthBiasSlop = dynamicStates.depthBiasSlope; } break; } @@ -2449,95 +2449,95 @@ export function WebGLCmdFuncBindStates ( export function WebGLCmdFuncDraw (device: WebGLDevice, drawInfo: Readonly): void { const { gl } = device; - const { ANGLE_instanced_arrays$: ia, WEBGL_multi_draw$: md } = device.extensions; - const { gpuInputAssembler$: gpuInputAssembler, glPrimitive$: glPrimitive } = gfxStateCache; + const { ANGLE_instanced_arrays: ia, WEBGL_multi_draw: md } = device.extensions; + const { gpuInputAssembler: gpuInputAssembler, glPrimitive: glPrimitive } = gfxStateCache; if (gpuInputAssembler) { - const indexBuffer = gpuInputAssembler.gpuIndexBuffer$; - if (gpuInputAssembler.gpuIndirectBuffer$) { - const indirects = gpuInputAssembler.gpuIndirectBuffer$.indirects$; - if (indirects.drawByIndex$) { - for (let j = 0; j < indirects.drawCount$; j++) { - indirects.byteOffsets$[j] = indirects.offsets$[j] * indexBuffer!.stride$; + const indexBuffer = gpuInputAssembler.gpuIndexBuffer; + if (gpuInputAssembler.gpuIndirectBuffer) { + const indirects = gpuInputAssembler.gpuIndirectBuffer.indirects; + if (indirects.drawByIndex) { + for (let j = 0; j < indirects.drawCount; j++) { + indirects.byteOffsets[j] = indirects.offsets[j] * indexBuffer!.stride; } if (md) { - if (indirects.instancedDraw$) { + if (indirects.instancedDraw) { md.multiDrawElementsInstancedWEBGL( glPrimitive, - indirects.counts$, + indirects.counts, 0, - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, - indirects.instances$, + indirects.instances, 0, - indirects.drawCount$, + indirects.drawCount, ); } else { md.multiDrawElementsWEBGL( glPrimitive, - indirects.counts$, + indirects.counts, 0, - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, - indirects.drawCount$, + indirects.drawCount, ); } } else { - for (let j = 0; j < indirects.drawCount$; j++) { - if (indirects.instances$[j] && ia) { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] && ia) { ia.drawElementsInstancedANGLE( glPrimitive, - indirects.counts$[j], - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$[j], - indirects.instances$[j], + indirects.counts[j], + gpuInputAssembler.glIndexType, + indirects.byteOffsets[j], + indirects.instances[j], ); } else { - gl.drawElements(glPrimitive, indirects.counts$[j], gpuInputAssembler.glIndexType$, indirects.byteOffsets$[j]); + gl.drawElements(glPrimitive, indirects.counts[j], gpuInputAssembler.glIndexType, indirects.byteOffsets[j]); } } } } else if (md) { - if (indirects.instancedDraw$) { + if (indirects.instancedDraw) { md.multiDrawArraysInstancedWEBGL( glPrimitive, - indirects.offsets$, + indirects.offsets, 0, - indirects.counts$, + indirects.counts, 0, - indirects.instances$, + indirects.instances, 0, - indirects.drawCount$, + indirects.drawCount, ); } else { md.multiDrawArraysWEBGL( glPrimitive, - indirects.offsets$, + indirects.offsets, 0, - indirects.counts$, + indirects.counts, 0, - indirects.drawCount$, + indirects.drawCount, ); } } else { - for (let j = 0; j < indirects.drawCount$; j++) { - if (indirects.instances$[j] && ia) { - ia.drawArraysInstancedANGLE(glPrimitive, indirects.offsets$[j], indirects.counts$[j], indirects.instances$[j]); + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] && ia) { + ia.drawArraysInstancedANGLE(glPrimitive, indirects.offsets[j], indirects.counts[j], indirects.instances[j]); } else { - gl.drawArrays(glPrimitive, indirects.offsets$[j], indirects.counts$[j]); + gl.drawArrays(glPrimitive, indirects.offsets[j], indirects.counts[j]); } } } } else if (drawInfo.instanceCount && ia) { if (indexBuffer) { if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * indexBuffer.stride$; + const offset = drawInfo.firstIndex * indexBuffer.stride; ia.drawElementsInstancedANGLE( glPrimitive, drawInfo.indexCount, - gpuInputAssembler.glIndexType$, + gpuInputAssembler.glIndexType, offset, drawInfo.instanceCount, ); @@ -2547,8 +2547,8 @@ export function WebGLCmdFuncDraw (device: WebGLDevice, drawInfo: Readonly 0) { - const offset = drawInfo.firstIndex * indexBuffer.stride$; - gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType$, offset); + const offset = drawInfo.firstIndex * indexBuffer.stride; + gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset); } } else if (drawInfo.vertexCount > 0) { gl.drawArrays(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount); @@ -2563,16 +2563,16 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( regions: Readonly, ): void { const { gl, stateCache } = device; - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } let n = 0; let f = 0; - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { for (let i = 0; i < regions.length; i++) { const region = regions[i]; @@ -2582,8 +2582,8 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, texImages[n++], ); } @@ -2600,8 +2600,8 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, texImages[n++], ); } @@ -2613,9 +2613,9 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( } } - if ((gpuTexture.flags$ & TextureFlagBit.GEN_MIPMAP) - && gpuTexture.isPowerOf2$) { - gl.generateMipmap(gpuTexture.glTarget$); + if ((gpuTexture.flags & TextureFlagBit.GEN_MIPMAP) + && gpuTexture.isPowerOf2) { + gl.generateMipmap(gpuTexture.glTarget); } } @@ -2665,25 +2665,25 @@ export function WebGLCmdFuncCopyBuffersToTexture ( regions: Readonly, ): void { const { gl, stateCache } = device; - const glTexUnit = stateCache.glTexUnits$[stateCache.texUnit$]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + const glTexUnit = stateCache.glTexUnits[stateCache.texUnit]; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } let n = 0; let f = 0; - const fmtInfo: FormatInfo = FormatInfos[gpuTexture.format$]; + const fmtInfo: FormatInfo = FormatInfos[gpuTexture.format]; const ArrayBufferCtor: TypedArrayConstructor = getTypedArrayConstructor(fmtInfo); const { isCompressed } = fmtInfo; - const blockSize = formatAlignment(gpuTexture.format$); + const blockSize = formatAlignment(gpuTexture.format); const extent: Extent = new Extent(); const offset: Offset = new Offset(); const stride: Extent = new Extent(); - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { for (let i = 0; i < regions.length; i++) { const region = regions[i]; @@ -2697,17 +2697,17 @@ export function WebGLCmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -2718,11 +2718,11 @@ export function WebGLCmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) && !device.extensions.noCompressedTexSubImage2D$) { + } else if (gpuTexture.glInternalFmt !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) && !device.extensions.noCompressedTexSubImage2D) { gl.compressedTexSubImage2D( WebGLConstants.TEXTURE_2D, mipLevel, @@ -2730,14 +2730,14 @@ export function WebGLCmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage2D( WebGLConstants.TEXTURE_2D, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, 0, @@ -2760,19 +2760,19 @@ export function WebGLCmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; const fcount = region.texSubres.baseArrayLayer + region.texSubres.layerCount; for (f = region.texSubres.baseArrayLayer; f < fcount; ++f) { let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -2783,12 +2783,12 @@ export function WebGLCmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) - && !device.extensions.noCompressedTexSubImage2D$) { + } else if (gpuTexture.glInternalFmt !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) + && !device.extensions.noCompressedTexSubImage2D) { gl.compressedTexSubImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, mipLevel, @@ -2796,14 +2796,14 @@ export function WebGLCmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, 0, @@ -2819,8 +2819,8 @@ export function WebGLCmdFuncCopyBuffersToTexture ( } } - if (gpuTexture.flags$ & TextureFlagBit.GEN_MIPMAP) { - gl.generateMipmap(gpuTexture.glTarget$); + if (gpuTexture.flags & TextureFlagBit.GEN_MIPMAP) { + gl.generateMipmap(gpuTexture.glTarget); } } @@ -2840,22 +2840,22 @@ export function WebGLCmdFuncCopyTextureToBuffers ( let w = 1; let h = 1; - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { for (let k = 0; k < regions.length; k++) { const region = regions[k]; gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0, - gpuTexture.glTarget$, - gpuTexture.glTexture$, + gpuTexture.glTarget, + gpuTexture.glTexture, region.texSubres.mipLevel, ); x = region.texOffset.x; y = region.texOffset.y; w = region.texExtent.width; h = region.texExtent.height; - gl.readPixels(x, y, w, h, gpuTexture.glFormat$, gpuTexture.glType$, buffers[k]); + gl.readPixels(x, y, w, h, gpuTexture.glFormat, gpuTexture.glType, buffers[k]); } break; } @@ -2864,7 +2864,7 @@ export function WebGLCmdFuncCopyTextureToBuffers ( } } gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, null); - cache.glFramebuffer$ = null; + cache.glFramebuffer = null; gl.deleteFramebuffer(framebuffer); } diff --git a/cocos/gfx/webgl/webgl-define.ts b/cocos/gfx/webgl/webgl-define.ts index 399a40cf305..39db595f0da 100644 --- a/cocos/gfx/webgl/webgl-define.ts +++ b/cocos/gfx/webgl/webgl-define.ts @@ -98,46 +98,46 @@ export enum WebGLEXT { } export interface IWebGLExtensions { - EXT_texture_filter_anisotropic$: EXT_texture_filter_anisotropic | null; - EXT_blend_minmax$: EXT_blend_minmax | null; - EXT_frag_depth$: EXT_frag_depth | null; - EXT_shader_texture_lod$: EXT_shader_texture_lod | null; - EXT_sRGB$: EXT_sRGB | null; - OES_vertex_array_object$: OES_vertex_array_object | null; - EXT_color_buffer_half_float$: EXT_color_buffer_half_float | null; - WEBGL_multi_draw$: WEBGL_multi_draw | null; - WEBGL_color_buffer_float$: WEBGL_color_buffer_float | null; - WEBGL_compressed_texture_etc1$: WEBGL_compressed_texture_etc1 | null; - WEBGL_compressed_texture_etc$: WEBGL_compressed_texture_etc | null; - WEBGL_compressed_texture_pvrtc$: WEBGL_compressed_texture_pvrtc | null; - WEBGL_compressed_texture_astc$: WEBGL_compressed_texture_astc | null; - WEBGL_compressed_texture_s3tc$: WEBGL_compressed_texture_s3tc | null; - WEBGL_compressed_texture_s3tc_srgb$: WEBGL_compressed_texture_s3tc_srgb | null; - WEBGL_debug_shaders$: WEBGL_debug_shaders | null; - WEBGL_draw_buffers$: WEBGL_draw_buffers | null; - WEBGL_lose_context$: WEBGL_lose_context | null; - WEBGL_depth_texture$: WEBGL_depth_texture | null; - WEBGL_debug_renderer_info$: WEBGL_debug_renderer_info | null; - OES_texture_half_float$: OES_texture_half_float | null; - OES_texture_half_float_linear$: OES_texture_half_float_linear | null; - OES_texture_float$: OES_texture_float | null; - OES_texture_float_linear$: OES_texture_float_linear | null; - OES_standard_derivatives$: OES_standard_derivatives | null; - OES_element_index_uint$: OES_element_index_uint | null; - ANGLE_instanced_arrays$: ANGLE_instanced_arrays | null; - destroyShadersImmediately$: boolean; - noCompressedTexSubImage2D$: boolean; - isLocationActive$: (glLoc: unknown) => glLoc is WebGLUniformLocation; - useVAO$: boolean; + EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null; + EXT_blend_minmax: EXT_blend_minmax | null; + EXT_frag_depth: EXT_frag_depth | null; + EXT_shader_texture_lod: EXT_shader_texture_lod | null; + EXT_sRGB: EXT_sRGB | null; + OES_vertex_array_object: OES_vertex_array_object | null; + EXT_color_buffer_half_float: EXT_color_buffer_half_float | null; + WEBGL_multi_draw: WEBGL_multi_draw | null; + WEBGL_color_buffer_float: WEBGL_color_buffer_float | null; + WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null; + WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null; + WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null; + WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null; + WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null; + WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null; + WEBGL_debug_shaders: WEBGL_debug_shaders | null; + WEBGL_draw_buffers: WEBGL_draw_buffers | null; + WEBGL_lose_context: WEBGL_lose_context | null; + WEBGL_depth_texture: WEBGL_depth_texture | null; + WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null; + OES_texture_half_float: OES_texture_half_float | null; + OES_texture_half_float_linear: OES_texture_half_float_linear | null; + OES_texture_float: OES_texture_float | null; + OES_texture_float_linear: OES_texture_float_linear | null; + OES_standard_derivatives: OES_standard_derivatives | null; + OES_element_index_uint: OES_element_index_uint | null; + ANGLE_instanced_arrays: ANGLE_instanced_arrays | null; + destroyShadersImmediately: boolean; + noCompressedTexSubImage2D: boolean; + isLocationActive: (glLoc: unknown) => glLoc is WebGLUniformLocation; + useVAO: boolean; } // put the global instance here so that we won't have circular dependencies export class WebGLDeviceManager { static get instance (): WebGLDevice { - return WebGLDeviceManager._instance$!; + return WebGLDeviceManager._instance!; } - static setInstance$ (instance: WebGLDevice): void { - WebGLDeviceManager._instance$ = instance; + static setInstance (instance: WebGLDevice): void { + WebGLDeviceManager._instance = instance; } - private static _instance$: WebGLDevice | null = null; + private static _instance: WebGLDevice | null = null; } diff --git a/cocos/gfx/webgl/webgl-descriptor-set-layout.ts b/cocos/gfx/webgl/webgl-descriptor-set-layout.ts index 9365ae77a9d..c136df24b32 100644 --- a/cocos/gfx/webgl/webgl-descriptor-set-layout.ts +++ b/cocos/gfx/webgl/webgl-descriptor-set-layout.ts @@ -27,37 +27,37 @@ import { DescriptorSetLayout } from '../base/descriptor-set-layout'; import { IWebGLGPUDescriptorSetLayout } from './webgl-gpu-objects'; export class WebGLDescriptorSetLayout extends DescriptorSetLayout { - get gpuDescriptorSetLayout (): IWebGLGPUDescriptorSetLayout { return this._gpuDescriptorSetLayout$!; } + get gpuDescriptorSetLayout (): IWebGLGPUDescriptorSetLayout { return this._gpuDescriptorSetLayout!; } - private _gpuDescriptorSetLayout$: IWebGLGPUDescriptorSetLayout | null = null; + private _gpuDescriptorSetLayout: IWebGLGPUDescriptorSetLayout | null = null; constructor () { super(); } public initialize (info: Readonly): void { - Array.prototype.push.apply(this._bindings$, info.bindings); + Array.prototype.push.apply(this._bindings, info.bindings); let descriptorCount = 0; let maxBinding = -1; const flattenedIndices: number[] = []; - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; flattenedIndices.push(descriptorCount); descriptorCount += binding.count; if (binding.binding > maxBinding) maxBinding = binding.binding; } - this._bindingIndices$ = Array(maxBinding + 1).fill(-1); - const descriptorIndices = this._descriptorIndices$ = Array(maxBinding + 1).fill(-1); - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; - this._bindingIndices$[binding.binding] = i; + this._bindingIndices = Array(maxBinding + 1).fill(-1); + const descriptorIndices = this._descriptorIndices = Array(maxBinding + 1).fill(-1); + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; + this._bindingIndices[binding.binding] = i; descriptorIndices[binding.binding] = flattenedIndices[i]; } const dynamicBindings: number[] = []; - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; if (binding.descriptorType & DESCRIPTOR_DYNAMIC_TYPE) { for (let j = 0; j < binding.count; j++) { dynamicBindings.push(binding.binding); @@ -65,15 +65,15 @@ export class WebGLDescriptorSetLayout extends DescriptorSetLayout { } } - this._gpuDescriptorSetLayout$ = { - bindings$: this._bindings$, - dynamicBindings$: dynamicBindings, - descriptorIndices$: descriptorIndices, - descriptorCount$: descriptorCount, + this._gpuDescriptorSetLayout = { + bindings: this._bindings, + dynamicBindings, + descriptorIndices, + descriptorCount, }; } public destroy (): void { - this._bindings$.length = 0; + this._bindings.length = 0; } } diff --git a/cocos/gfx/webgl/webgl-descriptor-set.ts b/cocos/gfx/webgl/webgl-descriptor-set.ts index 7e43b1c0ddf..4acfab1749e 100644 --- a/cocos/gfx/webgl/webgl-descriptor-set.ts +++ b/cocos/gfx/webgl/webgl-descriptor-set.ts @@ -32,63 +32,63 @@ import { DescriptorSetInfo, DESCRIPTOR_SAMPLER_TYPE, DESCRIPTOR_BUFFER_TYPE } fr export class WebGLDescriptorSet extends DescriptorSet { get gpuDescriptorSet (): IWebGLGPUDescriptorSet { - return this._gpuDescriptorSet$ as IWebGLGPUDescriptorSet; + return this._gpuDescriptorSet as IWebGLGPUDescriptorSet; } - private _gpuDescriptorSet$: IWebGLGPUDescriptorSet | null = null; + private _gpuDescriptorSet: IWebGLGPUDescriptorSet | null = null; constructor () { super(); } public initialize (info: Readonly): void { - this._layout$ = info.layout; - const { bindings$: bindings, descriptorIndices$: descriptorIndices, descriptorCount$: descriptorCount } = (info.layout as WebGLDescriptorSetLayout).gpuDescriptorSetLayout; + this._layout = info.layout; + const { bindings, descriptorIndices, descriptorCount } = (info.layout as WebGLDescriptorSetLayout).gpuDescriptorSetLayout; - this._buffers$ = Array(descriptorCount).fill(null); - this._textures$ = Array(descriptorCount).fill(null); - this._samplers$ = Array(descriptorCount).fill(null); + this._buffers = Array(descriptorCount).fill(null); + this._textures = Array(descriptorCount).fill(null); + this._samplers = Array(descriptorCount).fill(null); const gpuDescriptors: IWebGLGPUDescriptor[] = []; - this._gpuDescriptorSet$ = { gpuDescriptors$: gpuDescriptors, descriptorIndices$: descriptorIndices }; + this._gpuDescriptorSet = { gpuDescriptors, descriptorIndices }; for (let i = 0; i < bindings.length; ++i) { const binding = bindings[i]; for (let j = 0; j < binding.count; j++) { gpuDescriptors.push({ - type$: binding.descriptorType, - gpuBuffer$: null, - gpuTexture$: null, - gpuSampler$: null, + type: binding.descriptorType, + gpuBuffer: null, + gpuTexture: null, + gpuSampler: null, }); } } } public destroy (): void { - this._layout$ = null; - this._gpuDescriptorSet$ = null; + this._layout = null; + this._gpuDescriptorSet = null; } public update (): void { - if (this._isDirty$ && this._gpuDescriptorSet$) { - const descriptors = this._gpuDescriptorSet$.gpuDescriptors$; + if (this._isDirty && this._gpuDescriptorSet) { + const descriptors = this._gpuDescriptorSet.gpuDescriptors; for (let i = 0; i < descriptors.length; ++i) { - if (descriptors[i].type$ & DESCRIPTOR_BUFFER_TYPE) { - const buffer = this._buffers$[i] as WebGLBuffer | null; + if (descriptors[i].type & DESCRIPTOR_BUFFER_TYPE) { + const buffer = this._buffers[i] as WebGLBuffer | null; if (buffer) { - descriptors[i].gpuBuffer$ = buffer.gpuBuffer || buffer.gpuBufferView; + descriptors[i].gpuBuffer = buffer.gpuBuffer || buffer.gpuBufferView; } - } else if (descriptors[i].type$ & DESCRIPTOR_SAMPLER_TYPE) { - if (this._textures$[i]) { - descriptors[i].gpuTexture$ = (this._textures$[i] as WebGLTexture).gpuTexture; + } else if (descriptors[i].type & DESCRIPTOR_SAMPLER_TYPE) { + if (this._textures[i]) { + descriptors[i].gpuTexture = (this._textures[i] as WebGLTexture).gpuTexture; } - if (this._samplers$[i]) { - descriptors[i].gpuSampler$ = (this._samplers$[i] as WebGLSampler).gpuSampler; + if (this._samplers[i]) { + descriptors[i].gpuSampler = (this._samplers[i] as WebGLSampler).gpuSampler; } } } - this._isDirty$ = false; + this._isDirty = false; } } } diff --git a/cocos/gfx/webgl/webgl-device.ts b/cocos/gfx/webgl/webgl-device.ts index 46487b24ed4..9965434babf 100644 --- a/cocos/gfx/webgl/webgl-device.ts +++ b/cocos/gfx/webgl/webgl-device.ts @@ -74,48 +74,48 @@ export class WebGLDevice extends Device { } get gl (): WebGLRenderingContext { - return this._context$!; + return this._context!; } get extensions (): IWebGLExtensions { - return this._swapchain$!.extensions; + return this._swapchain!.extensions; } get stateCache (): WebGLStateCache { - return this._swapchain$!.stateCache$; + return this._swapchain!.stateCache; } get nullTex2D (): WebGLTexture { - return this._swapchain$!.nullTex2D$; + return this._swapchain!.nullTex2D; } get nullTexCube (): WebGLTexture { - return this._swapchain$!.nullTexCube$; + return this._swapchain!.nullTexCube; } get textureExclusive (): boolean[] { - return this._textureExclusive$; + return this._textureExclusive; } get bindingMappings (): IWebGLBindingMapping { - return this._bindingMappings$!; + return this._bindingMappings!; } get blitManager (): IWebGLBlitManager { - return this._swapchain$!.blitManager; + return this._swapchain!.blitManager; } - private _swapchain$: WebGLSwapchain | null = null; - private _context$: WebGLRenderingContext | null = null; - private _bindingMappings$: IWebGLBindingMapping | null = null; + private _swapchain: WebGLSwapchain | null = null; + private _context: WebGLRenderingContext | null = null; + private _bindingMappings: IWebGLBindingMapping | null = null; - protected _textureExclusive$ = new Array(Format.COUNT); + protected _textureExclusive = new Array(Format.COUNT); public initialize (info: Readonly): boolean { - WebGLDeviceManager.setInstance$(this); - this._gfxAPI$ = API.WEBGL; + WebGLDeviceManager.setInstance(this); + this._gfxAPI = API.WEBGL; - const mapping = this._bindingMappingInfo$ = info.bindingMappingInfo; + const mapping = this._bindingMappingInfo = info.bindingMappingInfo; const blockOffsets: number[] = []; const samplerTextureOffsets: number[] = []; const firstSet = mapping.setIndices[0]; @@ -133,13 +133,13 @@ export class WebGLDevice extends Device { // textures always come after UBOs samplerTextureOffsets[curSet] -= mapping.maxBlockCounts[curSet]; } - this._bindingMappings$ = { - blockOffsets$: blockOffsets, - samplerTextureOffsets$: samplerTextureOffsets, - flexibleSet$: mapping.setIndices[mapping.setIndices.length - 1], + this._bindingMappings = { + blockOffsets: blockOffsets, + samplerTextureOffsets: samplerTextureOffsets, + flexibleSet: mapping.setIndices[mapping.setIndices.length - 1], }; - const gl = this._context$ = getContext(Device.canvas); + const gl = this._context = getContext(Device.canvas); if (!gl) { errorID(16333); @@ -147,23 +147,23 @@ export class WebGLDevice extends Device { } // create queue - this._queue$ = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff$ = this.createCommandBuffer(new CommandBufferInfo(this._queue$)); + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); const glGetParameter = gl.getParameter.bind(gl); - this._caps$.maxVertexAttributes = glGetParameter(WebGLConstants.MAX_VERTEX_ATTRIBS); - this._caps$.maxVertexUniformVectors = glGetParameter(WebGLConstants.MAX_VERTEX_UNIFORM_VECTORS); - this._caps$.maxFragmentUniformVectors = glGetParameter(WebGLConstants.MAX_FRAGMENT_UNIFORM_VECTORS); - this._caps$.maxTextureUnits = glGetParameter(WebGLConstants.MAX_TEXTURE_IMAGE_UNITS); - this._caps$.maxVertexTextureUnits = glGetParameter(WebGLConstants.MAX_VERTEX_TEXTURE_IMAGE_UNITS); - this._caps$.maxTextureSize = glGetParameter(WebGLConstants.MAX_TEXTURE_SIZE); - this._caps$.maxCubeMapTextureSize = glGetParameter(WebGLConstants.MAX_CUBE_MAP_TEXTURE_SIZE); - this._caps$.maxArrayTextureLayers = 0; - this._caps$.max3DTextureSize = 0; + this._caps.maxVertexAttributes = glGetParameter(WebGLConstants.MAX_VERTEX_ATTRIBS); + this._caps.maxVertexUniformVectors = glGetParameter(WebGLConstants.MAX_VERTEX_UNIFORM_VECTORS); + this._caps.maxFragmentUniformVectors = glGetParameter(WebGLConstants.MAX_FRAGMENT_UNIFORM_VECTORS); + this._caps.maxTextureUnits = glGetParameter(WebGLConstants.MAX_TEXTURE_IMAGE_UNITS); + this._caps.maxVertexTextureUnits = glGetParameter(WebGLConstants.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + this._caps.maxTextureSize = glGetParameter(WebGLConstants.MAX_TEXTURE_SIZE); + this._caps.maxCubeMapTextureSize = glGetParameter(WebGLConstants.MAX_CUBE_MAP_TEXTURE_SIZE); + this._caps.maxArrayTextureLayers = 0; + this._caps.max3DTextureSize = 0; // WebGL doesn't support UBOs at all, so here we return // the guaranteed minimum number of available bindings in WebGL2 - this._caps$.maxUniformBufferBindings = 16; + this._caps.maxUniformBufferBindings = 16; const extensions = gl.getSupportedExtensions(); let extStr = ''; @@ -175,34 +175,34 @@ export class WebGLDevice extends Device { const exts = getExtensions(gl); - if (exts.WEBGL_debug_renderer_info$) { - this._renderer$ = glGetParameter(exts.WEBGL_debug_renderer_info$.UNMASKED_RENDERER_WEBGL); - this._vendor$ = glGetParameter(exts.WEBGL_debug_renderer_info$.UNMASKED_VENDOR_WEBGL); + if (exts.WEBGL_debug_renderer_info) { + this._renderer = glGetParameter(exts.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = glGetParameter(exts.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); } else { - this._renderer$ = glGetParameter(WebGLConstants.RENDERER); - this._vendor$ = glGetParameter(WebGLConstants.VENDOR); + this._renderer = glGetParameter(WebGLConstants.RENDERER); + this._vendor = glGetParameter(WebGLConstants.VENDOR); } const version: string = glGetParameter(WebGLConstants.VERSION); - this._features$.fill(false); + this._features.fill(false); this.initFormatFeatures(exts); - if (exts.EXT_blend_minmax$) { - this._features$[Feature.BLEND_MINMAX] = true; + if (exts.EXT_blend_minmax) { + this._features[Feature.BLEND_MINMAX] = true; } - if (exts.OES_element_index_uint$) { - this._features$[Feature.ELEMENT_INDEX_UINT] = true; + if (exts.OES_element_index_uint) { + this._features[Feature.ELEMENT_INDEX_UINT] = true; } - if (exts.ANGLE_instanced_arrays$) { - this._features$[Feature.INSTANCED_ARRAYS] = true; + if (exts.ANGLE_instanced_arrays) { + this._features[Feature.INSTANCED_ARRAYS] = true; } - if (exts.WEBGL_draw_buffers$) { - this._features$[Feature.MULTIPLE_RENDER_TARGETS] = true; + if (exts.WEBGL_draw_buffers) { + this._features[Feature.MULTIPLE_RENDER_TARGETS] = true; } let compressedFormat = ''; @@ -228,8 +228,8 @@ export class WebGLDevice extends Device { } debug('WebGL device initialized.'); - debug(`RENDERER: ${this._renderer$}`); - debug(`VENDOR: ${this._vendor$}`); + debug(`RENDERER: ${this._renderer}`); + debug(`VENDOR: ${this._vendor}`); debug(`VERSION: ${version}`); debug(`COMPRESSED_FORMAT: ${compressedFormat}`); debug(`EXTENSIONS: ${extStr}`); @@ -238,17 +238,17 @@ export class WebGLDevice extends Device { } public destroy (): void { - if (this._queue$) { - this._queue$.destroy(); - this._queue$ = null; + if (this._queue) { + this._queue.destroy(); + this._queue = null; } - if (this._cmdBuff$) { - this._cmdBuff$.destroy(); - this._cmdBuff$ = null; + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; } - this._swapchain$ = null; + this._swapchain = null; } public flushCommands (cmdBuffs: CommandBuffer[]): void { @@ -260,16 +260,16 @@ export class WebGLDevice extends Device { } public present (): void { - const queue = (this._queue$ as WebGLQueue); - this._numDrawCalls$ = queue.numDrawCalls$; - this._numInstances$ = queue.numInstances$; - this._numTris$ = queue.numTris$; + const queue = (this._queue as WebGLQueue); + this._numDrawCalls = queue.numDrawCalls; + this._numInstances = queue.numInstances; + this._numTris = queue.numTris; queue.clear(); } protected initFormatFeatures (exts: IWebGLExtensions): void { - const formatFeatures = this._formatFeatures$; - const textureExclusive = this._textureExclusive$; + const formatFeatures = this._formatFeatures; + const textureExclusive = this._textureExclusive; formatFeatures.fill(FormatFeatureBit.NONE); textureExclusive.fill(true); @@ -318,59 +318,59 @@ export class WebGLDevice extends Device { formatFeatures[Format.RGB32F] |= FormatFeatureBit.VERTEX_ATTRIBUTE; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.VERTEX_ATTRIBUTE; - if (exts.EXT_sRGB$) { + if (exts.EXT_sRGB) { formatFeatures[Format.SRGB8] = tempFeature; formatFeatures[Format.SRGB8_A8] = tempFeature; textureExclusive[Format.SRGB8_A8] = false; } - if (exts.WEBGL_depth_texture$) { + if (exts.WEBGL_depth_texture) { formatFeatures[Format.DEPTH] |= tempFeature; formatFeatures[Format.DEPTH_STENCIL] |= tempFeature; } - if (exts.WEBGL_color_buffer_float$) { + if (exts.WEBGL_color_buffer_float) { formatFeatures[Format.RGB32F] |= FormatFeatureBit.RENDER_TARGET; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.RENDER_TARGET; textureExclusive[Format.RGB32F] = false; textureExclusive[Format.RGBA32F] = false; } - if (exts.EXT_color_buffer_half_float$) { + if (exts.EXT_color_buffer_half_float) { formatFeatures[Format.RGB16F] |= FormatFeatureBit.RENDER_TARGET; formatFeatures[Format.RGBA16F] |= FormatFeatureBit.RENDER_TARGET; textureExclusive[Format.RGB16F] = false; textureExclusive[Format.RGBA16F] = false; } - if (exts.OES_texture_float$) { + if (exts.OES_texture_float) { formatFeatures[Format.RGB32F] |= FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE; } - if (exts.OES_texture_half_float$) { + if (exts.OES_texture_half_float) { formatFeatures[Format.RGB16F] |= FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE; formatFeatures[Format.RGBA16F] |= FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE; } - if (exts.OES_texture_float_linear$) { + if (exts.OES_texture_float_linear) { formatFeatures[Format.RGB32F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.LINEAR_FILTER; } - if (exts.OES_texture_half_float_linear$) { + if (exts.OES_texture_half_float_linear) { formatFeatures[Format.RGB16F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.RGBA16F] |= FormatFeatureBit.LINEAR_FILTER; } const compressedFeature: FormatFeature = FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; - if (exts.WEBGL_compressed_texture_etc1$) { + if (exts.WEBGL_compressed_texture_etc1) { formatFeatures[Format.ETC_RGB8] = compressedFeature; } - if (exts.WEBGL_compressed_texture_etc$) { + if (exts.WEBGL_compressed_texture_etc) { formatFeatures[Format.ETC2_RGB8] = compressedFeature; formatFeatures[Format.ETC2_RGBA8] = compressedFeature; formatFeatures[Format.ETC2_SRGB8] = compressedFeature; @@ -379,7 +379,7 @@ export class WebGLDevice extends Device { formatFeatures[Format.ETC2_SRGB8_A1] = compressedFeature; } - if (exts.WEBGL_compressed_texture_s3tc$) { + if (exts.WEBGL_compressed_texture_s3tc) { formatFeatures[Format.BC1] = compressedFeature; formatFeatures[Format.BC1_ALPHA] = compressedFeature; formatFeatures[Format.BC1_SRGB] = compressedFeature; @@ -390,14 +390,14 @@ export class WebGLDevice extends Device { formatFeatures[Format.BC3_SRGB] = compressedFeature; } - if (exts.WEBGL_compressed_texture_pvrtc$) { + if (exts.WEBGL_compressed_texture_pvrtc) { formatFeatures[Format.PVRTC_RGB2] |= compressedFeature; formatFeatures[Format.PVRTC_RGBA2] |= compressedFeature; formatFeatures[Format.PVRTC_RGB4] |= compressedFeature; formatFeatures[Format.PVRTC_RGBA4] |= compressedFeature; } - if (exts.WEBGL_compressed_texture_astc$) { + if (exts.WEBGL_compressed_texture_astc) { formatFeatures[Format.ASTC_RGBA_4X4] |= compressedFeature; formatFeatures[Format.ASTC_RGBA_5X4] |= compressedFeature; formatFeatures[Format.ASTC_RGBA_5X5] |= compressedFeature; @@ -440,7 +440,7 @@ export class WebGLDevice extends Device { public createSwapchain (info: Readonly): Swapchain { const swapchain = new WebGLSwapchain(); - this._swapchain$ = swapchain; + this._swapchain = swapchain; swapchain.initialize(info); return swapchain; } @@ -513,38 +513,38 @@ export class WebGLDevice extends Device { public getSampler (info: Readonly): Sampler { const hash = Sampler.computeHash(info); - if (!this._samplers$.has(hash)) { - this._samplers$.set(hash, new WebGLSampler(info, hash)); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new WebGLSampler(info, hash)); } - return this._samplers$.get(hash)!; + return this._samplers.get(hash)!; } public getSwapchains (): Readonly { - return [this._swapchain$ as Swapchain]; + return [this._swapchain as Swapchain]; } public getGeneralBarrier (info: Readonly): GeneralBarrier { const hash = GeneralBarrier.computeHash(info); - if (!this._generalBarrierss$.has(hash)) { - this._generalBarrierss$.set(hash, new GeneralBarrier(info, hash)); + if (!this._generalBarrierss.has(hash)) { + this._generalBarrierss.set(hash, new GeneralBarrier(info, hash)); } - return this._generalBarrierss$.get(hash)!; + return this._generalBarrierss.get(hash)!; } public getTextureBarrier (info: Readonly): TextureBarrier { const hash = TextureBarrier.computeHash(info); - if (!this._textureBarriers$.has(hash)) { - this._textureBarriers$.set(hash, new TextureBarrier(info, hash)); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info, hash)); } - return this._textureBarriers$.get(hash)!; + return this._textureBarriers.get(hash)!; } public getBufferBarrier (info: Readonly): BufferBarrier { const hash = BufferBarrier.computeHash(info); - if (!this._bufferBarriers$.has(hash)) { - this._bufferBarriers$.set(hash, new BufferBarrier(info, hash)); + if (!this._bufferBarriers.has(hash)) { + this._bufferBarriers.set(hash, new BufferBarrier(info, hash)); } - return this._bufferBarriers$.get(hash)!; + return this._bufferBarriers.get(hash)!; } public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { diff --git a/cocos/gfx/webgl/webgl-framebuffer.ts b/cocos/gfx/webgl/webgl-framebuffer.ts index fa688cb3ed3..f5ac220faf8 100644 --- a/cocos/gfx/webgl/webgl-framebuffer.ts +++ b/cocos/gfx/webgl/webgl-framebuffer.ts @@ -33,12 +33,12 @@ import { WebGLTexture as CCWebGLTexture } from './webgl-texture'; export class WebGLFramebuffer extends Framebuffer { get gpuFramebuffer (): IWebGLGPUFramebuffer { - return this._gpuFramebuffer$!; + return this._gpuFramebuffer!; } - private _gpuFramebuffer$: IWebGLGPUFramebuffer | null = null; - private _gpuColorTextures$: (WebGLTexture | null)[] = []; - private _gpuDepthStencilTexture$: WebGLTexture | null | undefined; + private _gpuFramebuffer: IWebGLGPUFramebuffer | null = null; + private _gpuColorTextures: (WebGLTexture | null)[] = []; + private _gpuDepthStencilTexture: WebGLTexture | null | undefined; constructor () { super(); @@ -46,12 +46,12 @@ export class WebGLFramebuffer extends Framebuffer { get needRebuild (): boolean { if (this.gpuFramebuffer) { - for (let i = 0; i < this.gpuFramebuffer.gpuColorTextures$.length; i++) { - if (this.gpuFramebuffer.gpuColorTextures$[i].glTexture$ !== this._gpuColorTextures$[i]) { + for (let i = 0; i < this.gpuFramebuffer.gpuColorTextures.length; i++) { + if (this.gpuFramebuffer.gpuColorTextures[i].glTexture !== this._gpuColorTextures[i]) { return true; } } - if (this.gpuFramebuffer.gpuDepthStencilTexture$?.glTexture$ !== this._gpuDepthStencilTexture$) { + if (this.gpuFramebuffer.gpuDepthStencilTexture?.glTexture !== this._gpuDepthStencilTexture) { return true; } } @@ -60,9 +60,9 @@ export class WebGLFramebuffer extends Framebuffer { } public initialize (info: Readonly): void { - this._renderPass$ = info.renderPass; - this._colorTextures$ = info.colorTextures || []; - const depthStencilTexture: CCWebGLTexture = this._depthStencilTexture$ = info.depthStencilTexture as CCWebGLTexture || null; + this._renderPass = info.renderPass; + this._colorTextures = info.colorTextures || []; + const depthStencilTexture: CCWebGLTexture = this._depthStencilTexture = info.depthStencilTexture as CCWebGLTexture || null; let lodLevel = 0; @@ -83,17 +83,17 @@ export class WebGLFramebuffer extends Framebuffer { let width = Number.MAX_SAFE_INTEGER; let height = Number.MAX_SAFE_INTEGER; - this._gpuFramebuffer$ = { - gpuRenderPass$: (info.renderPass as WebGLRenderPass).gpuRenderPass, - gpuColorTextures$: gpuColorTextures, - gpuDepthStencilTexture$: gpuDepthStencilTexture, - glFramebuffer$: null, - isOffscreen$: true, + this._gpuFramebuffer = { + gpuRenderPass: (info.renderPass as WebGLRenderPass).gpuRenderPass, + gpuColorTextures, + gpuDepthStencilTexture, + glFramebuffer: null, + isOffscreen: true, get width (): number { - if (this.gpuColorTextures$.length > 0) { - return this.gpuColorTextures$[0].width$; - } else if (this.gpuDepthStencilTexture$) { - return this.gpuDepthStencilTexture$.width$; + if (this.gpuColorTextures.length > 0) { + return this.gpuColorTextures[0].width; + } else if (this.gpuDepthStencilTexture) { + return this.gpuDepthStencilTexture.width; } return width; }, @@ -101,32 +101,32 @@ export class WebGLFramebuffer extends Framebuffer { width = val; }, get height (): number { - if (this.gpuColorTextures$.length > 0) { - return this.gpuColorTextures$[0].height$; - } else if (this.gpuDepthStencilTexture$) { - return this.gpuDepthStencilTexture$.height$; + if (this.gpuColorTextures.length > 0) { + return this.gpuColorTextures[0].height; + } else if (this.gpuDepthStencilTexture) { + return this.gpuDepthStencilTexture.height; } return height; }, set height (val) { height = val; }, - lodLevel$: lodLevel, + lodLevel, }; - WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer$); - this.gpuFramebuffer.gpuColorTextures$.forEach((tex) => this._gpuColorTextures$.push(tex.glTexture$)); - this._gpuDepthStencilTexture$ = this.gpuFramebuffer.gpuDepthStencilTexture$?.glTexture$; - this._width$ = this._gpuFramebuffer$.width; - this._height$ = this._gpuFramebuffer$.height; + WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); + this.gpuFramebuffer.gpuColorTextures.forEach((tex) => this._gpuColorTextures.push(tex.glTexture)); + this._gpuDepthStencilTexture = this.gpuFramebuffer.gpuDepthStencilTexture?.glTexture; + this._width = this._gpuFramebuffer.width; + this._height = this._gpuFramebuffer.height; } public destroy (): void { - if (this._gpuFramebuffer$) { - WebGLCmdFuncDestroyFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer$); - this._gpuFramebuffer$ = null; - this._gpuColorTextures$.length = 0; - this._gpuDepthStencilTexture$ = null; + if (this._gpuFramebuffer) { + WebGLCmdFuncDestroyFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); + this._gpuFramebuffer = null; + this._gpuColorTextures.length = 0; + this._gpuDepthStencilTexture = null; } } } diff --git a/cocos/gfx/webgl/webgl-gpu-objects.ts b/cocos/gfx/webgl/webgl-gpu-objects.ts index 34a67ef3623..e3ca7e116bc 100644 --- a/cocos/gfx/webgl/webgl-gpu-objects.ts +++ b/cocos/gfx/webgl/webgl-gpu-objects.ts @@ -44,307 +44,307 @@ function createInt32Array (capacity: number): Int32Array { } export class WebGLIndirectDrawInfos { - public declare counts$: Int32Array; - public declare offsets$: Int32Array; - public declare instances$: Int32Array; - public drawCount$ = 0; - public drawByIndex$ = false; - public instancedDraw$ = false; + public declare counts: Int32Array; + public declare offsets: Int32Array; + public declare instances: Int32Array; + public drawCount = 0; + public drawByIndex = false; + public instancedDraw = false; // staging buffer - public declare byteOffsets$: Int32Array; + public declare byteOffsets: Int32Array; - private _capacity$ = 4; + private _capacity = 4; constructor () { - this.counts$ = createInt32Array(this._capacity$); - this.offsets$ = createInt32Array(this._capacity$); - this.instances$ = createInt32Array(this._capacity$); - this.byteOffsets$ = createInt32Array(this._capacity$); + this.counts = createInt32Array(this._capacity); + this.offsets = createInt32Array(this._capacity); + this.instances = createInt32Array(this._capacity); + this.byteOffsets = createInt32Array(this._capacity); } - public clearDraws$ (): void { - this.drawCount$ = 0; - this.drawByIndex$ = false; - this.instancedDraw$ = false; + public clearDraws (): void { + this.drawCount = 0; + this.drawByIndex = false; + this.instancedDraw = false; } - public setDrawInfo$ (idx: number, info: Readonly): void { - this._ensureCapacity$(idx); - this.drawByIndex$ = info.indexCount > 0; - this.instancedDraw$ = !!info.instanceCount; - this.drawCount$ = Math.max(idx + 1, this.drawCount$); + public setDrawInfo (idx: number, info: Readonly): void { + this._ensureCapacity(idx); + this.drawByIndex = info.indexCount > 0; + this.instancedDraw = !!info.instanceCount; + this.drawCount = Math.max(idx + 1, this.drawCount); - if (this.drawByIndex$) { - this.counts$[idx] = info.indexCount; - this.offsets$[idx] = info.firstIndex; + if (this.drawByIndex) { + this.counts[idx] = info.indexCount; + this.offsets[idx] = info.firstIndex; } else { - this.counts$[idx] = info.vertexCount; - this.offsets$[idx] = info.firstVertex; + this.counts[idx] = info.vertexCount; + this.offsets[idx] = info.firstVertex; } - this.instances$[idx] = Math.max(1, info.instanceCount); + this.instances[idx] = Math.max(1, info.instanceCount); } - private _ensureCapacity$ (target: number): void { - if (this._capacity$ > target) return; - this._capacity$ = nextPow2(target); + private _ensureCapacity (target: number): void { + if (this._capacity > target) return; + this._capacity = nextPow2(target); - const counts = createInt32Array(this._capacity$); - const offsets = createInt32Array(this._capacity$); - const instances = createInt32Array(this._capacity$); - this.byteOffsets$ = createInt32Array(this._capacity$); + const counts = createInt32Array(this._capacity); + const offsets = createInt32Array(this._capacity); + const instances = createInt32Array(this._capacity); + this.byteOffsets = createInt32Array(this._capacity); - counts.set(this.counts$); - offsets.set(this.offsets$); - instances.set(this.instances$); + counts.set(this.counts); + offsets.set(this.offsets); + instances.set(this.instances); - this.counts$ = counts; - this.offsets$ = offsets; - this.instances$ = instances; + this.counts = counts; + this.offsets = offsets; + this.instances = instances; } } export interface IWebGLGPUUniformInfo { - name$: string; - type$: Type; - count$: number; - offset$: number; - view$: Float32Array | Int32Array; - isDirty$: boolean; + name: string; + type: Type; + count: number; + offset: number; + view: Float32Array | Int32Array; + isDirty: boolean; } export interface IWebGLBindingMapping { - blockOffsets$: number[]; - samplerTextureOffsets$: number[]; - flexibleSet$: number; + blockOffsets: number[]; + samplerTextureOffsets: number[]; + flexibleSet: number; } export interface IWebGLGPUBufferView { - gpuBuffer$: IWebGLGPUBuffer; - offset$: number; - range$: number; + gpuBuffer: IWebGLGPUBuffer; + offset: number; + range: number; } export interface IWebGLGPUBuffer { - usage$: BufferUsage; - memUsage$: MemoryUsage; - size$: number; - stride$: number; + usage: BufferUsage; + memUsage: MemoryUsage; + size: number; + stride: number; - glTarget$: GLenum; - glBuffer$: WebGLBuffer | null; + glTarget: GLenum; + glBuffer: WebGLBuffer | null; - buffer$: ArrayBufferView | null; + buffer: ArrayBufferView | null; vf32: Float32Array | null; - indirects$: WebGLIndirectDrawInfos; + indirects: WebGLIndirectDrawInfos; } export interface IWebGLGPUTexture { - type$: TextureType; - format$: Format; - usage$: TextureUsage; - width$: number; - height$: number; - depth$: number; - size$: number; - arrayLayer$: number; - mipLevel$: number; - samples$: SampleCount; - flags$: TextureFlags; - isPowerOf2$: boolean; - - glTarget$: GLenum; - glInternalFmt$: GLenum; - glFormat$: GLenum; - glType$: GLenum; - glUsage$: GLenum; - glTexture$: WebGLTexture | null; - glRenderbuffer$: WebGLRenderbuffer | null; - glWrapS$: GLenum; - glWrapT$: GLenum; - glMinFilter$: GLenum; - glMagFilter$: GLenum; - - isSwapchainTexture$: boolean; + type: TextureType; + format: Format; + usage: TextureUsage; + width: number; + height: number; + depth: number; + size: number; + arrayLayer: number; + mipLevel: number; + samples: SampleCount; + flags: TextureFlags; + isPowerOf2: boolean; + + glTarget: GLenum; + glInternalFmt: GLenum; + glFormat: GLenum; + glType: GLenum; + glUsage: GLenum; + glTexture: WebGLTexture | null; + glRenderbuffer: WebGLRenderbuffer | null; + glWrapS: GLenum; + glWrapT: GLenum; + glMinFilter: GLenum; + glMagFilter: GLenum; + + isSwapchainTexture: boolean; } export interface IWebGLGPURenderPass { - colorAttachments$: ColorAttachment[]; - depthStencilAttachment$: DepthStencilAttachment | null; + colorAttachments: ColorAttachment[]; + depthStencilAttachment: DepthStencilAttachment | null; } export interface IWebGLGPUFramebuffer { - gpuRenderPass$: IWebGLGPURenderPass; - gpuColorTextures$: IWebGLGPUTexture[]; - gpuDepthStencilTexture$: IWebGLGPUTexture | null; - glFramebuffer$: WebGLFramebuffer | null; - isOffscreen$: boolean; + gpuRenderPass: IWebGLGPURenderPass; + gpuColorTextures: IWebGLGPUTexture[]; + gpuDepthStencilTexture: IWebGLGPUTexture | null; + glFramebuffer: WebGLFramebuffer | null; + isOffscreen: boolean; width: number; height: number; - lodLevel$: number; + lodLevel: number; } export interface IWebGLGPUSampler { - glMinFilter$: GLenum; - glMagFilter$: GLenum; - glWrapS$: GLenum; - glWrapT$: GLenum; - glWrapR$: GLenum; + glMinFilter: GLenum; + glMagFilter: GLenum; + glWrapS: GLenum; + glWrapT: GLenum; + glWrapR: GLenum; } export interface IWebGLGPUInput { - binding$: number; - name$: string; - type$: Type; - stride$: number; - count$: number; - size$: number; - - glType$: GLenum; - glLoc$: GLint; + binding: number; + name: string; + type: Type; + stride: number; + count: number; + size: number; + + glType: GLenum; + glLoc: GLint; } export interface IWebGLGPUUniform { - binding$: number; - name$: string; - type$: Type; - stride$: number; - count$: number; - size$: number; - offset$: number; - - glType$: GLenum; - glLoc$: WebGLUniformLocation; - array$: Int32Array | Float32Array; + binding: number; + name: string; + type: Type; + stride: number; + count: number; + size: number; + offset: number; + + glType: GLenum; + glLoc: WebGLUniformLocation; + array: Int32Array | Float32Array; } export interface IWebGLGPUUniformBlock { - set$: number; - binding$: number; - name$: string; - size$: number; - glUniforms$: IWebGLGPUUniform[]; - glActiveUniforms$: IWebGLGPUUniform[]; + set: number; + binding: number; + name: string; + size: number; + glUniforms: IWebGLGPUUniform[]; + glActiveUniforms: IWebGLGPUUniform[]; } export interface IWebGLGPUUniformSamplerTexture { - set$: number; - binding$: number; - name$: string; - type$: Type; - count$: number; - units$: number[]; - glUnits$: Int32Array; - - glType$: GLenum; - glLoc$: WebGLUniformLocation; + set: number; + binding: number; + name: string; + type: Type; + count: number; + units: number[]; + glUnits: Int32Array; + + glType: GLenum; + glLoc: WebGLUniformLocation; } export interface IWebGLGPUShaderStage { - type$: ShaderStageFlagBit; - source$: string; - glShader$: WebGLShader | null; + type: ShaderStageFlagBit; + source: string; + glShader: WebGLShader | null; } export interface IWebGLGPUShader { - name$: string; - blocks$: UniformBlock[]; - samplerTextures$: UniformSamplerTexture[]; - subpassInputs$: UniformInputAttachment[]; - - gpuStages$: IWebGLGPUShaderStage[]; - glProgram$: WebGLProgram | null; - glInputs$: IWebGLGPUInput[]; - glUniforms$: IWebGLGPUUniform[]; - glBlocks$: IWebGLGPUUniformBlock[]; - glSamplerTextures$: IWebGLGPUUniformSamplerTexture[]; + name: string; + blocks: UniformBlock[]; + samplerTextures: UniformSamplerTexture[]; + subpassInputs: UniformInputAttachment[]; + + gpuStages: IWebGLGPUShaderStage[]; + glProgram: WebGLProgram | null; + glInputs: IWebGLGPUInput[]; + glUniforms: IWebGLGPUUniform[]; + glBlocks: IWebGLGPUUniformBlock[]; + glSamplerTextures: IWebGLGPUUniformSamplerTexture[]; } export interface IWebGLGPUDescriptorSetLayout { - bindings$: DescriptorSetLayoutBinding[]; - dynamicBindings$: number[]; - descriptorIndices$: number[]; - descriptorCount$: number; + bindings: DescriptorSetLayoutBinding[]; + dynamicBindings: number[]; + descriptorIndices: number[]; + descriptorCount: number; } export interface IWebGLGPUPipelineLayout { - gpuSetLayouts$: IWebGLGPUDescriptorSetLayout[]; - dynamicOffsetCount$: number; - dynamicOffsetOffsets$: number[]; - dynamicOffsetIndices$: number[][]; + gpuSetLayouts: IWebGLGPUDescriptorSetLayout[]; + dynamicOffsetCount: number; + dynamicOffsetOffsets: number[]; + dynamicOffsetIndices: number[][]; } export interface IWebGLGPUPipelineState { - glPrimitive$: GLenum; - gpuShader$: IWebGLGPUShader | null; - gpuPipelineLayout$: IWebGLGPUPipelineLayout | null; - rs$: RasterizerState; - dss$: DepthStencilState; - bs$: BlendState; - dynamicStates$: DynamicStateFlagBit[]; - gpuRenderPass$: IWebGLGPURenderPass | null; + glPrimitive: GLenum; + gpuShader: IWebGLGPUShader | null; + gpuPipelineLayout: IWebGLGPUPipelineLayout | null; + rs: RasterizerState; + dss: DepthStencilState; + bs: BlendState; + dynamicStates: DynamicStateFlagBit[]; + gpuRenderPass: IWebGLGPURenderPass | null; } export interface IWebGLGPUDescriptor { - type$: DescriptorType; - gpuBuffer$: IWebGLGPUBuffer | IWebGLGPUBufferView | null; - gpuTexture$: IWebGLGPUTexture | null; - gpuSampler$: IWebGLGPUSampler | null; + type: DescriptorType; + gpuBuffer: IWebGLGPUBuffer | IWebGLGPUBufferView | null; + gpuTexture: IWebGLGPUTexture | null; + gpuSampler: IWebGLGPUSampler | null; } export interface IWebGLGPUDescriptorSet { - gpuDescriptors$: IWebGLGPUDescriptor[]; - descriptorIndices$: number[]; + gpuDescriptors: IWebGLGPUDescriptor[]; + descriptorIndices: number[]; } export interface IWebGLAttrib { - name$: string; - glBuffer$: WebGLBuffer | null; - glType$: GLenum; - size$: number; - count$: number; - stride$: number; - componentCount$: number; - isNormalized$: boolean; - isInstanced$: boolean; - offset$: number; + name: string; + glBuffer: WebGLBuffer | null; + glType: GLenum; + size: number; + count: number; + stride: number; + componentCount: number; + isNormalized: boolean; + isInstanced: boolean; + offset: number; } export interface IWebGLGPUInputAssembler { - attributes$: Attribute[]; - gpuVertexBuffers$: IWebGLGPUBuffer[]; - gpuIndexBuffer$: IWebGLGPUBuffer | null; - gpuIndirectBuffer$: IWebGLGPUBuffer | null; - - glAttribs$: IWebGLAttrib[]; - glIndexType$: GLenum; - glVAOs$: Map; + attributes: Attribute[]; + gpuVertexBuffers: IWebGLGPUBuffer[]; + gpuIndexBuffer: IWebGLGPUBuffer | null; + gpuIndirectBuffer: IWebGLGPUBuffer | null; + + glAttribs: IWebGLAttrib[]; + glIndexType: GLenum; + glVAOs: Map; } export class IWebGLBlitManager { - private _gpuShader$: IWebGLGPUShader | null = null; - private _gpuDescriptorSetLayout$: IWebGLGPUDescriptorSetLayout | null = null; - private _gpuPipelineLayout$: IWebGLGPUPipelineLayout | null = null; - private _gpuPipelineState$: IWebGLGPUPipelineState | null = null; - - private _gpuVertexBuffer$: IWebGLGPUBuffer | null = null; - private _gpuInputAssembler$: IWebGLGPUInputAssembler | null = null; - private _gpuPointSampler$: IWebGLGPUSampler | null = null; - private _gpuLinearSampler$: IWebGLGPUSampler | null = null; - private _gpuDescriptorSet$: IWebGLGPUDescriptorSet | null = null; - private _gpuUniformBuffer$: IWebGLGPUBuffer | null = null; - private _drawInfo$: DrawInfo | null = null; - private _glFramebuffer$: WebGLFramebuffer | null = null; - - private _uniformBuffer$: Float32Array | null = null; + private _gpuShader: IWebGLGPUShader | null = null; + private _gpuDescriptorSetLayout: IWebGLGPUDescriptorSetLayout | null = null; + private _gpuPipelineLayout: IWebGLGPUPipelineLayout | null = null; + private _gpuPipelineState: IWebGLGPUPipelineState | null = null; + + private _gpuVertexBuffer: IWebGLGPUBuffer | null = null; + private _gpuInputAssembler: IWebGLGPUInputAssembler | null = null; + private _gpuPointSampler: IWebGLGPUSampler | null = null; + private _gpuLinearSampler: IWebGLGPUSampler | null = null; + private _gpuDescriptorSet: IWebGLGPUDescriptorSet | null = null; + private _gpuUniformBuffer: IWebGLGPUBuffer | null = null; + private _drawInfo: DrawInfo | null = null; + private _glFramebuffer: WebGLFramebuffer | null = null; + + private _uniformBuffer: Float32Array | null = null; constructor () { const device = WebGLDeviceManager.instance; const samplerOffset = device.bindingMappingInfo.maxBlockCounts[0]; - this._gpuShader$ = { - name$: 'Blit Pass', - blocks$: [ + this._gpuShader = { + name: 'Blit Pass', + blocks: [ new UniformBlock( 0, 0, @@ -356,12 +356,12 @@ export class IWebGLBlitManager { 1, ), ], - samplerTextures$: [new UniformSamplerTexture(0, samplerOffset, 'textureSrc', Type.SAMPLER2D, 1)], - subpassInputs$: [], - gpuStages$: [ + samplerTextures: [new UniformSamplerTexture(0, samplerOffset, 'textureSrc', Type.SAMPLER2D, 1)], + subpassInputs: [], + gpuStages: [ { - type$: ShaderStageFlagBit.VERTEX, - source$: ` + type: ShaderStageFlagBit.VERTEX, + source: ` precision mediump float; attribute vec2 a_position; attribute vec2 a_texCoord; @@ -372,152 +372,152 @@ void main() { v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw; gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1); }`, - glShader$: null }, + glShader: null }, { - type$: ShaderStageFlagBit.FRAGMENT, - source$: ` + type: ShaderStageFlagBit.FRAGMENT, + source: ` precision mediump float; uniform sampler2D textureSrc; varying vec2 v_texCoord; void main() { gl_FragColor = texture2D(textureSrc, v_texCoord); }`, - glShader$: null }, + glShader: null }, ], - glProgram$: null, - glInputs$: [], - glUniforms$: [], - glBlocks$: [], - glSamplerTextures$: [], + glProgram: null, + glInputs: [], + glUniforms: [], + glBlocks: [], + glSamplerTextures: [], }; - WebGLCmdFuncCreateShader(WebGLDeviceManager.instance, this._gpuShader$); + WebGLCmdFuncCreateShader(WebGLDeviceManager.instance, this._gpuShader); - this._gpuDescriptorSetLayout$ = { - bindings$: [ + this._gpuDescriptorSetLayout = { + bindings: [ new DescriptorSetLayoutBinding(0, DescriptorType.UNIFORM_BUFFER, 1, ShaderStageFlagBit.VERTEX), new DescriptorSetLayoutBinding(samplerOffset, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT), ], - dynamicBindings$: [], - descriptorIndices$: [], - descriptorCount$: samplerOffset + 1, + dynamicBindings: [], + descriptorIndices: [], + descriptorCount: samplerOffset + 1, }; for (let i = 0; i < samplerOffset; i++) { - this._gpuDescriptorSetLayout$.descriptorIndices$[i] = 0; + this._gpuDescriptorSetLayout.descriptorIndices[i] = 0; } - this._gpuDescriptorSetLayout$.descriptorIndices$.push(1); + this._gpuDescriptorSetLayout.descriptorIndices.push(1); - this._gpuPipelineLayout$ = { - gpuSetLayouts$: [this._gpuDescriptorSetLayout$], - dynamicOffsetCount$: 0, - dynamicOffsetOffsets$: [0], - dynamicOffsetIndices$: [[]], + this._gpuPipelineLayout = { + gpuSetLayouts: [this._gpuDescriptorSetLayout], + dynamicOffsetCount: 0, + dynamicOffsetOffsets: [0], + dynamicOffsetIndices: [[]], }; - this._gpuPipelineState$ = { - glPrimitive$: WebGLConstants.TRIANGLE_STRIP, - gpuShader$: this._gpuShader$, - gpuPipelineLayout$: this._gpuPipelineLayout$, - rs$: null!, - dss$: new DepthStencilState(false, false), - bs$: null!, - dynamicStates$: [], - gpuRenderPass$: null, + this._gpuPipelineState = { + glPrimitive: WebGLConstants.TRIANGLE_STRIP, + gpuShader: this._gpuShader, + gpuPipelineLayout: this._gpuPipelineLayout, + rs: null!, + dss: new DepthStencilState(false, false), + bs: null!, + dynamicStates: [], + gpuRenderPass: null, }; - this._gpuVertexBuffer$ = { - usage$: BufferUsageBit.VERTEX, - memUsage$: MemoryUsageBit.DEVICE, - size$: 16 * Float32Array.BYTES_PER_ELEMENT, - stride$: 4 * Float32Array.BYTES_PER_ELEMENT, - buffer$: null, + this._gpuVertexBuffer = { + usage: BufferUsageBit.VERTEX, + memUsage: MemoryUsageBit.DEVICE, + size: 16 * Float32Array.BYTES_PER_ELEMENT, + stride: 4 * Float32Array.BYTES_PER_ELEMENT, + buffer: null, vf32: null, - indirects$: new WebGLIndirectDrawInfos(), - glTarget$: 0, - glBuffer$: null, + indirects: new WebGLIndirectDrawInfos(), + glTarget: 0, + glBuffer: null, }; - WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer$); - WebGLDeviceManager.instance.memoryStatus.bufferSize += this._gpuVertexBuffer$.size$; + WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer); + WebGLDeviceManager.instance.memoryStatus.bufferSize += this._gpuVertexBuffer.size; const data = new Float32Array( [-1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0], ); - WebGLCmdFuncUpdateBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer$, data, 0, data.length); + WebGLCmdFuncUpdateBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer, data, 0, data.length); - this._gpuInputAssembler$ = { - attributes$: [new Attribute(`a_position`, Format.RG32F), new Attribute(`a_texCoord`, Format.RG32F)], - gpuVertexBuffers$: [this._gpuVertexBuffer$], - gpuIndexBuffer$: null, - gpuIndirectBuffer$: null, + this._gpuInputAssembler = { + attributes: [new Attribute(`a_position`, Format.RG32F), new Attribute(`a_texCoord`, Format.RG32F)], + gpuVertexBuffers: [this._gpuVertexBuffer], + gpuIndexBuffer: null, + gpuIndirectBuffer: null, - glAttribs$: [], - glIndexType$: 0, - glVAOs$: new Map(), + glAttribs: [], + glIndexType: 0, + glVAOs: new Map(), }; - WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler$); - - this._gpuPointSampler$ = { - glMinFilter$: 0x2600, // WebGLRenderingContext.NEAREST - glMagFilter$: 0x2600, // WebGLRenderingContext.NEAREST - glWrapS$: 0x2901, // WebGLRenderingContext.REPEAT, - glWrapT$: 0x2901, // WebGLRenderingContext.REPEAT, - glWrapR$: 0x2901, // WebGLRenderingContext.REPEAT, + WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler); + + this._gpuPointSampler = { + glMinFilter: 0x2600, // WebGLRenderingContext.NEAREST + glMagFilter: 0x2600, // WebGLRenderingContext.NEAREST + glWrapS: 0x2901, // WebGLRenderingContext.REPEAT, + glWrapT: 0x2901, // WebGLRenderingContext.REPEAT, + glWrapR: 0x2901, // WebGLRenderingContext.REPEAT, }; - this._gpuLinearSampler$ = { - glMinFilter$: 0x2601, // WebGLRenderingContext.LINEAR; - glMagFilter$: 0x2601, // WebGLRenderingContext.LINEAR; - glWrapS$: 0x2901, // WebGLRenderingContext.REPEAT, - glWrapT$: 0x2901, // WebGLRenderingContext.REPEAT, - glWrapR$: 0x2901, // WebGLRenderingContext.REPEAT, + this._gpuLinearSampler = { + glMinFilter: 0x2601, // WebGLRenderingContext.LINEAR; + glMagFilter: 0x2601, // WebGLRenderingContext.LINEAR; + glWrapS: 0x2901, // WebGLRenderingContext.REPEAT, + glWrapT: 0x2901, // WebGLRenderingContext.REPEAT, + glWrapR: 0x2901, // WebGLRenderingContext.REPEAT, }; - this._uniformBuffer$ = new Float32Array(8); - this._gpuUniformBuffer$ = { - usage$: BufferUsageBit.UNIFORM, - memUsage$: MemoryUsageBit.DEVICE, - size$: 8 * Float32Array.BYTES_PER_ELEMENT, - stride$: 8 * Float32Array.BYTES_PER_ELEMENT, - buffer$: this._uniformBuffer$, + this._uniformBuffer = new Float32Array(8); + this._gpuUniformBuffer = { + usage: BufferUsageBit.UNIFORM, + memUsage: MemoryUsageBit.DEVICE, + size: 8 * Float32Array.BYTES_PER_ELEMENT, + stride: 8 * Float32Array.BYTES_PER_ELEMENT, + buffer: this._uniformBuffer, vf32: null, - indirects$: new WebGLIndirectDrawInfos(), - glTarget$: 0, - glBuffer$: null, + indirects: new WebGLIndirectDrawInfos(), + glTarget: 0, + glBuffer: null, }; - WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuUniformBuffer$); - WebGLDeviceManager.instance.memoryStatus.bufferSize += this._gpuUniformBuffer$.size$; - - this._gpuDescriptorSet$ = { - gpuDescriptors$: [ - { type$: DescriptorType.UNIFORM_BUFFER, gpuBuffer$: this._gpuUniformBuffer$, gpuTexture$: null, gpuSampler$: null }, - { type$: DescriptorType.SAMPLER_TEXTURE, gpuBuffer$: null, gpuTexture$: null, gpuSampler$: null }], - descriptorIndices$: this._gpuDescriptorSetLayout$.descriptorIndices$, + WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuUniformBuffer); + WebGLDeviceManager.instance.memoryStatus.bufferSize += this._gpuUniformBuffer.size; + + this._gpuDescriptorSet = { + gpuDescriptors: [ + { type: DescriptorType.UNIFORM_BUFFER, gpuBuffer: this._gpuUniformBuffer, gpuTexture: null, gpuSampler: null }, + { type: DescriptorType.SAMPLER_TEXTURE, gpuBuffer: null, gpuTexture: null, gpuSampler: null }], + descriptorIndices: this._gpuDescriptorSetLayout.descriptorIndices, }; - this._drawInfo$ = new DrawInfo(4, 0, 0, 0, 0, 0, 0); - this._glFramebuffer$ = WebGLDeviceManager.instance.gl.createFramebuffer(); + this._drawInfo = new DrawInfo(4, 0, 0, 0, 0, 0, 0); + this._glFramebuffer = WebGLDeviceManager.instance.gl.createFramebuffer(); } public destroy (): void { - if (this._glFramebuffer$) { - WebGLDeviceManager.instance.gl.deleteFramebuffer(this._glFramebuffer$); - this._glFramebuffer$ = null; + if (this._glFramebuffer) { + WebGLDeviceManager.instance.gl.deleteFramebuffer(this._glFramebuffer); + this._glFramebuffer = null; } - if (this._gpuVertexBuffer$) { - WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._gpuVertexBuffer$.size$; - WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer$); + if (this._gpuVertexBuffer) { + WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._gpuVertexBuffer.size; + WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuVertexBuffer); } - if (this._gpuUniformBuffer$) { - WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._gpuUniformBuffer$.size$; - WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuUniformBuffer$); + if (this._gpuUniformBuffer) { + WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._gpuUniformBuffer.size; + WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuUniformBuffer); } - if (this._gpuShader$) { - WebGLCmdFuncDestroyShader(WebGLDeviceManager.instance, this._gpuShader$); + if (this._gpuShader) { + WebGLCmdFuncDestroyShader(WebGLDeviceManager.instance, this._gpuShader); } - if (this._gpuInputAssembler$) { - WebGLCmdFuncDestroyInputAssembler(WebGLDeviceManager.instance, this._gpuInputAssembler$); + if (this._gpuInputAssembler) { + WebGLCmdFuncDestroyInputAssembler(WebGLDeviceManager.instance, this._gpuInputAssembler); } } @@ -525,21 +525,21 @@ void main() { const device = WebGLDeviceManager.instance; const { gl } = device; const stateCache = device.stateCache; - const origFramebuffer = stateCache.glFramebuffer$; + const origFramebuffer = stateCache.glFramebuffer; - gl.viewport(0, 0, gpuTextureDst.width$, gpuTextureDst.height$); - gl.scissor(0, 0, gpuTextureDst.width$, gpuTextureDst.height$); + gl.viewport(0, 0, gpuTextureDst.width, gpuTextureDst.height); + gl.scissor(0, 0, gpuTextureDst.width, gpuTextureDst.height); - if (!this._uniformBuffer$ || !this._gpuUniformBuffer$ || !this._gpuPipelineState$ - || !this._gpuInputAssembler$ || !this._gpuDescriptorSet$ || !this._drawInfo$) { + if (!this._uniformBuffer || !this._gpuUniformBuffer || !this._gpuPipelineState + || !this._gpuInputAssembler || !this._gpuDescriptorSet || !this._drawInfo) { return; } - const descriptor = this._gpuDescriptorSet$.gpuDescriptors$[1]; - descriptor.gpuTexture$ = gpuTextureSrc; - descriptor.gpuSampler$ = filter === Filter.POINT ? this._gpuPointSampler$ : this._gpuLinearSampler$; + const descriptor = this._gpuDescriptorSet.gpuDescriptors[1]; + descriptor.gpuTexture = gpuTextureSrc; + descriptor.gpuSampler = filter === Filter.POINT ? this._gpuPointSampler : this._gpuLinearSampler; - const formatInfo = FormatInfos[gpuTextureDst.format$]; + const formatInfo = FormatInfos[gpuTextureDst.format]; let attachment: number = WebGLConstants.COLOR_ATTACHMENT0; if (formatInfo.hasStencil) { attachment = WebGLConstants.DEPTH_STENCIL_ATTACHMENT; @@ -550,61 +550,61 @@ void main() { const regionIndices = regions.map((_, i): number => i); regionIndices.sort((a, b): number => regions[a].srcSubres.mipLevel - regions[b].srcSubres.mipLevel); - if (stateCache.glFramebuffer$ !== this._glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, this._glFramebuffer$); - stateCache.glFramebuffer$ = this._glFramebuffer$; + if (stateCache.glFramebuffer !== this._glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, this._glFramebuffer); + stateCache.glFramebuffer = this._glFramebuffer; } let mipLevel = regions[0].dstSubres.mipLevel; - if (gpuTextureDst.glTexture$) { - gl.framebufferTexture2D(WebGLConstants.FRAMEBUFFER, attachment, gpuTextureDst.glTarget$, gpuTextureDst.glTexture$, mipLevel); + if (gpuTextureDst.glTexture) { + gl.framebufferTexture2D(WebGLConstants.FRAMEBUFFER, attachment, gpuTextureDst.glTarget, gpuTextureDst.glTexture, mipLevel); } else { - gl.framebufferRenderbuffer(WebGLConstants.FRAMEBUFFER, attachment, WebGLConstants.RENDERBUFFER, gpuTextureDst.glRenderbuffer$); + gl.framebufferRenderbuffer(WebGLConstants.FRAMEBUFFER, attachment, WebGLConstants.RENDERBUFFER, gpuTextureDst.glRenderbuffer); } for (let i = 0; i < regionIndices.length; ++i) { const region = regions[regionIndices[i]]; - if (gpuTextureSrc.glTexture$ && mipLevel !== region.srcSubres.mipLevel) { + if (gpuTextureSrc.glTexture && mipLevel !== region.srcSubres.mipLevel) { mipLevel = region.srcSubres.mipLevel; - gl.framebufferTexture2D(WebGLConstants.FRAMEBUFFER, attachment, gpuTextureDst.glTarget$, gpuTextureDst.glTexture$, mipLevel); + gl.framebufferTexture2D(WebGLConstants.FRAMEBUFFER, attachment, gpuTextureDst.glTarget, gpuTextureDst.glTexture, mipLevel); } - const srcWidth = gpuTextureSrc.width$; - const srcHeight = gpuTextureSrc.height$; - const dstWidth = gpuTextureDst.width$; - const dstHeight = gpuTextureDst.height$; + const srcWidth = gpuTextureSrc.width; + const srcHeight = gpuTextureSrc.height; + const dstWidth = gpuTextureDst.width; + const dstHeight = gpuTextureDst.height; - this._uniformBuffer$[0] = region.srcExtent.width / srcWidth; - this._uniformBuffer$[1] = region.srcExtent.height / srcHeight; - this._uniformBuffer$[2] = region.srcOffset.x / srcWidth; - this._uniformBuffer$[3] = region.srcOffset.y / srcHeight; - this._uniformBuffer$[4] = region.dstExtent.width / dstWidth; - this._uniformBuffer$[5] = region.dstExtent.height / dstHeight; - this._uniformBuffer$[6] = region.dstOffset.x / dstWidth; - this._uniformBuffer$[7] = region.dstOffset.y / dstHeight; + this._uniformBuffer[0] = region.srcExtent.width / srcWidth; + this._uniformBuffer[1] = region.srcExtent.height / srcHeight; + this._uniformBuffer[2] = region.srcOffset.x / srcWidth; + this._uniformBuffer[3] = region.srcOffset.y / srcHeight; + this._uniformBuffer[4] = region.dstExtent.width / dstWidth; + this._uniformBuffer[5] = region.dstExtent.height / dstHeight; + this._uniformBuffer[6] = region.dstOffset.x / dstWidth; + this._uniformBuffer[7] = region.dstOffset.y / dstHeight; WebGLCmdFuncUpdateBuffer( device, - this._gpuUniformBuffer$, - this._uniformBuffer$, + this._gpuUniformBuffer, + this._uniformBuffer, 0, - this._uniformBuffer$.length * Float32Array.BYTES_PER_ELEMENT, + this._uniformBuffer.length * Float32Array.BYTES_PER_ELEMENT, ); - WebGLCmdFuncBindStates(device, this._gpuPipelineState$, this._gpuInputAssembler$, [this._gpuDescriptorSet$], [], null!); - WebGLCmdFuncDraw(device, this._drawInfo$); + WebGLCmdFuncBindStates(device, this._gpuPipelineState, this._gpuInputAssembler, [this._gpuDescriptorSet], [], null!); + WebGLCmdFuncDraw(device, this._drawInfo); } // restore fbo - if (stateCache.glFramebuffer$ !== origFramebuffer) { + if (stateCache.glFramebuffer !== origFramebuffer) { gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, origFramebuffer); - stateCache.glFramebuffer$ = origFramebuffer; + stateCache.glFramebuffer = origFramebuffer; } // restore viewport - const origViewport = stateCache.viewport$; + const origViewport = stateCache.viewport; gl.viewport(origViewport.left, origViewport.top, origViewport.width, origViewport.height); // restore scissor - const origScissor = stateCache.scissorRect$; + const origScissor = stateCache.scissorRect; gl.scissor(origScissor.x, origScissor.y, origScissor.width, origScissor.height); } } diff --git a/cocos/gfx/webgl/webgl-input-assembler.ts b/cocos/gfx/webgl/webgl-input-assembler.ts index 07fab5c1a38..1a810a4cd9b 100644 --- a/cocos/gfx/webgl/webgl-input-assembler.ts +++ b/cocos/gfx/webgl/webgl-input-assembler.ts @@ -32,10 +32,10 @@ import { IWebGLGPUInputAssembler, IWebGLGPUBuffer } from './webgl-gpu-objects'; export class WebGLInputAssembler extends InputAssembler { get gpuInputAssembler (): IWebGLGPUInputAssembler { - return this._gpuInputAssembler$!; + return this._gpuInputAssembler!; } - private _gpuInputAssembler$: IWebGLGPUInputAssembler | null = null; + private _gpuInputAssembler: IWebGLGPUInputAssembler | null = null; constructor () { super(); @@ -47,24 +47,24 @@ export class WebGLInputAssembler extends InputAssembler { return; } - this._attributes$ = info.attributes; - this._attributesHash$ = this.computeAttributesHash$(); - this._vertexBuffers$ = info.vertexBuffers; + this._attributes = info.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = info.vertexBuffers; if (info.indexBuffer) { - this._indexBuffer$ = info.indexBuffer; - this._drawInfo$.indexCount = this._indexBuffer$.size / this._indexBuffer$.stride; - this._drawInfo$.firstIndex = 0; + this._indexBuffer = info.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; } else { - const vertBuff = this._vertexBuffers$[0]; - this._drawInfo$.vertexCount = vertBuff.size / vertBuff.stride; - this._drawInfo$.firstVertex = 0; - this._drawInfo$.vertexOffset = 0; + const vertBuff = this._vertexBuffers[0]; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; } - this._drawInfo$.instanceCount = 0; - this._drawInfo$.firstInstance = 0; + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; - this._indirectBuffer$ = info.indirectBuffer || null; + this._indirectBuffer = info.indirectBuffer || null; const gpuVertexBuffers: IWebGLGPUBuffer[] = new Array(info.vertexBuffers.length); for (let i = 0; i < info.vertexBuffers.length; ++i) { @@ -79,7 +79,7 @@ export class WebGLInputAssembler extends InputAssembler { if (info.indexBuffer) { gpuIndexBuffer = (info.indexBuffer as WebGLBuffer).gpuBuffer; if (gpuIndexBuffer) { - switch (gpuIndexBuffer.stride$) { + switch (gpuIndexBuffer.stride) { case 1: glIndexType = 0x1401; break; // WebGLRenderingContext.UNSIGNED_BYTE case 2: glIndexType = 0x1403; break; // WebGLRenderingContext.UNSIGNED_SHORT case 4: glIndexType = 0x1405; break; // WebGLRenderingContext.UNSIGNED_INT @@ -95,25 +95,25 @@ export class WebGLInputAssembler extends InputAssembler { gpuIndirectBuffer = (info.indirectBuffer as WebGLBuffer).gpuBuffer; } - this._gpuInputAssembler$ = { - attributes$: info.attributes, - gpuVertexBuffers$: gpuVertexBuffers, - gpuIndexBuffer$: gpuIndexBuffer, - gpuIndirectBuffer$: gpuIndirectBuffer, + this._gpuInputAssembler = { + attributes: info.attributes, + gpuVertexBuffers, + gpuIndexBuffer, + gpuIndirectBuffer, - glAttribs$: [], - glIndexType$: glIndexType, - glVAOs$: new Map(), + glAttribs: [], + glIndexType, + glVAOs: new Map(), }; - WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler$); + WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler); } public destroy (): void { const device = WebGLDeviceManager.instance; - if (this._gpuInputAssembler$ && device.extensions.useVAO$) { - WebGLCmdFuncDestroyInputAssembler(device, this._gpuInputAssembler$); + if (this._gpuInputAssembler && device.extensions.useVAO) { + WebGLCmdFuncDestroyInputAssembler(device, this._gpuInputAssembler); } - this._gpuInputAssembler$ = null; + this._gpuInputAssembler = null; } } diff --git a/cocos/gfx/webgl/webgl-pipeline-layout.ts b/cocos/gfx/webgl/webgl-pipeline-layout.ts index 907edaf787f..1e026b2c6db 100644 --- a/cocos/gfx/webgl/webgl-pipeline-layout.ts +++ b/cocos/gfx/webgl/webgl-pipeline-layout.ts @@ -28,24 +28,24 @@ import { WebGLDescriptorSetLayout } from './webgl-descriptor-set-layout'; import { PipelineLayoutInfo } from '../base/define'; export class WebGLPipelineLayout extends PipelineLayout { - get gpuPipelineLayout (): IWebGLGPUPipelineLayout { return this._gpuPipelineLayout$!; } + get gpuPipelineLayout (): IWebGLGPUPipelineLayout { return this._gpuPipelineLayout!; } - private _gpuPipelineLayout$: IWebGLGPUPipelineLayout | null = null; + private _gpuPipelineLayout: IWebGLGPUPipelineLayout | null = null; constructor () { super(); } public initialize (info: Readonly): void { - Array.prototype.push.apply(this._setLayouts$, info.setLayouts); + Array.prototype.push.apply(this._setLayouts, info.setLayouts); const dynamicOffsetIndices: number[][] = []; const gpuSetLayouts: IWebGLGPUDescriptorSetLayout[] = []; let dynamicOffsetCount = 0; const dynamicOffsetOffsets: number[] = []; - for (let i = 0; i < this._setLayouts$.length; i++) { - const setLayout = this._setLayouts$[i] as WebGLDescriptorSetLayout; - const dynamicBindings = setLayout.gpuDescriptorSetLayout.dynamicBindings$; + for (let i = 0; i < this._setLayouts.length; i++) { + const setLayout = this._setLayouts[i] as WebGLDescriptorSetLayout; + const dynamicBindings = setLayout.gpuDescriptorSetLayout.dynamicBindings; const indices = Array(setLayout.bindingIndices.length).fill(-1); for (let j = 0; j < dynamicBindings.length; j++) { const binding = dynamicBindings[j]; @@ -58,15 +58,15 @@ export class WebGLPipelineLayout extends PipelineLayout { dynamicOffsetCount += dynamicBindings.length; } - this._gpuPipelineLayout$ = { - gpuSetLayouts$: gpuSetLayouts, - dynamicOffsetIndices$: dynamicOffsetIndices, - dynamicOffsetCount$: dynamicOffsetCount, - dynamicOffsetOffsets$: dynamicOffsetOffsets, + this._gpuPipelineLayout = { + gpuSetLayouts, + dynamicOffsetIndices, + dynamicOffsetCount, + dynamicOffsetOffsets, }; } public destroy (): void { - this._setLayouts$.length = 0; + this._setLayouts.length = 0; } } diff --git a/cocos/gfx/webgl/webgl-pipeline-state.ts b/cocos/gfx/webgl/webgl-pipeline-state.ts index 09379b698e3..1b7d6ae2244 100644 --- a/cocos/gfx/webgl/webgl-pipeline-state.ts +++ b/cocos/gfx/webgl/webgl-pipeline-state.ts @@ -48,20 +48,20 @@ const WebGLPrimitives: GLenum[] = [ export class WebGLPipelineState extends PipelineState { get gpuPipelineState (): IWebGLGPUPipelineState { - return this._gpuPipelineState$!; + return this._gpuPipelineState!; } - private _gpuPipelineState$: IWebGLGPUPipelineState | null = null; + private _gpuPipelineState: IWebGLGPUPipelineState | null = null; constructor () { super(); } public initialize (info: Readonly): void { - this._primitive$ = info.primitive; - this._shader$ = info.shader; - this._pipelineLayout$ = info.pipelineLayout; - const bs = this._bs$; + this._primitive = info.primitive; + this._shader = info.shader; + this._pipelineLayout = info.pipelineLayout; + const bs = this._bs; if (info.blendState) { const bsInfo = info.blendState; const { targets } = bsInfo; @@ -75,32 +75,32 @@ export class WebGLPipelineState extends PipelineState { if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; } if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor; } } - Object.assign(this._rs$, info.rasterizerState); - Object.assign(this._dss$, info.depthStencilState); - this._is$ = info.inputState; - this._renderPass$ = info.renderPass; - this._dynamicStates$ = info.dynamicStates; + Object.assign(this._rs, info.rasterizerState); + Object.assign(this._dss, info.depthStencilState); + this._is = info.inputState; + this._renderPass = info.renderPass; + this._dynamicStates = info.dynamicStates; const dynamicStates: DynamicStateFlagBit[] = []; for (let i = 0; i < 31; i++) { - if (this._dynamicStates$ & (1 << i)) { + if (this._dynamicStates & (1 << i)) { dynamicStates.push(1 << i); } } - this._gpuPipelineState$ = { - glPrimitive$: WebGLPrimitives[info.primitive], - gpuShader$: (info.shader as WebGLShader).gpuShader, - gpuPipelineLayout$: (info.pipelineLayout as WebGLPipelineLayout).gpuPipelineLayout, - rs$: info.rasterizerState, - dss$: info.depthStencilState, - bs$: info.blendState, - gpuRenderPass$: (info.renderPass as WebGLRenderPass).gpuRenderPass, - dynamicStates$: dynamicStates, + this._gpuPipelineState = { + glPrimitive: WebGLPrimitives[info.primitive], + gpuShader: (info.shader as WebGLShader).gpuShader, + gpuPipelineLayout: (info.pipelineLayout as WebGLPipelineLayout).gpuPipelineLayout, + rs: info.rasterizerState, + dss: info.depthStencilState, + bs: info.blendState, + gpuRenderPass: (info.renderPass as WebGLRenderPass).gpuRenderPass, + dynamicStates, }; } public destroy (): void { - this._gpuPipelineState$ = null; + this._gpuPipelineState = null; } } diff --git a/cocos/gfx/webgl/webgl-primary-command-buffer.ts b/cocos/gfx/webgl/webgl-primary-command-buffer.ts index adf98ed8088..d15f749ee4d 100644 --- a/cocos/gfx/webgl/webgl-primary-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-primary-command-buffer.ts @@ -59,12 +59,12 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { clearDepth, clearStencil, ); - this._isInRenderPass$ = true; + this._isInRenderPass = true; } public draw (infoOrAssembler: DrawInfo | InputAssembler): void { - if (this._isInRenderPass$) { - if (this._isStateInvalied$) { + if (this._isInRenderPass) { + if (this._isStateInvalied) { this.bindStates(); } @@ -72,19 +72,19 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { WebGLCmdFuncDraw(WebGLDeviceManager.instance, info); - ++this._numDrawCalls$; - this._numInstances$ += info.instanceCount; + ++this._numDrawCalls; + this._numInstances += info.instanceCount; const indexCount = info.indexCount || info.vertexCount; - if (this._curGPUPipelineState$) { - const glPrimitive = this._curGPUPipelineState$.glPrimitive$; + if (this._curGPUPipelineState) { + const glPrimitive = this._curGPUPipelineState.glPrimitive; switch (glPrimitive) { case WebGLConstants.TRIANGLES: { - this._numTris$ += indexCount / 3 * Math.max(info.instanceCount, 1); + this._numTris += indexCount / 3 * Math.max(info.instanceCount, 1); break; } case WebGLConstants.TRIANGLE_STRIP: case WebGLConstants.TRIANGLE_FAN: { - this._numTris$ += (indexCount - 2) * Math.max(info.instanceCount, 1); + this._numTris += (indexCount - 2) * Math.max(info.instanceCount, 1); break; } default: @@ -98,37 +98,37 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { public setViewport (viewport: Readonly): void { const { stateCache: cache, gl } = WebGLDeviceManager.instance; - if (cache.viewport$.left !== viewport.left - || cache.viewport$.top !== viewport.top - || cache.viewport$.width !== viewport.width - || cache.viewport$.height !== viewport.height) { + if (cache.viewport.left !== viewport.left + || cache.viewport.top !== viewport.top + || cache.viewport.width !== viewport.width + || cache.viewport.height !== viewport.height) { gl.viewport(viewport.left, viewport.top, viewport.width, viewport.height); - cache.viewport$.left = viewport.left; - cache.viewport$.top = viewport.top; - cache.viewport$.width = viewport.width; - cache.viewport$.height = viewport.height; + cache.viewport.left = viewport.left; + cache.viewport.top = viewport.top; + cache.viewport.width = viewport.width; + cache.viewport.height = viewport.height; } } public setScissor (scissor: Readonly): void { const { stateCache: cache, gl } = WebGLDeviceManager.instance; - if (cache.scissorRect$.x !== scissor.x - || cache.scissorRect$.y !== scissor.y - || cache.scissorRect$.width !== scissor.width - || cache.scissorRect$.height !== scissor.height) { + if (cache.scissorRect.x !== scissor.x + || cache.scissorRect.y !== scissor.y + || cache.scissorRect.width !== scissor.width + || cache.scissorRect.height !== scissor.height) { gl.scissor(scissor.x, scissor.y, scissor.width, scissor.height); - cache.scissorRect$.x = scissor.x; - cache.scissorRect$.y = scissor.y; - cache.scissorRect$.width = scissor.width; - cache.scissorRect$.height = scissor.height; + cache.scissorRect.x = scissor.x; + cache.scissorRect.y = scissor.y; + cache.scissorRect.width = scissor.width; + cache.scissorRect.height = scissor.height; } } public updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { - if (!this._isInRenderPass$) { + if (!this._isInRenderPass) { const gpuBuffer = (buffer as WebGLBuffer).gpuBuffer; if (gpuBuffer) { let buffSize: number; @@ -148,7 +148,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { - if (!this._isInRenderPass$) { + if (!this._isInRenderPass) { const gpuTexture = (texture as WebGLTexture).gpuTexture; if (gpuTexture) { WebGLCmdFuncCopyBuffersToTexture(WebGLDeviceManager.instance, buffers, gpuTexture, regions); @@ -165,13 +165,13 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { protected bindStates (): void { WebGLCmdFuncBindStates( WebGLDeviceManager.instance, - this._curGPUPipelineState$, - this._curGPUInputAssembler$, - this._curGPUDescriptorSets$, - this._curDynamicOffsets$, - this._curDynamicStates$, + this._curGPUPipelineState, + this._curGPUInputAssembler, + this._curGPUDescriptorSets, + this._curDynamicOffsets, + this._curDynamicStates, ); - this._isStateInvalied$ = false; + this._isStateInvalied = false; } public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { diff --git a/cocos/gfx/webgl/webgl-queue.ts b/cocos/gfx/webgl/webgl-queue.ts index 9a3a99bac5d..d6c8c4021ad 100644 --- a/cocos/gfx/webgl/webgl-queue.ts +++ b/cocos/gfx/webgl/webgl-queue.ts @@ -27,16 +27,16 @@ import { CommandBuffer } from '../base/command-buffer'; import { Queue } from '../base/queue'; export class WebGLQueue extends Queue { - public numDrawCalls$ = 0; - public numInstances$ = 0; - public numTris$ = 0; + public numDrawCalls = 0; + public numInstances = 0; + public numTris = 0; constructor () { super(); } public initialize (info: Readonly): void { - this._type$ = info.type; + this._type = info.type; } public destroy (): void { @@ -47,15 +47,15 @@ export class WebGLQueue extends Queue { for (let i = 0; i < len; i++) { const cmdBuff = cmdBuffs[i]; // WebGLCmdFuncExecuteCmds( this._device as WebGLDevice, (cmdBuff as WebGLCommandBuffer).cmdPackage); // opted out - this.numDrawCalls$ += cmdBuff.numDrawCalls; - this.numInstances$ += cmdBuff.numInstances; - this.numTris$ += cmdBuff.numTris; + this.numDrawCalls += cmdBuff.numDrawCalls; + this.numInstances += cmdBuff.numInstances; + this.numTris += cmdBuff.numTris; } } public clear (): void { - this.numDrawCalls$ = 0; - this.numInstances$ = 0; - this.numTris$ = 0; + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; } } diff --git a/cocos/gfx/webgl/webgl-render-pass.ts b/cocos/gfx/webgl/webgl-render-pass.ts index 1374871d362..bfc72257708 100644 --- a/cocos/gfx/webgl/webgl-render-pass.ts +++ b/cocos/gfx/webgl/webgl-render-pass.ts @@ -28,29 +28,29 @@ import { IWebGLGPURenderPass } from './webgl-gpu-objects'; export class WebGLRenderPass extends RenderPass { public get gpuRenderPass (): IWebGLGPURenderPass { - return this._gpuRenderPass$!; + return this._gpuRenderPass!; } - private _gpuRenderPass$: IWebGLGPURenderPass | null = null; + private _gpuRenderPass: IWebGLGPURenderPass | null = null; constructor () { super(); } public initialize (info: Readonly): void { - this._colorInfos$ = info.colorAttachments; - this._depthStencilInfo$ = info.depthStencilAttachment; - this._subpasses$ = info.subpasses; + this._colorInfos = info.colorAttachments; + this._depthStencilInfo = info.depthStencilAttachment; + this._subpasses = info.subpasses; - this._gpuRenderPass$ = { - colorAttachments$: this._colorInfos$, - depthStencilAttachment$: this._depthStencilInfo$, + this._gpuRenderPass = { + colorAttachments: this._colorInfos, + depthStencilAttachment: this._depthStencilInfo, }; - this._hash$ = this.computeHash(); + this._hash = this.computeHash(); } public destroy (): void { - this._gpuRenderPass$ = null; + this._gpuRenderPass = null; } } diff --git a/cocos/gfx/webgl/webgl-shader.ts b/cocos/gfx/webgl/webgl-shader.ts index 5128bdaad18..bd32e50361d 100644 --- a/cocos/gfx/webgl/webgl-shader.ts +++ b/cocos/gfx/webgl/webgl-shader.ts @@ -30,53 +30,53 @@ import { IWebGLGPUShader, IWebGLGPUShaderStage } from './webgl-gpu-objects'; export class WebGLShader extends Shader { get gpuShader (): IWebGLGPUShader { - if (this._gpuShader$!.glProgram$ === null) { - WebGLCmdFuncCreateShader(WebGLDeviceManager.instance, this._gpuShader$!); + if (this._gpuShader!.glProgram === null) { + WebGLCmdFuncCreateShader(WebGLDeviceManager.instance, this._gpuShader!); } - return this._gpuShader$!; + return this._gpuShader!; } - private _gpuShader$: IWebGLGPUShader | null = null; + private _gpuShader: IWebGLGPUShader | null = null; constructor () { super(); } public initialize (info: Readonly): void { - this._name$ = info.name; - this._stages$ = info.stages; - this._attributes$ = info.attributes; - this._blocks$ = info.blocks; - this._samplers$ = info.samplers; + this._name = info.name; + this._stages = info.stages; + this._attributes = info.attributes; + this._blocks = info.blocks; + this._samplers = info.samplers; - this._gpuShader$ = { - name$: info.name, - blocks$: info.blocks.slice(), - samplerTextures$: info.samplerTextures.slice(), - subpassInputs$: info.subpassInputs.slice(), + this._gpuShader = { + name: info.name, + blocks: info.blocks.slice(), + samplerTextures: info.samplerTextures.slice(), + subpassInputs: info.subpassInputs.slice(), - gpuStages$: new Array(info.stages.length), - glProgram$: null, - glInputs$: [], - glUniforms$: [], - glBlocks$: [], - glSamplerTextures$: [], + gpuStages: new Array(info.stages.length), + glProgram: null, + glInputs: [], + glUniforms: [], + glBlocks: [], + glSamplerTextures: [], }; for (let i = 0; i < info.stages.length; ++i) { const stage = info.stages[i]; - this._gpuShader$.gpuStages$[i] = { - type$: stage.stage, - source$: stage.source, - glShader$: null, + this._gpuShader.gpuStages[i] = { + type: stage.stage, + source: stage.source, + glShader: null, }; } } public destroy (): void { - if (this._gpuShader$) { - WebGLCmdFuncDestroyShader(WebGLDeviceManager.instance, this._gpuShader$); - this._gpuShader$ = null; + if (this._gpuShader) { + WebGLCmdFuncDestroyShader(WebGLDeviceManager.instance, this._gpuShader); + this._gpuShader = null; } } } diff --git a/cocos/gfx/webgl/webgl-state-cache.ts b/cocos/gfx/webgl/webgl-state-cache.ts index c20fd03b34a..7114526a19d 100644 --- a/cocos/gfx/webgl/webgl-state-cache.ts +++ b/cocos/gfx/webgl/webgl-state-cache.ts @@ -26,34 +26,34 @@ import { Rect, Viewport } from '../base/define'; import { BlendState, DepthStencilState, RasterizerState } from '../base/pipeline-state'; export interface IWebGLTexUnit { - glTexture$: WebGLTexture | null; + glTexture: WebGLTexture | null; } export class WebGLStateCache { - public glArrayBuffer$: WebGLBuffer | null = null; - public glElementArrayBuffer$: WebGLBuffer | null = null; - public glVAO$: WebGLVertexArrayObjectOES | null = null; - public texUnit$ = 0; - public glTexUnits$: IWebGLTexUnit[] = []; - public glRenderbuffer$: WebGLRenderbuffer | null = null; - public glFramebuffer$: WebGLFramebuffer | null = null; - public viewport$ = new Viewport(); - public scissorRect$ = new Rect(0, 0, 0, 0); - public rs$ = new RasterizerState(); - public dss$ = new DepthStencilState(); - public bs$ = new BlendState(); - public glProgram$: WebGLProgram | null = null; - public glEnabledAttribLocs$: boolean[] = []; - public glCurrentAttribLocs$: boolean[] = []; - public texUnitCacheMap$: Record = {}; + public glArrayBuffer: WebGLBuffer | null = null; + public glElementArrayBuffer: WebGLBuffer | null = null; + public glVAO: WebGLVertexArrayObjectOES | null = null; + public texUnit = 0; + public glTexUnits: IWebGLTexUnit[] = []; + public glRenderbuffer: WebGLRenderbuffer | null = null; + public glFramebuffer: WebGLFramebuffer | null = null; + public viewport = new Viewport(); + public scissorRect = new Rect(0, 0, 0, 0); + public rs = new RasterizerState(); + public dss = new DepthStencilState(); + public bs = new BlendState(); + public glProgram: WebGLProgram | null = null; + public glEnabledAttribLocs: boolean[] = []; + public glCurrentAttribLocs: boolean[] = []; + public texUnitCacheMap: Record = {}; initialize (texUnit: number, vertexAttributes: number): void { - for (let i = 0; i < texUnit; ++i) this.glTexUnits$.push({ glTexture$: null }); + for (let i = 0; i < texUnit; ++i) this.glTexUnits.push({ glTexture: null }); - this.glEnabledAttribLocs$.length = vertexAttributes; - this.glEnabledAttribLocs$.fill(false); + this.glEnabledAttribLocs.length = vertexAttributes; + this.glEnabledAttribLocs.fill(false); - this.glCurrentAttribLocs$.length = vertexAttributes; - this.glCurrentAttribLocs$.fill(false); + this.glCurrentAttribLocs.length = vertexAttributes; + this.glCurrentAttribLocs.fill(false); } } diff --git a/cocos/gfx/webgl/webgl-swapchain.ts b/cocos/gfx/webgl/webgl-swapchain.ts index 7cefd10dcb9..15d5ec7c7fd 100644 --- a/cocos/gfx/webgl/webgl-swapchain.ts +++ b/cocos/gfx/webgl/webgl-swapchain.ts @@ -91,37 +91,37 @@ function getExtension (gl: WebGLRenderingContext, ext: string): any { export function getExtensions (gl: WebGLRenderingContext): IWebGLExtensions { const res: IWebGLExtensions = { - EXT_texture_filter_anisotropic$: getExtension(gl, 'EXT_texture_filter_anisotropic'), - EXT_blend_minmax$: getExtension(gl, 'EXT_blend_minmax'), - EXT_frag_depth$: getExtension(gl, 'EXT_frag_depth'), - EXT_shader_texture_lod$: getExtension(gl, 'EXT_shader_texture_lod'), - EXT_sRGB$: getExtension(gl, 'EXT_sRGB'), - OES_vertex_array_object$: getExtension(gl, 'OES_vertex_array_object'), - EXT_color_buffer_half_float$: getExtension(gl, 'EXT_color_buffer_half_float'), - WEBGL_color_buffer_float$: getExtension(gl, 'WEBGL_color_buffer_float'), - WEBGL_compressed_texture_etc1$: getExtension(gl, 'WEBGL_compressed_texture_etc1'), - WEBGL_compressed_texture_etc$: getExtension(gl, 'WEBGL_compressed_texture_etc'), - WEBGL_compressed_texture_pvrtc$: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), - WEBGL_compressed_texture_s3tc$: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), - WEBGL_compressed_texture_s3tc_srgb$: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), - WEBGL_debug_shaders$: getExtension(gl, 'WEBGL_debug_shaders'), - WEBGL_draw_buffers$: getExtension(gl, 'WEBGL_draw_buffers'), - WEBGL_lose_context$: getExtension(gl, 'WEBGL_lose_context'), - WEBGL_depth_texture$: getExtension(gl, 'WEBGL_depth_texture'), - OES_texture_half_float$: getExtension(gl, 'OES_texture_half_float'), - OES_texture_half_float_linear$: getExtension(gl, 'OES_texture_half_float_linear'), - OES_texture_float$: getExtension(gl, 'OES_texture_float'), - OES_texture_float_linear$: getExtension(gl, 'OES_texture_float_linear'), - OES_standard_derivatives$: getExtension(gl, 'OES_standard_derivatives'), - OES_element_index_uint$: getExtension(gl, 'OES_element_index_uint'), - ANGLE_instanced_arrays$: getExtension(gl, 'ANGLE_instanced_arrays'), - WEBGL_debug_renderer_info$: getExtension(gl, 'WEBGL_debug_renderer_info'), - WEBGL_multi_draw$: null, - WEBGL_compressed_texture_astc$: null, - destroyShadersImmediately$: true, - noCompressedTexSubImage2D$: false, - isLocationActive$: (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc, - useVAO$: false, + EXT_texture_filter_anisotropic: getExtension(gl, 'EXT_texture_filter_anisotropic'), + EXT_blend_minmax: getExtension(gl, 'EXT_blend_minmax'), + EXT_frag_depth: getExtension(gl, 'EXT_frag_depth'), + EXT_shader_texture_lod: getExtension(gl, 'EXT_shader_texture_lod'), + EXT_sRGB: getExtension(gl, 'EXT_sRGB'), + OES_vertex_array_object: getExtension(gl, 'OES_vertex_array_object'), + EXT_color_buffer_half_float: getExtension(gl, 'EXT_color_buffer_half_float'), + WEBGL_color_buffer_float: getExtension(gl, 'WEBGL_color_buffer_float'), + WEBGL_compressed_texture_etc1: getExtension(gl, 'WEBGL_compressed_texture_etc1'), + WEBGL_compressed_texture_etc: getExtension(gl, 'WEBGL_compressed_texture_etc'), + WEBGL_compressed_texture_pvrtc: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), + WEBGL_compressed_texture_s3tc: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), + WEBGL_compressed_texture_s3tc_srgb: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), + WEBGL_debug_shaders: getExtension(gl, 'WEBGL_debug_shaders'), + WEBGL_draw_buffers: getExtension(gl, 'WEBGL_draw_buffers'), + WEBGL_lose_context: getExtension(gl, 'WEBGL_lose_context'), + WEBGL_depth_texture: getExtension(gl, 'WEBGL_depth_texture'), + OES_texture_half_float: getExtension(gl, 'OES_texture_half_float'), + OES_texture_half_float_linear: getExtension(gl, 'OES_texture_half_float_linear'), + OES_texture_float: getExtension(gl, 'OES_texture_float'), + OES_texture_float_linear: getExtension(gl, 'OES_texture_float_linear'), + OES_standard_derivatives: getExtension(gl, 'OES_standard_derivatives'), + OES_element_index_uint: getExtension(gl, 'OES_element_index_uint'), + ANGLE_instanced_arrays: getExtension(gl, 'ANGLE_instanced_arrays'), + WEBGL_debug_renderer_info: getExtension(gl, 'WEBGL_debug_renderer_info'), + WEBGL_multi_draw: null, + WEBGL_compressed_texture_astc: null, + destroyShadersImmediately: true, + noCompressedTexSubImage2D: false, + isLocationActive: (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc, + useVAO: false, }; // platform-specific extension hacks @@ -129,65 +129,65 @@ export function getExtensions (gl: WebGLRenderingContext): IWebGLExtensions { { // iOS 14 browsers crash on getExtension('WEBGL_compressed_texture_astc') if (systemInfo.os !== OS.IOS || systemInfo.osMainVersion !== 14 || !systemInfo.isBrowser) { - res.WEBGL_compressed_texture_astc$ = getExtension(gl, 'WEBGL_compressed_texture_astc'); + res.WEBGL_compressed_texture_astc = getExtension(gl, 'WEBGL_compressed_texture_astc'); } // Mobile implementation seems to have performance issues if (systemInfo.os !== OS.ANDROID && systemInfo.os !== OS.IOS) { - res.WEBGL_multi_draw$ = getExtension(gl, 'WEBGL_multi_draw'); + res.WEBGL_multi_draw = getExtension(gl, 'WEBGL_multi_draw'); } // UC browser instancing implementation doesn't work if (systemInfo.browserType === BrowserType.UC) { - res.ANGLE_instanced_arrays$ = null; + res.ANGLE_instanced_arrays = null; } // bytedance ios depth texture implementation doesn't work if (BYTEDANCE && systemInfo.os === OS.IOS) { - res.WEBGL_depth_texture$ = null; + res.WEBGL_depth_texture = null; } if (RUNTIME_BASED) { // VAO implementations doesn't work well on some runtime platforms if (HUAWEI) { - res.OES_vertex_array_object$ = null; + res.OES_vertex_array_object = null; } } // some earlier version of iOS and android wechat implement gl.detachShader incorrectly if ((systemInfo.os === OS.IOS && systemInfo.osMainVersion <= 10) || ((WECHAT || WECHAT_MINI_PROGRAM) && systemInfo.os === OS.ANDROID)) { - res.destroyShadersImmediately$ = false; + res.destroyShadersImmediately = false; } // getUniformLocation has always been problematic because the // paradigm differs from GLES, and many platforms get it wrong [eyerolling] if (WECHAT || WECHAT_MINI_PROGRAM) { // wEcHaT just returns { id: -1 } for inactive names - res.isLocationActive$ = (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc && (glLoc as { id: number }).id !== -1; + res.isLocationActive = (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc && (glLoc as { id: number }).id !== -1; } if (ALIPAY) { // aLiPaY just returns the location number directly on actual devices, and WebGLUniformLocation objects in simulators - res.isLocationActive$ = (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc && glLoc !== -1 || glLoc === 0; + res.isLocationActive = (glLoc: unknown): glLoc is WebGLUniformLocation => !!glLoc && glLoc !== -1 || glLoc === 0; } // compressedTexSubImage2D too if (WECHAT || WECHAT_MINI_PROGRAM) { - res.noCompressedTexSubImage2D$ = true; + res.noCompressedTexSubImage2D = true; } // HACK: on Taobao Android, some devices can't query texture float extension correctly, especially Huawei devices // the query interface returns null. if ((TAOBAO || TAOBAO_MINIGAME) && systemInfo.os === OS.ANDROID) { - res.OES_texture_half_float$ = { HALF_FLOAT_OES: 36193 }; - res.OES_texture_half_float_linear$ = {}; - res.OES_texture_float$ = {}; - res.OES_texture_float_linear$ = {}; + res.OES_texture_half_float = { HALF_FLOAT_OES: 36193 }; + res.OES_texture_half_float_linear = {}; + res.OES_texture_float = {}; + res.OES_texture_float_linear = {}; } } - if (res.OES_vertex_array_object$) { - res.useVAO$ = true; + if (res.OES_vertex_array_object) { + res.useVAO = true; } return res; @@ -217,38 +217,38 @@ export function getContext (canvas: HTMLCanvasElement): WebGLRenderingContext | export class WebGLSwapchain extends Swapchain { get extensions (): IWebGLExtensions { - return this._extensions$ as IWebGLExtensions; + return this._extensions as IWebGLExtensions; } get blitManager (): IWebGLBlitManager { - return this._blitManager$!; + return this._blitManager!; } - public stateCache$: WebGLStateCache = new WebGLStateCache(); - public nullTex2D$: WebGLTexture = null!; - public nullTexCube$: WebGLTexture = null!; + public stateCache: WebGLStateCache = new WebGLStateCache(); + public nullTex2D: WebGLTexture = null!; + public nullTexCube: WebGLTexture = null!; - private _canvas$: HTMLCanvasElement | null = null; - private _webGLContextLostHandler$: ((event: Event) => void) | null = null; - private _extensions$: IWebGLExtensions | null = null; - private _blitManager$: IWebGLBlitManager | null = null; + private _canvas: HTMLCanvasElement | null = null; + private _webGLContextLostHandler: ((event: Event) => void) | null = null; + private _extensions: IWebGLExtensions | null = null; + private _blitManager: IWebGLBlitManager | null = null; constructor () { super(); } public initialize (info: Readonly): void { - this._canvas$ = info.windowHandle; + this._canvas = info.windowHandle; - this._webGLContextLostHandler$ = this._onWebGLContextLost$.bind(this); - this._canvas$.addEventListener(eventWebGLContextLost, this._webGLContextLostHandler$); + this._webGLContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(eventWebGLContextLost, this._webGLContextLostHandler); const { instance } = WebGLDeviceManager; const { gl, capabilities } = instance; - this.stateCache$.initialize(capabilities.maxTextureUnits, capabilities.maxVertexAttributes); + this.stateCache.initialize(capabilities.maxTextureUnits, capabilities.maxVertexAttributes); - this._extensions$ = getExtensions(gl); + this._extensions = getExtensions(gl); // init states initStates(gl); @@ -266,16 +266,16 @@ export class WebGLSwapchain extends Swapchain { if (depthBits && stencilBits) depthStencilFmt = Format.DEPTH_STENCIL; else if (depthBits) depthStencilFmt = Format.DEPTH; - this._colorTexture$ = new WebGLTexture(); - this._colorTexture$.initAsSwapchainTexture({ + this._colorTexture = new WebGLTexture(); + this._colorTexture.initAsSwapchainTexture({ swapchain: this, format: colorFmt, width: info.width, height: info.height, }); - this._depthStencilTexture$ = new WebGLTexture(); - this._depthStencilTexture$.initAsSwapchainTexture({ + this._depthStencilTexture = new WebGLTexture(); + this._depthStencilTexture.initAsSwapchainTexture({ swapchain: this, format: depthStencilFmt, width: info.width, @@ -283,7 +283,7 @@ export class WebGLSwapchain extends Swapchain { }); // create default null texture - this.nullTex2D$ = instance.createTexture(new TextureInfo( + this.nullTex2D = instance.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED, Format.RGBA8, @@ -292,7 +292,7 @@ export class WebGLSwapchain extends Swapchain { TextureFlagBit.GEN_MIPMAP, )) as WebGLTexture; - this.nullTexCube$ = instance.createTexture(new TextureInfo( + this.nullTexCube = instance.createTexture(new TextureInfo( TextureType.CUBE, TextureUsageBit.SAMPLED, Format.RGBA8, @@ -306,55 +306,55 @@ export class WebGLSwapchain extends Swapchain { nullTexRegion.texExtent.width = 2; nullTexRegion.texExtent.height = 2; - const nullTexBuff = new Uint8Array(this.nullTex2D$.size); + const nullTexBuff = new Uint8Array(this.nullTex2D.size); nullTexBuff.fill(0); - instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D$, [nullTexRegion]); + instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); nullTexRegion.texSubres.layerCount = 6; instance.copyBuffersToTexture( [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], - this.nullTexCube$, + this.nullTexCube, [nullTexRegion], ); - this._blitManager$ = new IWebGLBlitManager(); + this._blitManager = new IWebGLBlitManager(); } public destroy (): void { - if (this._canvas$ && this._webGLContextLostHandler$) { - this._canvas$.removeEventListener(eventWebGLContextLost, this._webGLContextLostHandler$); - this._webGLContextLostHandler$ = null; + if (this._canvas && this._webGLContextLostHandler) { + this._canvas.removeEventListener(eventWebGLContextLost, this._webGLContextLostHandler); + this._webGLContextLostHandler = null; } - if (this.nullTex2D$) { - this.nullTex2D$.destroy(); - this.nullTex2D$ = null!; + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null!; } - if (this.nullTexCube$) { - this.nullTexCube$.destroy(); - this.nullTexCube$ = null!; + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null!; } - if (this._blitManager$) { - this._blitManager$.destroy(); - this._blitManager$ = null!; + if (this._blitManager) { + this._blitManager.destroy(); + this._blitManager = null!; } - this._extensions$ = null; - this._canvas$ = null; + this._extensions = null; + this._canvas = null; } public resize (width: number, height: number, surfaceTransform: SurfaceTransform): void { - if (this._colorTexture$.width !== width || this._colorTexture$.height !== height) { + if (this._colorTexture.width !== width || this._colorTexture.height !== height) { debug(`Resizing swapchain: ${width}x${height}`); - this._canvas$!.width = width; - this._canvas$!.height = height; - this._colorTexture$.resize(width, height); - this._depthStencilTexture$.resize(width, height); + this._canvas!.width = width; + this._canvas!.height = height; + this._colorTexture.resize(width, height); + this._depthStencilTexture.resize(width, height); } } - private _onWebGLContextLost$ (event: Event): void { + private _onWebGLContextLost (event: Event): void { warnID(11000); warn(event); // 2020.9.3: `preventDefault` is not available on some platforms diff --git a/cocos/gfx/webgl/webgl-texture.ts b/cocos/gfx/webgl/webgl-texture.ts index 30666a32bfa..3bf6754e8c1 100644 --- a/cocos/gfx/webgl/webgl-texture.ts +++ b/cocos/gfx/webgl/webgl-texture.ts @@ -30,15 +30,15 @@ import { IWebGLGPUTexture } from './webgl-gpu-objects'; export class WebGLTexture extends Texture { get gpuTexture (): IWebGLGPUTexture { - return this._gpuTexture$!; + return this._gpuTexture!; } get lodLevel (): number { - return this._lodLevel$; + return this._lodLevel; } - private _gpuTexture$: IWebGLGPUTexture | null = null; - private _lodLevel$ = 0; + private _gpuTexture: IWebGLGPUTexture | null = null; + private _lodLevel = 0; constructor () { super(); @@ -50,123 +50,123 @@ export class WebGLTexture extends Texture { if ('texture' in info) { texInfo = viewInfo.texture.info; - this._isTextureView$ = true; + this._isTextureView = true; } - this._info$.copy(texInfo); + this._info.copy(texInfo); - this._isPowerOf2$ = IsPowerOf2(this._info$.width) && IsPowerOf2(this._info$.height); - this._size$ = FormatSurfaceSize( - this._info$.format, + this._isPowerOf2 = IsPowerOf2(this._info.width) && IsPowerOf2(this._info.height); + this._size = FormatSurfaceSize( + this._info.format, this.width, this.height, this.depth, - this._info$.levelCount, - ) * this._info$.layerCount; - - if (!this._isTextureView$) { - this._gpuTexture$ = { - type$: texInfo.type, - format$: texInfo.format, - usage$: texInfo.usage, - width$: texInfo.width, - height$: texInfo.height, - depth$: texInfo.depth, - size$: this._size$, - arrayLayer$: texInfo.layerCount, - mipLevel$: texInfo.levelCount, - samples$: texInfo.samples, - flags$: texInfo.flags, - isPowerOf2$: this._isPowerOf2$, - - glTarget$: 0, - glInternalFmt$: 0, - glFormat$: 0, - glType$: 0, - glUsage$: 0, - glTexture$: null, - glRenderbuffer$: null, - glWrapS$: 0, - glWrapT$: 0, - glMinFilter$: 0, - glMagFilter$: 0, - - isSwapchainTexture$: isSwapchainTexture || false, + this._info.levelCount, + ) * this._info.layerCount; + + if (!this._isTextureView) { + this._gpuTexture = { + type: texInfo.type, + format: texInfo.format, + usage: texInfo.usage, + width: texInfo.width, + height: texInfo.height, + depth: texInfo.depth, + size: this._size, + arrayLayer: texInfo.layerCount, + mipLevel: texInfo.levelCount, + samples: texInfo.samples, + flags: texInfo.flags, + isPowerOf2: this._isPowerOf2, + + glTarget: 0, + glInternalFmt: 0, + glFormat: 0, + glType: 0, + glUsage: 0, + glTexture: null, + glRenderbuffer: null, + glWrapS: 0, + glWrapT: 0, + glMinFilter: 0, + glMagFilter: 0, + + isSwapchainTexture: isSwapchainTexture || false, }; - if (!this._gpuTexture$.isSwapchainTexture$) { - WebGLCmdFuncCreateTexture(WebGLDeviceManager.instance, this._gpuTexture$); - WebGLDeviceManager.instance.memoryStatus.textureSize += this._size$; + if (!this._gpuTexture.isSwapchainTexture) { + WebGLCmdFuncCreateTexture(WebGLDeviceManager.instance, this._gpuTexture); + WebGLDeviceManager.instance.memoryStatus.textureSize += this._size; } - this._viewInfo$.texture = this; - this._viewInfo$.type = info.type; - this._viewInfo$.format = info.format; - this._viewInfo$.baseLevel = 0; - this._viewInfo$.levelCount = info.levelCount; - this._viewInfo$.baseLayer = 0; - this._viewInfo$.layerCount = info.layerCount; + this._viewInfo.texture = this; + this._viewInfo.type = info.type; + this._viewInfo.format = info.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = info.levelCount; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = info.layerCount; } else { - this._viewInfo$.copy(viewInfo); - this._lodLevel$ = viewInfo.baseLevel; - this._gpuTexture$ = (viewInfo.texture as WebGLTexture)._gpuTexture$; + this._viewInfo.copy(viewInfo); + this._lodLevel = viewInfo.baseLevel; + this._gpuTexture = (viewInfo.texture as WebGLTexture)._gpuTexture; } } public destroy (): void { - if (!this._isTextureView$ && this._gpuTexture$) { - WebGLCmdFuncDestroyTexture(WebGLDeviceManager.instance, this._gpuTexture$); - WebGLDeviceManager.instance.memoryStatus.textureSize -= this._size$; - this._gpuTexture$ = null; + if (!this._isTextureView && this._gpuTexture) { + WebGLCmdFuncDestroyTexture(WebGLDeviceManager.instance, this._gpuTexture); + WebGLDeviceManager.instance.memoryStatus.textureSize -= this._size; + this._gpuTexture = null; } } public getTextureHandle (): number { - const gpuTexture = this._gpuTexture$; + const gpuTexture = this._gpuTexture; if (!gpuTexture) { return 0; } - if (gpuTexture.glTexture$) { - return gpuTexture.glTexture$ as number; - } else if (gpuTexture.glRenderbuffer$) { - return gpuTexture.glRenderbuffer$ as number; + if (gpuTexture.glTexture) { + return gpuTexture.glTexture as number; + } else if (gpuTexture.glRenderbuffer) { + return gpuTexture.glRenderbuffer as number; } return 0; } public resize (width: number, height: number): void { - if (this._info$.width === width && this._info$.height === height) { + if (this._info.width === width && this._info.height === height) { return; } - if (this._info$.levelCount === WebGLTexture.getLevelCount(this._info$.width, this._info$.height)) { - this._info$.levelCount = WebGLTexture.getLevelCount(width, height); - } else if (this._info$.levelCount > 1) { - this._info$.levelCount = Math.min(this._info$.levelCount, WebGLTexture.getLevelCount(width, height)); + if (this._info.levelCount === WebGLTexture.getLevelCount(this._info.width, this._info.height)) { + this._info.levelCount = WebGLTexture.getLevelCount(width, height); + } else if (this._info.levelCount > 1) { + this._info.levelCount = Math.min(this._info.levelCount, WebGLTexture.getLevelCount(width, height)); } - const oldSize = this._size$; - this._info$.width = width; - this._info$.height = height; + const oldSize = this._size; + this._info.width = width; + this._info.height = height; - this._size$ = FormatSurfaceSize( - this._info$.format, + this._size = FormatSurfaceSize( + this._info.format, this.width, this.height, this.depth, - this._info$.levelCount, - ) * this._info$.layerCount; - - if (!this._isTextureView$ && this._gpuTexture$) { - this._gpuTexture$.width$ = width; - this._gpuTexture$.height$ = height; - this._gpuTexture$.size$ = this._size$; - if (!this._gpuTexture$.isSwapchainTexture$) { - WebGLCmdFuncResizeTexture(WebGLDeviceManager.instance, this._gpuTexture$); + this._info.levelCount, + ) * this._info.layerCount; + + if (!this._isTextureView && this._gpuTexture) { + this._gpuTexture.width = width; + this._gpuTexture.height = height; + this._gpuTexture.size = this._size; + if (!this._gpuTexture.isSwapchainTexture) { + WebGLCmdFuncResizeTexture(WebGLDeviceManager.instance, this._gpuTexture); WebGLDeviceManager.instance.memoryStatus.textureSize -= oldSize; - WebGLDeviceManager.instance.memoryStatus.textureSize += this._size$; + WebGLDeviceManager.instance.memoryStatus.textureSize += this._size; } } } diff --git a/cocos/gfx/webgl2/states/webgl2-sampler.ts b/cocos/gfx/webgl2/states/webgl2-sampler.ts index beb4d4a2f12..bcc78f18a2e 100644 --- a/cocos/gfx/webgl2/states/webgl2-sampler.ts +++ b/cocos/gfx/webgl2/states/webgl2-sampler.ts @@ -32,59 +32,59 @@ import { IWebGL2GPUSampler } from '../webgl2-gpu-objects'; export class WebGL2Sampler extends Sampler { public get gpuSampler (): IWebGL2GPUSampler { - return this._gpuSampler$!; + return this._gpuSampler!; } - private _gpuSampler$: IWebGL2GPUSampler | null = null; + private _gpuSampler: IWebGL2GPUSampler | null = null; constructor (info: Readonly, hash: number) { super(info, hash); - this._gpuSampler$ = { - glSamplers$: new Map(), - minFilter$: this._info$.minFilter, - magFilter$: this._info$.magFilter, - mipFilter$: this._info$.mipFilter, - addressU$: this._info$.addressU, - addressV$: this._info$.addressV, - addressW$: this._info$.addressW, + this._gpuSampler = { + glSamplers: new Map(), + minFilter: this._info.minFilter, + magFilter: this._info.magFilter, + mipFilter: this._info.mipFilter, + addressU: this._info.addressU, + addressV: this._info.addressV, + addressW: this._info.addressW, - glMinFilter$: 0, - glMagFilter$: 0, - glWrapS$: 0, - glWrapT$: 0, - glWrapR$: 0, + glMinFilter: 0, + glMagFilter: 0, + glWrapS: 0, + glWrapT: 0, + glWrapR: 0, - getGLSampler$ (device: WebGL2Device, minLod: number, maxLod: number): WebGLSampler { + getGLSampler (device: WebGL2Device, minLod: number, maxLod: number): WebGLSampler { const { gl } = device; const samplerHash = minLod << 16 | maxLod; - if (!this.glSamplers$.has(samplerHash)) { + if (!this.glSamplers.has(samplerHash)) { const glSampler = gl.createSampler(); if (glSampler) { - this.glSamplers$.set(samplerHash, glSampler); + this.glSamplers.set(samplerHash, glSampler); const glSamplerParameteri = gl.samplerParameteri.bind(gl); const glSamplerParameterf = gl.samplerParameterf.bind(gl); - glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_MIN_FILTER, this.glMinFilter$); - glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_MAG_FILTER, this.glMagFilter$); - glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_S, this.glWrapS$); - glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_T, this.glWrapT$); - glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_R, this.glWrapR$); + glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_MIN_FILTER, this.glMinFilter); + glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_MAG_FILTER, this.glMagFilter); + glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_S, this.glWrapS); + glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_T, this.glWrapT); + glSamplerParameteri(glSampler, WebGLConstants.TEXTURE_WRAP_R, this.glWrapR); glSamplerParameterf(glSampler, WebGLConstants.TEXTURE_MIN_LOD, minLod); glSamplerParameterf(glSampler, WebGLConstants.TEXTURE_MAX_LOD, maxLod); } } - const sampler = this.glSamplers$.get(samplerHash)!; + const sampler = this.glSamplers.get(samplerHash)!; return sampler; }, }; - WebGL2CmdFuncPrepareSamplerInfo(WebGL2DeviceManager.instance, this._gpuSampler$); + WebGL2CmdFuncPrepareSamplerInfo(WebGL2DeviceManager.instance, this._gpuSampler); } destroy (): void { - if (this._gpuSampler$) { - WebGL2CmdFuncDestroySampler(WebGL2DeviceManager.instance, this._gpuSampler$); - this._gpuSampler$ = null; + if (this._gpuSampler) { + WebGL2CmdFuncDestroySampler(WebGL2DeviceManager.instance, this._gpuSampler); + this._gpuSampler = null; } } } diff --git a/cocos/gfx/webgl2/webgl2-buffer.ts b/cocos/gfx/webgl2/webgl2-buffer.ts index 04443832842..b6e4679953d 100644 --- a/cocos/gfx/webgl2/webgl2-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-buffer.ts @@ -39,87 +39,87 @@ export class WebGL2Buffer extends Buffer { super(); } - getGpuBuffer$ (): IWebGL2GPUBuffer { - return this._gpuBuffer$!; + getGpuBuffer (): IWebGL2GPUBuffer { + return this._gpuBuffer!; } - private _gpuBuffer$: IWebGL2GPUBuffer | null = null; + private _gpuBuffer: IWebGL2GPUBuffer | null = null; public initialize (info: Readonly | Readonly): void { if ('buffer' in info) { // buffer view - this._isBufferView$ = true; + this._isBufferView = true; const buffer = info.buffer as WebGL2Buffer; - this._usage$ = buffer.usage; - this._memUsage$ = buffer.memUsage; - this._size$ = this._stride$ = info.range; - this._count$ = 1; - this._flags$ = buffer.flags; - - this._gpuBuffer$ = { - usage$: this._usage$, - memUsage$: this._memUsage$, - size$: this._size$, - stride$: this._stride$, - buffer$: null, - indirects$: buffer.getGpuBuffer$().indirects$, - glTarget$: buffer.getGpuBuffer$().glTarget$, - glBuffer$: buffer.getGpuBuffer$().glBuffer$, - glOffset$: info.offset, + this._usage = buffer.usage; + this._memUsage = buffer.memUsage; + this._size = this._stride = info.range; + this._count = 1; + this._flags = buffer.flags; + + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, + indirects: buffer.getGpuBuffer().indirects, + glTarget: buffer.getGpuBuffer().glTarget, + glBuffer: buffer.getGpuBuffer().glBuffer, + glOffset: info.offset, }; } else { // native buffer - this._usage$ = info.usage; - this._memUsage$ = info.memUsage; - this._size$ = info.size; - this._stride$ = Math.max(info.stride || this._size$, 1); - this._count$ = this._size$ / this._stride$; - this._flags$ = info.flags; - - this._gpuBuffer$ = { - usage$: this._usage$, - memUsage$: this._memUsage$, - size$: this._size$, - stride$: this._stride$, - buffer$: null, - indirects$: new WebGL2IndirectDrawInfos(), - glTarget$: 0, - glBuffer$: null, - glOffset$: 0, + this._usage = info.usage; + this._memUsage = info.memUsage; + this._size = info.size; + this._stride = Math.max(info.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = info.flags; + + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, + indirects: new WebGL2IndirectDrawInfos(), + glTarget: 0, + glBuffer: null, + glOffset: 0, }; - WebGL2CmdFuncCreateBuffer(WebGL2DeviceManager.instance, this._gpuBuffer$); + WebGL2CmdFuncCreateBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); - WebGL2DeviceManager.instance.memoryStatus.bufferSize += this._size$; + WebGL2DeviceManager.instance.memoryStatus.bufferSize += this._size; } } public destroy (): void { - if (this._gpuBuffer$) { - if (!this._isBufferView$) { - WebGL2CmdFuncDestroyBuffer(WebGL2DeviceManager.instance, this._gpuBuffer$); - WebGL2DeviceManager.instance.memoryStatus.bufferSize -= this._size$; + if (this._gpuBuffer) { + if (!this._isBufferView) { + WebGL2CmdFuncDestroyBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); + WebGL2DeviceManager.instance.memoryStatus.bufferSize -= this._size; } - this._gpuBuffer$ = null; + this._gpuBuffer = null; } } public resize (size: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16379); return; } - const oldSize = this._size$; + const oldSize = this._size; if (oldSize === size) { return; } - this._size$ = size; - this._count$ = this._size$ / this._stride$; + this._size = size; + this._count = this._size / this._stride; - if (this._gpuBuffer$) { - this._gpuBuffer$.size$ = size; + if (this._gpuBuffer) { + this._gpuBuffer.size = size; if (size > 0) { - WebGL2CmdFuncResizeBuffer(WebGL2DeviceManager.instance, this._gpuBuffer$); + WebGL2CmdFuncResizeBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); WebGL2DeviceManager.instance.memoryStatus.bufferSize -= oldSize; WebGL2DeviceManager.instance.memoryStatus.bufferSize += size; } @@ -127,7 +127,7 @@ export class WebGL2Buffer extends Buffer { } public update (buffer: Readonly, size?: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16380); return; } @@ -135,7 +135,7 @@ export class WebGL2Buffer extends Buffer { let buffSize: number; if (size !== undefined) { buffSize = size; - } else if (this._usage$ & BufferUsageBit.INDIRECT) { + } else if (this._usage & BufferUsageBit.INDIRECT) { buffSize = 0; } else { buffSize = (buffer as ArrayBuffer).byteLength; @@ -143,7 +143,7 @@ export class WebGL2Buffer extends Buffer { WebGL2CmdFuncUpdateBuffer( WebGL2DeviceManager.instance, - this._gpuBuffer$!, + this._gpuBuffer!, buffer as BufferSource, 0, buffSize, diff --git a/cocos/gfx/webgl2/webgl2-command-buffer.ts b/cocos/gfx/webgl2/webgl2-command-buffer.ts index e317f295478..80bc3f646ae 100644 --- a/cocos/gfx/webgl2/webgl2-command-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-command-buffer.ts @@ -47,25 +47,25 @@ import { WebGL2DeviceManager } from './webgl2-define'; import { errorID } from '../../core/platform/debug'; export class WebGL2CommandBuffer extends CommandBuffer { - protected _isInRenderPass$ = false; - protected _curGPUPipelineState$: IWebGL2GPUPipelineState | null = null; - protected _curGPUDescriptorSets$: IWebGL2GPUDescriptorSet[] = []; - protected _curGPUInputAssembler$: IWebGL2GPUInputAssembler | null = null; - protected _curDynamicOffsets$: number[] = Array(8).fill(0); - protected _curDynamicStates$: DynamicStates = new DynamicStates(); - protected _isStateInvalid$ = false; + protected _isInRenderPass = false; + protected _curGPUPipelineState: IWebGL2GPUPipelineState | null = null; + protected _curGPUDescriptorSets: IWebGL2GPUDescriptorSet[] = []; + protected _curGPUInputAssembler: IWebGL2GPUInputAssembler | null = null; + protected _curDynamicOffsets: number[] = Array(8).fill(0); + protected _curDynamicStates: DynamicStates = new DynamicStates(); + protected _isStateInvalid = false; constructor () { super(); } public initialize (info: Readonly): void { - this._type$ = info.type; - this._queue$ = info.queue; + this._type = info.type; + this._queue = info.queue; - const setCount = WebGL2DeviceManager.instance.bindingMappings.blockOffsets$.length; + const setCount = WebGL2DeviceManager.instance.bindingMappings.blockOffsets.length; for (let i = 0; i < setCount; i++) { - this._curGPUDescriptorSets$.push(null!); + this._curGPUDescriptorSets.push(null!); } } @@ -74,20 +74,20 @@ export class WebGL2CommandBuffer extends CommandBuffer { } public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { - this._curGPUPipelineState$ = null; - this._curGPUInputAssembler$ = null; - this._curGPUDescriptorSets$.length = 0; - this._numDrawCalls$ = 0; - this._numInstances$ = 0; - this._numTris$ = 0; + this._curGPUPipelineState = null; + this._curGPUInputAssembler = null; + this._curGPUDescriptorSets.length = 0; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; } public end (): void { - if (this._isStateInvalid$) { + if (this._isStateInvalid) { this.bindStates(); } - this._isInRenderPass$ = false; + this._isInRenderPass = false; } public beginRenderPass ( @@ -99,46 +99,46 @@ export class WebGL2CommandBuffer extends CommandBuffer { clearStencil: number, ): void { errorID(16401); - this._isInRenderPass$ = true; + this._isInRenderPass = true; } public endRenderPass (): void { - this._isInRenderPass$ = false; + this._isInRenderPass = false; } public bindPipelineState (pipelineState: PipelineState): void { const gpuPipelineState = (pipelineState as WebGL2PipelineState).gpuPipelineState; - if (gpuPipelineState !== this._curGPUPipelineState$) { - this._curGPUPipelineState$ = gpuPipelineState; - this._isStateInvalid$ = true; + if (gpuPipelineState !== this._curGPUPipelineState) { + this._curGPUPipelineState = gpuPipelineState; + this._isStateInvalid = true; } } public bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: Readonly): void { const gpuDescriptorSets = (descriptorSet as WebGL2DescriptorSet).gpuDescriptorSet; - if (gpuDescriptorSets !== this._curGPUDescriptorSets$[set]) { - this._curGPUDescriptorSets$[set] = gpuDescriptorSets; - this._isStateInvalid$ = true; + if (gpuDescriptorSets !== this._curGPUDescriptorSets[set]) { + this._curGPUDescriptorSets[set] = gpuDescriptorSets; + this._isStateInvalid = true; } if (dynamicOffsets) { - const gpuPipelineLayout = this._curGPUPipelineState$?.gpuPipelineLayout$; + const gpuPipelineLayout = this._curGPUPipelineState?.gpuPipelineLayout; if (gpuPipelineLayout) { - const offsets = this._curDynamicOffsets$; - const idx = gpuPipelineLayout.dynamicOffsetOffsets$[set]; + const offsets = this._curDynamicOffsets; + const idx = gpuPipelineLayout.dynamicOffsetOffsets[set]; for (let i = 0; i < dynamicOffsets.length; i++) offsets[idx + i] = dynamicOffsets[i]; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } } public bindInputAssembler (inputAssembler: InputAssembler): void { const gpuInputAssembler = (inputAssembler as WebGL2InputAssembler).gpuInputAssembler; - this._curGPUInputAssembler$ = gpuInputAssembler; - this._isStateInvalid$ = true; + this._curGPUInputAssembler = gpuInputAssembler; + this._isStateInvalid = true; } public setViewport (viewport: Readonly): void { - const cache = this._curDynamicStates$.viewport; + const cache = this._curDynamicStates.viewport; if (cache.left !== viewport.left || cache.top !== viewport.top || cache.width !== viewport.width @@ -151,12 +151,12 @@ export class WebGL2CommandBuffer extends CommandBuffer { cache.height = viewport.height; cache.minDepth = viewport.minDepth; cache.maxDepth = viewport.maxDepth; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } public setScissor (scissor: Readonly): void { - const cache = this._curDynamicStates$.scissor; + const cache = this._curDynamicStates.scissor; if (cache.x !== scissor.x || cache.y !== scissor.y || cache.width !== scissor.width @@ -165,76 +165,76 @@ export class WebGL2CommandBuffer extends CommandBuffer { cache.y = scissor.y; cache.width = scissor.width; cache.height = scissor.height; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } public setLineWidth (lineWidth: number): void { - if (this._curDynamicStates$.lineWidth !== lineWidth) { - this._curDynamicStates$.lineWidth = lineWidth; - this._isStateInvalid$ = true; + if (this._curDynamicStates.lineWidth !== lineWidth) { + this._curDynamicStates.lineWidth = lineWidth; + this._isStateInvalid = true; } } public setDepthBias (depthBiasConstantFactor: number, depthBiasClamp: number, depthBiasSlopeFactor: number): void { - const cache = this._curDynamicStates$; + const cache = this._curDynamicStates; if (cache.depthBiasConstant !== depthBiasConstantFactor || cache.depthBiasClamp !== depthBiasClamp || cache.depthBiasSlope !== depthBiasSlopeFactor) { cache.depthBiasConstant = depthBiasConstantFactor; cache.depthBiasClamp = depthBiasClamp; cache.depthBiasSlope = depthBiasSlopeFactor; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } public setBlendConstants (blendConstants: Color): void { - const cache = this._curDynamicStates$.blendConstant; + const cache = this._curDynamicStates.blendConstant; if (cache.x !== blendConstants.x || cache.y !== blendConstants.y || cache.z !== blendConstants.z || cache.w !== blendConstants.w) { cache.copy(blendConstants); - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } public setDepthBound (minDepthBounds: number, maxDepthBounds: number): void { - const cache = this._curDynamicStates$; + const cache = this._curDynamicStates; if (cache.depthMinBounds !== minDepthBounds || cache.depthMaxBounds !== maxDepthBounds) { cache.depthMinBounds = minDepthBounds; cache.depthMaxBounds = maxDepthBounds; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } public setStencilWriteMask (face: StencilFace, writeMask: number): void { - const front = this._curDynamicStates$.stencilStatesFront; - const back = this._curDynamicStates$.stencilStatesBack; + const front = this._curDynamicStates.stencilStatesFront; + const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { if (front.writeMask !== writeMask) { front.writeMask = writeMask; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } if (face & StencilFace.BACK) { if (back.writeMask !== writeMask) { back.writeMask = writeMask; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } } public setStencilCompareMask (face: StencilFace, reference: number, compareMask: number): void { - const front = this._curDynamicStates$.stencilStatesFront; - const back = this._curDynamicStates$.stencilStatesBack; + const front = this._curDynamicStates.stencilStatesFront; + const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { if (front.compareMask !== compareMask || front.reference !== reference) { front.reference = reference; front.compareMask = compareMask; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } if (face & StencilFace.BACK) { @@ -242,7 +242,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { || back.reference !== reference) { back.reference = reference; back.compareMask = compareMask; - this._isStateInvalid$ = true; + this._isStateInvalid = true; } } } @@ -275,7 +275,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { protected bindStates (): void { errorID(16401); - this._isStateInvalid$ = false; + this._isStateInvalid = false; } public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index 5ba4b2fec43..071f311e10b 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -621,192 +621,192 @@ const WebGLBlendFactors: GLenum[] = [ export function WebGL2CmdFuncCreateBuffer (device: WebGL2Device, gpuBuffer: IWebGL2GPUBuffer): void { const { gl } = device; - const cache = device.getStateCache$(); - const glUsage: GLenum = gpuBuffer.memUsage$ & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; + const cache = device.getStateCache(); + const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; - if (gpuBuffer.usage$ & BufferUsageBit.VERTEX) { - gpuBuffer.glTarget$ = WebGLConstants.ARRAY_BUFFER; + if (gpuBuffer.usage & BufferUsageBit.VERTEX) { + gpuBuffer.glTarget = WebGLConstants.ARRAY_BUFFER; const glBuffer = gl.createBuffer(); if (glBuffer) { - gpuBuffer.glBuffer$ = glBuffer; - if (gpuBuffer.size$ > 0) { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + gpuBuffer.glBuffer = glBuffer; + if (gpuBuffer.size > 0) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glArrayBuffer = gpuBuffer.glBuffer; } - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; + cache.glArrayBuffer = null; } } - } else if (gpuBuffer.usage$ & BufferUsageBit.INDEX) { - gpuBuffer.glTarget$ = WebGLConstants.ELEMENT_ARRAY_BUFFER; + } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { + gpuBuffer.glTarget = WebGLConstants.ELEMENT_ARRAY_BUFFER; const glBuffer = gl.createBuffer(); if (glBuffer) { - gpuBuffer.glBuffer$ = glBuffer; - if (gpuBuffer.size$ > 0) { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + gpuBuffer.glBuffer = glBuffer; + if (gpuBuffer.size > 0) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glElementArrayBuffer = gpuBuffer.glBuffer; } - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glElementArrayBuffer$ = null; + cache.glElementArrayBuffer = null; } } - } else if (gpuBuffer.usage$ & BufferUsageBit.UNIFORM) { - gpuBuffer.glTarget$ = WebGLConstants.UNIFORM_BUFFER; + } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { + gpuBuffer.glTarget = WebGLConstants.UNIFORM_BUFFER; const glBuffer = gl.createBuffer(); - if (glBuffer && gpuBuffer.size$ > 0) { - gpuBuffer.glBuffer$ = glBuffer; - if (cache.glUniformBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer$); - cache.glUniformBuffer$ = gpuBuffer.glBuffer$; + if (glBuffer && gpuBuffer.size > 0) { + gpuBuffer.glBuffer = glBuffer; + if (cache.glUniformBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer); + cache.glUniformBuffer = gpuBuffer.glBuffer; } - gl.bufferData(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, null); - cache.glUniformBuffer$ = null; - } - } else if (gpuBuffer.usage$ & BufferUsageBit.INDIRECT) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; - } else if (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_DST) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; - } else if (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_SRC) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; + cache.glUniformBuffer = null; + } + } else if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { + gpuBuffer.glTarget = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.TRANSFER_DST) { + gpuBuffer.glTarget = WebGLConstants.NONE; + } else if (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC) { + gpuBuffer.glTarget = WebGLConstants.NONE; } else { errorID(16315); - gpuBuffer.glTarget$ = WebGLConstants.NONE; + gpuBuffer.glTarget = WebGLConstants.NONE; } } export function WebGL2CmdFuncDestroyBuffer (device: WebGL2Device, gpuBuffer: IWebGL2GPUBuffer): void { const { gl } = device; - const cache = device.getStateCache$(); - const useVAO = device.extensions.useVAO$; + const cache = device.getStateCache(); + const useVAO = device.extensions.useVAO; - if (gpuBuffer.glBuffer$) { + if (gpuBuffer.glBuffer) { // Firefox 75+ implicitly unbind whatever buffer there was on the slot sometimes // can be reproduced in the static batching scene at https://github.com/cocos-creator/test-cases-3d - switch (gpuBuffer.glTarget$) { + switch (gpuBuffer.glTarget) { case WebGLConstants.ARRAY_BUFFER: if (useVAO) { - if (cache.glVAO$) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; + cache.glArrayBuffer = null; break; case WebGLConstants.ELEMENT_ARRAY_BUFFER: if (useVAO) { - if (cache.glVAO$) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glElementArrayBuffer$ = null; + cache.glElementArrayBuffer = null; break; case WebGLConstants.UNIFORM_BUFFER: gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, null); - cache.glUniformBuffer$ = null; + cache.glUniformBuffer = null; break; default: } - gl.deleteBuffer(gpuBuffer.glBuffer$); - gpuBuffer.glBuffer$ = null; + gl.deleteBuffer(gpuBuffer.glBuffer); + gpuBuffer.glBuffer = null; } } export function WebGL2CmdFuncResizeBuffer (device: WebGL2Device, gpuBuffer: IWebGL2GPUBuffer): void { const { gl } = device; - const cache = device.getStateCache$(); - const glUsage: GLenum = gpuBuffer.memUsage$ & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; + const cache = device.getStateCache(); + const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? WebGLConstants.DYNAMIC_DRAW : WebGLConstants.STATIC_DRAW; - if (gpuBuffer.usage$ & BufferUsageBit.VERTEX) { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + if (gpuBuffer.usage & BufferUsageBit.VERTEX) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); + if (cache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); } - if (gpuBuffer.buffer$) { - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.buffer$, glUsage); + if (gpuBuffer.buffer) { + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.buffer, glUsage); } else { - gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ARRAY_BUFFER, gpuBuffer.size, glUsage); } gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; - } else if (gpuBuffer.usage$ & BufferUsageBit.INDEX) { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + cache.glArrayBuffer = null; + } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); + if (cache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); } - if (gpuBuffer.buffer$) { - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.buffer$, glUsage); + if (gpuBuffer.buffer) { + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.buffer, glUsage); } else { - gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.size, glUsage); } gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glElementArrayBuffer$ = null; - } else if (gpuBuffer.usage$ & BufferUsageBit.UNIFORM) { - if (cache.glUniformBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer$); + cache.glElementArrayBuffer = null; + } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { + if (cache.glUniformBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer); } - gl.bufferData(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.size$, glUsage); + gl.bufferData(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.size, glUsage); gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, null); - cache.glUniformBuffer$ = null; - } else if ((gpuBuffer.usage$ & BufferUsageBit.INDIRECT) - || (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_DST) - || (gpuBuffer.usage$ & BufferUsageBit.TRANSFER_SRC)) { - gpuBuffer.glTarget$ = WebGLConstants.NONE; + cache.glUniformBuffer = null; + } else if ((gpuBuffer.usage & BufferUsageBit.INDIRECT) + || (gpuBuffer.usage & BufferUsageBit.TRANSFER_DST) + || (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC)) { + gpuBuffer.glTarget = WebGLConstants.NONE; } else { errorID(16315); - gpuBuffer.glTarget$ = WebGLConstants.NONE; + gpuBuffer.glTarget = WebGLConstants.NONE; } } @@ -817,88 +817,88 @@ export function WebGL2CmdFuncUpdateBuffer ( offset: number, size: number, ): void { - if (gpuBuffer.usage$ & BufferUsageBit.INDIRECT) { - gpuBuffer.indirects$.clearDraws$(); + if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { + gpuBuffer.indirects.clearDraws(); const drawInfos = (buffer as IndirectBuffer).drawInfos; for (let i = 0; i < drawInfos.length; ++i) { - gpuBuffer.indirects$.setDrawInfo$(offset + i, drawInfos[i]); + gpuBuffer.indirects.setDrawInfo(offset + i, drawInfos[i]); } } else { const buff = buffer as ArrayBuffer; const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); - switch (gpuBuffer.glTarget$) { + switch (gpuBuffer.glTarget) { case WebGLConstants.ARRAY_BUFFER: { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glArrayBuffer = gpuBuffer.glBuffer; } - if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage$ & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { + if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { // Fix performance issue on iOS. // TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases. // We should use multiple buffers to avoid stall (cpu write conflicts with gpu read). // Before that, we will use glBufferData instead of glBufferSubData. - gl.bufferData(gpuBuffer.glTarget$, buff, gl.DYNAMIC_DRAW); + gl.bufferData(gpuBuffer.glTarget, buff, gl.DYNAMIC_DRAW); } else if (size === buff.byteLength) { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff); } else { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff.slice(0, size)); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff.slice(0, size)); } break; } case WebGLConstants.ELEMENT_ARRAY_BUFFER: { - if (device.extensions.useVAO$) { - if (cache.glVAO$) { + if (device.extensions.useVAO) { + if (cache.glVAO) { gl.bindVertexArray(null); - cache.glVAO$ = null; + cache.glVAO = null; } } gfxStateCache.gpuInputAssembler = null; - if (cache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glElementArrayBuffer = gpuBuffer.glBuffer; } - if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage$ & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { + if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { // Fix performance issue on iOS. // TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases. // We should use multiple buffers to avoid stall (cpu write conflicts with gpu read). // Before that, we will use glBufferData instead of glBufferSubData. - gl.bufferData(gpuBuffer.glTarget$, buff, gl.DYNAMIC_DRAW); + gl.bufferData(gpuBuffer.glTarget, buff, gl.DYNAMIC_DRAW); } else if (size === buff.byteLength) { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff); } else { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff.slice(0, size)); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff.slice(0, size)); } break; } case WebGLConstants.UNIFORM_BUFFER: { - if (cache.glUniformBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer$); - cache.glUniformBuffer$ = gpuBuffer.glBuffer$; + if (cache.glUniformBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.UNIFORM_BUFFER, gpuBuffer.glBuffer); + cache.glUniformBuffer = gpuBuffer.glBuffer; } - if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage$ & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { + if (systemInfo.os === OS.IOS && (gpuBuffer.memUsage & MemoryUsageBit.HOST) && offset === 0 && size === buff.byteLength) { // Fix performance issue on iOS. // TODO(zhouzhenglong): glBufferSubData is faster than glBufferData in most cases. // We should use multiple buffers to avoid stall (cpu write conflicts with gpu read). // Before that, we will use glBufferData instead of glBufferSubData. - gl.bufferData(gpuBuffer.glTarget$, buff, gl.DYNAMIC_DRAW); + gl.bufferData(gpuBuffer.glTarget, buff, gl.DYNAMIC_DRAW); } else if (size === buff.byteLength) { - gl.bufferSubData(gpuBuffer.glTarget$, offset, buff); + gl.bufferSubData(gpuBuffer.glTarget, offset, buff); } else { - gl.bufferSubData(gpuBuffer.glTarget$, offset, new Float32Array(buff, 0, size / 4)); + gl.bufferSubData(gpuBuffer.glTarget, offset, new Float32Array(buff, 0, size / 4)); } break; } @@ -911,72 +911,72 @@ export function WebGL2CmdFuncUpdateBuffer ( export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IWebGL2GPUTexture): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); const capabilities = device.capabilities; - gpuTexture.glInternalFmt$ = GFXFormatToWebGLInternalFormat(gpuTexture.format$, gl); - gpuTexture.glFormat$ = GFXFormatToWebGLFormat(gpuTexture.format$, gl); - gpuTexture.glType$ = GFXFormatToWebGLType(gpuTexture.format$, gl); + gpuTexture.glInternalFmt = GFXFormatToWebGLInternalFormat(gpuTexture.format, gl); + gpuTexture.glFormat = GFXFormatToWebGLFormat(gpuTexture.format, gl); + gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl); - let w = gpuTexture.width$; - let h = gpuTexture.height$; - const d = gpuTexture.depth$; - const l = gpuTexture.arrayLayer$; + let w = gpuTexture.width; + let h = gpuTexture.height; + const d = gpuTexture.depth; + const l = gpuTexture.arrayLayer; - switch (gpuTexture.type$) { + switch (gpuTexture.type) { case TextureType.TEX2D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; const maxSize = max(w, h); if (maxSize > capabilities.maxTextureSize) { errorID(9100, maxSize, capabilities.maxTextureSize); } - if (gpuTexture.samples$ === SampleCount.X1) { - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + if (gpuTexture.samples === SampleCount.X1) { + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } - } else if (gpuTexture.flags$ & TextureFlagBit.MUTABLE_STORAGE) { - gl.texImage2D(WebGLConstants.TEXTURE_2D, 0, gpuTexture.glInternalFmt$, w, h, 0, gpuTexture.glFormat$, gpuTexture.glType$, null); + } else if (gpuTexture.flags & TextureFlagBit.MUTABLE_STORAGE) { + gl.texImage2D(WebGLConstants.TEXTURE_2D, 0, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); } else { - gl.texStorage2D(WebGLConstants.TEXTURE_2D, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h); + gl.texStorage2D(WebGLConstants.TEXTURE_2D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); } } } else { - gpuTexture.glRenderbuffer$ = gl.createRenderbuffer(); - if (gpuTexture.size$ > 0) { - if (cache.glRenderbuffer$ !== gpuTexture.glRenderbuffer$) { - gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer$); - cache.glRenderbuffer$ = gpuTexture.glRenderbuffer$; + gpuTexture.glRenderbuffer = gl.createRenderbuffer(); + if (gpuTexture.size > 0) { + if (cache.glRenderbuffer !== gpuTexture.glRenderbuffer) { + gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer); + cache.glRenderbuffer = gpuTexture.glRenderbuffer; } gl.renderbufferStorageMultisample( WebGLConstants.RENDERBUFFER, - gpuTexture.samples$, - gpuTexture.glInternalFmt$, - gpuTexture.width$, - gpuTexture.height$, + gpuTexture.samples, + gpuTexture.glInternalFmt, + gpuTexture.width, + gpuTexture.height, ); } } break; } case TextureType.TEX2D_ARRAY: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D_ARRAY; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D_ARRAY; const maxSize = max(w, h); if (maxSize > capabilities.maxTextureSize) { @@ -986,165 +986,165 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW errorID(9100, l, capabilities.maxArrayTextureLayers); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, l); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, l); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage3D(WebGLConstants.TEXTURE_2D_ARRAY, i, gpuTexture.glInternalFmt$, w, h, l, 0, view); + gl.compressedTexImage3D(WebGLConstants.TEXTURE_2D_ARRAY, i, gpuTexture.glInternalFmt, w, h, l, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - gl.texStorage3D(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h, l); + gl.texStorage3D(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h, l); } } break; } case TextureType.TEX3D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_3D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_3D; const maxSize = max(max(w, h), d); if (maxSize > capabilities.max3DTextureSize) { errorID(9100, maxSize, capabilities.max3DTextureSize); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_3D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_3D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, d); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, d); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage3D(WebGLConstants.TEXTURE_3D, i, gpuTexture.glInternalFmt$, w, h, d, 0, view); + gl.compressedTexImage3D(WebGLConstants.TEXTURE_3D, i, gpuTexture.glInternalFmt, w, h, d, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - gl.texStorage3D(WebGLConstants.TEXTURE_3D, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h, d); + gl.texStorage3D(WebGLConstants.TEXTURE_3D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h, d); } } break; } case TextureType.CUBE: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_CUBE_MAP; + gpuTexture.glTarget = WebGLConstants.TEXTURE_CUBE_MAP; const maxSize = max(w, h); if (maxSize > capabilities.maxCubeMapTextureSize) { errorID(9100, maxSize, capabilities.maxTextureSize); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); for (let f = 0; f < 6; ++f) { - gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt, w, h, 0, view); } w = max(1, w >> 1); h = max(1, h >> 1); } } else { - gl.texStorage2D(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h); + gl.texStorage2D(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); } } break; } default: { errorID(16317); - gpuTexture.type$ = TextureType.TEX2D; - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.type = TextureType.TEX2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; } } } export function WebGL2CmdFuncDestroyTexture (device: WebGL2Device, gpuTexture: IWebGL2GPUTexture): void { const { gl } = device; - const cache = device.getStateCache$(); - if (gpuTexture.glTexture$) { - const glTexUnits = cache.glTexUnits$; - let texUnit = cache.texUnit$; - gl.deleteTexture(gpuTexture.glTexture$); + const cache = device.getStateCache(); + if (gpuTexture.glTexture) { + const glTexUnits = cache.glTexUnits; + let texUnit = cache.texUnit; + gl.deleteTexture(gpuTexture.glTexture); for (let i = 0; i < glTexUnits.length; ++i) { - if (glTexUnits[i].glTexture$ === gpuTexture.glTexture$) { + if (glTexUnits[i].glTexture === gpuTexture.glTexture) { gl.activeTexture(WebGLConstants.TEXTURE0 + i); texUnit = i; - gl.bindTexture(gpuTexture.glTarget$, null); - glTexUnits[i].glTexture$ = null; + gl.bindTexture(gpuTexture.glTarget, null); + glTexUnits[i].glTexture = null; } } - cache.texUnit$ = texUnit; - gpuTexture.glTexture$ = null; + cache.texUnit = texUnit; + gpuTexture.glTexture = null; } - if (gpuTexture.glRenderbuffer$) { - let glRenderbuffer = cache.glRenderbuffer$; - gl.deleteRenderbuffer(gpuTexture.glRenderbuffer$); - if (glRenderbuffer === gpuTexture.glRenderbuffer$) { + if (gpuTexture.glRenderbuffer) { + let glRenderbuffer = cache.glRenderbuffer; + gl.deleteRenderbuffer(gpuTexture.glRenderbuffer); + if (glRenderbuffer === gpuTexture.glRenderbuffer) { gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, null); - cache.glRenderbuffer$ = null; + cache.glRenderbuffer = null; } - gpuTexture.glRenderbuffer$ = null; + gpuTexture.glRenderbuffer = null; } } export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IWebGL2GPUTexture): void { - if (!gpuTexture.size$) return; + if (!gpuTexture.size) return; const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); const capabilities = device.capabilities; - let w = gpuTexture.width$; - let h = gpuTexture.height$; - const d = gpuTexture.depth$; - const l = gpuTexture.arrayLayer$; + let w = gpuTexture.width; + let h = gpuTexture.height; + const d = gpuTexture.depth; + const l = gpuTexture.arrayLayer; - switch (gpuTexture.type$) { + switch (gpuTexture.type) { case TextureType.TEX2D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; const maxSize = max(w, h); if (maxSize > capabilities.maxTextureSize) { errorID(9100, maxSize, capabilities.maxTextureSize); } - if (gpuTexture.samples$ === SampleCount.X1) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + if (gpuTexture.samples === SampleCount.X1) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } @@ -1153,24 +1153,24 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW WebGL2CmdFuncDestroyTexture(device, gpuTexture); WebGL2CmdFuncCreateTexture(device, gpuTexture); } - } else if (gpuTexture.glRenderbuffer$) { - if (cache.glRenderbuffer$ !== gpuTexture.glRenderbuffer$) { - gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer$); - cache.glRenderbuffer$ = gpuTexture.glRenderbuffer$; + } else if (gpuTexture.glRenderbuffer) { + if (cache.glRenderbuffer !== gpuTexture.glRenderbuffer) { + gl.bindRenderbuffer(WebGLConstants.RENDERBUFFER, gpuTexture.glRenderbuffer); + cache.glRenderbuffer = gpuTexture.glRenderbuffer; } gl.renderbufferStorageMultisample( WebGLConstants.RENDERBUFFER, - gpuTexture.samples$, - gpuTexture.glInternalFmt$, - gpuTexture.width$, - gpuTexture.height$, + gpuTexture.samples, + gpuTexture.glInternalFmt, + gpuTexture.width, + gpuTexture.height, ); } break; } case TextureType.TEX2D_ARRAY: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D_ARRAY; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D_ARRAY; const maxSize = max(w, h); if (maxSize > capabilities.maxTextureSize) { @@ -1180,84 +1180,84 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW errorID(9100, l, capabilities.maxArrayTextureLayers); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, l); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, l); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage3D(WebGLConstants.TEXTURE_2D_ARRAY, i, gpuTexture.glInternalFmt$, w, h, l, 0, view); + gl.compressedTexImage3D(WebGLConstants.TEXTURE_2D_ARRAY, i, gpuTexture.glInternalFmt, w, h, l, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - gl.texStorage3D(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h, l); + gl.texStorage3D(WebGLConstants.TEXTURE_2D_ARRAY, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h, l); } } break; } case TextureType.TEX3D: { - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_3D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_3D; const maxSize = max(max(w, h), d); if (maxSize > capabilities.max3DTextureSize) { errorID(9100, maxSize, capabilities.max3DTextureSize); } - gpuTexture.glTexture$ = gl.createTexture(); - if (gpuTexture.size$ > 0) { - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + gpuTexture.glTexture = gl.createTexture(); + if (gpuTexture.size > 0) { + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_3D, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_3D, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, d); + if (FormatInfos[gpuTexture.format].isCompressed) { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, d); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage3D(WebGLConstants.TEXTURE_3D, i, gpuTexture.glInternalFmt$, w, h, d, 0, view); + gl.compressedTexImage3D(WebGLConstants.TEXTURE_3D, i, gpuTexture.glInternalFmt, w, h, d, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } } else { - gl.texStorage3D(WebGLConstants.TEXTURE_3D, gpuTexture.mipLevel$, gpuTexture.glInternalFmt$, w, h, d); + gl.texStorage3D(WebGLConstants.TEXTURE_3D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h, d); } } break; } case TextureType.CUBE: { - gpuTexture.type$ = TextureType.CUBE; - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_CUBE_MAP; + gpuTexture.type = TextureType.CUBE; + gpuTexture.glTarget = WebGLConstants.TEXTURE_CUBE_MAP; const maxSize = max(w, h); if (maxSize > capabilities.maxCubeMapTextureSize) { errorID(9100, maxSize, capabilities.maxTextureSize); } - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; + const glTexUnit = cache.glTexUnits[cache.texUnit]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(WebGLConstants.TEXTURE_CUBE_MAP, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } - if (FormatInfos[gpuTexture.format$].isCompressed) { + if (FormatInfos[gpuTexture.format].isCompressed) { for (let f = 0; f < 6; ++f) { - w = gpuTexture.width$; - h = gpuTexture.height$; - for (let i = 0; i < gpuTexture.mipLevel$; ++i) { - const imgSize = FormatSize(gpuTexture.format$, w, h, 1); + w = gpuTexture.width; + h = gpuTexture.height; + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); - gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt$, w, h, 0, view); + gl.compressedTexImage2D(WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternalFmt, w, h, 0, view); w = max(1, w >> 1); h = max(1, h >> 1); } @@ -1271,8 +1271,8 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW } default: { errorID(16317); - gpuTexture.type$ = TextureType.TEX2D; - gpuTexture.glTarget$ = WebGLConstants.TEXTURE_2D; + gpuTexture.type = TextureType.TEX2D; + gpuTexture.glTarget = WebGLConstants.TEXTURE_2D; } } } @@ -1280,42 +1280,42 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW export function WebGL2CmdFuncPrepareSamplerInfo (device: WebGL2Device, gpuSampler: IWebGL2GPUSampler): void { const { gl } = device; - if (gpuSampler.minFilter$ === Filter.LINEAR || gpuSampler.minFilter$ === Filter.ANISOTROPIC) { - if (gpuSampler.mipFilter$ === Filter.LINEAR || gpuSampler.mipFilter$ === Filter.ANISOTROPIC) { - gpuSampler.glMinFilter$ = WebGLConstants.LINEAR_MIPMAP_LINEAR; - } else if (gpuSampler.mipFilter$ === Filter.POINT) { - gpuSampler.glMinFilter$ = WebGLConstants.LINEAR_MIPMAP_NEAREST; + if (gpuSampler.minFilter === Filter.LINEAR || gpuSampler.minFilter === Filter.ANISOTROPIC) { + if (gpuSampler.mipFilter === Filter.LINEAR || gpuSampler.mipFilter === Filter.ANISOTROPIC) { + gpuSampler.glMinFilter = WebGLConstants.LINEAR_MIPMAP_LINEAR; + } else if (gpuSampler.mipFilter === Filter.POINT) { + gpuSampler.glMinFilter = WebGLConstants.LINEAR_MIPMAP_NEAREST; } else { - gpuSampler.glMinFilter$ = WebGLConstants.LINEAR; + gpuSampler.glMinFilter = WebGLConstants.LINEAR; } - } else if (gpuSampler.mipFilter$ === Filter.LINEAR || gpuSampler.mipFilter$ === Filter.ANISOTROPIC) { - gpuSampler.glMinFilter$ = WebGLConstants.NEAREST_MIPMAP_LINEAR; - } else if (gpuSampler.mipFilter$ === Filter.POINT) { - gpuSampler.glMinFilter$ = WebGLConstants.NEAREST_MIPMAP_NEAREST; + } else if (gpuSampler.mipFilter === Filter.LINEAR || gpuSampler.mipFilter === Filter.ANISOTROPIC) { + gpuSampler.glMinFilter = WebGLConstants.NEAREST_MIPMAP_LINEAR; + } else if (gpuSampler.mipFilter === Filter.POINT) { + gpuSampler.glMinFilter = WebGLConstants.NEAREST_MIPMAP_NEAREST; } else { - gpuSampler.glMinFilter$ = WebGLConstants.NEAREST; + gpuSampler.glMinFilter = WebGLConstants.NEAREST; } - if (gpuSampler.magFilter$ === Filter.LINEAR || gpuSampler.magFilter$ === Filter.ANISOTROPIC) { - gpuSampler.glMagFilter$ = WebGLConstants.LINEAR; + if (gpuSampler.magFilter === Filter.LINEAR || gpuSampler.magFilter === Filter.ANISOTROPIC) { + gpuSampler.glMagFilter = WebGLConstants.LINEAR; } else { - gpuSampler.glMagFilter$ = WebGLConstants.NEAREST; + gpuSampler.glMagFilter = WebGLConstants.NEAREST; } - gpuSampler.glWrapS$ = WebGLWraps[gpuSampler.addressU$]; - gpuSampler.glWrapT$ = WebGLWraps[gpuSampler.addressV$]; - gpuSampler.glWrapR$ = WebGLWraps[gpuSampler.addressW$]; + gpuSampler.glWrapS = WebGLWraps[gpuSampler.addressU]; + gpuSampler.glWrapT = WebGLWraps[gpuSampler.addressV]; + gpuSampler.glWrapR = WebGLWraps[gpuSampler.addressW]; } export function WebGL2CmdFuncDestroySampler (device: WebGL2Device, gpuSampler: IWebGL2GPUSampler): void { const { gl } = device; - const it = gpuSampler.glSamplers$.values(); + const it = gpuSampler.glSamplers.values(); const res = it.next(); while (!res.done) { gl.deleteSampler(res.value); - const glSamplerUnits = device.getStateCache$().glSamplerUnits$; + const glSamplerUnits = device.getStateCache().glSamplerUnits; for (let i = 0; i < glSamplerUnits.length; ++i) { if (glSamplerUnits[i] === res.value) { gl.bindSampler(i, null); @@ -1324,15 +1324,15 @@ export function WebGL2CmdFuncDestroySampler (device: WebGL2Device, gpuSampler: I } } - gpuSampler.glSamplers$.clear(); + gpuSampler.glSamplers.clear(); } export function WebGL2CmdFuncCreateFramebuffer (device: WebGL2Device, gpuFramebuffer: IWebGL2GPUFramebuffer): void { - const cache = device.getStateCache$(); - for (let i = 0; i < gpuFramebuffer.gpuColorViews$.length; ++i) { - const tex = gpuFramebuffer.gpuColorViews$[i].gpuTexture$; - if (tex.isSwapchainTexture$) { - gpuFramebuffer.isOffscreen$ = false; + const cache = device.getStateCache(); + for (let i = 0; i < gpuFramebuffer.gpuColorViews.length; ++i) { + const tex = gpuFramebuffer.gpuColorViews[i].gpuTexture; + if (tex.isSwapchainTexture) { + gpuFramebuffer.isOffscreen = false; return; } } @@ -1342,61 +1342,61 @@ export function WebGL2CmdFuncCreateFramebuffer (device: WebGL2Device, gpuFramebu const glFramebuffer = gl.createFramebuffer(); if (glFramebuffer) { - gpuFramebuffer.glFramebuffer$ = glFramebuffer; + gpuFramebuffer.glFramebuffer = glFramebuffer; - if (cache.glFramebuffer$ !== gpuFramebuffer.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer$); + if (cache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer); } - for (let i = 0; i < gpuFramebuffer.gpuColorViews$.length; ++i) { - const colorTextureView = gpuFramebuffer.gpuColorViews$[i]; - const colorTexture = colorTextureView.gpuTexture$; + for (let i = 0; i < gpuFramebuffer.gpuColorViews.length; ++i) { + const colorTextureView = gpuFramebuffer.gpuColorViews[i]; + const colorTexture = colorTextureView.gpuTexture; if (colorTexture) { - if (colorTexture.glTexture$) { + if (colorTexture.glTexture) { gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0 + i, - colorTexture.glTarget$, - colorTexture.glTexture$, - colorTextureView.baseLevel$, + colorTexture.glTarget, + colorTexture.glTexture, + colorTextureView.baseLevel, ); } else { gl.framebufferRenderbuffer( WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0 + i, WebGLConstants.RENDERBUFFER, - colorTexture.glRenderbuffer$, + colorTexture.glRenderbuffer, ); } attachments.push(WebGLConstants.COLOR_ATTACHMENT0 + i); - gpuFramebuffer.width = min(gpuFramebuffer.width, colorTexture.width$ >> colorTextureView.baseLevel$); - gpuFramebuffer.height = min(gpuFramebuffer.height, colorTexture.height$ >> colorTextureView.baseLevel$); + gpuFramebuffer.width = min(gpuFramebuffer.width, colorTexture.width >> colorTextureView.baseLevel); + gpuFramebuffer.height = min(gpuFramebuffer.height, colorTexture.height >> colorTextureView.baseLevel); } } - const dstView = gpuFramebuffer.gpuDepthStencilView$; + const dstView = gpuFramebuffer.gpuDepthStencilView; if (dstView) { - const dst = dstView.gpuTexture$; - const glAttachment = FormatInfos[dst.format$].hasStencil ? WebGLConstants.DEPTH_STENCIL_ATTACHMENT : WebGLConstants.DEPTH_ATTACHMENT; - if (dst.glTexture$) { + const dst = dstView.gpuTexture; + const glAttachment = FormatInfos[dst.format].hasStencil ? WebGLConstants.DEPTH_STENCIL_ATTACHMENT : WebGLConstants.DEPTH_ATTACHMENT; + if (dst.glTexture) { gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, glAttachment, - dst.glTarget$, - dst.glTexture$, - gpuFramebuffer.gpuDepthStencilView$!.baseLevel$, + dst.glTarget, + dst.glTexture, + gpuFramebuffer.gpuDepthStencilView!.baseLevel, ); } else { gl.framebufferRenderbuffer( WebGLConstants.FRAMEBUFFER, glAttachment, WebGLConstants.RENDERBUFFER, - dst.glRenderbuffer$, + dst.glRenderbuffer, ); } - gpuFramebuffer.width = min(gpuFramebuffer.width, dst.width$ >> dstView.baseLevel$); - gpuFramebuffer.height = min(gpuFramebuffer.height, dst.height$ >> dstView.baseLevel$); + gpuFramebuffer.width = min(gpuFramebuffer.width, dst.width >> dstView.baseLevel); + gpuFramebuffer.height = min(gpuFramebuffer.height, dst.height >> dstView.baseLevel); } gl.drawBuffers(attachments); @@ -1424,38 +1424,38 @@ export function WebGL2CmdFuncCreateFramebuffer (device: WebGL2Device, gpuFramebu } } - if (cache.glFramebuffer$ !== gpuFramebuffer.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, cache.glFramebuffer$); + if (cache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, cache.glFramebuffer); } } } export function WebGL2CmdFuncDestroyFramebuffer (device: WebGL2Device, gpuFramebuffer: IWebGL2GPUFramebuffer): void { const { gl } = device; - const cache = device.getStateCache$(); - if (gpuFramebuffer.glFramebuffer$) { - gl.deleteFramebuffer(gpuFramebuffer.glFramebuffer$); - if (cache.glFramebuffer$ === gpuFramebuffer.glFramebuffer$) { + const cache = device.getStateCache(); + if (gpuFramebuffer.glFramebuffer) { + gl.deleteFramebuffer(gpuFramebuffer.glFramebuffer); + if (cache.glFramebuffer === gpuFramebuffer.glFramebuffer) { gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, null); - cache.glFramebuffer$ = null; + cache.glFramebuffer = null; } - gpuFramebuffer.glFramebuffer$ = null; + gpuFramebuffer.glFramebuffer = null; } } export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWebGL2GPUShader): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); const capabilities = device.capabilities; - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; let glShaderType: GLenum = 0; let shaderTypeStr = ''; let lineNumber = 1; - switch (gpuStage.type$) { + switch (gpuStage.type) { case ShaderStageFlagBit.VERTEX: { shaderTypeStr = 'VertexShader'; glShaderType = WebGLConstants.VERTEX_SHADER; @@ -1474,20 +1474,20 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb const glShader = gl.createShader(glShaderType); if (glShader) { - gpuStage.glShader$ = glShader; - gl.shaderSource(gpuStage.glShader$, `#version 300 es\n${gpuStage.source$}`); - gl.compileShader(gpuStage.glShader$); - - if (!gl.getShaderParameter(gpuStage.glShader$, WebGLConstants.COMPILE_STATUS)) { - errorID(16323, shaderTypeStr, gpuShader.name$); - errorID(16324, gpuStage.source$.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); - error(gl.getShaderInfoLog(gpuStage.glShader$)); - - for (let l = 0; l < gpuShader.gpuStages$.length; l++) { - const stage = gpuShader.gpuStages$[k]; - if (stage.glShader$) { - gl.deleteShader(stage.glShader$); - stage.glShader$ = null; + gpuStage.glShader = glShader; + gl.shaderSource(gpuStage.glShader, `#version 300 es\n${gpuStage.source}`); + gl.compileShader(gpuStage.glShader); + + if (!gl.getShaderParameter(gpuStage.glShader, WebGLConstants.COMPILE_STATUS)) { + errorID(16323, shaderTypeStr, gpuShader.name); + errorID(16324, gpuStage.source.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); + error(gl.getShaderInfoLog(gpuStage.glShader)); + + for (let l = 0; l < gpuShader.gpuStages.length; l++) { + const stage = gpuShader.gpuStages[k]; + if (stage.glShader) { + gl.deleteShader(stage.glShader); + stage.glShader = null; } } return; @@ -1500,42 +1500,42 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb return; } - gpuShader.glProgram$ = glProgram; + gpuShader.glProgram = glProgram; const enableEffectImport = !!(cclegacy.rendering && cclegacy.rendering.enableEffectImport); // link program - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; - gl.attachShader(gpuShader.glProgram$, gpuStage.glShader$!); + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; + gl.attachShader(gpuShader.glProgram, gpuStage.glShader!); } - gl.linkProgram(gpuShader.glProgram$); + gl.linkProgram(gpuShader.glProgram); // detach & delete immediately - for (let k = 0; k < gpuShader.gpuStages$.length; k++) { - const gpuStage = gpuShader.gpuStages$[k]; - if (gpuStage.glShader$) { - gl.detachShader(gpuShader.glProgram$, gpuStage.glShader$); - gl.deleteShader(gpuStage.glShader$); - gpuStage.glShader$ = null; + for (let k = 0; k < gpuShader.gpuStages.length; k++) { + const gpuStage = gpuShader.gpuStages[k]; + if (gpuStage.glShader) { + gl.detachShader(gpuShader.glProgram, gpuStage.glShader); + gl.deleteShader(gpuStage.glShader); + gpuStage.glShader = null; } } - if (gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.LINK_STATUS)) { - debugID(16325, gpuShader.name$); + if (gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.LINK_STATUS)) { + debugID(16325, gpuShader.name); } else { - errorID(16326, gpuShader.name$); - error(gl.getProgramInfoLog(gpuShader.glProgram$)); + errorID(16326, gpuShader.name); + error(gl.getProgramInfoLog(gpuShader.glProgram)); return; } // parse inputs - const activeAttribCount: number = gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.ACTIVE_ATTRIBUTES); - gpuShader.glInputs$ = new Array(activeAttribCount); + const activeAttribCount: number = gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.ACTIVE_ATTRIBUTES); + gpuShader.glInputs = new Array(activeAttribCount); for (let i = 0; i < activeAttribCount; ++i) { - const attribInfo = gl.getActiveAttrib(gpuShader.glProgram$, i); + const attribInfo = gl.getActiveAttrib(gpuShader.glProgram, i); if (attribInfo) { let varName: string; const nameOffset = attribInfo.name.indexOf('['); @@ -1545,35 +1545,35 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb varName = attribInfo.name; } - const glLoc = gl.getAttribLocation(gpuShader.glProgram$, varName); + const glLoc = gl.getAttribLocation(gpuShader.glProgram, varName); const type = WebGLTypeToGFXType(attribInfo.type, gl); const stride = WebGLGetTypeSize(attribInfo.type, gl); - gpuShader.glInputs$[i] = { - name$: varName, - type$: type, - stride$: stride, - count$: attribInfo.size, - size$: stride * attribInfo.size, + gpuShader.glInputs[i] = { + name: varName, + type: type, + stride: stride, + count: attribInfo.size, + size: stride * attribInfo.size, - glType$: attribInfo.type, - glLoc$: glLoc, + glType: attribInfo.type, + glLoc: glLoc, }; } } // create uniform blocks - const activeBlockCount: number = gl.getProgramParameter(gpuShader.glProgram$, WebGLConstants.ACTIVE_UNIFORM_BLOCKS); + const activeBlockCount: number = gl.getProgramParameter(gpuShader.glProgram, WebGLConstants.ACTIVE_UNIFORM_BLOCKS); let blockName: string; let blockIdx: number; let blockSize: number; let block: UniformBlock | null; if (activeBlockCount) { - gpuShader.glBlocks$ = new Array(activeBlockCount); + gpuShader.glBlocks = new Array(activeBlockCount); for (let b = 0; b < activeBlockCount; ++b) { - blockName = gl.getActiveUniformBlockName(gpuShader.glProgram$, b)!; + blockName = gl.getActiveUniformBlockName(gpuShader.glProgram, b)!; const nameOffset = blockName.indexOf('['); if (nameOffset !== -1) { blockName = blockName.substr(0, nameOffset); @@ -1581,9 +1581,9 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb // blockIdx = gl.getUniformBlockIndex(gpuShader.glProgram, blockName); block = null; - for (let k = 0; k < gpuShader.blocks$.length; k++) { - if (gpuShader.blocks$[k].name === blockName) { - block = gpuShader.blocks$[k]; + for (let k = 0; k < gpuShader.blocks.length; k++) { + if (gpuShader.blocks[k].name === blockName) { + block = gpuShader.blocks[k]; break; } } @@ -1593,50 +1593,50 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb } else { // blockIdx = gl.getUniformBlockIndex(gpuShader.glProgram, blockName); blockIdx = b; - blockSize = gl.getActiveUniformBlockParameter(gpuShader.glProgram$, blockIdx, WebGLConstants.UNIFORM_BLOCK_DATA_SIZE); + blockSize = gl.getActiveUniformBlockParameter(gpuShader.glProgram, blockIdx, WebGLConstants.UNIFORM_BLOCK_DATA_SIZE); const glBinding = enableEffectImport ? block.flattened - : block.binding + (device.bindingMappings.blockOffsets$[block.set] || 0); + : block.binding + (device.bindingMappings.blockOffsets[block.set] || 0); - gl.uniformBlockBinding(gpuShader.glProgram$, blockIdx, glBinding); + gl.uniformBlockBinding(gpuShader.glProgram, blockIdx, glBinding); - gpuShader.glBlocks$[b] = { - set$: block.set, - binding$: block.binding, - idx$: blockIdx, - name$: blockName, - size$: blockSize, - glBinding$: glBinding, + gpuShader.glBlocks[b] = { + set: block.set, + binding: block.binding, + idx: blockIdx, + name: blockName, + size: blockSize, + glBinding: glBinding, }; } } } // WebGL doesn't support Framebuffer Fetch - for (let i = 0; i < gpuShader.subpassInputs$.length; ++i) { - const subpassInput = gpuShader.subpassInputs$[i]; - gpuShader.samplerTextures$.push( + for (let i = 0; i < gpuShader.subpassInputs.length; ++i) { + const subpassInput = gpuShader.subpassInputs[i]; + gpuShader.samplerTextures.push( new UniformSamplerTexture(subpassInput.set, subpassInput.binding, subpassInput.name, Type.SAMPLER2D, subpassInput.count), ); } // create uniform sampler textures - if (gpuShader.samplerTextures$.length > 0) { - gpuShader.glSamplerTextures$ = new Array(gpuShader.samplerTextures$.length); - - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - gpuShader.glSamplerTextures$[i] = { - set$: sampler.set, - binding$: sampler.binding, - name$: sampler.name, - type$: sampler.type, - count$: sampler.count, - units$: [], - glUnits$: null!, - glType$: GFXTypeToWebGLType(sampler.type, gl), - glLoc$: null!, + if (gpuShader.samplerTextures.length > 0) { + gpuShader.glSamplerTextures = new Array(gpuShader.samplerTextures.length); + + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + gpuShader.glSamplerTextures[i] = { + set: sampler.set, + binding: sampler.binding, + name: sampler.name, + type: sampler.type, + count: sampler.count, + units: [], + glUnits: null!, + glType: GFXTypeToWebGLType(sampler.type, gl), + glLoc: null!, }; } } @@ -1644,39 +1644,39 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb // texture unit index mapping optimization const glActiveSamplers: IWebGL2GPUUniformSamplerTexture[] = []; const glActiveSamplerLocations: WebGLUniformLocation[] = []; - const texUnitCacheMap = cache.texUnitCacheMap$; + const texUnitCacheMap = cache.texUnitCacheMap; if (!enableEffectImport) { let flexibleSetBaseOffset = 0; - for (let i = 0; i < gpuShader.blocks$.length; ++i) { - if (gpuShader.blocks$[i].set === device.bindingMappings.flexibleSet$) { + for (let i = 0; i < gpuShader.blocks.length; ++i) { + if (gpuShader.blocks[i].set === device.bindingMappings.flexibleSet) { flexibleSetBaseOffset++; } } let arrayOffset = 0; - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - const glLoc = gl.getUniformLocation(gpuShader.glProgram$, sampler.name); + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); // wEcHAT just returns { id: -1 } for non-existing names /eyerolling if (glLoc && (glLoc as any).id !== -1) { - glActiveSamplers.push(gpuShader.glSamplerTextures$[i]); + glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } if (texUnitCacheMap[sampler.name] === undefined) { - let binding = sampler.binding + device.bindingMappings.samplerTextureOffsets$[sampler.set] + arrayOffset; - if (sampler.set === device.bindingMappings.flexibleSet$) { binding -= flexibleSetBaseOffset; } + let binding = sampler.binding + device.bindingMappings.samplerTextureOffsets[sampler.set] + arrayOffset; + if (sampler.set === device.bindingMappings.flexibleSet) { binding -= flexibleSetBaseOffset; } texUnitCacheMap[sampler.name] = binding % capabilities.maxTextureUnits; arrayOffset += sampler.count - 1; } } } else { - for (let i = 0; i < gpuShader.samplerTextures$.length; ++i) { - const sampler = gpuShader.samplerTextures$[i]; - const glLoc = gl.getUniformLocation(gpuShader.glProgram$, sampler.name); + for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { + const sampler = gpuShader.samplerTextures[i]; + const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); // wEcHAT just returns { id: -1 } for non-existing names /eyerolling if (glLoc && (glLoc as any).id !== -1) { - glActiveSamplers.push(gpuShader.glSamplerTextures$[i]); + glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } if (texUnitCacheMap[sampler.name] === undefined) { @@ -1691,14 +1691,14 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb for (let i = 0; i < glActiveSamplers.length; ++i) { const glSampler = glActiveSamplers[i]; - let cachedUnit = texUnitCacheMap[glSampler.name$]; + let cachedUnit = texUnitCacheMap[glSampler.name]; if (cachedUnit !== undefined) { - glSampler.glLoc$ = glActiveSamplerLocations[i]; - for (let t = 0; t < glSampler.count$; ++t) { + glSampler.glLoc = glActiveSamplerLocations[i]; + for (let t = 0; t < glSampler.count; ++t) { while (usedTexUnits[cachedUnit]) { cachedUnit = (cachedUnit + 1) % capabilities.maxTextureUnits; } - glSampler.units$.push(cachedUnit); + glSampler.units.push(cachedUnit); usedTexUnits[cachedUnit] = true; } } @@ -1708,82 +1708,82 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb for (let i = 0; i < glActiveSamplers.length; ++i) { const glSampler = glActiveSamplers[i]; - if (!glSampler.glLoc$) { - glSampler.glLoc$ = glActiveSamplerLocations[i]; + if (!glSampler.glLoc) { + glSampler.glLoc = glActiveSamplerLocations[i]; while (usedTexUnits[unitIdx]) { unitIdx++; } - for (let t = 0; t < glSampler.count$; ++t) { + for (let t = 0; t < glSampler.count; ++t) { while (usedTexUnits[unitIdx]) { unitIdx = (unitIdx + 1) % capabilities.maxTextureUnits; } - if (texUnitCacheMap[glSampler.name$] === undefined) { - texUnitCacheMap[glSampler.name$] = unitIdx; + if (texUnitCacheMap[glSampler.name] === undefined) { + texUnitCacheMap[glSampler.name] = unitIdx; } - glSampler.units$.push(unitIdx); + glSampler.units.push(unitIdx); usedTexUnits[unitIdx] = true; } } } - if (cache.glProgram$ !== gpuShader.glProgram$) { - gl.useProgram(gpuShader.glProgram$); + if (cache.glProgram !== gpuShader.glProgram) { + gl.useProgram(gpuShader.glProgram); } for (let k = 0; k < glActiveSamplers.length; k++) { const glSampler = glActiveSamplers[k]; - glSampler.glUnits$ = new Int32Array(glSampler.units$); - gl.uniform1iv(glSampler.glLoc$, glSampler.glUnits$); + glSampler.glUnits = new Int32Array(glSampler.units); + gl.uniform1iv(glSampler.glLoc, glSampler.glUnits); } - if (cache.glProgram$ !== gpuShader.glProgram$) { - gl.useProgram(cache.glProgram$); + if (cache.glProgram !== gpuShader.glProgram) { + gl.useProgram(cache.glProgram); } } - gpuShader.glSamplerTextures$ = glActiveSamplers; + gpuShader.glSamplerTextures = glActiveSamplers; } export function WebGL2CmdFuncDestroyShader (device: WebGL2Device, gpuShader: IWebGL2GPUShader): void { const { gl } = device; - const cache = device.getStateCache$(); - if (gpuShader.glProgram$) { - gl.deleteProgram(gpuShader.glProgram$); - if (cache.glProgram$ === gpuShader.glProgram$) { + const cache = device.getStateCache(); + if (gpuShader.glProgram) { + gl.deleteProgram(gpuShader.glProgram); + if (cache.glProgram === gpuShader.glProgram) { gl.useProgram(null); - cache.glProgram$ = null; + cache.glProgram = null; } - gpuShader.glProgram$ = null; + gpuShader.glProgram = null; } } export function WebGL2CmdFuncCreateInputAssember (device: WebGL2Device, gpuInputAssembler: IWebGL2GPUInputAssembler): void { const { gl } = device; - gpuInputAssembler.glAttribs$ = new Array(gpuInputAssembler.attributes$.length); + gpuInputAssembler.glAttribs = new Array(gpuInputAssembler.attributes.length); const offsets = [0, 0, 0, 0, 0, 0, 0, 0]; - for (let i = 0; i < gpuInputAssembler.attributes$.length; ++i) { - const attrib = gpuInputAssembler.attributes$[i]; + for (let i = 0; i < gpuInputAssembler.attributes.length; ++i) { + const attrib = gpuInputAssembler.attributes[i]; const stream = attrib.stream !== undefined ? attrib.stream : 0; // if (stream < gpuInputAssembler.gpuVertexBuffers.length) { - const gpuBuffer = gpuInputAssembler.gpuVertexBuffers$[stream]; + const gpuBuffer = gpuInputAssembler.gpuVertexBuffers[stream]; const glType = GFXFormatToWebGLType(attrib.format, gl); const { size } = FormatInfos[attrib.format]; - gpuInputAssembler.glAttribs$[i] = { - name$: attrib.name, - glBuffer$: gpuBuffer.glBuffer$, - glType$: glType, - size$: size, - count$: FormatInfos[attrib.format].count, - stride$: gpuBuffer.stride$, - componentCount$: WebGLGetComponentCount(glType, gl), - isNormalized$: (attrib.isNormalized !== undefined ? attrib.isNormalized : false), - isInstanced$: (attrib.isInstanced !== undefined ? attrib.isInstanced : false), - offset$: offsets[stream], + gpuInputAssembler.glAttribs[i] = { + name: attrib.name, + glBuffer: gpuBuffer.glBuffer, + glType: glType, + size: size, + count: FormatInfos[attrib.format].count, + stride: gpuBuffer.stride, + componentCount: WebGLGetComponentCount(glType, gl), + isNormalized: (attrib.isNormalized !== undefined ? attrib.isNormalized : false), + isInstanced: (attrib.isInstanced !== undefined ? attrib.isInstanced : false), + offset: offsets[stream], }; offsets[stream] += size; @@ -1792,12 +1792,12 @@ export function WebGL2CmdFuncCreateInputAssember (device: WebGL2Device, gpuInput export function WebGL2CmdFuncDestroyInputAssembler (device: WebGL2Device, gpuInputAssembler: IWebGL2GPUInputAssembler): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); - const it = gpuInputAssembler.glVAOs$.values(); + const it = gpuInputAssembler.glVAOs.values(); let res = it.next(); - let glVAO = cache.glVAO$; + let glVAO = cache.glVAO; while (!res.done) { gl.deleteVertexArray(res.value); if (glVAO === res.value) { @@ -1806,8 +1806,8 @@ export function WebGL2CmdFuncDestroyInputAssembler (device: WebGL2Device, gpuInp } res = it.next(); } - cache.glVAO$ = glVAO; - gpuInputAssembler.glVAOs$.clear(); + cache.glVAO = glVAO; + gpuInputAssembler.glVAOs.clear(); } interface IWebGL2StateCache { @@ -1833,55 +1833,55 @@ export function WebGL2CmdFuncBeginRenderPass ( clearStencil: number, ): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); let clears: GLbitfield = 0; if (gpuFramebuffer && gpuRenderPass) { - if (cache.glFramebuffer$ !== gpuFramebuffer.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer$); - cache.glFramebuffer$ = gpuFramebuffer.glFramebuffer$; + if (cache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, gpuFramebuffer.glFramebuffer); + cache.glFramebuffer = gpuFramebuffer.glFramebuffer; } - if (cache.viewport$.left !== renderArea.x - || cache.viewport$.top !== renderArea.y - || cache.viewport$.width !== renderArea.width - || cache.viewport$.height !== renderArea.height) { + if (cache.viewport.left !== renderArea.x + || cache.viewport.top !== renderArea.y + || cache.viewport.width !== renderArea.width + || cache.viewport.height !== renderArea.height) { gl.viewport(renderArea.x, renderArea.y, renderArea.width, renderArea.height); - cache.viewport$.left = renderArea.x; - cache.viewport$.top = renderArea.y; - cache.viewport$.width = renderArea.width; - cache.viewport$.height = renderArea.height; + cache.viewport.left = renderArea.x; + cache.viewport.top = renderArea.y; + cache.viewport.width = renderArea.width; + cache.viewport.height = renderArea.height; } - if (cache.scissorRect$.x !== renderArea.x - || cache.scissorRect$.y !== renderArea.y - || cache.scissorRect$.width !== renderArea.width - || cache.scissorRect$.height !== renderArea.height) { + if (cache.scissorRect.x !== renderArea.x + || cache.scissorRect.y !== renderArea.y + || cache.scissorRect.width !== renderArea.width + || cache.scissorRect.height !== renderArea.height) { gl.scissor(renderArea.x, renderArea.y, renderArea.width, renderArea.height); - cache.scissorRect$.x = renderArea.x; - cache.scissorRect$.y = renderArea.y; - cache.scissorRect$.width = renderArea.width; - cache.scissorRect$.height = renderArea.height; + cache.scissorRect.x = renderArea.x; + cache.scissorRect.y = renderArea.y; + cache.scissorRect.width = renderArea.width; + cache.scissorRect.height = renderArea.height; } gfxStateCache.invalidateAttachments.length = 0; for (let j = 0; j < clearColors.length; ++j) { - const colorAttachment = gpuRenderPass.colorAttachments$[j]; + const colorAttachment = gpuRenderPass.colorAttachments[j]; if (colorAttachment.format !== Format.UNKNOWN) { switch (colorAttachment.loadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { - if (cache.bs$.targets[0].blendColorMask !== ColorMask.ALL) { + if (cache.bs.targets[0].blendColorMask !== ColorMask.ALL) { gl.colorMask(true, true, true, true); } // We-chat mini-game, glClearBufferfv get INVALID_ENUM. MRT may not be supported. use clearColor instead. - if (gpuRenderPass.colorAttachments$.length === 1) { + if (gpuRenderPass.colorAttachments.length === 1) { const clearColor = clearColors[0]; gl.clearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w); clears |= WebGLConstants.COLOR_BUFFER_BIT; @@ -1904,12 +1904,12 @@ export function WebGL2CmdFuncBeginRenderPass ( } } // if (curGPURenderPass) - if (gpuRenderPass.depthStencilAttachment$) { - if (gpuRenderPass.depthStencilAttachment$.format !== Format.UNKNOWN) { - switch (gpuRenderPass.depthStencilAttachment$.depthLoadOp) { + if (gpuRenderPass.depthStencilAttachment) { + if (gpuRenderPass.depthStencilAttachment.format !== Format.UNKNOWN) { + switch (gpuRenderPass.depthStencilAttachment.depthLoadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { - if (!cache.dss$.depthWrite) { + if (!cache.dss.depthWrite) { gl.depthMask(true); } @@ -1926,15 +1926,15 @@ export function WebGL2CmdFuncBeginRenderPass ( default: } - if (FormatInfos[gpuRenderPass.depthStencilAttachment$.format].hasStencil) { - switch (gpuRenderPass.depthStencilAttachment$.stencilLoadOp) { + if (FormatInfos[gpuRenderPass.depthStencilAttachment.format].hasStencil) { + switch (gpuRenderPass.depthStencilAttachment.stencilLoadOp) { case LoadOp.LOAD: break; // GL default behavior case LoadOp.CLEAR: { - if (!cache.dss$.stencilWriteMaskFront) { + if (!cache.dss.stencilWriteMaskFront) { gl.stencilMaskSeparate(WebGLConstants.FRONT, 0xffff); } - if (!cache.dss$.stencilWriteMaskBack) { + if (!cache.dss.stencilWriteMaskBack) { gl.stencilMaskSeparate(WebGLConstants.BACK, 0xffff); } @@ -1953,7 +1953,7 @@ export function WebGL2CmdFuncBeginRenderPass ( } } // if (curGPURenderPass.depthStencilAttachment) - if (gpuFramebuffer.glFramebuffer$ && gfxStateCache.invalidateAttachments.length) { + if (gpuFramebuffer.glFramebuffer && gfxStateCache.invalidateAttachments.length) { gl.invalidateFramebuffer(WebGLConstants.FRAMEBUFFER, gfxStateCache.invalidateAttachments); } @@ -1963,7 +1963,7 @@ export function WebGL2CmdFuncBeginRenderPass ( // restore states if (clears & WebGLConstants.COLOR_BUFFER_BIT) { - const colorMask = cache.bs$.targets[0].blendColorMask; + const colorMask = cache.bs.targets[0].blendColorMask; if (colorMask !== ColorMask.ALL) { const r = (colorMask & ColorMask.R) !== ColorMask.NONE; const g = (colorMask & ColorMask.G) !== ColorMask.NONE; @@ -1974,16 +1974,16 @@ export function WebGL2CmdFuncBeginRenderPass ( } if ((clears & WebGLConstants.DEPTH_BUFFER_BIT) - && !cache.dss$.depthWrite) { + && !cache.dss.depthWrite) { gl.depthMask(false); } if (clears & WebGLConstants.STENCIL_BUFFER_BIT) { - if (!cache.dss$.stencilWriteMaskFront) { + if (!cache.dss.stencilWriteMaskFront) { gl.stencilMaskSeparate(WebGLConstants.FRONT, 0); } - if (!cache.dss$.stencilWriteMaskBack) { + if (!cache.dss.stencilWriteMaskBack) { gl.stencilMaskSeparate(WebGLConstants.BACK, 0); } } @@ -2000,31 +2000,31 @@ export function WebGL2CmdFuncBindStates ( ): void { const { gl } = device; const capabilities = device.capabilities; - const cache = device.getStateCache$(); - const cacheRs = cache.rs$; - const cacheDss = cache.dss$; - const cacheBs = cache.bs$; + const cache = device.getStateCache(); + const cacheRs = cache.rs; + const cacheDss = cache.dss; + const cacheBs = cache.bs; const cacheBlendColor = cacheBs.blendColor; - const gpuShader = gpuPipelineState && gpuPipelineState.gpuShader$; + const gpuShader = gpuPipelineState && gpuPipelineState.gpuShader; let isShaderChanged = false; // bind pipeline if (gpuPipelineState && gfxStateCache.gpuPipelineState !== gpuPipelineState) { gfxStateCache.gpuPipelineState = gpuPipelineState; - gfxStateCache.glPrimitive = gpuPipelineState.glPrimitive$; + gfxStateCache.glPrimitive = gpuPipelineState.glPrimitive; if (gpuShader) { - const { glProgram$: glProgram } = gpuShader; - if (cache.glProgram$ !== glProgram) { + const { glProgram } = gpuShader; + if (cache.glProgram !== glProgram) { gl.useProgram(glProgram); - cache.glProgram$ = glProgram; + cache.glProgram = glProgram; isShaderChanged = true; } } // rasterizer state - const { rs$: rs } = gpuPipelineState; + const { rs } = gpuPipelineState; if (rs) { if (cacheRs.cullMode !== rs.cullMode) { switch (rs.cullMode) { @@ -2068,7 +2068,7 @@ export function WebGL2CmdFuncBindStates ( } // rasterizater state // depth-stencil state - const { dss$: dss } = gpuPipelineState; + const { dss } = gpuPipelineState; if (dss) { if (cacheDss.depthTest !== dss.depthTest) { if (dss.depthTest) { @@ -2174,7 +2174,7 @@ export function WebGL2CmdFuncBindStates ( } // depth-stencil state // blend state - const { bs$: bs } = gpuPipelineState; + const { bs } = gpuPipelineState; if (bs) { if (cacheBs.isA2C !== bs.isA2C) { if (bs.isA2C) { @@ -2200,7 +2200,7 @@ export function WebGL2CmdFuncBindStates ( } const target0 = bs.targets[0]; - const target0Cache = cache.bs$.targets[0]; + const target0Cache = cache.bs.targets[0]; if (target0Cache.blend !== target0.blend) { if (target0.blend) { @@ -2249,89 +2249,89 @@ export function WebGL2CmdFuncBindStates ( } // bind pipeline // bind descriptor sets - if (gpuPipelineState && gpuPipelineState.gpuPipelineLayout$ && gpuShader) { - const blockLen = gpuShader.glBlocks$.length; - const { dynamicOffsetIndices$: dynamicOffsetIndices } = gpuPipelineState.gpuPipelineLayout$; + if (gpuPipelineState && gpuPipelineState.gpuPipelineLayout && gpuShader) { + const blockLen = gpuShader.glBlocks.length; + const { dynamicOffsetIndices } = gpuPipelineState.gpuPipelineLayout; for (let j = 0; j < blockLen; j++) { - const glBlock = gpuShader.glBlocks$[j]; - const gpuDescriptorSet = gpuDescriptorSets[glBlock.set$]; - const descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices$[glBlock.binding$]; - const gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors$[descriptorIndex]; + const glBlock = gpuShader.glBlocks[j]; + const gpuDescriptorSet = gpuDescriptorSets[glBlock.set]; + const descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices[glBlock.binding]; + const gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors[descriptorIndex]; - if (!gpuDescriptor || !gpuDescriptor.gpuBuffer$) { + if (!gpuDescriptor || !gpuDescriptor.gpuBuffer) { // error(`Buffer binding '${glBlock.name}' at set ${glBlock.set} binding ${glBlock.binding} is not bounded`); continue; } - const dynamicOffsetIndexSet = dynamicOffsetIndices[glBlock.set$]; - const dynamicOffsetIndex = dynamicOffsetIndexSet && dynamicOffsetIndexSet[glBlock.binding$]; - let offset = gpuDescriptor.gpuBuffer$.glOffset$; + const dynamicOffsetIndexSet = dynamicOffsetIndices[glBlock.set]; + const dynamicOffsetIndex = dynamicOffsetIndexSet && dynamicOffsetIndexSet[glBlock.binding]; + let offset = gpuDescriptor.gpuBuffer.glOffset; if (dynamicOffsetIndex >= 0) { offset += dynamicOffsets[dynamicOffsetIndex]; } - if (cache.glBindUBOs$[glBlock.glBinding$] !== gpuDescriptor.gpuBuffer$.glBuffer$ - || cache.glBindUBOOffsets$[glBlock.glBinding$] !== offset) { + if (cache.glBindUBOs[glBlock.glBinding] !== gpuDescriptor.gpuBuffer.glBuffer + || cache.glBindUBOOffsets[glBlock.glBinding] !== offset) { if (offset) { gl.bindBufferRange( WebGLConstants.UNIFORM_BUFFER, - glBlock.glBinding$, - gpuDescriptor.gpuBuffer$.glBuffer$, + glBlock.glBinding, + gpuDescriptor.gpuBuffer.glBuffer, offset, - gpuDescriptor.gpuBuffer$.size$, + gpuDescriptor.gpuBuffer.size, ); } else { - gl.bindBufferBase(WebGLConstants.UNIFORM_BUFFER, glBlock.glBinding$, gpuDescriptor.gpuBuffer$.glBuffer$); + gl.bindBufferBase(WebGLConstants.UNIFORM_BUFFER, glBlock.glBinding, gpuDescriptor.gpuBuffer.glBuffer); } - cache.glUniformBuffer$ = cache.glBindUBOs$[glBlock.glBinding$] = gpuDescriptor.gpuBuffer$.glBuffer$; - cache.glBindUBOOffsets$[glBlock.glBinding$] = offset; + cache.glUniformBuffer = cache.glBindUBOs[glBlock.glBinding] = gpuDescriptor.gpuBuffer.glBuffer; + cache.glBindUBOOffsets[glBlock.glBinding] = offset; } } - const samplerLen = gpuShader.glSamplerTextures$.length; + const samplerLen = gpuShader.glSamplerTextures.length; for (let i = 0; i < samplerLen; i++) { - const glSampler = gpuShader.glSamplerTextures$[i]; - const gpuDescriptorSet = gpuDescriptorSets[glSampler.set$]; - let descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices$[glSampler.binding$]; - let gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors$[descriptorIndex]; + const glSampler = gpuShader.glSamplerTextures[i]; + const gpuDescriptorSet = gpuDescriptorSets[glSampler.set]; + let descriptorIndex = gpuDescriptorSet && gpuDescriptorSet.descriptorIndices[glSampler.binding]; + let gpuDescriptor = descriptorIndex >= 0 && gpuDescriptorSet.gpuDescriptors[descriptorIndex]; - for (let l = 0; l < glSampler.units$.length; l++) { - const texUnit = glSampler.units$[l]; + for (let l = 0; l < glSampler.units.length; l++) { + const texUnit = glSampler.units[l]; - const glTexUnit = cache.glTexUnits$[texUnit]; + const glTexUnit = cache.glTexUnits[texUnit]; - if (!gpuDescriptor || !gpuDescriptor.gpuTextureView$ || !gpuDescriptor.gpuTextureView$.gpuTexture$ || !gpuDescriptor.gpuSampler$) { + if (!gpuDescriptor || !gpuDescriptor.gpuTextureView || !gpuDescriptor.gpuTextureView.gpuTexture || !gpuDescriptor.gpuSampler) { // error(`Sampler binding '${glSampler.name}' at set ${glSampler.set} binding ${glSampler.binding} index ${l} is not bounded`); continue; } - const gpuTextureView = gpuDescriptor.gpuTextureView$; - const gpuTexture = gpuTextureView.gpuTexture$; - const minLod = gpuTextureView.baseLevel$; - const maxLod = minLod + gpuTextureView.levelCount$; + const gpuTextureView = gpuDescriptor.gpuTextureView; + const gpuTexture = gpuTextureView.gpuTexture; + const minLod = gpuTextureView.baseLevel; + const maxLod = minLod + gpuTextureView.levelCount; - if (gpuTexture.size$ > 0) { - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - if (cache.texUnit$ !== texUnit) { + if (gpuTexture.size > 0) { + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + if (cache.texUnit !== texUnit) { gl.activeTexture(WebGLConstants.TEXTURE0 + texUnit); - cache.texUnit$ = texUnit; + cache.texUnit = texUnit; } - if (gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); + if (gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); } else { - gl.bindTexture(gpuTexture.glTarget$, device.nullTex2D.gpuTexture.glTexture$); + gl.bindTexture(gpuTexture.glTarget, device.nullTex2D.gpuTexture.glTexture); } - glTexUnit.glTexture$ = gpuTexture.glTexture$; + glTexUnit.glTexture = gpuTexture.glTexture; } - const { gpuSampler$: gpuSampler } = gpuDescriptor; // get sampler with different mipmap levels - const glSampler = gpuSampler.getGLSampler$(device, minLod, maxLod); - if (cache.glSamplerUnits$[texUnit] !== glSampler) { + const { gpuSampler } = gpuDescriptor; // get sampler with different mipmap levels + const glSampler = gpuSampler.getGLSampler(device, minLod, maxLod); + if (cache.glSamplerUnits[texUnit] !== glSampler) { gl.bindSampler(texUnit, glSampler); - cache.glSamplerUnits$[texUnit] = glSampler; + cache.glSamplerUnits[texUnit] = glSampler; } } - gpuDescriptor = gpuDescriptorSet.gpuDescriptors$[++descriptorIndex]; + gpuDescriptor = gpuDescriptorSet.gpuDescriptors[++descriptorIndex]; } } } // bind descriptor sets @@ -2341,128 +2341,128 @@ export function WebGL2CmdFuncBindStates ( && (isShaderChanged || gfxStateCache.gpuInputAssembler !== gpuInputAssembler)) { gfxStateCache.gpuInputAssembler = gpuInputAssembler; - if (device.extensions.useVAO$) { + if (device.extensions.useVAO) { // check vao - let glVAO = gpuInputAssembler.glVAOs$.get(gpuShader.glProgram$!); + let glVAO = gpuInputAssembler.glVAOs.get(gpuShader.glProgram!); if (!glVAO) { glVAO = gl.createVertexArray()!; - gpuInputAssembler.glVAOs$.set(gpuShader.glProgram$!, glVAO); + gpuInputAssembler.glVAOs.set(gpuShader.glProgram!, glVAO); gl.bindVertexArray(glVAO); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; - cache.glElementArrayBuffer$ = null; + cache.glArrayBuffer = null; + cache.glElementArrayBuffer = null; let glAttrib: IWebGL2Attrib | null; - for (let j = 0; j < gpuShader.glInputs$.length; j++) { - const glInput = gpuShader.glInputs$[j]; + for (let j = 0; j < gpuShader.glInputs.length; j++) { + const glInput = gpuShader.glInputs[j]; glAttrib = null; - for (let k = 0; k < gpuInputAssembler.glAttribs$.length; k++) { - const attrib = gpuInputAssembler.glAttribs$[k]; - if (attrib.name$ === glInput.name$) { + for (let k = 0; k < gpuInputAssembler.glAttribs.length; k++) { + const attrib = gpuInputAssembler.glAttribs[k]; + if (attrib.name === glInput.name) { glAttrib = attrib; break; } } if (glAttrib) { - if (cache.glArrayBuffer$ !== glAttrib.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer$); - cache.glArrayBuffer$ = glAttrib.glBuffer$; + if (cache.glArrayBuffer !== glAttrib.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer); + cache.glArrayBuffer = glAttrib.glBuffer; } - for (let c = 0; c < glAttrib.componentCount$; ++c) { - const glLoc = glInput.glLoc$ + c; - const attribOffset = glAttrib.offset$ + glAttrib.size$ * c; + for (let c = 0; c < glAttrib.componentCount; ++c) { + const glLoc = glInput.glLoc + c; + const attribOffset = glAttrib.offset + glAttrib.size * c; gl.enableVertexAttribArray(glLoc); - cache.glCurrentAttribLocs$[glLoc] = true; + cache.glCurrentAttribLocs[glLoc] = true; - gl.vertexAttribPointer(glLoc, glAttrib.count$, glAttrib.glType$, glAttrib.isNormalized$, glAttrib.stride$, attribOffset); - gl.vertexAttribDivisor(glLoc, glAttrib.isInstanced$ ? 1 : 0); + gl.vertexAttribPointer(glLoc, glAttrib.count, glAttrib.glType, glAttrib.isNormalized, glAttrib.stride, attribOffset); + gl.vertexAttribDivisor(glLoc, glAttrib.isInstanced ? 1 : 0); } } } - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer$; + const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuBuffer) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); } gl.bindVertexArray(null); gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, null); gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, null); - cache.glArrayBuffer$ = null; - cache.glElementArrayBuffer$ = null; + cache.glArrayBuffer = null; + cache.glElementArrayBuffer = null; } - if (cache.glVAO$ !== glVAO) { + if (cache.glVAO !== glVAO) { gl.bindVertexArray(glVAO); - cache.glVAO$ = glVAO; + cache.glVAO = glVAO; } } else { for (let a = 0; a < capabilities.maxVertexAttributes; ++a) { - cache.glCurrentAttribLocs$[a] = false; + cache.glCurrentAttribLocs[a] = false; } - for (let j = 0; j < gpuShader.glInputs$.length; j++) { - const glInput = gpuShader.glInputs$[j]; + for (let j = 0; j < gpuShader.glInputs.length; j++) { + const glInput = gpuShader.glInputs[j]; let glAttrib: IWebGL2Attrib | null = null; - for (let k = 0; k < gpuInputAssembler.glAttribs$.length; k++) { - const attrib = gpuInputAssembler.glAttribs$[k]; - if (attrib.name$ === glInput.name$) { + for (let k = 0; k < gpuInputAssembler.glAttribs.length; k++) { + const attrib = gpuInputAssembler.glAttribs[k]; + if (attrib.name === glInput.name) { glAttrib = attrib; break; } } if (glAttrib) { - if (cache.glArrayBuffer$ !== glAttrib.glBuffer$) { - gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer$); - cache.glArrayBuffer$ = glAttrib.glBuffer$; + if (cache.glArrayBuffer !== glAttrib.glBuffer) { + gl.bindBuffer(WebGLConstants.ARRAY_BUFFER, glAttrib.glBuffer); + cache.glArrayBuffer = glAttrib.glBuffer; } - for (let c = 0; c < glAttrib.componentCount$; ++c) { - const glLoc = glInput.glLoc$ + c; - const attribOffset = glAttrib.offset$ + glAttrib.size$ * c; + for (let c = 0; c < glAttrib.componentCount; ++c) { + const glLoc = glInput.glLoc + c; + const attribOffset = glAttrib.offset + glAttrib.size * c; - if (!cache.glEnabledAttribLocs$[glLoc] && glLoc >= 0) { + if (!cache.glEnabledAttribLocs[glLoc] && glLoc >= 0) { gl.enableVertexAttribArray(glLoc); - cache.glEnabledAttribLocs$[glLoc] = true; + cache.glEnabledAttribLocs[glLoc] = true; } - cache.glCurrentAttribLocs$[glLoc] = true; + cache.glCurrentAttribLocs[glLoc] = true; - gl.vertexAttribPointer(glLoc, glAttrib.count$, glAttrib.glType$, glAttrib.isNormalized$, glAttrib.stride$, attribOffset); - gl.vertexAttribDivisor(glLoc, glAttrib.isInstanced$ ? 1 : 0); + gl.vertexAttribPointer(glLoc, glAttrib.count, glAttrib.glType, glAttrib.isNormalized, glAttrib.stride, attribOffset); + gl.vertexAttribDivisor(glLoc, glAttrib.isInstanced ? 1 : 0); } } } // for - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer$; + const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuBuffer) { - if (cache.glElementArrayBuffer$ !== gpuBuffer.glBuffer$) { - gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer$); - cache.glElementArrayBuffer$ = gpuBuffer.glBuffer$; + if (cache.glElementArrayBuffer !== gpuBuffer.glBuffer) { + gl.bindBuffer(WebGLConstants.ELEMENT_ARRAY_BUFFER, gpuBuffer.glBuffer); + cache.glElementArrayBuffer = gpuBuffer.glBuffer; } } for (let a = 0; a < capabilities.maxVertexAttributes; ++a) { - if (cache.glEnabledAttribLocs$[a] !== cache.glCurrentAttribLocs$[a]) { + if (cache.glEnabledAttribLocs[a] !== cache.glCurrentAttribLocs[a]) { gl.disableVertexAttribArray(a); - cache.glEnabledAttribLocs$[a] = false; + cache.glEnabledAttribLocs[a] = false; } } } } // bind vertex/index buffer // update dynamic states - if (gpuPipelineState && gpuPipelineState.dynamicStates$.length) { - const dsLen = gpuPipelineState.dynamicStates$.length; + if (gpuPipelineState && gpuPipelineState.dynamicStates.length) { + const dsLen = gpuPipelineState.dynamicStates.length; for (let k = 0; k < dsLen; k++) { - const dynamicState = gpuPipelineState.dynamicStates$[k]; + const dynamicState = gpuPipelineState.dynamicStates[k]; switch (dynamicState) { case DynamicStateFlagBit.LINE_WIDTH: { if (cacheRs.lineWidth !== dynamicStates.lineWidth) { @@ -2473,7 +2473,7 @@ export function WebGL2CmdFuncBindStates ( } case DynamicStateFlagBit.DEPTH_BIAS: { if (cacheRs.depthBias !== dynamicStates.depthBiasConstant - || cache.rs$.depthBiasSlop !== dynamicStates.depthBiasSlope) { + || cache.rs.depthBiasSlop !== dynamicStates.depthBiasSlope) { gl.polygonOffset(dynamicStates.depthBiasConstant, dynamicStates.depthBiasSlope); cacheRs.depthBias = dynamicStates.depthBiasConstant; cacheRs.depthBiasSlop = dynamicStates.depthBiasSlope; @@ -2530,94 +2530,94 @@ export function WebGL2CmdFuncBindStates ( export function WebGL2CmdFuncDraw (device: WebGL2Device, drawInfo: Readonly): void { const { gl } = device; const { gpuInputAssembler, glPrimitive } = gfxStateCache; - const md = device.extensions.WEBGL_multi_draw$; + const md = device.extensions.WEBGL_multi_draw; if (gpuInputAssembler) { - const indexBuffer = gpuInputAssembler.gpuIndexBuffer$; - if (gpuInputAssembler.gpuIndirectBuffer$) { - const { indirects$: indirects } = gpuInputAssembler.gpuIndirectBuffer$; - if (indirects.drawByIndex$) { - for (let j = 0; j < indirects.drawCount$; j++) { - indirects.byteOffsets$[j] = indirects.offsets$[j] * indexBuffer!.stride$; + const indexBuffer = gpuInputAssembler.gpuIndexBuffer; + if (gpuInputAssembler.gpuIndirectBuffer) { + const { indirects } = gpuInputAssembler.gpuIndirectBuffer; + if (indirects.drawByIndex) { + for (let j = 0; j < indirects.drawCount; j++) { + indirects.byteOffsets[j] = indirects.offsets[j] * indexBuffer!.stride; } if (md) { - if (indirects.instancedDraw$) { + if (indirects.instancedDraw) { md.multiDrawElementsInstancedWEBGL( glPrimitive, - indirects.counts$, + indirects.counts, 0, - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, - indirects.instances$, + indirects.instances, 0, - indirects.drawCount$, + indirects.drawCount, ); } else { md.multiDrawElementsWEBGL( glPrimitive, - indirects.counts$, + indirects.counts, 0, - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, - indirects.drawCount$, + indirects.drawCount, ); } } else { - for (let j = 0; j < indirects.drawCount$; j++) { - if (indirects.instances$[j]) { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j]) { gl.drawElementsInstanced( glPrimitive, - indirects.counts$[j], - gpuInputAssembler.glIndexType$, - indirects.byteOffsets$[j], - indirects.instances$[j], + indirects.counts[j], + gpuInputAssembler.glIndexType, + indirects.byteOffsets[j], + indirects.instances[j], ); } else { - gl.drawElements(glPrimitive, indirects.counts$[j], gpuInputAssembler.glIndexType$, indirects.byteOffsets$[j]); + gl.drawElements(glPrimitive, indirects.counts[j], gpuInputAssembler.glIndexType, indirects.byteOffsets[j]); } } } } else if (md) { - if (indirects.instancedDraw$) { + if (indirects.instancedDraw) { md.multiDrawArraysInstancedWEBGL( glPrimitive, - indirects.offsets$, + indirects.offsets, 0, - indirects.counts$, + indirects.counts, 0, - indirects.instances$, + indirects.instances, 0, - indirects.drawCount$, + indirects.drawCount, ); } else { md.multiDrawArraysWEBGL( glPrimitive, - indirects.offsets$, + indirects.offsets, 0, - indirects.counts$, + indirects.counts, 0, - indirects.drawCount$, + indirects.drawCount, ); } } else { - for (let j = 0; j < indirects.drawCount$; j++) { - if (indirects.instances$[j]) { - gl.drawArraysInstanced(glPrimitive, indirects.offsets$[j], indirects.counts$[j], indirects.instances$[j]); + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j]) { + gl.drawArraysInstanced(glPrimitive, indirects.offsets[j], indirects.counts[j], indirects.instances[j]); } else { - gl.drawArrays(glPrimitive, indirects.offsets$[j], indirects.counts$[j]); + gl.drawArrays(glPrimitive, indirects.offsets[j], indirects.counts[j]); } } } } else if (drawInfo.instanceCount) { if (indexBuffer) { if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * indexBuffer.stride$; + const offset = drawInfo.firstIndex * indexBuffer.stride; gl.drawElementsInstanced( glPrimitive, drawInfo.indexCount, - gpuInputAssembler.glIndexType$, + gpuInputAssembler.glIndexType, offset, drawInfo.instanceCount, ); @@ -2627,8 +2627,8 @@ export function WebGL2CmdFuncDraw (device: WebGL2Device, drawInfo: Readonly 0) { - const offset = drawInfo.firstIndex * indexBuffer.stride$; - gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType$, offset); + const offset = drawInfo.firstIndex * indexBuffer.stride; + gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset); } } else if (drawInfo.vertexCount > 0) { gl.drawArrays(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount); @@ -2657,28 +2657,28 @@ export function WebGL2CmdFuncCopyTexImagesToTexture ( regions: Readonly, ): void { const { gl } = device; - const cache = device.getStateCache$(); - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + const cache = device.getStateCache(); + const glTexUnit = cache.glTexUnits[cache.texUnit]; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } let n = 0; let f = 0; - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { - if ((gpuTexture.flags$ & TextureFlagBit.MUTABLE_STORAGE) || toUseTexImage2D(texImages, regions)) { + if ((gpuTexture.flags & TextureFlagBit.MUTABLE_STORAGE) || toUseTexImage2D(texImages, regions)) { gl.texImage2D( WebGLConstants.TEXTURE_2D, regions[0].texSubres.mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, regions[0].texExtent.width, regions[0].texExtent.height, 0, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, texImages[0], ); } else { @@ -2689,8 +2689,8 @@ export function WebGL2CmdFuncCopyTexImagesToTexture ( region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, texImages[n++], ); } @@ -2707,8 +2707,8 @@ export function WebGL2CmdFuncCopyTexImagesToTexture ( region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, texImages[n++], ); } @@ -2720,8 +2720,8 @@ export function WebGL2CmdFuncCopyTexImagesToTexture ( } } - if (gpuTexture.flags$ & TextureFlagBit.GEN_MIPMAP) { - gl.generateMipmap(gpuTexture.glTarget$); + if (gpuTexture.flags & TextureFlagBit.GEN_MIPMAP) { + gl.generateMipmap(gpuTexture.glTarget); } } @@ -2771,26 +2771,26 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( regions: Readonly, ): void { const { gl } = device; - const cache = device.getStateCache$(); - const glTexUnit = cache.glTexUnits$[cache.texUnit$]; - if (glTexUnit.glTexture$ !== gpuTexture.glTexture$) { - gl.bindTexture(gpuTexture.glTarget$, gpuTexture.glTexture$); - glTexUnit.glTexture$ = gpuTexture.glTexture$; + const cache = device.getStateCache(); + const glTexUnit = cache.glTexUnits[cache.texUnit]; + if (glTexUnit.glTexture !== gpuTexture.glTexture) { + gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); + glTexUnit.glTexture = gpuTexture.glTexture; } let n = 0; let f = 0; - const fmtInfo: FormatInfo = FormatInfos[gpuTexture.format$]; + const fmtInfo: FormatInfo = FormatInfos[gpuTexture.format]; const ArrayBufferCtor: TypedArrayConstructor = getTypedArrayConstructor(fmtInfo); const { isCompressed } = fmtInfo; - const blockSize = formatAlignment(gpuTexture.format$); + const blockSize = formatAlignment(gpuTexture.format); const extent: Extent = new Extent(); const offset: Offset = new Offset(); const stride: Extent = new Extent(); - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { for (let k = 0; k < regions.length; k++) { const region = regions[k]; @@ -2804,17 +2804,17 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -2825,11 +2825,11 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { gl.compressedTexSubImage2D( WebGLConstants.TEXTURE_2D, mipLevel, @@ -2837,14 +2837,14 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage2D( WebGLConstants.TEXTURE_2D, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, 0, @@ -2868,8 +2868,8 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; const fcount = region.texSubres.baseArrayLayer + region.texSubres.layerCount; for (f = region.texSubres.baseArrayLayer; f < fcount; ++f) { @@ -2878,11 +2878,11 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -2895,11 +2895,11 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( destWidth, destHeight, extent.depth, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { gl.compressedTexSubImage3D( WebGLConstants.TEXTURE_2D_ARRAY, mipLevel, @@ -2909,14 +2909,14 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( destWidth, destHeight, extent.depth, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage3D( WebGLConstants.TEXTURE_2D_ARRAY, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, extent.depth, @@ -2943,17 +2943,17 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, extent.depth) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, extent.depth) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -2966,11 +2966,11 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( destWidth, destHeight, extent.depth, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { gl.compressedTexSubImage3D( WebGLConstants.TEXTURE_2D_ARRAY, mipLevel, @@ -2980,14 +2980,14 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( destWidth, destHeight, extent.depth, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage3D( WebGLConstants.TEXTURE_2D_ARRAY, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, extent.depth, @@ -3011,19 +3011,19 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( stride.width = region.buffStride > 0 ? region.buffStride : extent.width; stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height; - const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width$ >> mipLevel)) ? region.texExtent.width : extent.width; - const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height$ >> mipLevel)) ? region.texExtent.height : extent.height; + const destWidth = (region.texExtent.width + offset.x === (gpuTexture.width >> mipLevel)) ? region.texExtent.width : extent.width; + const destHeight = (region.texExtent.height + offset.y === (gpuTexture.height >> mipLevel)) ? region.texExtent.height : extent.height; const fcount = region.texSubres.baseArrayLayer + region.texSubres.layerCount; for (f = region.texSubres.baseArrayLayer; f < fcount; ++f) { let pixels: ArrayBufferView; const buffer = buffers[n++]; if (stride.width === extent.width && stride.height === extent.height) { - const length = FormatSize(gpuTexture.format$, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; + const length = FormatSize(gpuTexture.format, destWidth, destHeight, 1) / ArrayBufferCtor.BYTES_PER_ELEMENT; assertID(Number.isInteger(length), 9101); pixels = new ArrayBufferCtor(buffer.buffer, buffer.byteOffset + region.buffOffset, length); } else { - pixels = pixelBufferPick(buffer, gpuTexture.format$, region.buffOffset, stride, extent); + pixels = pixelBufferPick(buffer, gpuTexture.format, region.buffOffset, stride, extent); } if (!isCompressed) { @@ -3034,11 +3034,11 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, - gpuTexture.glType$, + gpuTexture.glFormat, + gpuTexture.glType, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { gl.compressedTexSubImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, mipLevel, @@ -3046,14 +3046,14 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( offset.y, destWidth, destHeight, - gpuTexture.glFormat$, + gpuTexture.glFormat, pixels, ); } else { // WEBGL_compressed_texture_etc1 gl.compressedTexImage2D( WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, mipLevel, - gpuTexture.glInternalFmt$, + gpuTexture.glInternalFmt, destWidth, destHeight, 0, @@ -3069,8 +3069,8 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( } } - if (gpuTexture.flags$ & TextureFlagBit.GEN_MIPMAP) { - gl.generateMipmap(gpuTexture.glTarget$); + if (gpuTexture.flags & TextureFlagBit.GEN_MIPMAP) { + gl.generateMipmap(gpuTexture.glTarget); } } @@ -3081,7 +3081,7 @@ export function WebGL2CmdFuncCopyTextureToBuffers ( regions: Readonly, ): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); const framebuffer = gl.createFramebuffer(); gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, framebuffer); @@ -3090,22 +3090,22 @@ export function WebGL2CmdFuncCopyTextureToBuffers ( let w = 1; let h = 1; - switch (gpuTexture.glTarget$) { + switch (gpuTexture.glTarget) { case WebGLConstants.TEXTURE_2D: { for (let k = 0; k < regions.length; k++) { const region = regions[k]; gl.framebufferTexture2D( WebGLConstants.FRAMEBUFFER, WebGLConstants.COLOR_ATTACHMENT0, - gpuTexture.glTarget$, - gpuTexture.glTexture$, + gpuTexture.glTarget, + gpuTexture.glTexture, region.texSubres.mipLevel, ); x = region.texOffset.x; y = region.texOffset.y; w = region.texExtent.width; h = region.texExtent.height; - gl.readPixels(x, y, w, h, gpuTexture.glFormat$, gpuTexture.glType$, buffers[k]); + gl.readPixels(x, y, w, h, gpuTexture.glFormat, gpuTexture.glType, buffers[k]); } break; } @@ -3114,7 +3114,7 @@ export function WebGL2CmdFuncCopyTextureToBuffers ( } } gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, null); - cache.glFramebuffer$ = null; + cache.glFramebuffer = null; gl.deleteFramebuffer(framebuffer); } @@ -3127,26 +3127,26 @@ export function WebGL2CmdFuncBlitFramebuffer ( filter: Filter, ): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); - if (cache.glReadFramebuffer$ !== src.glFramebuffer$) { - gl.bindFramebuffer(WebGLConstants.READ_FRAMEBUFFER, src.glFramebuffer$); - cache.glReadFramebuffer$ = src.glFramebuffer$; + if (cache.glReadFramebuffer !== src.glFramebuffer) { + gl.bindFramebuffer(WebGLConstants.READ_FRAMEBUFFER, src.glFramebuffer); + cache.glReadFramebuffer = src.glFramebuffer; } - const rebindFBO = (dst.glFramebuffer$ !== cache.glFramebuffer$); + const rebindFBO = (dst.glFramebuffer !== cache.glFramebuffer); if (rebindFBO) { - gl.bindFramebuffer(WebGLConstants.DRAW_FRAMEBUFFER, dst.glFramebuffer$); + gl.bindFramebuffer(WebGLConstants.DRAW_FRAMEBUFFER, dst.glFramebuffer); } let mask = 0; - if (src.gpuColorViews$.length > 0) { + if (src.gpuColorViews.length > 0) { mask |= WebGLConstants.COLOR_BUFFER_BIT; } - if (src.gpuDepthStencilView$) { + if (src.gpuDepthStencilView) { mask |= WebGLConstants.DEPTH_BUFFER_BIT; - if (FormatInfos[src.gpuDepthStencilView$.gpuTexture$.format$].hasStencil) { + if (FormatInfos[src.gpuDepthStencilView.gpuTexture.format].hasStencil) { mask |= WebGLConstants.STENCIL_BUFFER_BIT; } } @@ -3167,7 +3167,7 @@ export function WebGL2CmdFuncBlitFramebuffer ( ); if (rebindFBO) { - gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, cache.glFramebuffer$); + gl.bindFramebuffer(WebGLConstants.FRAMEBUFFER, cache.glFramebuffer); } } @@ -3179,7 +3179,7 @@ export function WebGL2CmdFuncBlitTexture ( filter: Filter, ): void { const { gl } = device; - const cache = device.getStateCache$(); + const cache = device.getStateCache(); const blitManager = device.blitManager; if (!blitManager) { return; @@ -3190,8 +3190,8 @@ export function WebGL2CmdFuncBlitTexture ( const srcFramebuffer = blitManager.srcFramebuffer; const dstFramebuffer = blitManager.dstFramebuffer; - const origReadFBO = cache.glReadFramebuffer$; - const origDrawFBO = cache.glFramebuffer$; + const origReadFBO = cache.glReadFramebuffer; + const origDrawFBO = cache.glFramebuffer; let srcMip = regions[0].srcSubres.mipLevel; let dstMip = regions[0].dstSubres.mipLevel; @@ -3223,42 +3223,42 @@ export function WebGL2CmdFuncBlitTexture ( const regionIndices = regions.map((_, i): number => i); regionIndices.sort((a, b): number => regions[a].srcSubres.mipLevel - regions[b].srcSubres.mipLevel); - const { mask: srcMask, attachment: srcAttachment } = blitInfo(FormatInfos[src.format$]); - const { mask: dstMask, attachment: dstAttachment } = blitInfo(FormatInfos[dst.format$]); + const { mask: srcMask, attachment: srcAttachment } = blitInfo(FormatInfos[src.format]); + const { mask: dstMask, attachment: dstAttachment } = blitInfo(FormatInfos[dst.format]); - if (cache.glReadFramebuffer$ !== srcFramebuffer) { + if (cache.glReadFramebuffer !== srcFramebuffer) { gl.bindFramebuffer(WebGLConstants.READ_FRAMEBUFFER, srcFramebuffer); - cache.glReadFramebuffer$ = srcFramebuffer; + cache.glReadFramebuffer = srcFramebuffer; } - if (cache.glFramebuffer$ !== dstFramebuffer) { + if (cache.glFramebuffer !== dstFramebuffer) { gl.bindFramebuffer(WebGLConstants.DRAW_FRAMEBUFFER, dstFramebuffer); - cache.glFramebuffer$ = dstFramebuffer; + cache.glFramebuffer = dstFramebuffer; } - if (src.glTexture$) { - gl.framebufferTexture2D(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, src.glTarget$, src.glTexture$, srcMip); + if (src.glTexture) { + gl.framebufferTexture2D(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, src.glTarget, src.glTexture, srcMip); } else { - gl.framebufferRenderbuffer(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, WebGLConstants.RENDERBUFFER, src.glRenderbuffer$); + gl.framebufferRenderbuffer(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, WebGLConstants.RENDERBUFFER, src.glRenderbuffer); } - if (dst.glTexture$) { - gl.framebufferTexture2D(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, dst.glTarget$, dst.glTexture$, dstMip); + if (dst.glTexture) { + gl.framebufferTexture2D(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, dst.glTarget, dst.glTexture, dstMip); } else { - gl.framebufferRenderbuffer(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, WebGLConstants.RENDERBUFFER, dst.glRenderbuffer$); + gl.framebufferRenderbuffer(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, WebGLConstants.RENDERBUFFER, dst.glRenderbuffer); } for (let i = 0; i < regionIndices.length; i++) { const region = regions[regionIndices[i]]; - if (src.glTexture$ && srcMip !== region.srcSubres.mipLevel) { + if (src.glTexture && srcMip !== region.srcSubres.mipLevel) { srcMip = region.srcSubres.mipLevel; - gl.framebufferTexture2D(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, src.glTarget$, src.glTexture$, srcMip); + gl.framebufferTexture2D(WebGLConstants.READ_FRAMEBUFFER, srcAttachment, src.glTarget, src.glTexture, srcMip); } - if (dst.glTexture$ && dstMip !== region.dstSubres.mipLevel) { + if (dst.glTexture && dstMip !== region.dstSubres.mipLevel) { dstMip = region.dstSubres.mipLevel; - gl.framebufferTexture2D(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, dst.glTarget$, dst.glTexture$, dstMip); + gl.framebufferTexture2D(WebGLConstants.DRAW_FRAMEBUFFER, dstAttachment, dst.glTarget, dst.glTexture, dstMip); } gl.blitFramebuffer( @@ -3276,12 +3276,12 @@ export function WebGL2CmdFuncBlitTexture ( } // restore fbo state - if (cache.glReadFramebuffer$ !== origReadFBO) { + if (cache.glReadFramebuffer !== origReadFBO) { gl.bindFramebuffer(WebGLConstants.READ_FRAMEBUFFER, origReadFBO); - cache.glReadFramebuffer$ = origReadFBO; + cache.glReadFramebuffer = origReadFBO; } - if (cache.glFramebuffer$ !== origDrawFBO) { + if (cache.glFramebuffer !== origDrawFBO) { gl.bindFramebuffer(WebGLConstants.DRAW_FRAMEBUFFER, origDrawFBO); - cache.glFramebuffer$ = origDrawFBO; + cache.glFramebuffer = origDrawFBO; } } diff --git a/cocos/gfx/webgl2/webgl2-define.ts b/cocos/gfx/webgl2/webgl2-define.ts index 91e06a149af..771aaf03719 100644 --- a/cocos/gfx/webgl2/webgl2-define.ts +++ b/cocos/gfx/webgl2/webgl2-define.ts @@ -86,22 +86,22 @@ export enum WebGL2EXT { } export interface IWebGL2Extensions { - EXT_texture_filter_anisotropic$: EXT_texture_filter_anisotropic | null; - EXT_color_buffer_half_float$: EXT_color_buffer_half_float | null; - EXT_color_buffer_float$: EXT_color_buffer_float | null; - WEBGL_multi_draw$: WEBGL_multi_draw | null; - WEBGL_compressed_texture_etc1$: WEBGL_compressed_texture_etc1 | null; - WEBGL_compressed_texture_etc$: WEBGL_compressed_texture_etc | null; - WEBGL_compressed_texture_pvrtc$: WEBGL_compressed_texture_pvrtc | null; - WEBGL_compressed_texture_astc$: WEBGL_compressed_texture_astc | null; - WEBGL_compressed_texture_s3tc$: WEBGL_compressed_texture_s3tc | null; - WEBGL_compressed_texture_s3tc_srgb$: WEBGL_compressed_texture_s3tc_srgb | null; - WEBGL_debug_shaders$: WEBGL_debug_shaders | null; - WEBGL_lose_context$: WEBGL_lose_context | null; - WEBGL_debug_renderer_info$: WEBGL_debug_renderer_info | null; - OES_texture_half_float_linear$: OES_texture_half_float_linear | null; - OES_texture_float_linear$: OES_texture_float_linear | null; - useVAO$: boolean; + EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null; + EXT_color_buffer_half_float: EXT_color_buffer_half_float | null; + EXT_color_buffer_float: EXT_color_buffer_float | null; + WEBGL_multi_draw: WEBGL_multi_draw | null; + WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null; + WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null; + WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null; + WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null; + WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null; + WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null; + WEBGL_debug_shaders: WEBGL_debug_shaders | null; + WEBGL_lose_context: WEBGL_lose_context | null; + WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null; + OES_texture_half_float_linear: OES_texture_half_float_linear | null; + OES_texture_float_linear: OES_texture_float_linear | null; + useVAO: boolean; } // put the global instance here so that we won't have circular dependencies diff --git a/cocos/gfx/webgl2/webgl2-descriptor-set-layout.ts b/cocos/gfx/webgl2/webgl2-descriptor-set-layout.ts index 745c54a4745..4f368f54052 100644 --- a/cocos/gfx/webgl2/webgl2-descriptor-set-layout.ts +++ b/cocos/gfx/webgl2/webgl2-descriptor-set-layout.ts @@ -27,37 +27,37 @@ import { DescriptorSetLayout } from '../base/descriptor-set-layout'; import { IWebGL2GPUDescriptorSetLayout } from './webgl2-gpu-objects'; export class WebGL2DescriptorSetLayout extends DescriptorSetLayout { - getGpuDescriptorSetLayout$ (): IWebGL2GPUDescriptorSetLayout { return this._gpuDescriptorSetLayout$!; } + getGpuDescriptorSetLayout (): IWebGL2GPUDescriptorSetLayout { return this._gpuDescriptorSetLayout!; } - private _gpuDescriptorSetLayout$: IWebGL2GPUDescriptorSetLayout | null = null; + private _gpuDescriptorSetLayout: IWebGL2GPUDescriptorSetLayout | null = null; constructor () { super(); } public initialize (info: Readonly): void { - Array.prototype.push.apply(this._bindings$, info.bindings); + Array.prototype.push.apply(this._bindings, info.bindings); let descriptorCount = 0; let maxBinding = -1; const flattenedIndices: number[] = []; - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; flattenedIndices.push(descriptorCount); descriptorCount += binding.count; if (binding.binding > maxBinding) maxBinding = binding.binding; } - this._bindingIndices$ = Array(maxBinding + 1).fill(-1); - const descriptorIndices = this._descriptorIndices$ = Array(maxBinding + 1).fill(-1); - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; - this._bindingIndices$[binding.binding] = i; + this._bindingIndices = Array(maxBinding + 1).fill(-1); + const descriptorIndices = this._descriptorIndices = Array(maxBinding + 1).fill(-1); + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; + this._bindingIndices[binding.binding] = i; descriptorIndices[binding.binding] = flattenedIndices[i]; } const dynamicBindings: number[] = []; - for (let i = 0; i < this._bindings$.length; i++) { - const binding = this._bindings$[i]; + for (let i = 0; i < this._bindings.length; i++) { + const binding = this._bindings[i]; if (binding.descriptorType & DESCRIPTOR_DYNAMIC_TYPE) { for (let j = 0; j < binding.count; j++) { dynamicBindings.push(binding.binding); @@ -65,15 +65,15 @@ export class WebGL2DescriptorSetLayout extends DescriptorSetLayout { } } - this._gpuDescriptorSetLayout$ = { - bindings$: this._bindings$, - dynamicBindings$: dynamicBindings, - descriptorIndices$: descriptorIndices, - descriptorCount$: descriptorCount, + this._gpuDescriptorSetLayout = { + bindings: this._bindings, + dynamicBindings, + descriptorIndices, + descriptorCount, }; } public destroy (): void { - this._bindings$.length = 0; + this._bindings.length = 0; } } diff --git a/cocos/gfx/webgl2/webgl2-descriptor-set.ts b/cocos/gfx/webgl2/webgl2-descriptor-set.ts index 5f76b161453..26e835892c7 100644 --- a/cocos/gfx/webgl2/webgl2-descriptor-set.ts +++ b/cocos/gfx/webgl2/webgl2-descriptor-set.ts @@ -36,62 +36,58 @@ export class WebGL2DescriptorSet extends DescriptorSet { } get gpuDescriptorSet (): IWebGL2GPUDescriptorSet { - return this._gpuDescriptorSet$ as IWebGL2GPUDescriptorSet; + return this._gpuDescriptorSet as IWebGL2GPUDescriptorSet; } - private _gpuDescriptorSet$: IWebGL2GPUDescriptorSet | null = null; + private _gpuDescriptorSet: IWebGL2GPUDescriptorSet | null = null; public initialize (info: Readonly): void { - this._layout$ = info.layout; - const { - bindings$: bindings, - descriptorIndices$: descriptorIndices, - descriptorCount$: descriptorCount, - } = (info.layout as WebGL2DescriptorSetLayout).getGpuDescriptorSetLayout$(); + this._layout = info.layout; + const { bindings, descriptorIndices, descriptorCount } = (info.layout as WebGL2DescriptorSetLayout).getGpuDescriptorSetLayout(); - this._buffers$ = Array(descriptorCount).fill(null); - this._textures$ = Array(descriptorCount).fill(null); - this._samplers$ = Array(descriptorCount).fill(null); + this._buffers = Array(descriptorCount).fill(null); + this._textures = Array(descriptorCount).fill(null); + this._samplers = Array(descriptorCount).fill(null); const gpuDescriptors: IWebGL2GPUDescriptor[] = []; - this._gpuDescriptorSet$ = { gpuDescriptors$: gpuDescriptors, descriptorIndices$: descriptorIndices }; + this._gpuDescriptorSet = { gpuDescriptors, descriptorIndices }; for (let i = 0; i < bindings.length; ++i) { const binding = bindings[i]; for (let j = 0; j < binding.count; j++) { gpuDescriptors.push({ - type$: binding.descriptorType, - gpuBuffer$: null, - gpuTextureView$: null, - gpuSampler$: null, + type: binding.descriptorType, + gpuBuffer: null, + gpuTextureView: null, + gpuSampler: null, }); } } } public destroy (): void { - this._layout$ = null; - this._gpuDescriptorSet$ = null; + this._layout = null; + this._gpuDescriptorSet = null; } public update (): void { - if (this._isDirty$ && this._gpuDescriptorSet$) { - const descriptors = this._gpuDescriptorSet$.gpuDescriptors$; + if (this._isDirty && this._gpuDescriptorSet) { + const descriptors = this._gpuDescriptorSet.gpuDescriptors; for (let i = 0; i < descriptors.length; ++i) { - if (descriptors[i].type$ & DESCRIPTOR_BUFFER_TYPE) { - if (this._buffers$[i]) { - descriptors[i].gpuBuffer$ = (this._buffers$[i] as WebGL2Buffer).getGpuBuffer$(); + if (descriptors[i].type & DESCRIPTOR_BUFFER_TYPE) { + if (this._buffers[i]) { + descriptors[i].gpuBuffer = (this._buffers[i] as WebGL2Buffer).getGpuBuffer(); } - } else if (descriptors[i].type$ & DESCRIPTOR_SAMPLER_TYPE) { - if (this._textures$[i]) { - descriptors[i].gpuTextureView$ = (this._textures$[i] as WebGL2Texture).gpuTextureView; + } else if (descriptors[i].type & DESCRIPTOR_SAMPLER_TYPE) { + if (this._textures[i]) { + descriptors[i].gpuTextureView = (this._textures[i] as WebGL2Texture).gpuTextureView; } - if (this._samplers$[i]) { - descriptors[i].gpuSampler$ = (this._samplers$[i] as WebGL2Sampler).gpuSampler; + if (this._samplers[i]) { + descriptors[i].gpuSampler = (this._samplers[i] as WebGL2Sampler).gpuSampler; } } } - this._isDirty$ = false; + this._isDirty = false; } } } diff --git a/cocos/gfx/webgl2/webgl2-device.ts b/cocos/gfx/webgl2/webgl2-device.ts index 7e1973b472b..9a3e03adfe2 100644 --- a/cocos/gfx/webgl2/webgl2-device.ts +++ b/cocos/gfx/webgl2/webgl2-device.ts @@ -77,48 +77,48 @@ export class WebGL2Device extends Device { } get gl (): WebGL2RenderingContext { - return this._context$!; + return this._context!; } get extensions (): IWebGL2Extensions { - return this._swapchain$!.extensions; + return this._swapchain!.extensions; } - getStateCache$ (): WebGL2StateCache { - return this._swapchain$!.stateCache$; + getStateCache (): WebGL2StateCache { + return this._swapchain!.stateCache; } get nullTex2D (): WebGL2Texture { - return this._swapchain$!.nullTex2D$; + return this._swapchain!.nullTex2D; } get nullTexCube (): WebGL2Texture { - return this._swapchain$!.nullTexCube$; + return this._swapchain!.nullTexCube; } get textureExclusive (): boolean[] { - return this._textureExclusive$; + return this._textureExclusive; } get bindingMappings (): IWebGL2BindingMapping { - return this._bindingMappings$!; + return this._bindingMappings!; } get blitManager (): IWebGL2BlitManager | null { - return this._swapchain$!.blitManager; + return this._swapchain!.blitManager; } - private _swapchain$: WebGL2Swapchain | null = null; - private _context$: WebGL2RenderingContext | null = null; - private _bindingMappings$: IWebGL2BindingMapping | null = null; + private _swapchain: WebGL2Swapchain | null = null; + private _context: WebGL2RenderingContext | null = null; + private _bindingMappings: IWebGL2BindingMapping | null = null; - protected _textureExclusive$ = new Array(Format.COUNT); + protected _textureExclusive = new Array(Format.COUNT); public initialize (info: Readonly): boolean { WebGL2DeviceManager.setInstance(this); - this._gfxAPI$ = API.WEBGL2; + this._gfxAPI = API.WEBGL2; - const mapping = this._bindingMappingInfo$ = info.bindingMappingInfo; + const mapping = this._bindingMappingInfo = info.bindingMappingInfo; const blockOffsets: number[] = []; const samplerTextureOffsets: number[] = []; const firstSet = mapping.setIndices[0]; @@ -136,13 +136,13 @@ export class WebGL2Device extends Device { // textures always come after UBOs samplerTextureOffsets[curSet] -= mapping.maxBlockCounts[curSet]; } - this._bindingMappings$ = { - blockOffsets$: blockOffsets, - samplerTextureOffsets$: samplerTextureOffsets, - flexibleSet$: mapping.setIndices[mapping.setIndices.length - 1], + this._bindingMappings = { + blockOffsets: blockOffsets, + samplerTextureOffsets: samplerTextureOffsets, + flexibleSet: mapping.setIndices[mapping.setIndices.length - 1], }; - const gl = this._context$ = getContext(Device.canvas); + const gl = this._context = getContext(Device.canvas); if (!gl) { errorID(16405); @@ -150,35 +150,35 @@ export class WebGL2Device extends Device { } // create queue - this._queue$ = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff$ = this.createCommandBuffer(new CommandBufferInfo(this._queue$)); + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); const glGetParameter = gl.getParameter.bind(gl); - this._caps$.maxVertexAttributes = glGetParameter(WebGLConstants.MAX_VERTEX_ATTRIBS); - this._caps$.maxVertexUniformVectors = glGetParameter(WebGLConstants.MAX_VERTEX_UNIFORM_VECTORS); + this._caps.maxVertexAttributes = glGetParameter(WebGLConstants.MAX_VERTEX_ATTRIBS); + this._caps.maxVertexUniformVectors = glGetParameter(WebGLConstants.MAX_VERTEX_UNIFORM_VECTORS); // Implementation of WebGL2 in WECHAT browser and Safari in IOS exist bugs. // It seems to be related to Safari's experimental features 'WebGL via Metal'. // So limit using vertex uniform vectors no more than 256 in wechat browser, // and using vertex uniform vectors no more than 512 in safari. if (systemInfo.os === OS.IOS) { - const maxVertexUniformVectors = this._caps$.maxVertexUniformVectors; + const maxVertexUniformVectors = this._caps.maxVertexUniformVectors; if (sys.browserType === BrowserType.WECHAT) { - this._caps$.maxVertexUniformVectors = maxVertexUniformVectors < 256 ? maxVertexUniformVectors : 256; + this._caps.maxVertexUniformVectors = maxVertexUniformVectors < 256 ? maxVertexUniformVectors : 256; } else if (sys.browserType === BrowserType.SAFARI) { - this._caps$.maxVertexUniformVectors = maxVertexUniformVectors < 512 ? maxVertexUniformVectors : 512; + this._caps.maxVertexUniformVectors = maxVertexUniformVectors < 512 ? maxVertexUniformVectors : 512; } } - this._caps$.maxFragmentUniformVectors = glGetParameter(WebGLConstants.MAX_FRAGMENT_UNIFORM_VECTORS); - this._caps$.maxTextureUnits = glGetParameter(WebGLConstants.MAX_TEXTURE_IMAGE_UNITS); - this._caps$.maxVertexTextureUnits = glGetParameter(WebGLConstants.MAX_VERTEX_TEXTURE_IMAGE_UNITS); - this._caps$.maxUniformBufferBindings = glGetParameter(WebGLConstants.MAX_UNIFORM_BUFFER_BINDINGS); - this._caps$.maxUniformBlockSize = glGetParameter(WebGLConstants.MAX_UNIFORM_BLOCK_SIZE); - this._caps$.maxTextureSize = glGetParameter(WebGLConstants.MAX_TEXTURE_SIZE); - this._caps$.maxCubeMapTextureSize = glGetParameter(WebGLConstants.MAX_CUBE_MAP_TEXTURE_SIZE); - this._caps$.maxArrayTextureLayers = glGetParameter(WebGLConstants.MAX_ARRAY_TEXTURE_LAYERS); - this._caps$.max3DTextureSize = glGetParameter(WebGLConstants.MAX_3D_TEXTURE_SIZE); - this._caps$.uboOffsetAlignment = glGetParameter(WebGLConstants.UNIFORM_BUFFER_OFFSET_ALIGNMENT); + this._caps.maxFragmentUniformVectors = glGetParameter(WebGLConstants.MAX_FRAGMENT_UNIFORM_VECTORS); + this._caps.maxTextureUnits = glGetParameter(WebGLConstants.MAX_TEXTURE_IMAGE_UNITS); + this._caps.maxVertexTextureUnits = glGetParameter(WebGLConstants.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + this._caps.maxUniformBufferBindings = glGetParameter(WebGLConstants.MAX_UNIFORM_BUFFER_BINDINGS); + this._caps.maxUniformBlockSize = glGetParameter(WebGLConstants.MAX_UNIFORM_BLOCK_SIZE); + this._caps.maxTextureSize = glGetParameter(WebGLConstants.MAX_TEXTURE_SIZE); + this._caps.maxCubeMapTextureSize = glGetParameter(WebGLConstants.MAX_CUBE_MAP_TEXTURE_SIZE); + this._caps.maxArrayTextureLayers = glGetParameter(WebGLConstants.MAX_ARRAY_TEXTURE_LAYERS); + this._caps.max3DTextureSize = glGetParameter(WebGLConstants.MAX_3D_TEXTURE_SIZE); + this._caps.uboOffsetAlignment = glGetParameter(WebGLConstants.UNIFORM_BUFFER_OFFSET_ALIGNMENT); const extensions = gl.getSupportedExtensions(); let extStr = ''; @@ -190,24 +190,24 @@ export class WebGL2Device extends Device { const exts = getExtensions(gl); - if (exts.WEBGL_debug_renderer_info$) { - this._renderer$ = glGetParameter(exts.WEBGL_debug_renderer_info$.UNMASKED_RENDERER_WEBGL); - this._vendor$ = glGetParameter(exts.WEBGL_debug_renderer_info$.UNMASKED_VENDOR_WEBGL); + if (exts.WEBGL_debug_renderer_info) { + this._renderer = glGetParameter(exts.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = glGetParameter(exts.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); } else { - this._renderer$ = glGetParameter(WebGLConstants.RENDERER); - this._vendor$ = glGetParameter(WebGLConstants.VENDOR); + this._renderer = glGetParameter(WebGLConstants.RENDERER); + this._vendor = glGetParameter(WebGLConstants.VENDOR); } const version: string = glGetParameter(WebGLConstants.VERSION); - this._features$.fill(false); + this._features.fill(false); this.initFormatFeatures(exts); - this._features$[Feature.ELEMENT_INDEX_UINT] = true; - this._features$[Feature.INSTANCED_ARRAYS] = true; - this._features$[Feature.MULTIPLE_RENDER_TARGETS] = true; - this._features$[Feature.BLEND_MINMAX] = true; + this._features[Feature.ELEMENT_INDEX_UINT] = true; + this._features[Feature.INSTANCED_ARRAYS] = true; + this._features[Feature.MULTIPLE_RENDER_TARGETS] = true; + this._features[Feature.BLEND_MINMAX] = true; let compressedFormat = ''; @@ -232,8 +232,8 @@ export class WebGL2Device extends Device { } debug('WebGL2 device initialized.'); - debug(`RENDERER: ${this._renderer$}`); - debug(`VENDOR: ${this._vendor$}`); + debug(`RENDERER: ${this._renderer}`); + debug(`VENDOR: ${this._vendor}`); debug(`VERSION: ${version}`); debug(`COMPRESSED_FORMAT: ${compressedFormat}`); debug(`EXTENSIONS: ${extStr}`); @@ -242,24 +242,24 @@ export class WebGL2Device extends Device { } public destroy (): void { - if (this._queue$) { - this._queue$.destroy(); - this._queue$ = null; + if (this._queue) { + this._queue.destroy(); + this._queue = null; } - if (this._cmdBuff$) { - this._cmdBuff$.destroy(); - this._cmdBuff$ = null; + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; } - const it = this._samplers$.values(); + const it = this._samplers.values(); let res = it.next(); while (!res.done) { (res.value as WebGL2Sampler).destroy(); res = it.next(); } - this._swapchain$ = null; + this._swapchain = null; } public flushCommands (cmdBuffs: Readonly): void { @@ -271,16 +271,16 @@ export class WebGL2Device extends Device { } public present (): void { - const queue = (this._queue$ as WebGL2Queue); - this._numDrawCalls$ = queue.numDrawCalls$; - this._numInstances$ = queue.numInstances$; - this._numTris$ = queue.numTris$; + const queue = (this._queue as WebGL2Queue); + this._numDrawCalls = queue.numDrawCalls; + this._numInstances = queue.numInstances; + this._numTris = queue.numTris; queue.clear(); } protected initFormatFeatures (exts: IWebGL2Extensions): void { - const formatFeatures = this._formatFeatures$; - const textureExclusive = this._textureExclusive$; + const formatFeatures = this._formatFeatures; + const textureExclusive = this._textureExclusive; formatFeatures.fill(FormatFeatureBit.NONE); textureExclusive.fill(true); @@ -402,7 +402,7 @@ export class WebGL2Device extends Device { textureExclusive[Format.DEPTH] = false; textureExclusive[Format.DEPTH_STENCIL] = false; - if (exts.EXT_color_buffer_float$) { + if (exts.EXT_color_buffer_float) { formatFeatures[Format.R32F] |= FormatFeatureBit.RENDER_TARGET; formatFeatures[Format.RG32F] |= FormatFeatureBit.RENDER_TARGET; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.RENDER_TARGET; @@ -412,20 +412,20 @@ export class WebGL2Device extends Device { textureExclusive[Format.RGBA32F] = false; } - if (exts.EXT_color_buffer_half_float$) { + if (exts.EXT_color_buffer_half_float) { textureExclusive[Format.R16F] = false; textureExclusive[Format.RG16F] = false; textureExclusive[Format.RGBA16F] = false; } - if (exts.OES_texture_float_linear$) { + if (exts.OES_texture_float_linear) { formatFeatures[Format.RGB32F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.RGBA32F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.R32F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.RG32F] |= FormatFeatureBit.LINEAR_FILTER; } - if (exts.OES_texture_half_float_linear$) { + if (exts.OES_texture_half_float_linear) { formatFeatures[Format.RGB16F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.RGBA16F] |= FormatFeatureBit.LINEAR_FILTER; formatFeatures[Format.R16F] |= FormatFeatureBit.LINEAR_FILTER; @@ -434,11 +434,11 @@ export class WebGL2Device extends Device { const compressedFeature: FormatFeature = FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; - if (exts.WEBGL_compressed_texture_etc1$) { + if (exts.WEBGL_compressed_texture_etc1) { formatFeatures[Format.ETC_RGB8] = compressedFeature; } - if (exts.WEBGL_compressed_texture_etc$) { + if (exts.WEBGL_compressed_texture_etc) { formatFeatures[Format.ETC2_RGB8] = compressedFeature; formatFeatures[Format.ETC2_RGBA8] = compressedFeature; formatFeatures[Format.ETC2_SRGB8] = compressedFeature; @@ -447,7 +447,7 @@ export class WebGL2Device extends Device { formatFeatures[Format.ETC2_SRGB8_A1] = compressedFeature; } - if (exts.WEBGL_compressed_texture_s3tc$) { + if (exts.WEBGL_compressed_texture_s3tc) { formatFeatures[Format.BC1] = compressedFeature; formatFeatures[Format.BC1_ALPHA] = compressedFeature; formatFeatures[Format.BC1_SRGB] = compressedFeature; @@ -458,14 +458,14 @@ export class WebGL2Device extends Device { formatFeatures[Format.BC3_SRGB] = compressedFeature; } - if (exts.WEBGL_compressed_texture_pvrtc$) { + if (exts.WEBGL_compressed_texture_pvrtc) { formatFeatures[Format.PVRTC_RGB2] = compressedFeature; formatFeatures[Format.PVRTC_RGBA2] = compressedFeature; formatFeatures[Format.PVRTC_RGB4] = compressedFeature; formatFeatures[Format.PVRTC_RGBA4] = compressedFeature; } - if (exts.WEBGL_compressed_texture_astc$) { + if (exts.WEBGL_compressed_texture_astc) { formatFeatures[Format.ASTC_RGBA_4X4] = compressedFeature; formatFeatures[Format.ASTC_RGBA_5X4] = compressedFeature; formatFeatures[Format.ASTC_RGBA_5X5] = compressedFeature; @@ -508,7 +508,7 @@ export class WebGL2Device extends Device { public createSwapchain (info: Readonly): Swapchain { const swapchain = new WebGL2Swapchain(); - this._swapchain$ = swapchain; + this._swapchain = swapchain; swapchain.initialize(info); return swapchain; } @@ -581,38 +581,38 @@ export class WebGL2Device extends Device { public getSampler (info: Readonly): Sampler { const hash = Sampler.computeHash(info); - if (!this._samplers$.has(hash)) { - this._samplers$.set(hash, new WebGL2Sampler(info, hash)); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new WebGL2Sampler(info, hash)); } - return this._samplers$.get(hash)!; + return this._samplers.get(hash)!; } public getSwapchains (): Readonly { - return [this._swapchain$ as Swapchain]; + return [this._swapchain as Swapchain]; } public getGeneralBarrier (info: Readonly): GeneralBarrier { const hash = GeneralBarrier.computeHash(info); - if (!this._generalBarrierss$.has(hash)) { - this._generalBarrierss$.set(hash, new GeneralBarrier(info, hash)); + if (!this._generalBarrierss.has(hash)) { + this._generalBarrierss.set(hash, new GeneralBarrier(info, hash)); } - return this._generalBarrierss$.get(hash)!; + return this._generalBarrierss.get(hash)!; } public getTextureBarrier (info: Readonly): TextureBarrier { const hash = TextureBarrier.computeHash(info); - if (!this._textureBarriers$.has(hash)) { - this._textureBarriers$.set(hash, new TextureBarrier(info, hash)); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info, hash)); } - return this._textureBarriers$.get(hash)!; + return this._textureBarriers.get(hash)!; } public getBufferBarrier (info: Readonly): BufferBarrier { const hash = BufferBarrier.computeHash(info); - if (!this._bufferBarriers$.has(hash)) { - this._bufferBarriers$.set(hash, new BufferBarrier(info, hash)); + if (!this._bufferBarriers.has(hash)) { + this._bufferBarriers.set(hash, new BufferBarrier(info, hash)); } - return this._bufferBarriers$.get(hash)!; + return this._bufferBarriers.get(hash)!; } public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { diff --git a/cocos/gfx/webgl2/webgl2-framebuffer.ts b/cocos/gfx/webgl2/webgl2-framebuffer.ts index 5e7501e2102..f4508bf9511 100644 --- a/cocos/gfx/webgl2/webgl2-framebuffer.ts +++ b/cocos/gfx/webgl2/webgl2-framebuffer.ts @@ -35,23 +35,23 @@ export class WebGL2Framebuffer extends Framebuffer { super(); } - getGpuFramebuffer$ (): IWebGL2GPUFramebuffer { - return this._gpuFramebuffer$!; + getGpuFramebuffer (): IWebGL2GPUFramebuffer { + return this._gpuFramebuffer!; } - private _gpuFramebuffer$: IWebGL2GPUFramebuffer | null = null; - private _gpuColorViews$: (WebGLTexture | null)[] = []; - private _gpuDepthStencilView$: WebGLTexture | null | undefined; + private _gpuFramebuffer: IWebGL2GPUFramebuffer | null = null; + private _gpuColorViews: (WebGLTexture | null)[] = []; + private _gpuDepthStencilView: WebGLTexture | null | undefined; get needRebuild (): boolean { - const gpuFramebuffer = this.getGpuFramebuffer$(); + const gpuFramebuffer = this.getGpuFramebuffer(); if (gpuFramebuffer) { - for (let i = 0; i < gpuFramebuffer.gpuColorViews$.length; i++) { - if (gpuFramebuffer.gpuColorViews$[i].gpuTexture$.glTexture$ !== this._gpuColorViews$[i]) { + for (let i = 0; i < gpuFramebuffer.gpuColorViews.length; i++) { + if (gpuFramebuffer.gpuColorViews[i].gpuTexture.glTexture !== this._gpuColorViews[i]) { return true; } } - if (gpuFramebuffer.gpuDepthStencilView$?.gpuTexture$.glTexture$ !== this._gpuDepthStencilView$) { + if (gpuFramebuffer.gpuDepthStencilView?.gpuTexture.glTexture !== this._gpuDepthStencilView) { return true; } } @@ -60,9 +60,9 @@ export class WebGL2Framebuffer extends Framebuffer { } public initialize (info: Readonly): void { - this._renderPass$ = info.renderPass; - this._colorTextures$ = info.colorTextures || []; - this._depthStencilTexture$ = info.depthStencilTexture || null; + this._renderPass = info.renderPass; + this._colorTextures = info.colorTextures || []; + this._depthStencilTexture = info.depthStencilTexture || null; const gpuColorViews: IWebGL2GPUTextureView[] = []; for (let i = 0; i < info.colorTextures.length; i++) { @@ -79,17 +79,17 @@ export class WebGL2Framebuffer extends Framebuffer { let width = Number.MAX_SAFE_INTEGER; let height = Number.MAX_SAFE_INTEGER; - this._gpuFramebuffer$ = { - gpuRenderPass$: (info.renderPass as WebGL2RenderPass).getGpuRenderPass$(), - gpuColorViews$: gpuColorViews, - gpuDepthStencilView$: gpuDepthStencilView, - glFramebuffer$: null, - isOffscreen$: true, + this._gpuFramebuffer = { + gpuRenderPass: (info.renderPass as WebGL2RenderPass).getGpuRenderPass(), + gpuColorViews: gpuColorViews, + gpuDepthStencilView: gpuDepthStencilView, + glFramebuffer: null, + isOffscreen: true, get width (): number { - if (this.gpuColorViews$.length > 0) { - return this.gpuColorViews$[0].gpuTexture$.width$; - } else if (this.gpuDepthStencilView$) { - return this.gpuDepthStencilView$.gpuTexture$.width$; + if (this.gpuColorViews.length > 0) { + return this.gpuColorViews[0].gpuTexture.width; + } else if (this.gpuDepthStencilView) { + return this.gpuDepthStencilView.gpuTexture.width; } return width; }, @@ -97,10 +97,10 @@ export class WebGL2Framebuffer extends Framebuffer { width = val; }, get height (): number { - if (this.gpuColorViews$.length > 0) { - return this.gpuColorViews$[0].gpuTexture$.height$; - } else if (this.gpuDepthStencilView$) { - return this.gpuDepthStencilView$.gpuTexture$.height$; + if (this.gpuColorViews.length > 0) { + return this.gpuColorViews[0].gpuTexture.height; + } else if (this.gpuDepthStencilView) { + return this.gpuDepthStencilView.gpuTexture.height; } return height; }, @@ -109,19 +109,19 @@ export class WebGL2Framebuffer extends Framebuffer { }, }; - WebGL2CmdFuncCreateFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer$); - this._gpuFramebuffer$.gpuColorViews$.forEach((tex) => this._gpuColorViews$.push(tex.gpuTexture$.glTexture$)); - this._gpuDepthStencilView$ = this._gpuFramebuffer$.gpuDepthStencilView$?.gpuTexture$.glTexture$; - this._width$ = this._gpuFramebuffer$.width; - this._height$ = this._gpuFramebuffer$.height; + WebGL2CmdFuncCreateFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer); + this._gpuFramebuffer.gpuColorViews.forEach((tex) => this._gpuColorViews.push(tex.gpuTexture.glTexture)); + this._gpuDepthStencilView = this._gpuFramebuffer.gpuDepthStencilView?.gpuTexture.glTexture; + this._width = this._gpuFramebuffer.width; + this._height = this._gpuFramebuffer.height; } public destroy (): void { - if (this._gpuFramebuffer$) { - WebGL2CmdFuncDestroyFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer$); - this._gpuFramebuffer$ = null; - this._gpuColorViews$.length = 0; - this._gpuDepthStencilView$ = null; + if (this._gpuFramebuffer) { + WebGL2CmdFuncDestroyFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer); + this._gpuFramebuffer = null; + this._gpuColorViews.length = 0; + this._gpuDepthStencilView = null; } } } diff --git a/cocos/gfx/webgl2/webgl2-gpu-objects.ts b/cocos/gfx/webgl2/webgl2-gpu-objects.ts index 96beaac9ae1..1cdec040420 100644 --- a/cocos/gfx/webgl2/webgl2-gpu-objects.ts +++ b/cocos/gfx/webgl2/webgl2-gpu-objects.ts @@ -33,316 +33,316 @@ import { WebGL2DeviceManager } from './webgl2-define'; import { WebGL2Device } from './webgl2-device'; export class WebGL2IndirectDrawInfos { - public counts$: Int32Array; - public offsets$: Int32Array; - public instances$: Int32Array; - public drawCount$ = 0; - public drawByIndex$ = false; - public instancedDraw$ = false; + public counts: Int32Array; + public offsets: Int32Array; + public instances: Int32Array; + public drawCount = 0; + public drawByIndex = false; + public instancedDraw = false; // staging buffer - public byteOffsets$: Int32Array; + public byteOffsets: Int32Array; - private _capacity$ = 4; + private _capacity = 4; constructor () { - this.counts$ = new Int32Array(this._capacity$); - this.offsets$ = new Int32Array(this._capacity$); - this.instances$ = new Int32Array(this._capacity$); - this.byteOffsets$ = new Int32Array(this._capacity$); + this.counts = new Int32Array(this._capacity); + this.offsets = new Int32Array(this._capacity); + this.instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); } - public clearDraws$ (): void { - this.drawCount$ = 0; - this.drawByIndex$ = false; - this.instancedDraw$ = false; + public clearDraws (): void { + this.drawCount = 0; + this.drawByIndex = false; + this.instancedDraw = false; } - public setDrawInfo$ (idx: number, info: Readonly): void { - this._ensureCapacity$(idx); - this.drawByIndex$ = info.indexCount > 0; - this.instancedDraw$ = !!info.instanceCount; - this.drawCount$ = Math.max(idx + 1, this.drawCount$); + public setDrawInfo (idx: number, info: Readonly): void { + this._ensureCapacity(idx); + this.drawByIndex = info.indexCount > 0; + this.instancedDraw = !!info.instanceCount; + this.drawCount = Math.max(idx + 1, this.drawCount); - if (this.drawByIndex$) { - this.counts$[idx] = info.indexCount; - this.offsets$[idx] = info.firstIndex; + if (this.drawByIndex) { + this.counts[idx] = info.indexCount; + this.offsets[idx] = info.firstIndex; } else { - this.counts$[idx] = info.vertexCount; - this.offsets$[idx] = info.firstVertex; + this.counts[idx] = info.vertexCount; + this.offsets[idx] = info.firstVertex; } - this.instances$[idx] = Math.max(1, info.instanceCount); + this.instances[idx] = Math.max(1, info.instanceCount); } - private _ensureCapacity$ (target: number): void { - if (this._capacity$ > target) return; - this._capacity$ = nextPow2(target); + private _ensureCapacity (target: number): void { + if (this._capacity > target) return; + this._capacity = nextPow2(target); - const counts = new Int32Array(this._capacity$); - const offsets = new Int32Array(this._capacity$); - const instances = new Int32Array(this._capacity$); - this.byteOffsets$ = new Int32Array(this._capacity$); + const counts = new Int32Array(this._capacity); + const offsets = new Int32Array(this._capacity); + const instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); - counts.set(this.counts$); - offsets.set(this.offsets$); - instances.set(this.instances$); + counts.set(this.counts); + offsets.set(this.offsets); + instances.set(this.instances); - this.counts$ = counts; - this.offsets$ = offsets; - this.instances$ = instances; + this.counts = counts; + this.offsets = offsets; + this.instances = instances; } } export interface IWebGL2BindingMapping { - blockOffsets$: number[]; - samplerTextureOffsets$: number[]; - flexibleSet$: number; + blockOffsets: number[]; + samplerTextureOffsets: number[]; + flexibleSet: number; } export interface IWebGL2GPUUniformInfo { - name$: string; - type$: Type; - count$: number; - offset$: number; - view$: Float32Array | Int32Array; - isDirty$: boolean; + name: string; + type: Type; + count: number; + offset: number; + view: Float32Array | Int32Array; + isDirty: boolean; } export interface IWebGL2GPUBuffer { - usage$: BufferUsage; - memUsage$: MemoryUsage; - size$: number; - stride$: number; + usage: BufferUsage; + memUsage: MemoryUsage; + size: number; + stride: number; - glTarget$: GLenum; - glBuffer$: WebGLBuffer | null; - glOffset$: number; + glTarget: GLenum; + glBuffer: WebGLBuffer | null; + glOffset: number; - buffer$: ArrayBufferView | null; - indirects$: WebGL2IndirectDrawInfos; + buffer: ArrayBufferView | null; + indirects: WebGL2IndirectDrawInfos; } export interface IWebGL2GPUTexture { - type$: TextureType; - format$: Format; - usage$: TextureUsage; - width$: number; - height$: number; - depth$: number; - size$: number; - arrayLayer$: number; - mipLevel$: number; - samples$: SampleCount; - flags$: TextureFlags; - isPowerOf2$: boolean; - - glTarget$: GLenum; - glInternalFmt$: GLenum; - glFormat$: GLenum; - glType$: GLenum; - glUsage$: GLenum; - glTexture$: WebGLTexture | null; - glRenderbuffer$: WebGLRenderbuffer | null; - glWrapS$: GLenum; - glWrapT$: GLenum; - glMinFilter$: GLenum; - glMagFilter$: GLenum; - - isSwapchainTexture$: boolean; + type: TextureType; + format: Format; + usage: TextureUsage; + width: number; + height: number; + depth: number; + size: number; + arrayLayer: number; + mipLevel: number; + samples: SampleCount; + flags: TextureFlags; + isPowerOf2: boolean; + + glTarget: GLenum; + glInternalFmt: GLenum; + glFormat: GLenum; + glType: GLenum; + glUsage: GLenum; + glTexture: WebGLTexture | null; + glRenderbuffer: WebGLRenderbuffer | null; + glWrapS: GLenum; + glWrapT: GLenum; + glMinFilter: GLenum; + glMagFilter: GLenum; + + isSwapchainTexture: boolean; } export interface IWebGL2GPUTextureView { - gpuTexture$: IWebGL2GPUTexture; - type$: TextureType; - format$: Format; - baseLevel$: number; - levelCount$: number; + gpuTexture: IWebGL2GPUTexture; + type: TextureType; + format: Format; + baseLevel: number; + levelCount: number; } export interface IWebGL2GPURenderPass { - colorAttachments$: ColorAttachment[]; - depthStencilAttachment$: DepthStencilAttachment | null; + colorAttachments: ColorAttachment[]; + depthStencilAttachment: DepthStencilAttachment | null; } export interface IWebGL2GPUFramebuffer { - gpuRenderPass$: IWebGL2GPURenderPass; - gpuColorViews$: IWebGL2GPUTextureView[]; - gpuDepthStencilView$: IWebGL2GPUTextureView | null; - glFramebuffer$: WebGLFramebuffer | null; - isOffscreen$: boolean; + gpuRenderPass: IWebGL2GPURenderPass; + gpuColorViews: IWebGL2GPUTextureView[]; + gpuDepthStencilView: IWebGL2GPUTextureView | null; + glFramebuffer: WebGLFramebuffer | null; + isOffscreen: boolean; width: number; height: number; } export interface IWebGL2GPUSampler { - glSamplers$: Map; - - minFilter$: Filter; - magFilter$: Filter; - mipFilter$: Filter; - addressU$: Address; - addressV$: Address; - addressW$: Address; - - glMinFilter$: GLenum; - glMagFilter$: GLenum; - glWrapS$: GLenum; - glWrapT$: GLenum; - glWrapR$: GLenum; - - getGLSampler$ (device: WebGL2Device, minLod: number, maxLod: number): WebGLSampler; + glSamplers: Map; + + minFilter: Filter; + magFilter: Filter; + mipFilter: Filter; + addressU: Address; + addressV: Address; + addressW: Address; + + glMinFilter: GLenum; + glMagFilter: GLenum; + glWrapS: GLenum; + glWrapT: GLenum; + glWrapR: GLenum; + + getGLSampler (device: WebGL2Device, minLod: number, maxLod: number): WebGLSampler; } export interface IWebGL2GPUInput { - name$: string; - type$: Type; - stride$: number; - count$: number; - size$: number; - - glType$: GLenum; - glLoc$: GLint; + name: string; + type: Type; + stride: number; + count: number; + size: number; + + glType: GLenum; + glLoc: GLint; } export interface IWebGL2GPUUniform { - binding$: number; - name$: string; - type$: Type; - stride$: number; - count$: number; - size$: number; - offset$: number; - - glType$: GLenum; - glLoc$: WebGLUniformLocation; - array$: number[]; - begin$: number; + binding: number; + name: string; + type: Type; + stride: number; + count: number; + size: number; + offset: number; + + glType: GLenum; + glLoc: WebGLUniformLocation; + array: number[]; + begin: number; } export interface IWebGL2GPUUniformBlock { - set$: number; - binding$: number; - idx$: number; - name$: string; - size$: number; - glBinding$: number; + set: number; + binding: number; + idx: number; + name: string; + size: number; + glBinding: number; } export interface IWebGL2GPUUniformSamplerTexture { - set$: number; - binding$: number; - name$: string; - type$: Type; - count$: number; - units$: number[]; - glUnits$: Int32Array; - - glType$: GLenum; - glLoc$: WebGLUniformLocation; + set: number; + binding: number; + name: string; + type: Type; + count: number; + units: number[]; + glUnits: Int32Array; + + glType: GLenum; + glLoc: WebGLUniformLocation; } export interface IWebGL2GPUShaderStage { - type$: ShaderStageFlagBit; - source$: string; - glShader$: WebGLShader | null; + type: ShaderStageFlagBit; + source: string; + glShader: WebGLShader | null; } export interface IWebGL2GPUShader { - name$: string; - blocks$: UniformBlock[]; - samplerTextures$: UniformSamplerTexture[]; - subpassInputs$: UniformInputAttachment[]; - - gpuStages$: IWebGL2GPUShaderStage[]; - glProgram$: WebGLProgram | null; - glInputs$: IWebGL2GPUInput[]; - glUniforms$: IWebGL2GPUUniform[]; - glBlocks$: IWebGL2GPUUniformBlock[]; - glSamplerTextures$: IWebGL2GPUUniformSamplerTexture[]; + name: string; + blocks: UniformBlock[]; + samplerTextures: UniformSamplerTexture[]; + subpassInputs: UniformInputAttachment[]; + + gpuStages: IWebGL2GPUShaderStage[]; + glProgram: WebGLProgram | null; + glInputs: IWebGL2GPUInput[]; + glUniforms: IWebGL2GPUUniform[]; + glBlocks: IWebGL2GPUUniformBlock[]; + glSamplerTextures: IWebGL2GPUUniformSamplerTexture[]; } export interface IWebGL2GPUDescriptorSetLayout { - bindings$: DescriptorSetLayoutBinding[]; - dynamicBindings$: number[]; - descriptorIndices$: number[]; - descriptorCount$: number; + bindings: DescriptorSetLayoutBinding[]; + dynamicBindings: number[]; + descriptorIndices: number[]; + descriptorCount: number; } export interface IWebGL2GPUPipelineLayout { - gpuSetLayouts$: IWebGL2GPUDescriptorSetLayout[]; - dynamicOffsetCount$: number; - dynamicOffsetOffsets$: number[]; - dynamicOffsetIndices$: number[][]; + gpuSetLayouts: IWebGL2GPUDescriptorSetLayout[]; + dynamicOffsetCount: number; + dynamicOffsetOffsets: number[]; + dynamicOffsetIndices: number[][]; } export interface IWebGL2GPUPipelineState { - glPrimitive$: GLenum; - gpuShader$: IWebGL2GPUShader | null; - gpuPipelineLayout$: IWebGL2GPUPipelineLayout | null; - rs$: RasterizerState; - dss$: DepthStencilState; - bs$: BlendState; - dynamicStates$: DynamicStateFlagBit[]; - gpuRenderPass$: IWebGL2GPURenderPass | null; + glPrimitive: GLenum; + gpuShader: IWebGL2GPUShader | null; + gpuPipelineLayout: IWebGL2GPUPipelineLayout | null; + rs: RasterizerState; + dss: DepthStencilState; + bs: BlendState; + dynamicStates: DynamicStateFlagBit[]; + gpuRenderPass: IWebGL2GPURenderPass | null; } export interface IWebGL2GPUDescriptor { - type$: DescriptorType; - gpuBuffer$: IWebGL2GPUBuffer | null; - gpuTextureView$: IWebGL2GPUTextureView | null; - gpuSampler$: IWebGL2GPUSampler | null; + type: DescriptorType; + gpuBuffer: IWebGL2GPUBuffer | null; + gpuTextureView: IWebGL2GPUTextureView | null; + gpuSampler: IWebGL2GPUSampler | null; } export interface IWebGL2GPUDescriptorSet { - gpuDescriptors$: IWebGL2GPUDescriptor[]; - descriptorIndices$: number[]; + gpuDescriptors: IWebGL2GPUDescriptor[]; + descriptorIndices: number[]; } export interface IWebGL2Attrib { - name$: string; - glBuffer$: WebGLBuffer | null; - glType$: GLenum; - size$: number; - count$: number; - stride$: number; - componentCount$: number; - isNormalized$: boolean; - isInstanced$: boolean; - offset$: number; + name: string; + glBuffer: WebGLBuffer | null; + glType: GLenum; + size: number; + count: number; + stride: number; + componentCount: number; + isNormalized: boolean; + isInstanced: boolean; + offset: number; } export interface IWebGL2GPUInputAssembler { - attributes$: Attribute[]; - gpuVertexBuffers$: IWebGL2GPUBuffer[]; - gpuIndexBuffer$: IWebGL2GPUBuffer | null; - gpuIndirectBuffer$: IWebGL2GPUBuffer | null; - - glAttribs$: IWebGL2Attrib[]; - glIndexType$: GLenum; - glVAOs$: Map; + attributes: Attribute[]; + gpuVertexBuffers: IWebGL2GPUBuffer[]; + gpuIndexBuffer: IWebGL2GPUBuffer | null; + gpuIndirectBuffer: IWebGL2GPUBuffer | null; + + glAttribs: IWebGL2Attrib[]; + glIndexType: GLenum; + glVAOs: Map; } export class IWebGL2BlitManager { - private _srcFramebuffer$: WebGLFramebuffer | null; - private _dstFramebuffer$: WebGLFramebuffer | null; + private _srcFramebuffer: WebGLFramebuffer | null; + private _dstFramebuffer: WebGLFramebuffer | null; get srcFramebuffer (): WebGLFramebuffer | null { - return this._srcFramebuffer$; + return this._srcFramebuffer; } get dstFramebuffer (): WebGLFramebuffer | null { - return this._dstFramebuffer$; + return this._dstFramebuffer; } constructor () { const { gl } = WebGL2DeviceManager.instance; - this._srcFramebuffer$ = gl.createFramebuffer(); - this._dstFramebuffer$ = gl.createFramebuffer(); + this._srcFramebuffer = gl.createFramebuffer(); + this._dstFramebuffer = gl.createFramebuffer(); } - destroy$ (): void { + destroy (): void { const { gl } = WebGL2DeviceManager.instance; - gl.deleteFramebuffer(this._srcFramebuffer$); - gl.deleteFramebuffer(this._dstFramebuffer$); + gl.deleteFramebuffer(this._srcFramebuffer); + gl.deleteFramebuffer(this._dstFramebuffer); } } diff --git a/cocos/gfx/webgl2/webgl2-input-assembler.ts b/cocos/gfx/webgl2/webgl2-input-assembler.ts index edd54916dd5..f0da776292c 100644 --- a/cocos/gfx/webgl2/webgl2-input-assembler.ts +++ b/cocos/gfx/webgl2/webgl2-input-assembler.ts @@ -37,10 +37,10 @@ export class WebGL2InputAssembler extends InputAssembler { } public get gpuInputAssembler (): IWebGL2GPUInputAssembler { - return this._gpuInputAssembler$!; + return this._gpuInputAssembler!; } - private _gpuInputAssembler$: IWebGL2GPUInputAssembler | null = null; + private _gpuInputAssembler: IWebGL2GPUInputAssembler | null = null; public initialize (info: Readonly): void { if (info.vertexBuffers.length === 0) { @@ -48,39 +48,39 @@ export class WebGL2InputAssembler extends InputAssembler { return; } - this._attributes$ = info.attributes; - this._attributesHash$ = this.computeAttributesHash$(); - this._vertexBuffers$ = info.vertexBuffers; + this._attributes = info.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = info.vertexBuffers; if (info.indexBuffer) { - this._indexBuffer$ = info.indexBuffer; - this._drawInfo$.indexCount = this._indexBuffer$.size / this._indexBuffer$.stride; - this._drawInfo$.firstIndex = 0; + this._indexBuffer = info.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; } else { - const vertBuff = this._vertexBuffers$[0]; - this._drawInfo$.vertexCount = vertBuff.size / vertBuff.stride; - this._drawInfo$.firstVertex = 0; - this._drawInfo$.vertexOffset = 0; + const vertBuff = this._vertexBuffers[0]; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; } - this._drawInfo$.instanceCount = 0; - this._drawInfo$.firstInstance = 0; + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; - this._indirectBuffer$ = info.indirectBuffer || null; + this._indirectBuffer = info.indirectBuffer || null; const gpuVertexBuffers: IWebGL2GPUBuffer[] = new Array(info.vertexBuffers.length); for (let i = 0; i < info.vertexBuffers.length; ++i) { const vb = info.vertexBuffers[i] as WebGL2Buffer; - if (vb.getGpuBuffer$()) { - gpuVertexBuffers[i] = vb.getGpuBuffer$(); + if (vb.getGpuBuffer()) { + gpuVertexBuffers[i] = vb.getGpuBuffer(); } } let gpuIndexBuffer: IWebGL2GPUBuffer | null = null; let glIndexType = 0; if (info.indexBuffer) { - gpuIndexBuffer = (info.indexBuffer as WebGL2Buffer).getGpuBuffer$(); + gpuIndexBuffer = (info.indexBuffer as WebGL2Buffer).getGpuBuffer(); if (gpuIndexBuffer) { - switch (gpuIndexBuffer.stride$) { + switch (gpuIndexBuffer.stride) { case 1: glIndexType = WebGLConstants.UNSIGNED_BYTE; break; case 2: glIndexType = WebGLConstants.UNSIGNED_SHORT; break; case 4: glIndexType = WebGLConstants.UNSIGNED_INT; break; @@ -93,28 +93,28 @@ export class WebGL2InputAssembler extends InputAssembler { let gpuIndirectBuffer: IWebGL2GPUBuffer | null = null; if (info.indirectBuffer) { - gpuIndirectBuffer = (info.indirectBuffer as WebGL2Buffer).getGpuBuffer$(); + gpuIndirectBuffer = (info.indirectBuffer as WebGL2Buffer).getGpuBuffer(); } - this._gpuInputAssembler$ = { - attributes$: info.attributes, - gpuVertexBuffers$: gpuVertexBuffers, - gpuIndexBuffer$: gpuIndexBuffer, - gpuIndirectBuffer$: gpuIndirectBuffer, + this._gpuInputAssembler = { + attributes: info.attributes, + gpuVertexBuffers, + gpuIndexBuffer, + gpuIndirectBuffer, - glAttribs$: [], - glIndexType$: glIndexType, - glVAOs$: new Map(), + glAttribs: [], + glIndexType, + glVAOs: new Map(), }; - WebGL2CmdFuncCreateInputAssember(WebGL2DeviceManager.instance, this._gpuInputAssembler$); + WebGL2CmdFuncCreateInputAssember(WebGL2DeviceManager.instance, this._gpuInputAssembler); } public destroy (): void { const device = WebGL2DeviceManager.instance; - if (this._gpuInputAssembler$ && device.extensions.useVAO$) { - WebGL2CmdFuncDestroyInputAssembler(device, this._gpuInputAssembler$); + if (this._gpuInputAssembler && device.extensions.useVAO) { + WebGL2CmdFuncDestroyInputAssembler(device, this._gpuInputAssembler); } - this._gpuInputAssembler$ = null; + this._gpuInputAssembler = null; } } diff --git a/cocos/gfx/webgl2/webgl2-pipeline-layout.ts b/cocos/gfx/webgl2/webgl2-pipeline-layout.ts index e99a46f2ce7..e6c33b952e8 100644 --- a/cocos/gfx/webgl2/webgl2-pipeline-layout.ts +++ b/cocos/gfx/webgl2/webgl2-pipeline-layout.ts @@ -32,22 +32,22 @@ export class WebGL2PipelineLayout extends PipelineLayout { super(); } - getGpuPipelineLayout$ (): IWebGL2GPUPipelineLayout { return this._gpuPipelineLayout$!; } + getGpuPipelineLayout (): IWebGL2GPUPipelineLayout { return this._gpuPipelineLayout!; } - private _gpuPipelineLayout$: IWebGL2GPUPipelineLayout | null = null; + private _gpuPipelineLayout: IWebGL2GPUPipelineLayout | null = null; public initialize (info: Readonly): void { - Array.prototype.push.apply(this._setLayouts$, info.setLayouts); + Array.prototype.push.apply(this._setLayouts, info.setLayouts); const dynamicOffsetIndices: number[][] = []; const gpuSetLayouts: IWebGL2GPUDescriptorSetLayout[] = []; let dynamicOffsetCount = 0; const dynamicOffsetOffsets: number[] = []; - for (let i = 0; i < this._setLayouts$.length; i++) { - const setLayout = this._setLayouts$[i] as WebGL2DescriptorSetLayout; - const gpuDescriptorSetLayout = setLayout.getGpuDescriptorSetLayout$(); - const dynamicBindings = gpuDescriptorSetLayout.dynamicBindings$; + for (let i = 0; i < this._setLayouts.length; i++) { + const setLayout = this._setLayouts[i] as WebGL2DescriptorSetLayout; + const gpuDescriptorSetLayout = setLayout.getGpuDescriptorSetLayout(); + const dynamicBindings = gpuDescriptorSetLayout.dynamicBindings; const indices = Array(setLayout.bindingIndices.length).fill(-1); for (let j = 0; j < dynamicBindings.length; j++) { const binding = dynamicBindings[j]; @@ -60,15 +60,15 @@ export class WebGL2PipelineLayout extends PipelineLayout { dynamicOffsetCount += dynamicBindings.length; } - this._gpuPipelineLayout$ = { - gpuSetLayouts$: gpuSetLayouts, - dynamicOffsetIndices$: dynamicOffsetIndices, - dynamicOffsetCount$: dynamicOffsetCount, - dynamicOffsetOffsets$: dynamicOffsetOffsets, + this._gpuPipelineLayout = { + gpuSetLayouts, + dynamicOffsetIndices, + dynamicOffsetCount, + dynamicOffsetOffsets, }; } public destroy (): void { - this._setLayouts$.length = 0; + this._setLayouts.length = 0; } } diff --git a/cocos/gfx/webgl2/webgl2-pipeline-state.ts b/cocos/gfx/webgl2/webgl2-pipeline-state.ts index b8e2ac3eae9..257a5f55556 100644 --- a/cocos/gfx/webgl2/webgl2-pipeline-state.ts +++ b/cocos/gfx/webgl2/webgl2-pipeline-state.ts @@ -53,16 +53,16 @@ export class WebGL2PipelineState extends PipelineState { } get gpuPipelineState (): IWebGL2GPUPipelineState { - return this._gpuPipelineState$!; + return this._gpuPipelineState!; } - private _gpuPipelineState$: IWebGL2GPUPipelineState | null = null; + private _gpuPipelineState: IWebGL2GPUPipelineState | null = null; public initialize (info: Readonly): void { - this._primitive$ = info.primitive; - this._shader$ = info.shader; - this._pipelineLayout$ = info.pipelineLayout; - const bs = this._bs$; + this._primitive = info.primitive; + this._shader = info.shader; + this._pipelineLayout = info.pipelineLayout; + const bs = this._bs; if (info.blendState) { const bsInfo = info.blendState; const { targets } = bsInfo; @@ -76,32 +76,32 @@ export class WebGL2PipelineState extends PipelineState { if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; } if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor; } } - Object.assign(this._rs$, info.rasterizerState); - Object.assign(this._dss$, info.depthStencilState); - this._is$ = info.inputState; - this._renderPass$ = info.renderPass; - this._dynamicStates$ = info.dynamicStates; + Object.assign(this._rs, info.rasterizerState); + Object.assign(this._dss, info.depthStencilState); + this._is = info.inputState; + this._renderPass = info.renderPass; + this._dynamicStates = info.dynamicStates; const dynamicStates: DynamicStateFlagBit[] = []; for (let i = 0; i < 31; i++) { - if (this._dynamicStates$ & (1 << i)) { + if (this._dynamicStates & (1 << i)) { dynamicStates.push(1 << i); } } - this._gpuPipelineState$ = { - glPrimitive$: WebGLPrimitives[info.primitive], - gpuShader$: (info.shader as WebGL2Shader).gpuShader, - gpuPipelineLayout$: (info.pipelineLayout as WebGL2PipelineLayout).getGpuPipelineLayout$(), - rs$: info.rasterizerState, - dss$: info.depthStencilState, - bs$: info.blendState, - gpuRenderPass$: (info.renderPass as WebGL2RenderPass).getGpuRenderPass$(), - dynamicStates$: dynamicStates, + this._gpuPipelineState = { + glPrimitive: WebGLPrimitives[info.primitive], + gpuShader: (info.shader as WebGL2Shader).gpuShader, + gpuPipelineLayout: (info.pipelineLayout as WebGL2PipelineLayout).getGpuPipelineLayout(), + rs: info.rasterizerState, + dss: info.depthStencilState, + bs: info.blendState, + gpuRenderPass: (info.renderPass as WebGL2RenderPass).getGpuRenderPass(), + dynamicStates, }; } public destroy (): void { - this._gpuPipelineState$ = null; + this._gpuPipelineState = null; } } diff --git a/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts b/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts index d61b0346fec..61ba412e7ad 100644 --- a/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts @@ -55,19 +55,19 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { ): void { WebGL2CmdFuncBeginRenderPass( WebGL2DeviceManager.instance, - (renderPass as WebGL2RenderPass).getGpuRenderPass$(), - (framebuffer as WebGL2Framebuffer).getGpuFramebuffer$(), + (renderPass as WebGL2RenderPass).getGpuRenderPass(), + (framebuffer as WebGL2Framebuffer).getGpuFramebuffer(), renderArea, clearColors, clearDepth, clearStencil, ); - this._isInRenderPass$ = true; + this._isInRenderPass = true; } public draw (infoOrAssembler: Readonly | Readonly): void { - if (this._isInRenderPass$) { - if (this._isStateInvalid$) { + if (this._isInRenderPass) { + if (this._isStateInvalid) { this.bindStates(); } @@ -75,19 +75,19 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { WebGL2CmdFuncDraw(WebGL2DeviceManager.instance, info as DrawInfo); - ++this._numDrawCalls$; - this._numInstances$ += info.instanceCount; + ++this._numDrawCalls; + this._numInstances += info.instanceCount; const indexCount = info.indexCount || info.vertexCount; - if (this._curGPUPipelineState$) { - const glPrimitive = this._curGPUPipelineState$.glPrimitive$; + if (this._curGPUPipelineState) { + const glPrimitive = this._curGPUPipelineState.glPrimitive; switch (glPrimitive) { case 0x0004: { // WebGLRenderingContext.TRIANGLES - this._numTris$ += indexCount / 3 * Math.max(info.instanceCount, 1); + this._numTris += indexCount / 3 * Math.max(info.instanceCount, 1); break; } case 0x0005: // WebGLRenderingContext.TRIANGLE_STRIP case 0x0006: { // WebGLRenderingContext.TRIANGLE_FAN - this._numTris$ += (indexCount - 2) * Math.max(info.instanceCount, 1); + this._numTris += (indexCount - 2) * Math.max(info.instanceCount, 1); break; } default: @@ -100,41 +100,41 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { public setViewport (viewport: Readonly): void { const { gl } = WebGL2DeviceManager.instance; - const cache = WebGL2DeviceManager.instance.getStateCache$(); + const cache = WebGL2DeviceManager.instance.getStateCache(); - if (cache.viewport$.left !== viewport.left - || cache.viewport$.top !== viewport.top - || cache.viewport$.width !== viewport.width - || cache.viewport$.height !== viewport.height) { + if (cache.viewport.left !== viewport.left + || cache.viewport.top !== viewport.top + || cache.viewport.width !== viewport.width + || cache.viewport.height !== viewport.height) { gl.viewport(viewport.left, viewport.top, viewport.width, viewport.height); - cache.viewport$.left = viewport.left; - cache.viewport$.top = viewport.top; - cache.viewport$.width = viewport.width; - cache.viewport$.height = viewport.height; + cache.viewport.left = viewport.left; + cache.viewport.top = viewport.top; + cache.viewport.width = viewport.width; + cache.viewport.height = viewport.height; } } public setScissor (scissor: Readonly): void { const { gl } = WebGL2DeviceManager.instance; - const cache = WebGL2DeviceManager.instance.getStateCache$(); + const cache = WebGL2DeviceManager.instance.getStateCache(); - if (cache.scissorRect$.x !== scissor.x - || cache.scissorRect$.y !== scissor.y - || cache.scissorRect$.width !== scissor.width - || cache.scissorRect$.height !== scissor.height) { + if (cache.scissorRect.x !== scissor.x + || cache.scissorRect.y !== scissor.y + || cache.scissorRect.width !== scissor.width + || cache.scissorRect.height !== scissor.height) { gl.scissor(scissor.x, scissor.y, scissor.width, scissor.height); - cache.scissorRect$.x = scissor.x; - cache.scissorRect$.y = scissor.y; - cache.scissorRect$.width = scissor.width; - cache.scissorRect$.height = scissor.height; + cache.scissorRect.x = scissor.x; + cache.scissorRect.y = scissor.y; + cache.scissorRect.width = scissor.width; + cache.scissorRect.height = scissor.height; } } public updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { - if (!this._isInRenderPass$) { - const gpuBuffer = (buffer as WebGL2Buffer).getGpuBuffer$(); + if (!this._isInRenderPass) { + const gpuBuffer = (buffer as WebGL2Buffer).getGpuBuffer(); if (gpuBuffer) { let buffSize: number; if (size !== undefined) { @@ -153,7 +153,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { } public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { - if (!this._isInRenderPass$) { + if (!this._isInRenderPass) { const gpuTexture = (texture as WebGL2Texture).gpuTexture; if (gpuTexture) { WebGL2CmdFuncCopyBuffersToTexture(WebGL2DeviceManager.instance, buffers, gpuTexture, regions); @@ -170,13 +170,13 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { protected bindStates (): void { WebGL2CmdFuncBindStates( WebGL2DeviceManager.instance, - this._curGPUPipelineState$, - this._curGPUInputAssembler$, - this._curGPUDescriptorSets$, - this._curDynamicOffsets$, - this._curDynamicStates$, + this._curGPUPipelineState, + this._curGPUInputAssembler, + this._curGPUDescriptorSets, + this._curDynamicOffsets, + this._curDynamicStates, ); - this._isStateInvalid$ = false; + this._isStateInvalid = false; } public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { diff --git a/cocos/gfx/webgl2/webgl2-queue.ts b/cocos/gfx/webgl2/webgl2-queue.ts index 3d6609c6759..998ae40c5c1 100644 --- a/cocos/gfx/webgl2/webgl2-queue.ts +++ b/cocos/gfx/webgl2/webgl2-queue.ts @@ -28,16 +28,16 @@ import { Queue } from '../base/queue'; import { WebGL2CommandBuffer } from './webgl2-command-buffer'; export class WebGL2Queue extends Queue { - public numDrawCalls$ = 0; - public numInstances$ = 0; - public numTris$ = 0; + public numDrawCalls = 0; + public numInstances = 0; + public numTris = 0; constructor () { super(); } public initialize (info: Readonly): void { - this._type$ = info.type; + this._type = info.type; } public destroy (): void { @@ -47,15 +47,15 @@ export class WebGL2Queue extends Queue { for (let i = 0; i < cmdBuffs.length; i++) { const cmdBuff = cmdBuffs[i] as WebGL2CommandBuffer; // WebGL2CmdFuncExecuteCmds(this._device as WebGL2Device, cmdBuff.cmdPackage); // opted out - this.numDrawCalls$ += cmdBuff.numDrawCalls; - this.numInstances$ += cmdBuff.numInstances; - this.numTris$ += cmdBuff.numTris; + this.numDrawCalls += cmdBuff.numDrawCalls; + this.numInstances += cmdBuff.numInstances; + this.numTris += cmdBuff.numTris; } } public clear (): void { - this.numDrawCalls$ = 0; - this.numInstances$ = 0; - this.numTris$ = 0; + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; } } diff --git a/cocos/gfx/webgl2/webgl2-render-pass.ts b/cocos/gfx/webgl2/webgl2-render-pass.ts index 5a683ade54a..529eed8a0b6 100644 --- a/cocos/gfx/webgl2/webgl2-render-pass.ts +++ b/cocos/gfx/webgl2/webgl2-render-pass.ts @@ -31,26 +31,26 @@ export class WebGL2RenderPass extends RenderPass { super(); } - public getGpuRenderPass$ (): IWebGL2GPURenderPass { - return this._gpuRenderPass$!; + public getGpuRenderPass (): IWebGL2GPURenderPass { + return this._gpuRenderPass!; } - private _gpuRenderPass$: IWebGL2GPURenderPass | null = null; + private _gpuRenderPass: IWebGL2GPURenderPass | null = null; public initialize (info: Readonly): void { - this._colorInfos$ = info.colorAttachments; - this._depthStencilInfo$ = info.depthStencilAttachment; - this._subpasses$ = info.subpasses; + this._colorInfos = info.colorAttachments; + this._depthStencilInfo = info.depthStencilAttachment; + this._subpasses = info.subpasses; - this._gpuRenderPass$ = { - colorAttachments$: this._colorInfos$, - depthStencilAttachment$: this._depthStencilInfo$, + this._gpuRenderPass = { + colorAttachments: this._colorInfos, + depthStencilAttachment: this._depthStencilInfo, }; - this._hash$ = this.computeHash(); + this._hash = this.computeHash(); } public destroy (): void { - this._gpuRenderPass$ = null; + this._gpuRenderPass = null; } } diff --git a/cocos/gfx/webgl2/webgl2-shader.ts b/cocos/gfx/webgl2/webgl2-shader.ts index 2d0d6f7d73e..64013a6c2de 100644 --- a/cocos/gfx/webgl2/webgl2-shader.ts +++ b/cocos/gfx/webgl2/webgl2-shader.ts @@ -34,49 +34,49 @@ export class WebGL2Shader extends Shader { } get gpuShader (): IWebGL2GPUShader { - if (this._gpuShader$!.glProgram$ === null) { - WebGL2CmdFuncCreateShader(WebGL2DeviceManager.instance, this._gpuShader$!); + if (this._gpuShader!.glProgram === null) { + WebGL2CmdFuncCreateShader(WebGL2DeviceManager.instance, this._gpuShader!); } - return this._gpuShader$!; + return this._gpuShader!; } - private _gpuShader$: IWebGL2GPUShader | null = null; + private _gpuShader: IWebGL2GPUShader | null = null; public initialize (info: Readonly): void { - this._name$ = info.name; - this._stages$ = info.stages; - this._attributes$ = info.attributes; - this._blocks$ = info.blocks; - this._samplers$ = info.samplers; + this._name = info.name; + this._stages = info.stages; + this._attributes = info.attributes; + this._blocks = info.blocks; + this._samplers = info.samplers; - this._gpuShader$ = { - name$: info.name, - blocks$: info.blocks.slice(), - samplerTextures$: info.samplerTextures.slice(), - subpassInputs$: info.subpassInputs.slice(), + this._gpuShader = { + name: info.name, + blocks: info.blocks.slice(), + samplerTextures: info.samplerTextures.slice(), + subpassInputs: info.subpassInputs.slice(), - gpuStages$: new Array(info.stages.length), - glProgram$: null, - glInputs$: [], - glUniforms$: [], - glBlocks$: [], - glSamplerTextures$: [], + gpuStages: new Array(info.stages.length), + glProgram: null, + glInputs: [], + glUniforms: [], + glBlocks: [], + glSamplerTextures: [], }; for (let i = 0; i < info.stages.length; ++i) { const stage = info.stages[i]; - this._gpuShader$.gpuStages$[i] = { - type$: stage.stage, - source$: stage.source, - glShader$: null, + this._gpuShader.gpuStages[i] = { + type: stage.stage, + source: stage.source, + glShader: null, }; } } public destroy (): void { - if (this._gpuShader$) { - WebGL2CmdFuncDestroyShader(WebGL2DeviceManager.instance, this._gpuShader$); - this._gpuShader$ = null; + if (this._gpuShader) { + WebGL2CmdFuncDestroyShader(WebGL2DeviceManager.instance, this._gpuShader); + this._gpuShader = null; } } } diff --git a/cocos/gfx/webgl2/webgl2-state-cache.ts b/cocos/gfx/webgl2/webgl2-state-cache.ts index e9436b76291..e6c102e357b 100644 --- a/cocos/gfx/webgl2/webgl2-state-cache.ts +++ b/cocos/gfx/webgl2/webgl2-state-cache.ts @@ -26,51 +26,51 @@ import { Rect, Viewport } from '../base/define'; import { BlendState, DepthStencilState, RasterizerState } from '../base/pipeline-state'; export interface IWebGL2TexUnit { - glTexture$: WebGLTexture | null; + glTexture: WebGLTexture | null; } export class WebGL2StateCache { - public glArrayBuffer$: WebGLBuffer | null = null; - public glElementArrayBuffer$: WebGLBuffer | null = null; - public glUniformBuffer$: WebGLBuffer | null = null; - public glBindUBOs$: (WebGLBuffer | null)[] = []; - public glBindUBOOffsets$: number[] = []; - public glVAO$: WebGLVertexArrayObject | null = null; - public texUnit$ = 0; - public glTexUnits$: IWebGL2TexUnit[] = []; - public glSamplerUnits$: (WebGLSampler | null)[] = []; - public glRenderbuffer$: WebGLRenderbuffer | null = null; - public glFramebuffer$: WebGLFramebuffer | null = null; - public glReadFramebuffer$: WebGLFramebuffer | null = null; - public viewport$ = new Viewport(); - public scissorRect$ = new Rect(0, 0, 0, 0); - public rs$ = new RasterizerState(); - public dss$ = new DepthStencilState(); - public bs$ = new BlendState(); - public glProgram$: WebGLProgram | null = null; - public glEnabledAttribLocs$: boolean[] = []; - public glCurrentAttribLocs$: boolean[] = []; - public texUnitCacheMap$: Record = {}; + public glArrayBuffer: WebGLBuffer | null = null; + public glElementArrayBuffer: WebGLBuffer | null = null; + public glUniformBuffer: WebGLBuffer | null = null; + public glBindUBOs: (WebGLBuffer | null)[] = []; + public glBindUBOOffsets: number[] = []; + public glVAO: WebGLVertexArrayObject | null = null; + public texUnit = 0; + public glTexUnits: IWebGL2TexUnit[] = []; + public glSamplerUnits: (WebGLSampler | null)[] = []; + public glRenderbuffer: WebGLRenderbuffer | null = null; + public glFramebuffer: WebGLFramebuffer | null = null; + public glReadFramebuffer: WebGLFramebuffer | null = null; + public viewport = new Viewport(); + public scissorRect = new Rect(0, 0, 0, 0); + public rs = new RasterizerState(); + public dss = new DepthStencilState(); + public bs = new BlendState(); + public glProgram: WebGLProgram | null = null; + public glEnabledAttribLocs: boolean[] = []; + public glCurrentAttribLocs: boolean[] = []; + public texUnitCacheMap: Record = {}; constructor () { } initialize (texUnit: number, bufferBindings: number, vertexAttributes: number): void { - for (let i = 0; i < texUnit; ++i) this.glTexUnits$.push({ glTexture$: null }); + for (let i = 0; i < texUnit; ++i) this.glTexUnits.push({ glTexture: null }); - this.glSamplerUnits$.length = texUnit; - this.glSamplerUnits$.fill(null); + this.glSamplerUnits.length = texUnit; + this.glSamplerUnits.fill(null); - this.glBindUBOs$.length = bufferBindings; - this.glBindUBOs$.fill(null); + this.glBindUBOs.length = bufferBindings; + this.glBindUBOs.fill(null); - this.glBindUBOOffsets$.length = bufferBindings; - this.glBindUBOOffsets$.fill(0); + this.glBindUBOOffsets.length = bufferBindings; + this.glBindUBOOffsets.fill(0); - this.glEnabledAttribLocs$.length = vertexAttributes; - this.glEnabledAttribLocs$.fill(false); + this.glEnabledAttribLocs.length = vertexAttributes; + this.glEnabledAttribLocs.fill(false); - this.glCurrentAttribLocs$.length = vertexAttributes; - this.glCurrentAttribLocs$.fill(false); + this.glCurrentAttribLocs.length = vertexAttributes; + this.glCurrentAttribLocs.fill(false); } } diff --git a/cocos/gfx/webgl2/webgl2-swapchain.ts b/cocos/gfx/webgl2/webgl2-swapchain.ts index 617b3030a1b..7feb6e9fa92 100644 --- a/cocos/gfx/webgl2/webgl2-swapchain.ts +++ b/cocos/gfx/webgl2/webgl2-swapchain.ts @@ -89,22 +89,22 @@ function getExtension (gl: WebGL2RenderingContext, ext: string): any { export function getExtensions (gl: WebGL2RenderingContext): IWebGL2Extensions { const res: IWebGL2Extensions = { - EXT_texture_filter_anisotropic$: getExtension(gl, 'EXT_texture_filter_anisotropic'), - EXT_color_buffer_half_float$: getExtension(gl, 'EXT_color_buffer_half_float'), - EXT_color_buffer_float$: getExtension(gl, 'EXT_color_buffer_float'), - WEBGL_compressed_texture_etc1$: getExtension(gl, 'WEBGL_compressed_texture_etc1'), - WEBGL_compressed_texture_etc$: getExtension(gl, 'WEBGL_compressed_texture_etc'), - WEBGL_compressed_texture_pvrtc$: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), - WEBGL_compressed_texture_astc$: getExtension(gl, 'WEBGL_compressed_texture_astc'), - WEBGL_compressed_texture_s3tc$: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), - WEBGL_compressed_texture_s3tc_srgb$: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), - WEBGL_debug_shaders$: getExtension(gl, 'WEBGL_debug_shaders'), - WEBGL_lose_context$: getExtension(gl, 'WEBGL_lose_context'), - WEBGL_debug_renderer_info$: getExtension(gl, 'WEBGL_debug_renderer_info'), - OES_texture_half_float_linear$: getExtension(gl, 'OES_texture_half_float_linear'), - OES_texture_float_linear$: getExtension(gl, 'OES_texture_float_linear'), - WEBGL_multi_draw$: null, - useVAO$: true, + EXT_texture_filter_anisotropic: getExtension(gl, 'EXT_texture_filter_anisotropic'), + EXT_color_buffer_half_float: getExtension(gl, 'EXT_color_buffer_half_float'), + EXT_color_buffer_float: getExtension(gl, 'EXT_color_buffer_float'), + WEBGL_compressed_texture_etc1: getExtension(gl, 'WEBGL_compressed_texture_etc1'), + WEBGL_compressed_texture_etc: getExtension(gl, 'WEBGL_compressed_texture_etc'), + WEBGL_compressed_texture_pvrtc: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), + WEBGL_compressed_texture_astc: getExtension(gl, 'WEBGL_compressed_texture_astc'), + WEBGL_compressed_texture_s3tc: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), + WEBGL_compressed_texture_s3tc_srgb: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), + WEBGL_debug_shaders: getExtension(gl, 'WEBGL_debug_shaders'), + WEBGL_lose_context: getExtension(gl, 'WEBGL_lose_context'), + WEBGL_debug_renderer_info: getExtension(gl, 'WEBGL_debug_renderer_info'), + OES_texture_half_float_linear: getExtension(gl, 'OES_texture_half_float_linear'), + OES_texture_float_linear: getExtension(gl, 'OES_texture_float_linear'), + WEBGL_multi_draw: null, + useVAO: true, }; // platform-specific extension hacks @@ -112,7 +112,7 @@ export function getExtensions (gl: WebGL2RenderingContext): IWebGL2Extensions { { // Mobile implementation seems to have performance issues if (systemInfo.os !== OS.ANDROID && systemInfo.os !== OS.IOS) { - res.WEBGL_multi_draw$ = getExtension(gl, 'WEBGL_multi_draw'); + res.WEBGL_multi_draw = getExtension(gl, 'WEBGL_multi_draw'); } } @@ -163,37 +163,37 @@ export class WebGL2Swapchain extends Swapchain { } get extensions (): IWebGL2Extensions { - return this._extensions$ as IWebGL2Extensions; + return this._extensions as IWebGL2Extensions; } get blitManager (): IWebGL2BlitManager | null { - return this._blitManager$; + return this._blitManager; } - public stateCache$: WebGL2StateCache = new WebGL2StateCache(); - public nullTex2D$: WebGL2Texture = null!; - public nullTexCube$: WebGL2Texture = null!; + public stateCache: WebGL2StateCache = new WebGL2StateCache(); + public nullTex2D: WebGL2Texture = null!; + public nullTexCube: WebGL2Texture = null!; - private _canvas$: HTMLCanvasElement | null = null; - private _webGL2ContextLostHandler$: ((event: Event) => void) | null = null; - private _extensions$: IWebGL2Extensions | null = null; - private _blitManager$: IWebGL2BlitManager | null = null; + private _canvas: HTMLCanvasElement | null = null; + private _webGL2ContextLostHandler: ((event: Event) => void) | null = null; + private _extensions: IWebGL2Extensions | null = null; + private _blitManager: IWebGL2BlitManager | null = null; public initialize (info: Readonly): void { - this._canvas$ = info.windowHandle; + this._canvas = info.windowHandle; - this._webGL2ContextLostHandler$ = this._onWebGLContextLost.bind(this); - this._canvas$.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); + this._webGL2ContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); const gl = WebGL2DeviceManager.instance.gl; - this.stateCache$.initialize( + this.stateCache.initialize( WebGL2DeviceManager.instance.capabilities.maxTextureUnits, WebGL2DeviceManager.instance.capabilities.maxUniformBufferBindings, WebGL2DeviceManager.instance.capabilities.maxVertexAttributes, ); - this._extensions$ = getExtensions(gl); + this._extensions = getExtensions(gl); // init states initStates(gl); @@ -207,16 +207,16 @@ export class WebGL2Swapchain extends Swapchain { if (depthBits && stencilBits) depthStencilFmt = Format.DEPTH_STENCIL; else if (depthBits) depthStencilFmt = Format.DEPTH; - this._colorTexture$ = new WebGL2Texture(); - this._colorTexture$.initAsSwapchainTexture({ + this._colorTexture = new WebGL2Texture(); + this._colorTexture.initAsSwapchainTexture({ swapchain: this, format: colorFmt, width: info.width, height: info.height, }); - this._depthStencilTexture$ = new WebGL2Texture(); - this._depthStencilTexture$.initAsSwapchainTexture({ + this._depthStencilTexture = new WebGL2Texture(); + this._depthStencilTexture.initAsSwapchainTexture({ swapchain: this, format: depthStencilFmt, width: info.width, @@ -224,7 +224,7 @@ export class WebGL2Swapchain extends Swapchain { }); // create default null texture - this.nullTex2D$ = WebGL2DeviceManager.instance.createTexture(new TextureInfo( + this.nullTex2D = WebGL2DeviceManager.instance.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED, Format.RGBA8, @@ -233,7 +233,7 @@ export class WebGL2Swapchain extends Swapchain { TextureFlagBit.NONE, )) as WebGL2Texture; - this.nullTexCube$ = WebGL2DeviceManager.instance.createTexture(new TextureInfo( + this.nullTexCube = WebGL2DeviceManager.instance.createTexture(new TextureInfo( TextureType.CUBE, TextureUsageBit.SAMPLED, Format.RGBA8, @@ -247,52 +247,52 @@ export class WebGL2Swapchain extends Swapchain { nullTexRegion.texExtent.width = 2; nullTexRegion.texExtent.height = 2; - const nullTexBuff = new Uint8Array(this.nullTex2D$.size); + const nullTexBuff = new Uint8Array(this.nullTex2D.size); nullTexBuff.fill(0); - WebGL2DeviceManager.instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D$, [nullTexRegion]); + WebGL2DeviceManager.instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); nullTexRegion.texSubres.layerCount = 6; WebGL2DeviceManager.instance.copyBuffersToTexture( [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], - this.nullTexCube$, + this.nullTexCube, [nullTexRegion], ); - this._blitManager$ = new IWebGL2BlitManager(); + this._blitManager = new IWebGL2BlitManager(); } public destroy (): void { - if (this._canvas$ && this._webGL2ContextLostHandler$) { - this._canvas$.removeEventListener(eventWebGLContextLost, this._webGL2ContextLostHandler$); - this._webGL2ContextLostHandler$ = null; + if (this._canvas && this._webGL2ContextLostHandler) { + this._canvas.removeEventListener(eventWebGLContextLost, this._webGL2ContextLostHandler); + this._webGL2ContextLostHandler = null; } - if (this.nullTex2D$) { - this.nullTex2D$.destroy(); - this.nullTex2D$ = null!; + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null!; } - if (this.nullTexCube$) { - this.nullTexCube$.destroy(); - this.nullTexCube$ = null!; + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null!; } - if (this._blitManager$) { - this._blitManager$.destroy$(); - this._blitManager$ = null; + if (this._blitManager) { + this._blitManager.destroy(); + this._blitManager = null; } - this._extensions$ = null; - this._canvas$ = null; + this._extensions = null; + this._canvas = null; } public resize (width: number, height: number, surfaceTransform: SurfaceTransform): void { - if (this._colorTexture$.width !== width || this._colorTexture$.height !== height) { + if (this._colorTexture.width !== width || this._colorTexture.height !== height) { debug(`Resizing swapchain: ${width}x${height}`); - this._canvas$!.width = width; - this._canvas$!.height = height; - this._colorTexture$.resize(width, height); - this._depthStencilTexture$.resize(width, height); + this._canvas!.width = width; + this._canvas!.height = height; + this._colorTexture.resize(width, height); + this._depthStencilTexture.resize(width, height); } } diff --git a/cocos/gfx/webgl2/webgl2-texture.ts b/cocos/gfx/webgl2/webgl2-texture.ts index 9bae5a3def4..676df803a0c 100644 --- a/cocos/gfx/webgl2/webgl2-texture.ts +++ b/cocos/gfx/webgl2/webgl2-texture.ts @@ -33,19 +33,19 @@ import { WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2GPUTexture, IWebGL2GPUTextureView } from './webgl2-gpu-objects'; export class WebGL2Texture extends Texture { - private _gpuTexture$: IWebGL2GPUTexture | null = null; - private _gpuTextureView$: IWebGL2GPUTextureView | null = null; + private _gpuTexture: IWebGL2GPUTexture | null = null; + private _gpuTextureView: IWebGL2GPUTextureView | null = null; constructor () { super(); } get gpuTexture (): IWebGL2GPUTexture { - return this._gpuTexture$!; + return this._gpuTexture!; } get gpuTextureView (): IWebGL2GPUTextureView { - return this._gpuTextureView$!; + return this._gpuTextureView!; } public initialize (info: Readonly | Readonly, isSwapchainTexture?: boolean): void { @@ -54,142 +54,142 @@ export class WebGL2Texture extends Texture { if ('texture' in info) { texInfo = viewInfo.texture.info; - this._isTextureView$ = true; + this._isTextureView = true; } - this._info$.copy(texInfo); + this._info.copy(texInfo); - this._isPowerOf2$ = IsPowerOf2(this._info$.width) && IsPowerOf2(this._info$.height); - this._size$ = FormatSurfaceSize( - this._info$.format, + this._isPowerOf2 = IsPowerOf2(this._info.width) && IsPowerOf2(this._info.height); + this._size = FormatSurfaceSize( + this._info.format, this.width, this.height, this.depth, - this._info$.levelCount, - ) * this._info$.layerCount; - - if (!this._isTextureView$) { - this._gpuTexture$ = { - type$: texInfo.type, - format$: texInfo.format, - usage$: texInfo.usage, - width$: texInfo.width, - height$: texInfo.height, - depth$: texInfo.depth, - size$: this._size$, - arrayLayer$: texInfo.layerCount, - mipLevel$: texInfo.levelCount, - samples$: texInfo.samples, - flags$: texInfo.flags, - isPowerOf2$: this._isPowerOf2$, - - glTarget$: 0, - glInternalFmt$: 0, - glFormat$: 0, - glType$: 0, - glUsage$: 0, - glTexture$: null, - glRenderbuffer$: null, - glWrapS$: 0, - glWrapT$: 0, - glMinFilter$: 0, - glMagFilter$: 0, - - isSwapchainTexture$: isSwapchainTexture || false, + this._info.levelCount, + ) * this._info.layerCount; + + if (!this._isTextureView) { + this._gpuTexture = { + type: texInfo.type, + format: texInfo.format, + usage: texInfo.usage, + width: texInfo.width, + height: texInfo.height, + depth: texInfo.depth, + size: this._size, + arrayLayer: texInfo.layerCount, + mipLevel: texInfo.levelCount, + samples: texInfo.samples, + flags: texInfo.flags, + isPowerOf2: this._isPowerOf2, + + glTarget: 0, + glInternalFmt: 0, + glFormat: 0, + glType: 0, + glUsage: 0, + glTexture: null, + glRenderbuffer: null, + glWrapS: 0, + glWrapT: 0, + glMinFilter: 0, + glMagFilter: 0, + + isSwapchainTexture: isSwapchainTexture || false, }; - if (!this._gpuTexture$.isSwapchainTexture$ && this._gpuTexture$) { - WebGL2CmdFuncCreateTexture(WebGL2DeviceManager.instance, this._gpuTexture$); - WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size$; + if (!this._gpuTexture.isSwapchainTexture && this._gpuTexture) { + WebGL2CmdFuncCreateTexture(WebGL2DeviceManager.instance, this._gpuTexture); + WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size; } - this._viewInfo$.texture = this; - this._viewInfo$.type = info.type; - this._viewInfo$.format = info.format; - this._viewInfo$.baseLevel = 0; - this._viewInfo$.levelCount = info.levelCount; - this._viewInfo$.baseLayer = 0; - this._viewInfo$.layerCount = info.layerCount; - - this._gpuTextureView$ = { - gpuTexture$: this._gpuTexture$, - type$: this._viewInfo$.type, - format$: this._viewInfo$.format, - baseLevel$: this._viewInfo$.baseLevel, - levelCount$: this._viewInfo$.levelCount, + this._viewInfo.texture = this; + this._viewInfo.type = info.type; + this._viewInfo.format = info.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = info.levelCount; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = info.layerCount; + + this._gpuTextureView = { + gpuTexture: this._gpuTexture, + type: this._viewInfo.type, + format: this._viewInfo.format, + baseLevel: this._viewInfo.baseLevel, + levelCount: this._viewInfo.levelCount, }; } else { - this._viewInfo$.copy(viewInfo); - this._gpuTexture$ = (viewInfo.texture as WebGL2Texture)._gpuTexture$; + this._viewInfo.copy(viewInfo); + this._gpuTexture = (viewInfo.texture as WebGL2Texture)._gpuTexture; - if (this._gpuTexture$?.format$ !== texInfo.format) { + if (this._gpuTexture?.format !== texInfo.format) { logID(16403); return; } - this._gpuTextureView$ = { - gpuTexture$: this._gpuTexture$, - type$: viewInfo.type, - format$: viewInfo.format, - baseLevel$: viewInfo.baseLevel, - levelCount$: viewInfo.levelCount, + this._gpuTextureView = { + gpuTexture: this._gpuTexture, + type: viewInfo.type, + format: viewInfo.format, + baseLevel: viewInfo.baseLevel, + levelCount: viewInfo.levelCount, }; } } public destroy (): void { - if (!this._isTextureView$ && this._gpuTexture$) { - WebGL2CmdFuncDestroyTexture(WebGL2DeviceManager.instance, this._gpuTexture$); - WebGL2DeviceManager.instance.memoryStatus.textureSize -= this._size$; - this._gpuTexture$ = null; + if (!this._isTextureView && this._gpuTexture) { + WebGL2CmdFuncDestroyTexture(WebGL2DeviceManager.instance, this._gpuTexture); + WebGL2DeviceManager.instance.memoryStatus.textureSize -= this._size; + this._gpuTexture = null; } } public getTextureHandle (): number { - const gpuTexture = this._gpuTexture$; + const gpuTexture = this._gpuTexture; if (!gpuTexture) { return 0; } - if (gpuTexture.glTexture$) { - return gpuTexture.glTexture$ as number; - } else if (gpuTexture.glRenderbuffer$) { - return gpuTexture.glRenderbuffer$ as number; + if (gpuTexture.glTexture) { + return gpuTexture.glTexture as number; + } else if (gpuTexture.glRenderbuffer) { + return gpuTexture.glRenderbuffer as number; } return 0; } public resize (width: number, height: number): void { - if (this._info$.width === width && this._info$.height === height) { + if (this._info.width === width && this._info.height === height) { return; } - if (this._info$.levelCount === WebGL2Texture.getLevelCount(this._info$.width, this._info$.height)) { - this._info$.levelCount = WebGL2Texture.getLevelCount(width, height); - } else if (this._info$.levelCount > 1) { - this._info$.levelCount = Math.min(this._info$.levelCount, WebGL2Texture.getLevelCount(width, height)); + if (this._info.levelCount === WebGL2Texture.getLevelCount(this._info.width, this._info.height)) { + this._info.levelCount = WebGL2Texture.getLevelCount(width, height); + } else if (this._info.levelCount > 1) { + this._info.levelCount = Math.min(this._info.levelCount, WebGL2Texture.getLevelCount(width, height)); } - const oldSize = this._size$; - this._info$.width = width; - this._info$.height = height; - this._size$ = FormatSurfaceSize( - this._info$.format, + const oldSize = this._size; + this._info.width = width; + this._info.height = height; + this._size = FormatSurfaceSize( + this._info.format, this.width, this.height, this.depth, - this._info$.levelCount, - ) * this._info$.layerCount; - - if (!this._isTextureView$ && this._gpuTexture$) { - this._gpuTexture$.width$ = width; - this._gpuTexture$.height$ = height; - this._gpuTexture$.size$ = this._size$; - if (!this._gpuTexture$.isSwapchainTexture$) { - WebGL2CmdFuncResizeTexture(WebGL2DeviceManager.instance, this._gpuTexture$); + this._info.levelCount, + ) * this._info.layerCount; + + if (!this._isTextureView && this._gpuTexture) { + this._gpuTexture.width = width; + this._gpuTexture.height = height; + this._gpuTexture.size = this._size; + if (!this._gpuTexture.isSwapchainTexture) { + WebGL2CmdFuncResizeTexture(WebGL2DeviceManager.instance, this._gpuTexture); WebGL2DeviceManager.instance.memoryStatus.textureSize -= oldSize; - WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size$; + WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size; } } } diff --git a/cocos/gfx/webgpu/webgpu-buffer.ts b/cocos/gfx/webgpu/webgpu-buffer.ts index da54cf3158b..52be3d4f5b7 100644 --- a/cocos/gfx/webgpu/webgpu-buffer.ts +++ b/cocos/gfx/webgpu/webgpu-buffer.ts @@ -59,50 +59,50 @@ export class WebGPUBuffer extends Buffer { if ('buffer' in info) { // buffer view // validate: webGPU buffer offset must be 256 bytes aligned // which can be guaranteed by WebGPUDevice::uboOffsetAligned - this._isBufferView$ = true; + this._isBufferView = true; const buffer = info.buffer as WebGPUBuffer; - this._usage$ = buffer.usage; - this._memUsage$ = buffer.memUsage; - this._size$ = this._stride$ = Math.ceil(info.range / 4.0) * 4; - this._count$ = 1; - this._flags$ = buffer.flags; + this._usage = buffer.usage; + this._memUsage = buffer.memUsage; + this._size = this._stride = Math.ceil(info.range / 4.0) * 4; + this._count = 1; + this._flags = buffer.flags; this._gpuBuffer = { - usage: this._usage$, - memUsage: this._memUsage$, - size: this._size$, - stride: this._stride$, + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, buffer: null, indirects: buffer.gpuBuffer.indirects, gpuTarget: buffer.gpuBuffer.gpuTarget, gpuBuffer: buffer.gpuBuffer.gpuBuffer, gpuOffset: info.offset, - flags: this._flags$, + flags: this._flags, drawIndirectByIndex: false, }; } else { // native buffer - this._usage$ = info.usage; - this._memUsage$ = info.memUsage; - this._size$ = Math.ceil(info.size / 4.0) * 4; - this._stride$ = Math.max(info.stride || this._size$, 1); - this._count$ = this._size$ / this._stride$; - this._flags$ = info.flags; - - if (this._usage$ & BufferUsageBit.INDIRECT) { + this._usage = info.usage; + this._memUsage = info.memUsage; + this._size = Math.ceil(info.size / 4.0) * 4; + this._stride = Math.max(info.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = info.flags; + + if (this._usage & BufferUsageBit.INDIRECT) { this._indirectBuffer = new IndirectBuffer(); } this._gpuBuffer = { - usage: this._usage$, - memUsage: this._memUsage$, - size: this._size$, - stride: this._stride$, + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, buffer: null, indirects: [], gpuTarget: 0, - flags: this._flags$, + flags: this._flags, gpuBuffer: null, gpuOffset: 0, drawIndirectByIndex: false, @@ -114,16 +114,16 @@ export class WebGPUBuffer extends Buffer { const device = WebGPUDeviceManager.instance; WebGPUCmdFuncCreateBuffer(device, this._gpuBuffer); - device.memoryStatus.bufferSize += this._size$; + device.memoryStatus.bufferSize += this._size; } } public destroy (): void { if (this._gpuBuffer) { - if (!this._isBufferView$) { + if (!this._isBufferView) { const device = WebGPUDeviceManager.instance; WebGPUCmdFuncDestroyBuffer(device, this._gpuBuffer); - device.memoryStatus.bufferSize -= this._size$; + device.memoryStatus.bufferSize -= this._size; } this._hasChange = true; this._gpuBuffer = null; @@ -131,30 +131,30 @@ export class WebGPUBuffer extends Buffer { } public resize (size: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16379); return; } - const oldSize = this._size$; + const oldSize = this._size; if (oldSize === size) { return; } - this._size$ = size; - this._count$ = this._size$ / this._stride$; + this._size = size; + this._count = this._size / this._stride; this._hasChange = true; if (this._gpuBuffer) { - this._gpuBuffer.size = this._size$; - if (this._size$ > 0) { + this._gpuBuffer.size = this._size; + if (this._size > 0) { const device = WebGPUDeviceManager.instance; WebGPUCmdFuncResizeBuffer(device, this._gpuBuffer); device.memoryStatus.bufferSize -= oldSize; - device.memoryStatus.bufferSize += this._size$; + device.memoryStatus.bufferSize += this._size; } } } public update (buffer: BufferSource, size?: number): void { - if (this._isBufferView$) { + if (this._isBufferView) { warnID(16380); return; } @@ -162,7 +162,7 @@ export class WebGPUBuffer extends Buffer { let buffSize: number; if (size !== undefined) { buffSize = size; - } else if (this._usage$ & BufferUsageBit.INDIRECT) { + } else if (this._usage & BufferUsageBit.INDIRECT) { buffSize = 0; } else { buffSize = (buffer as ArrayBuffer).byteLength; diff --git a/cocos/gfx/webgpu/webgpu-command-buffer.ts b/cocos/gfx/webgpu/webgpu-command-buffer.ts index 398be743fdf..0a9caad7ec8 100644 --- a/cocos/gfx/webgpu/webgpu-command-buffer.ts +++ b/cocos/gfx/webgpu/webgpu-command-buffer.ts @@ -144,8 +144,8 @@ export class WebGPUCommandBuffer extends CommandBuffer { private _renderPassFuncQueue: ((renPassEncoder: GPURenderPassEncoder) => void)[] = []; public initialize (info: CommandBufferInfo): boolean { - this._type$ = info.type; - this._queue$ = info.queue; + this._type = info.type; + this._queue = info.queue; const device = WebGPUDeviceManager.instance; this._webGPUAllocator = device.cmdAllocator; this._encoder = {} as CommandEncoder; @@ -184,9 +184,9 @@ export class WebGPUCommandBuffer extends CommandBuffer { this._curDepthBounds = null; this._curStencilWriteMask = null; this._curStencilCompareMask = null; - this._numDrawCalls$ = 0; - this._numInstances$ = 0; - this._numTris$ = 0; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; } public end (): void { @@ -440,7 +440,7 @@ export class WebGPUCommandBuffer extends CommandBuffer { public draw (inputAssembler: InputAssembler): void { const device = WebGPUDeviceManager.instance; - if (this._type$ === CommandBufferType.PRIMARY && !this._isInRenderPass) { + if (this._type === CommandBufferType.PRIMARY && !this._isInRenderPass) { errorID(16328); return; } @@ -497,17 +497,17 @@ export class WebGPUCommandBuffer extends CommandBuffer { } } - ++this._numDrawCalls$; - this._numInstances$ += inputAssembler.instanceCount; + ++this._numDrawCalls; + this._numInstances += inputAssembler.instanceCount; const indexCount = inputAssembler.indexCount || inputAssembler.vertexCount; if (this._curGPUPipelineState) { const gpuPrimitive = this._curGPUPipelineState.gpuPrimitive; switch (gpuPrimitive) { case 'triangle-strip': - this._numTris$ += (indexCount - 2) * Math.max(inputAssembler.instanceCount, 1); + this._numTris += (indexCount - 2) * Math.max(inputAssembler.instanceCount, 1); break; case 'triangle-list': { - this._numTris$ += indexCount / 3 * Math.max(inputAssembler.instanceCount, 1); + this._numTris += indexCount / 3 * Math.max(inputAssembler.instanceCount, 1); break; } default: @@ -517,7 +517,7 @@ export class WebGPUCommandBuffer extends CommandBuffer { } public updateBuffer (buffer: Buffer, data: BufferSource, offset?: number, size?: number): void { - if (this._type$ === CommandBufferType.PRIMARY && this._isInRenderPass) { + if (this._type === CommandBufferType.PRIMARY && this._isInRenderPass) { errorID(16329); return; } @@ -547,7 +547,7 @@ export class WebGPUCommandBuffer extends CommandBuffer { } public copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]): void { - if (this._type$ === CommandBufferType.PRIMARY && this._isInRenderPass) { + if (this._type === CommandBufferType.PRIMARY && this._isInRenderPass) { errorID(16330); return; } @@ -603,9 +603,9 @@ export class WebGPUCommandBuffer extends CommandBuffer { this.cmdPackage.cmds.concat(cmdPackage.cmds.array); - this._numDrawCalls$ += WebGPUCmdBuff._numDrawCalls$; - this._numInstances$ += WebGPUCmdBuff._numInstances$; - this._numTris$ += WebGPUCmdBuff._numTris$; + this._numDrawCalls += WebGPUCmdBuff._numDrawCalls; + this._numInstances += WebGPUCmdBuff._numInstances; + this._numTris += WebGPUCmdBuff._numTris; } } diff --git a/cocos/gfx/webgpu/webgpu-descriptor-set-layout.ts b/cocos/gfx/webgpu/webgpu-descriptor-set-layout.ts index b3b4a5efff9..2d1b5d6b88d 100644 --- a/cocos/gfx/webgpu/webgpu-descriptor-set-layout.ts +++ b/cocos/gfx/webgpu/webgpu-descriptor-set-layout.ts @@ -78,28 +78,28 @@ export class WebGPUDescriptorSetLayout extends DescriptorSetLayout { this._hasChange = false; } public initialize (info: Readonly): void { - Array.prototype.push.apply(this._bindings$, info.bindings); + Array.prototype.push.apply(this._bindings, info.bindings); let descriptorCount = 0; let maxBinding = -1; const flattenedIndices: number[] = []; - const bindingSize = this._bindings$.length; + const bindingSize = this._bindings.length; for (let i = 0; i < bindingSize; i++) { - const binding = this._bindings$[i]; + const binding = this._bindings[i]; flattenedIndices.push(descriptorCount); descriptorCount += binding.count; if (binding.binding > maxBinding) maxBinding = binding.binding; } - this._bindingIndices$ = Array(maxBinding + 1).fill(-1); - const descriptorIndices = this._descriptorIndices$ = Array(maxBinding + 1).fill(-1); + this._bindingIndices = Array(maxBinding + 1).fill(-1); + const descriptorIndices = this._descriptorIndices = Array(maxBinding + 1).fill(-1); for (let i = 0; i < bindingSize; i++) { - const binding = this._bindings$[i]; - this._bindingIndices$[binding.binding] = i; + const binding = this._bindings[i]; + this._bindingIndices[binding.binding] = i; descriptorIndices[binding.binding] = flattenedIndices[i]; } const dynamicBindings: number[] = []; for (let i = 0; i < bindingSize; i++) { - const binding = this._bindings$[i]; + const binding = this._bindings[i]; if (binding.descriptorType & DESCRIPTOR_DYNAMIC_TYPE) { for (let j = 0; j < binding.count; j++) { dynamicBindings.push(binding.binding); @@ -107,7 +107,7 @@ export class WebGPUDescriptorSetLayout extends DescriptorSetLayout { } } this._gpuDescriptorSetLayout = { - bindings: this._bindings$, + bindings: this._bindings, dynamicBindings, descriptorIndices, descriptorCount, @@ -223,7 +223,7 @@ export class WebGPUDescriptorSetLayout extends DescriptorSetLayout { } public destroy (): void { - this._bindings$.length = 0; + this._bindings.length = 0; this.clear(); this._gpuDescriptorSetLayout = null; } diff --git a/cocos/gfx/webgpu/webgpu-descriptor-set.ts b/cocos/gfx/webgpu/webgpu-descriptor-set.ts index 41bda332942..c5329c38edb 100644 --- a/cocos/gfx/webgpu/webgpu-descriptor-set.ts +++ b/cocos/gfx/webgpu/webgpu-descriptor-set.ts @@ -59,13 +59,13 @@ export class WebGPUDescriptorSet extends DescriptorSet { } public initialize (info: Readonly): void { - const layout = this._layout$ = info.layout as WebGPUDescriptorSetLayout; + const layout = this._layout = info.layout as WebGPUDescriptorSetLayout; layout.addRef(this); const { bindings, descriptorIndices, descriptorCount } = layout.gpuDescriptorSetLayout!; - this._buffers$ = Array(descriptorCount).fill(null); - this._textures$ = Array(descriptorCount).fill(null); - this._samplers$ = Array(descriptorCount).fill(null); + this._buffers = Array(descriptorCount).fill(null); + this._textures = Array(descriptorCount).fill(null); + this._samplers = Array(descriptorCount).fill(null); const gpuDescriptors: IWebGPUGPUDescriptor[] = []; const bindGroup = null!; @@ -87,13 +87,13 @@ export class WebGPUDescriptorSet extends DescriptorSet { } public destroy (): void { - const layout = (this._layout$ as WebGPUDescriptorSetLayout);// .removeRef(this); + const layout = (this._layout as WebGPUDescriptorSetLayout);// .removeRef(this); layout.removeRef(this); - this._layout$ = null; + this._layout = null; this._gpuDescriptorSet = null; - this._buffers$.length = 0; - this._textures$.length = 0; - this._samplers$.length = 0; + this._buffers.length = 0; + this._textures.length = 0; + this._samplers.length = 0; this._bindGroupEntries.clear(); } @@ -102,7 +102,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { if (destBind) { destBind.gpuBuffer = buffer.gpuBuffer; } - const layout = this._layout$ as WebGPUDescriptorSetLayout; + const layout = this._layout as WebGPUDescriptorSetLayout; const nativeBuffer = buffer.gpuBuffer.gpuBuffer; const bindGrpEntry: GPUBindGroupEntry = { binding: bind.binding, @@ -119,7 +119,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { private _bindTextureEntry (bind: DescriptorSetLayoutBinding, texture: WebGPUTexture): void { this._gpuDescriptorSet!.gpuDescriptors[bind.binding].gpuTexture = texture.gpuTexture; - const layout = this._layout$ as WebGPUDescriptorSetLayout; + const layout = this._layout as WebGPUDescriptorSetLayout; const nativeTexView = texture.getNativeTextureView()!; const bindGrpEntry: GPUBindGroupEntry = { binding: bind.binding, @@ -133,8 +133,8 @@ export class WebGPUDescriptorSet extends DescriptorSet { private _bindSamplerEntry (bind: DescriptorSetLayoutBinding, sampler: WebGPUSampler): void { const samplerIdx = bind.binding + SEPARATE_SAMPLER_BINDING_OFFSET; this._gpuDescriptorSet!.gpuDescriptors[bind.binding].gpuSampler = sampler.gpuSampler; - const layout = this._layout$ as WebGPUDescriptorSetLayout; - const currTexture = this._textures$[bind.binding] as WebGPUTexture; + const layout = this._layout as WebGPUDescriptorSetLayout; + const currTexture = this._textures[bind.binding] as WebGPUTexture; const levelCount = currTexture.levelCount; const texFormat = currTexture.format; const isUnFilter = FormatToWGPUFormatType(texFormat) === 'unfilterable-float'; @@ -166,8 +166,8 @@ export class WebGPUDescriptorSet extends DescriptorSet { } private _applyBindGroup (): void { - if (this._isDirty$ && this._gpuDescriptorSet) { - const layout = this._layout$ as WebGPUDescriptorSetLayout; + if (this._isDirty && this._gpuDescriptorSet) { + const layout = this._layout as WebGPUDescriptorSetLayout; this._bindGroupEntries.clear(); this._dynamicOffsets.length = 0; const descriptors = this._gpuDescriptorSet.gpuDescriptors; @@ -177,7 +177,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { const bindIdx = binding.binding; // const isNeedBind = this._isNeedBindFromLayout(bindIdx); if (descriptors[i].type & DESCRIPTOR_BUFFER_TYPE) { - const buffer = this._buffers$[i] as WebGPUBuffer; + const buffer = this._buffers[i] as WebGPUBuffer; if (buffer) { this._bindBufferEntry(binding, buffer); if (descriptors[i].type & (DescriptorType.DYNAMIC_STORAGE_BUFFER | DescriptorType.DYNAMIC_UNIFORM_BUFFER)) { @@ -186,18 +186,18 @@ export class WebGPUDescriptorSet extends DescriptorSet { } } else if (descriptors[i].type & DESCRIPTOR_SAMPLER_TYPE) { // texture - const currTex = this._textures$[i] as WebGPUTexture; + const currTex = this._textures[i] as WebGPUTexture; if (currTex) { this._bindTextureEntry(binding, currTex); } // sampler - const currSampler = this._samplers$[i] as WebGPUSampler; + const currSampler = this._samplers[i] as WebGPUSampler; if (currSampler) { this._bindSamplerEntry(binding, currSampler); } } } - this._isDirty$ = false; + this._isDirty = false; this._needUpdate = true; } } @@ -230,14 +230,14 @@ export class WebGPUDescriptorSet extends DescriptorSet { private _isResourceChange (binds: number[]): boolean { return binds.every((bind) => { - const resource = this._buffers$[bind] as WebGPUBuffer || this._textures$[bind] || this._samplers$[bind]; + const resource = this._buffers[bind] as WebGPUBuffer || this._textures[bind] || this._samplers[bind]; return !this._hasResourceChange(bind, resource); }); } public prepare (frequency: DescUpdateFrequency, binds: number[], vertBinds: number[] = [], fragBinds: number[] = []): void { // set null - const layout = this._layout$ as WebGPUDescriptorSetLayout; + const layout = this._layout as WebGPUDescriptorSetLayout; if (!binds) { const device = WebGPUDeviceManager.instance; if (!this._bindGroupEntries.size) { @@ -277,7 +277,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { } else { this._bindGroupEntries.forEach((val, currBind) => { if (val.resource instanceof GPUTextureView) { - const currTex = this._textures$[currBind] as WebGPUTexture; + const currTex = this._textures[currBind] as WebGPUTexture; const texFormat = FormatToWGPUFormatType(currTex.format); if (layout.bindGrpLayoutEntries.get(currBind)?.texture?.sampleType !== texFormat) { layout.updateBindGroupLayout(layout.gpuDescriptorSetLayout!.bindings[currBind], null, currTex, null); @@ -297,7 +297,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { private _createBindGroup (): void { const device = WebGPUDeviceManager.instance; const nativeDevice = device.nativeDevice; - const layout = this._layout$ as WebGPUDescriptorSetLayout; + const layout = this._layout as WebGPUDescriptorSetLayout; const bindGroup = nativeDevice?.createBindGroup({ layout: layout.gpuDescriptorSetLayout!.bindGroupLayout!, entries: this._prepareEntries, diff --git a/cocos/gfx/webgpu/webgpu-device.ts b/cocos/gfx/webgpu/webgpu-device.ts index d19192a588f..9c41ec2c124 100644 --- a/cocos/gfx/webgpu/webgpu-device.ts +++ b/cocos/gfx/webgpu/webgpu-device.ts @@ -99,34 +99,34 @@ export class WebGPUDevice extends Device { } public getSampler (info: Readonly): Sampler { const hash = Sampler.computeHash(info); - if (!this._samplers$.has(hash)) { - this._samplers$.set(hash, new WebGPUSampler(info, hash)); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new WebGPUSampler(info, hash)); } - return this._samplers$.get(hash)!; + return this._samplers.get(hash)!; } public getSwapchains (): readonly Swapchain[] { return [this._swapchain as Swapchain]; } public getGeneralBarrier (info: Readonly): GeneralBarrier { const hash = GeneralBarrier.computeHash(info); - if (!this._generalBarrierss$.has(hash)) { - this._generalBarrierss$.set(hash, new GeneralBarrier(info, hash)); + if (!this._generalBarrierss.has(hash)) { + this._generalBarrierss.set(hash, new GeneralBarrier(info, hash)); } - return this._generalBarrierss$.get(hash)!; + return this._generalBarrierss.get(hash)!; } public getTextureBarrier (info: Readonly): TextureBarrier { const hash = TextureBarrier.computeHash(info); - if (!this._textureBarriers$.has(hash)) { - this._textureBarriers$.set(hash, new TextureBarrier(info, hash)); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info, hash)); } - return this._textureBarriers$.get(hash)!; + return this._textureBarriers.get(hash)!; } public getBufferBarrier (info: Readonly): BufferBarrier { const hash = BufferBarrier.computeHash(info); - if (!this._bufferBarriers$.has(hash)) { - this._bufferBarriers$.set(hash, new BufferBarrier(info, hash)); + if (!this._bufferBarriers.has(hash)) { + this._bufferBarriers.set(hash, new BufferBarrier(info, hash)); } - return this._bufferBarriers$.get(hash)!; + return this._bufferBarriers.get(hash)!; } public async copyTextureToBuffers (texture: Readonly, buffers: ArrayBufferView[], regions: readonly BufferTextureCopy[]): Promise { await WebGPUCmdFuncCopyTextureToBuffer(this, (texture as WebGPUTexture).gpuTexture, buffers, regions); @@ -185,91 +185,91 @@ export class WebGPUDevice extends Device { } protected initFormatFeatures (exts: GPUSupportedFeatures): void { - this._formatFeatures$.fill(FormatFeatureBit.NONE); + this._formatFeatures.fill(FormatFeatureBit.NONE); this._textureExclusive.fill(true); let tempFeature: FormatFeature = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.LINEAR_FILTER | FormatFeatureBit.VERTEX_ATTRIBUTE; - this._formatFeatures$[Format.R8] = tempFeature; - this._formatFeatures$[Format.RG8] = tempFeature; - this._formatFeatures$[Format.RGB8] = tempFeature; - this._formatFeatures$[Format.RGBA8] = tempFeature; + this._formatFeatures[Format.R8] = tempFeature; + this._formatFeatures[Format.RG8] = tempFeature; + this._formatFeatures[Format.RGB8] = tempFeature; + this._formatFeatures[Format.RGBA8] = tempFeature; tempFeature = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.R8SN] = tempFeature; - this._formatFeatures$[Format.RG8SN] = tempFeature; - this._formatFeatures$[Format.RGB8SN] = tempFeature; - this._formatFeatures$[Format.RGBA8SN] = tempFeature; - this._formatFeatures$[Format.R5G6B5] = tempFeature; - this._formatFeatures$[Format.RGBA4] = tempFeature; - this._formatFeatures$[Format.RGB5A1] = tempFeature; - this._formatFeatures$[Format.RGB10A2] = tempFeature; + this._formatFeatures[Format.R8SN] = tempFeature; + this._formatFeatures[Format.RG8SN] = tempFeature; + this._formatFeatures[Format.RGB8SN] = tempFeature; + this._formatFeatures[Format.RGBA8SN] = tempFeature; + this._formatFeatures[Format.R5G6B5] = tempFeature; + this._formatFeatures[Format.RGBA4] = tempFeature; + this._formatFeatures[Format.RGB5A1] = tempFeature; + this._formatFeatures[Format.RGB10A2] = tempFeature; - this._formatFeatures$[Format.SRGB8] = tempFeature; - this._formatFeatures$[Format.SRGB8_A8] = tempFeature; + this._formatFeatures[Format.SRGB8] = tempFeature; + this._formatFeatures[Format.SRGB8_A8] = tempFeature; - this._formatFeatures$[Format.R11G11B10F] = tempFeature; - this._formatFeatures$[Format.RGB9E5] = tempFeature; + this._formatFeatures[Format.R11G11B10F] = tempFeature; + this._formatFeatures[Format.RGB9E5] = tempFeature; - this._formatFeatures$[Format.DEPTH] = tempFeature; - this._formatFeatures$[Format.DEPTH_STENCIL] = tempFeature; + this._formatFeatures[Format.DEPTH] = tempFeature; + this._formatFeatures[Format.DEPTH_STENCIL] = tempFeature; - this._formatFeatures$[Format.RGB10A2UI] = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.STORAGE_TEXTURE + this._formatFeatures[Format.RGB10A2UI] = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; tempFeature = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.VERTEX_ATTRIBUTE; - this._formatFeatures$[Format.R16F] = tempFeature; - this._formatFeatures$[Format.RG16F] = tempFeature; - this._formatFeatures$[Format.RGB16F] = tempFeature; - this._formatFeatures$[Format.RGBA16F] = tempFeature; + this._formatFeatures[Format.R16F] = tempFeature; + this._formatFeatures[Format.RG16F] = tempFeature; + this._formatFeatures[Format.RGB16F] = tempFeature; + this._formatFeatures[Format.RGBA16F] = tempFeature; tempFeature = FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.VERTEX_ATTRIBUTE; - this._formatFeatures$[Format.R32F] = tempFeature; - this._formatFeatures$[Format.RG32F] = tempFeature; - this._formatFeatures$[Format.RGB32F] = tempFeature; - this._formatFeatures$[Format.RGBA32F] = tempFeature; + this._formatFeatures[Format.R32F] = tempFeature; + this._formatFeatures[Format.RG32F] = tempFeature; + this._formatFeatures[Format.RGB32F] = tempFeature; + this._formatFeatures[Format.RGBA32F] = tempFeature; - this._formatFeatures$[Format.RGB10A2UI] = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.STORAGE_TEXTURE + this._formatFeatures[Format.RGB10A2UI] = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; tempFeature = FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.STORAGE_TEXTURE | FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER | FormatFeatureBit.VERTEX_ATTRIBUTE; - this._formatFeatures$[Format.R8I] = tempFeature; - this._formatFeatures$[Format.R8UI] = tempFeature; - this._formatFeatures$[Format.R16I] = tempFeature; - this._formatFeatures$[Format.R16UI] = tempFeature; - this._formatFeatures$[Format.R32I] = tempFeature; - this._formatFeatures$[Format.R32UI] = tempFeature; - - this._formatFeatures$[Format.RG8I] = tempFeature; - this._formatFeatures$[Format.RG8UI] = tempFeature; - this._formatFeatures$[Format.RG16I] = tempFeature; - this._formatFeatures$[Format.RG16UI] = tempFeature; - this._formatFeatures$[Format.RG32I] = tempFeature; - this._formatFeatures$[Format.RG32UI] = tempFeature; - - this._formatFeatures$[Format.RGB8I] = tempFeature; - this._formatFeatures$[Format.RGB8UI] = tempFeature; - this._formatFeatures$[Format.RGB16I] = tempFeature; - this._formatFeatures$[Format.RGB16UI] = tempFeature; - this._formatFeatures$[Format.RGB32I] = tempFeature; - this._formatFeatures$[Format.RGB32UI] = tempFeature; - - this._formatFeatures$[Format.RGBA8I] = tempFeature; - this._formatFeatures$[Format.RGBA8UI] = tempFeature; - this._formatFeatures$[Format.RGBA16I] = tempFeature; - this._formatFeatures$[Format.RGBA16UI] = tempFeature; - this._formatFeatures$[Format.RGBA32I] = tempFeature; - this._formatFeatures$[Format.RGBA32UI] = tempFeature; + this._formatFeatures[Format.R8I] = tempFeature; + this._formatFeatures[Format.R8UI] = tempFeature; + this._formatFeatures[Format.R16I] = tempFeature; + this._formatFeatures[Format.R16UI] = tempFeature; + this._formatFeatures[Format.R32I] = tempFeature; + this._formatFeatures[Format.R32UI] = tempFeature; + + this._formatFeatures[Format.RG8I] = tempFeature; + this._formatFeatures[Format.RG8UI] = tempFeature; + this._formatFeatures[Format.RG16I] = tempFeature; + this._formatFeatures[Format.RG16UI] = tempFeature; + this._formatFeatures[Format.RG32I] = tempFeature; + this._formatFeatures[Format.RG32UI] = tempFeature; + + this._formatFeatures[Format.RGB8I] = tempFeature; + this._formatFeatures[Format.RGB8UI] = tempFeature; + this._formatFeatures[Format.RGB16I] = tempFeature; + this._formatFeatures[Format.RGB16UI] = tempFeature; + this._formatFeatures[Format.RGB32I] = tempFeature; + this._formatFeatures[Format.RGB32UI] = tempFeature; + + this._formatFeatures[Format.RGBA8I] = tempFeature; + this._formatFeatures[Format.RGBA8UI] = tempFeature; + this._formatFeatures[Format.RGBA16I] = tempFeature; + this._formatFeatures[Format.RGBA16UI] = tempFeature; + this._formatFeatures[Format.RGBA32I] = tempFeature; + this._formatFeatures[Format.RGBA32UI] = tempFeature; this._textureExclusive[Format.R8] = false; this._textureExclusive[Format.RG8] = false; @@ -308,18 +308,18 @@ export class WebGPUDevice extends Device { this._textureExclusive[Format.DEPTH_STENCIL] = false; if (exts.has('float32-filterable')) { - this._formatFeatures$[Format.R32F] |= FormatFeatureBit.RENDER_TARGET; - this._formatFeatures$[Format.RG32F] |= FormatFeatureBit.RENDER_TARGET; - this._formatFeatures$[Format.RGBA32F] |= FormatFeatureBit.RENDER_TARGET; + this._formatFeatures[Format.R32F] |= FormatFeatureBit.RENDER_TARGET; + this._formatFeatures[Format.RG32F] |= FormatFeatureBit.RENDER_TARGET; + this._formatFeatures[Format.RGBA32F] |= FormatFeatureBit.RENDER_TARGET; this._textureExclusive[Format.R32F] = false; this._textureExclusive[Format.RG32F] = false; this._textureExclusive[Format.RGBA32F] = false; - this._formatFeatures$[Format.RGB32F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.RGBA32F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.R32F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.RG32F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RGB32F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RGBA32F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.R32F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RG32F] |= FormatFeatureBit.LINEAR_FILTER; } if (exts.has('shader-f16')) { @@ -327,64 +327,64 @@ export class WebGPUDevice extends Device { this._textureExclusive[Format.RG16F] = false; this._textureExclusive[Format.RGBA16F] = false; - this._formatFeatures$[Format.RGB16F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.RGBA16F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.R16F] |= FormatFeatureBit.LINEAR_FILTER; - this._formatFeatures$[Format.RG16F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RGB16F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RGBA16F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.R16F] |= FormatFeatureBit.LINEAR_FILTER; + this._formatFeatures[Format.RG16F] |= FormatFeatureBit.LINEAR_FILTER; } const compressedFeature: FormatFeature = FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER; if (exts.has('texture-compression-etc2')) { - this._formatFeatures$[Format.ETC2_RGB8] = compressedFeature; - this._formatFeatures$[Format.ETC2_RGBA8] = compressedFeature; - this._formatFeatures$[Format.ETC2_SRGB8] = compressedFeature; - this._formatFeatures$[Format.ETC2_SRGB8_A8] = compressedFeature; - this._formatFeatures$[Format.ETC2_RGB8_A1] = compressedFeature; - this._formatFeatures$[Format.ETC2_SRGB8_A1] = compressedFeature; + this._formatFeatures[Format.ETC2_RGB8] = compressedFeature; + this._formatFeatures[Format.ETC2_RGBA8] = compressedFeature; + this._formatFeatures[Format.ETC2_SRGB8] = compressedFeature; + this._formatFeatures[Format.ETC2_SRGB8_A8] = compressedFeature; + this._formatFeatures[Format.ETC2_RGB8_A1] = compressedFeature; + this._formatFeatures[Format.ETC2_SRGB8_A1] = compressedFeature; } if (exts.has('texture-compression-bc')) { - this._formatFeatures$[Format.BC1] = compressedFeature; - this._formatFeatures$[Format.BC1_ALPHA] = compressedFeature; - this._formatFeatures$[Format.BC1_SRGB] = compressedFeature; - this._formatFeatures$[Format.BC1_SRGB_ALPHA] = compressedFeature; - this._formatFeatures$[Format.BC2] = compressedFeature; - this._formatFeatures$[Format.BC2_SRGB] = compressedFeature; - this._formatFeatures$[Format.BC3] = compressedFeature; - this._formatFeatures$[Format.BC3_SRGB] = compressedFeature; + this._formatFeatures[Format.BC1] = compressedFeature; + this._formatFeatures[Format.BC1_ALPHA] = compressedFeature; + this._formatFeatures[Format.BC1_SRGB] = compressedFeature; + this._formatFeatures[Format.BC1_SRGB_ALPHA] = compressedFeature; + this._formatFeatures[Format.BC2] = compressedFeature; + this._formatFeatures[Format.BC2_SRGB] = compressedFeature; + this._formatFeatures[Format.BC3] = compressedFeature; + this._formatFeatures[Format.BC3_SRGB] = compressedFeature; } if (exts.has('texture-compression-astc')) { - this._formatFeatures$[Format.ASTC_RGBA_4X4] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_5X4] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_5X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_6X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_6X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_8X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_8X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_8X8] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_10X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_10X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_10X8] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_10X10] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_12X10] = compressedFeature; - this._formatFeatures$[Format.ASTC_RGBA_12X12] = compressedFeature; - - this._formatFeatures$[Format.ASTC_SRGBA_4X4] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_5X4] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_5X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_6X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_6X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_8X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_8X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_8X8] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_10X5] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_10X6] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_10X8] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_10X10] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_12X10] = compressedFeature; - this._formatFeatures$[Format.ASTC_SRGBA_12X12] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_4X4] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_5X4] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_5X5] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_6X5] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_6X6] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_8X5] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_8X6] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_8X8] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_10X5] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_10X6] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_10X8] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_10X10] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_12X10] = compressedFeature; + this._formatFeatures[Format.ASTC_RGBA_12X12] = compressedFeature; + + this._formatFeatures[Format.ASTC_SRGBA_4X4] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_5X4] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_5X5] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_6X5] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_6X6] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_8X5] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_8X6] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_8X8] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_10X5] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_10X6] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_10X8] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_10X10] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_12X10] = compressedFeature; + this._formatFeatures[Format.ASTC_SRGBA_12X12] = compressedFeature; } } @@ -496,9 +496,9 @@ export class WebGPUDevice extends Device { this._glslang = await glslangLoader(await fetchUrl(glslangUrl)); this._twgsl = await twgslLoader(await fetchUrl(twgslUrl)); - this._gfxAPI$ = API.WEBGPU; - this._swapchainFormat$ = WGPUFormatToGFXFormat(navigator.gpu.getPreferredCanvasFormat()); - const mapping = this._bindingMappingInfo$ = info.bindingMappingInfo; + this._gfxAPI = API.WEBGPU; + this._swapchainFormat = WGPUFormatToGFXFormat(navigator.gpu.getPreferredCanvasFormat()); + const mapping = this._bindingMappingInfo = info.bindingMappingInfo; const blockOffsets: number[] = []; const samplerTextureOffsets: number[] = []; const firstSet = mapping.setIndices[0]; @@ -528,35 +528,35 @@ export class WebGPUDevice extends Device { const device: GPUDevice = this._device as GPUDevice; const adapterInfo = await this._adapter!.requestAdapterInfo(); - this._vendor$ = adapterInfo.vendor; - this._renderer$ = adapterInfo.device; + this._vendor = adapterInfo.vendor; + this._renderer = adapterInfo.device; const description = adapterInfo.description; const limits = this._adapter!.limits; - this._caps$.clipSpaceMinZ = 0.0; - this._caps$.screenSpaceSignY = -1.0; - this._caps$.uboOffsetAlignment = 256; - this._caps$.maxUniformBufferBindings = 12; - this._caps$.maxVertexAttributes = limits.maxVertexAttributes; - this._caps$.maxUniformBufferBindings = limits.maxUniformBufferBindingSize; - this._caps$.maxTextureSize = limits.maxTextureDimension2D; - this._caps$.maxArrayTextureLayers = limits.maxTextureArrayLayers; - this._caps$.max3DTextureSize = limits.maxTextureDimension3D; - this._caps$.uboOffsetAlignment = limits.minUniformBufferOffsetAlignment; + this._caps.clipSpaceMinZ = 0.0; + this._caps.screenSpaceSignY = -1.0; + this._caps.uboOffsetAlignment = 256; + this._caps.maxUniformBufferBindings = 12; + this._caps.maxVertexAttributes = limits.maxVertexAttributes; + this._caps.maxUniformBufferBindings = limits.maxUniformBufferBindingSize; + this._caps.maxTextureSize = limits.maxTextureDimension2D; + this._caps.maxArrayTextureLayers = limits.maxTextureArrayLayers; + this._caps.max3DTextureSize = limits.maxTextureDimension3D; + this._caps.uboOffsetAlignment = limits.minUniformBufferOffsetAlignment; const features = this._adapter!.features; // FIXME: require by query this._multiDrawIndirect = false; - this._features$.fill(false); - this._features$[Feature.ELEMENT_INDEX_UINT] = true; - this._features$[Feature.INSTANCED_ARRAYS] = true; - this._features$[Feature.MULTIPLE_RENDER_TARGETS] = true; - this._features$[Feature.BLEND_MINMAX] = true; + this._features.fill(false); + this._features[Feature.ELEMENT_INDEX_UINT] = true; + this._features[Feature.INSTANCED_ARRAYS] = true; + this._features[Feature.MULTIPLE_RENDER_TARGETS] = true; + this._features[Feature.BLEND_MINMAX] = true; this.initFormatFeatures(features); - this._queue$ = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff$ = this.createCommandBuffer(new CommandBufferInfo(this._queue$)); + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); const texInfo = new TextureInfo( TextureType.TEX2D, @@ -611,25 +611,25 @@ export class WebGPUDevice extends Device { compressedFormat += 'astc '; } debug('WebGPU device initialized.'); - debug(`RENDERER: ${this._renderer$}`); - debug(`VENDOR: ${this._vendor$}`); + debug(`RENDERER: ${this._renderer}`); + debug(`VENDOR: ${this._vendor}`); debug(`DESCRIPTION: ${description}`); debug(`COMPRESSED_FORMAT: ${compressedFormat}`); return Promise.resolve(true); } public destroy (): void { - if (this._queue$) { - this._queue$.destroy(); - this._queue$ = null; + if (this._queue) { + this._queue.destroy(); + this._queue = null; } - if (this._cmdBuff$) { - this._cmdBuff$.destroy(); - this._cmdBuff$ = null; + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; } - const it = this._samplers$.values(); + const it = this._samplers.values(); let res = it.next(); while (!res.done) { (res.value as WebGPUSampler).destroy(); @@ -664,10 +664,10 @@ export class WebGPUDevice extends Device { } public present (): void { - const queue = (this._queue$ as unknown as WebGPUQueue); - this._numDrawCalls$ = queue.numDrawCalls; - this._numInstances$ = queue.numInstances; - this._numTris$ = queue.numTris; + const queue = (this._queue as unknown as WebGPUQueue); + this._numDrawCalls = queue.numDrawCalls; + this._numInstances = queue.numInstances; + this._numTris = queue.numTris; queue.clear(); } diff --git a/cocos/gfx/webgpu/webgpu-framebuffer.ts b/cocos/gfx/webgpu/webgpu-framebuffer.ts index 2844b946159..3445fbddcb1 100644 --- a/cocos/gfx/webgpu/webgpu-framebuffer.ts +++ b/cocos/gfx/webgpu/webgpu-framebuffer.ts @@ -35,9 +35,9 @@ export class WebGPUFramebuffer extends Framebuffer { private _gpuFramebuffer: IWebGPUGPUFramebuffer | null = null; public initialize (info: Readonly): void { - this._renderPass$ = info.renderPass; - this._colorTextures$ = info.colorTextures || []; - this._depthStencilTexture$ = info.depthStencilTexture || null; + this._renderPass = info.renderPass; + this._colorTextures = info.colorTextures || []; + this._depthStencilTexture = info.depthStencilTexture || null; const gpuColorTextures: IWebGPUTexture[] = []; let isOffscreen = true; @@ -88,8 +88,8 @@ export class WebGPUFramebuffer extends Framebuffer { height = val; }, }; - this._width$ = this._gpuFramebuffer.width; - this._height$ = this._gpuFramebuffer.height; + this._width = this._gpuFramebuffer.width; + this._height = this._gpuFramebuffer.height; } public destroy (): void { diff --git a/cocos/gfx/webgpu/webgpu-input-assembler.ts b/cocos/gfx/webgpu/webgpu-input-assembler.ts index 7d03d940a8d..14ece6b593b 100644 --- a/cocos/gfx/webgpu/webgpu-input-assembler.ts +++ b/cocos/gfx/webgpu/webgpu-input-assembler.ts @@ -43,25 +43,25 @@ export class WebGPUInputAssembler extends InputAssembler { return; } - this._attributes$ = info.attributes; - this._attributesHash$ = this.computeAttributesHash$(); - this._vertexBuffers$ = info.vertexBuffers; + this._attributes = info.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = info.vertexBuffers; if (info.indexBuffer) { - this._indexBuffer$ = info.indexBuffer; - this.drawInfo.indexCount = this._indexBuffer$.size / this._indexBuffer$.stride; + this._indexBuffer = info.indexBuffer; + this.drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; this.drawInfo.firstIndex = 0; } else { - const vertBuff = this._vertexBuffers$[0]; + const vertBuff = this._vertexBuffers[0]; this.drawInfo.vertexCount = vertBuff.size / vertBuff.stride; this.drawInfo.firstVertex = 0; this.drawInfo.vertexOffset = 0; } - this._drawInfo$.instanceCount = 0; - this._drawInfo$.firstInstance = 0; + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; - this._indirectBuffer$ = info.indirectBuffer || null; + this._indirectBuffer = info.indirectBuffer || null; const vertBuffSize = info.vertexBuffers.length; const gpuVertexBuffers: IWebGPUGPUBuffer[] = new Array(vertBuffSize); for (let i = 0; i < vertBuffSize; ++i) { diff --git a/cocos/gfx/webgpu/webgpu-pipeline-layout.ts b/cocos/gfx/webgpu/webgpu-pipeline-layout.ts index 9b22102c51d..2acd08898ef 100644 --- a/cocos/gfx/webgpu/webgpu-pipeline-layout.ts +++ b/cocos/gfx/webgpu/webgpu-pipeline-layout.ts @@ -44,9 +44,9 @@ export class WebGPUPipelineLayout extends PipelineLayout { const webGPUDevice = WebGPUDeviceManager.instance; const nativeDevice = webGPUDevice.nativeDevice; this._bindGrpLayouts.length = 0; - const setLayoutSize = this._setLayouts$.length; + const setLayoutSize = this._setLayouts.length; for (let i = 0; i < setLayoutSize; i++) { - const setLayout = this._setLayouts$[i] as WebGPUDescriptorSetLayout; + const setLayout = this._setLayouts[i] as WebGPUDescriptorSetLayout; const bindGroupLayout = setLayout.gpuDescriptorSetLayout!.bindGroupLayout; if (bindGroupLayout) { if (resetAll) { @@ -72,7 +72,7 @@ export class WebGPUPipelineLayout extends PipelineLayout { } public initialize (info: PipelineLayoutInfo): boolean { - Array.prototype.push.apply(this._setLayouts$, info.setLayouts); + Array.prototype.push.apply(this._setLayouts, info.setLayouts); const dynamicOffsetIndices: number[][] = []; @@ -83,7 +83,7 @@ export class WebGPUPipelineLayout extends PipelineLayout { // eslint-disable-next-line @typescript-eslint/no-this-alias const that = this; this._gpuPipelineLayout = { - setLayouts: this._setLayouts$, + setLayouts: this._setLayouts, gpuSetLayouts, dynamicOffsetIndices, dynamicOffsetCount, @@ -100,10 +100,10 @@ export class WebGPUPipelineLayout extends PipelineLayout { } public changeSetLayout (idx: number, setLayout: WebGPUDescriptorSetLayout): void { - this._setLayouts$[idx] = setLayout; + this._setLayouts[idx] = setLayout; } public destroy (): void { - this._setLayouts$.length = 0; + this._setLayouts.length = 0; } } diff --git a/cocos/gfx/webgpu/webgpu-pipeline-state.ts b/cocos/gfx/webgpu/webgpu-pipeline-state.ts index 78c62928e1e..e3600356336 100644 --- a/cocos/gfx/webgpu/webgpu-pipeline-state.ts +++ b/cocos/gfx/webgpu/webgpu-pipeline-state.ts @@ -64,43 +64,43 @@ export class WebGPUPipelineState extends PipelineState { private _gpuPipelineState: IWebGPUGPUPipelineState | null = null; private _locations: Map = new Map(); public initialize (info: Readonly): void { - this._primitive$ = info.primitive; - this._shader$ = info.shader; - this._pipelineLayout$ = info.pipelineLayout; - this._rs$ = info.rasterizerState; - this._dss$ = info.depthStencilState; - this._bs$ = info.blendState; - this._is$ = info.inputState; - this._renderPass$ = info.renderPass; - this._dynamicStates$ = info.dynamicStates; + this._primitive = info.primitive; + this._shader = info.shader; + this._pipelineLayout = info.pipelineLayout; + this._rs = info.rasterizerState; + this._dss = info.depthStencilState; + this._bs = info.blendState; + this._is = info.inputState; + this._renderPass = info.renderPass; + this._dynamicStates = info.dynamicStates; const dynamicStates: DynamicStateFlagBit[] = []; for (let i = 0; i < 31; i++) { - if (this._dynamicStates$ & (1 << i)) { + if (this._dynamicStates & (1 << i)) { dynamicStates.push(1 << i); } } // colorstates - const colorAttachments = this._renderPass$.colorAttachments; + const colorAttachments = this._renderPass.colorAttachments; const colorDescs: GPUColorTargetState[] = []; const colAttachmentSize = colorAttachments.length; for (let i = 0; i < colAttachmentSize; i++) { const colDesc: GPUColorTargetState = { format: GFXFormatToWGPUFormat(colorAttachments[i].format), - writeMask: WebGPUBlendMask(this._bs$.targets[i].blendColorMask), + writeMask: WebGPUBlendMask(this._bs.targets[i].blendColorMask), }; - if (this._bs$.targets[i].blend) { + if (this._bs.targets[i].blend) { colDesc.blend = { color: { - dstFactor: WebGPUBlendFactors[this._bs$.targets[i].blendDst], - operation: WebGPUBlendOps[this._bs$.targets[i].blendEq === BlendOp.MAX ? BlendOp.ADD : this._bs$.targets[i].blendEq], - srcFactor: WebGPUBlendFactors[this._bs$.targets[i].blendSrc], + dstFactor: WebGPUBlendFactors[this._bs.targets[i].blendDst], + operation: WebGPUBlendOps[this._bs.targets[i].blendEq === BlendOp.MAX ? BlendOp.ADD : this._bs.targets[i].blendEq], + srcFactor: WebGPUBlendFactors[this._bs.targets[i].blendSrc], }, alpha: { - dstFactor: WebGPUBlendFactors[this._bs$.targets[i].blendDstAlpha], - operation: WebGPUBlendOps[this._bs$.targets[i].blendAlphaEq === BlendOp.MAX ? BlendOp.ADD : this._bs$.targets[i].blendAlphaEq], - srcFactor: WebGPUBlendFactors[this._bs$.targets[i].blendSrcAlpha], + dstFactor: WebGPUBlendFactors[this._bs.targets[i].blendDstAlpha], + operation: WebGPUBlendOps[this._bs.targets[i].blendAlphaEq === BlendOp.MAX ? BlendOp.ADD : this._bs.targets[i].blendAlphaEq], + srcFactor: WebGPUBlendFactors[this._bs.targets[i].blendSrcAlpha], }, }; } @@ -109,7 +109,7 @@ export class WebGPUPipelineState extends PipelineState { let vertexStage: GPUProgrammableStage; let fragmentStage: GPUProgrammableStage; - const shaderStages = (this._shader$ as WebGPUShader).gpuShader.gpuStages; + const shaderStages = (this._shader as WebGPUShader).gpuShader.gpuStages; const stageSize = shaderStages.length; for (let i = 0; i < stageSize; i++) { if (shaderStages[i].type === ShaderStageFlagBit.VERTEX) { vertexStage = shaderStages[i].gpuShader!; } @@ -133,8 +133,8 @@ export class WebGPUPipelineState extends PipelineState { }, primitive: { topology: WebPUPrimitives[info.primitive], - frontFace: this._rs$.isFrontFaceCCW ? 'ccw' : 'cw', - cullMode: this._rs$.cullMode === CullMode.NONE ? 'none' : (this._rs$.cullMode === CullMode.FRONT) ? 'front' : 'back', + frontFace: this._rs.isFrontFaceCCW ? 'ccw' : 'cw', + cullMode: this._rs.cullMode === CullMode.NONE ? 'none' : (this._rs.cullMode === CullMode.FRONT) ? 'front' : 'back', }, fragment: { @@ -147,41 +147,41 @@ export class WebGPUPipelineState extends PipelineState { // depthstencil states let stencilRef = 0; - if (this._renderPass$.depthStencilAttachment) { + if (this._renderPass.depthStencilAttachment) { const dssDesc = {} as GPUDepthStencilState; - dssDesc.format = GFXFormatToWGPUFormat(this._renderPass$.depthStencilAttachment.format); - dssDesc.depthWriteEnabled = this._dss$.depthWrite; - dssDesc.depthCompare = this._dss$.depthTest ? WebGPUCompereFunc[this._dss$.depthFunc] : 'always'; + dssDesc.format = GFXFormatToWGPUFormat(this._renderPass.depthStencilAttachment.format); + dssDesc.depthWriteEnabled = this._dss.depthWrite; + dssDesc.depthCompare = this._dss.depthTest ? WebGPUCompereFunc[this._dss.depthFunc] : 'always'; let stencilReadMask = 0; let stencilWriteMask = 0; - if (this._dss$.stencilTestFront) { + if (this._dss.stencilTestFront) { dssDesc.stencilFront = { - compare: WebGPUCompereFunc[this._dss$.stencilFuncFront], - depthFailOp: WebGPUStencilOp[this._dss$.stencilZFailOpFront], - passOp: WebGPUStencilOp[this._dss$.stencilPassOpFront], - failOp: WebGPUStencilOp[this._dss$.stencilFailOpFront], + compare: WebGPUCompereFunc[this._dss.stencilFuncFront], + depthFailOp: WebGPUStencilOp[this._dss.stencilZFailOpFront], + passOp: WebGPUStencilOp[this._dss.stencilPassOpFront], + failOp: WebGPUStencilOp[this._dss.stencilFailOpFront], }; - stencilReadMask |= this._dss$.stencilReadMaskFront; - stencilWriteMask |= this._dss$.stencilWriteMaskFront; - stencilRef |= this._dss$.stencilRefFront; + stencilReadMask |= this._dss.stencilReadMaskFront; + stencilWriteMask |= this._dss.stencilWriteMaskFront; + stencilRef |= this._dss.stencilRefFront; } - if (this._dss$.stencilTestBack) { + if (this._dss.stencilTestBack) { dssDesc.stencilBack = { - compare: WebGPUCompereFunc[this._dss$.stencilFuncBack], - depthFailOp: WebGPUStencilOp[this._dss$.stencilZFailOpBack], - passOp: WebGPUStencilOp[this._dss$.stencilPassOpBack], - failOp: WebGPUStencilOp[this._dss$.stencilFailOpBack], + compare: WebGPUCompereFunc[this._dss.stencilFuncBack], + depthFailOp: WebGPUStencilOp[this._dss.stencilZFailOpBack], + passOp: WebGPUStencilOp[this._dss.stencilPassOpBack], + failOp: WebGPUStencilOp[this._dss.stencilFailOpBack], }; - stencilReadMask |= this._dss$.stencilReadMaskBack; - stencilWriteMask |= this._dss$.stencilWriteMaskBack; - stencilRef |= this._dss$.stencilRefBack; + stencilReadMask |= this._dss.stencilReadMaskBack; + stencilWriteMask |= this._dss.stencilWriteMaskBack; + stencilRef |= this._dss.stencilRefBack; } dssDesc.stencilReadMask = stencilReadMask; dssDesc.stencilWriteMask = stencilWriteMask; - dssDesc.depthBias = this._rs$.depthBias; - dssDesc.depthBiasSlopeScale = this._rs$.depthBiasSlop; - dssDesc.depthBiasClamp = this._rs$.depthBiasClamp; + dssDesc.depthBias = this._rs.depthBias; + dssDesc.depthBiasSlopeScale = this._rs.depthBiasSlop; + dssDesc.depthBiasClamp = this._rs.depthBiasClamp; renderPplDesc.depthStencil = dssDesc; } @@ -206,7 +206,7 @@ export class WebGPUPipelineState extends PipelineState { public updatePipelineLayout (): void { if (this._gpuPipelineState && this._gpuPipelineState.pipelineState) { - this._gpuPipelineState.pipelineState.layout = (this._pipelineLayout$ as WebGPUPipelineLayout).gpuPipelineLayout!.nativePipelineLayout; + this._gpuPipelineState.pipelineState.layout = (this._pipelineLayout as WebGPUPipelineLayout).gpuPipelineLayout!.nativePipelineLayout; } } diff --git a/cocos/gfx/webgpu/webgpu-queue.ts b/cocos/gfx/webgpu/webgpu-queue.ts index 9a06faa678e..4df451c765c 100644 --- a/cocos/gfx/webgpu/webgpu-queue.ts +++ b/cocos/gfx/webgpu/webgpu-queue.ts @@ -35,7 +35,7 @@ export class WebGPUQueue extends Queue { private _nativeQueue: GPUQueue | null = null; private _isAsync = false; public initialize (info: QueueInfo): boolean { - this._type$ = info.type; + this._type = info.type; return true; } diff --git a/cocos/gfx/webgpu/webgpu-render-pass.ts b/cocos/gfx/webgpu/webgpu-render-pass.ts index 251da255c85..bdf77124745 100644 --- a/cocos/gfx/webgpu/webgpu-render-pass.ts +++ b/cocos/gfx/webgpu/webgpu-render-pass.ts @@ -51,9 +51,9 @@ export class WebGPURenderPass extends RenderPass { return depthStencilDescriptor; } public initialize (info: Readonly): void { - this._colorInfos$ = info.colorAttachments; - this._depthStencilInfo$ = info.depthStencilAttachment; - this._subpasses$ = info.subpasses; + this._colorInfos = info.colorAttachments; + this._depthStencilInfo = info.depthStencilAttachment; + this._subpasses = info.subpasses; const colorDescriptions: GPURenderPassColorAttachment[] = []; const originalColorDesc: GPURenderPassColorAttachment[] = []; @@ -78,8 +78,8 @@ export class WebGPURenderPass extends RenderPass { } this._gpuRenderPass = { - colorAttachments: this._colorInfos$, - depthStencilAttachment: this._depthStencilInfo$, + colorAttachments: this._colorInfos, + depthStencilAttachment: this._depthStencilInfo, nativeRenderPass: renderPassDesc, originalRP: originalRPDesc, }; diff --git a/cocos/gfx/webgpu/webgpu-sampler.ts b/cocos/gfx/webgpu/webgpu-sampler.ts index 1767fe6d763..c6bcc0afbe9 100644 --- a/cocos/gfx/webgpu/webgpu-sampler.ts +++ b/cocos/gfx/webgpu/webgpu-sampler.ts @@ -36,7 +36,7 @@ export class WebGPUSampler extends Sampler { } public get samplerInfo (): SamplerInfo { - return this._info$; + return this._info; } private _gpuSampler: IWebGPUGPUSampler | null = null; diff --git a/cocos/gfx/webgpu/webgpu-shader.ts b/cocos/gfx/webgpu/webgpu-shader.ts index d97108b030e..73087c12004 100644 --- a/cocos/gfx/webgpu/webgpu-shader.ts +++ b/cocos/gfx/webgpu/webgpu-shader.ts @@ -36,11 +36,11 @@ export class WebGPUShader extends Shader { private _gpuShader: IWebGPUGPUShader | null = null; public initialize (info: Readonly): void { - this._name$ = info.name; - this._stages$ = info.stages; - this._attributes$ = info.attributes; - this._blocks$ = info.blocks; - this._samplers$ = info.samplers; + this._name = info.name; + this._stages = info.stages; + this._attributes = info.attributes; + this._blocks = info.blocks; + this._samplers = info.samplers; const stageSize = info.stages.length; this._gpuShader = { name: info.name, diff --git a/cocos/gfx/webgpu/webgpu-swapchain.ts b/cocos/gfx/webgpu/webgpu-swapchain.ts index f037a7d1ed8..7172b671b4f 100644 --- a/cocos/gfx/webgpu/webgpu-swapchain.ts +++ b/cocos/gfx/webgpu/webgpu-swapchain.ts @@ -64,7 +64,7 @@ export class WebGPUSwapchain extends Swapchain { ); this._createTexture(width, height); - this._depthStencilTexture$ = this._createDepthStencilTexture(width, height); + this._depthStencilTexture = this._createDepthStencilTexture(width, height); this.nullTex2D = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED, @@ -107,12 +107,12 @@ export class WebGPUSwapchain extends Swapchain { width = Math.max(1, Math.min(width, device.limits.maxTextureDimension2D)); height = Math.max(1, Math.min(height, device.limits.maxTextureDimension2D)); - if (this._colorTexture$.width !== width || this._colorTexture$.height !== height) { + if (this._colorTexture.width !== width || this._colorTexture.height !== height) { debug(`Resizing swapchain: ${width}x${height}`); this._canvas!.width = width; this._canvas!.height = height; - this._colorTexture$.resize(width, height); - this._depthStencilTexture$.resize(width, height); + this._colorTexture.resize(width, height); + this._depthStencilTexture.resize(width, height); } } @@ -139,37 +139,37 @@ export class WebGPUSwapchain extends Swapchain { } public get colorTexture (): Texture { - (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); - return this._colorTexture$; + (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); + return this._colorTexture; } public get colorGPUTexture (): GPUTexture { - (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); - return (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture!; + (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); + return (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture!; } public get colorGPUTextureView (): GPUTextureView { - (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); - return (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture!.createView(); + (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture = WebGPUDeviceManager.instance.context.getCurrentTexture(); + return (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture!.createView(); } public get depthStencilTexture (): Texture { - return this._depthStencilTexture$; + return this._depthStencilTexture; } public get gpuDepthStencilTexture (): GPUTexture { - return (this._depthStencilTexture$ as WebGPUTexture).gpuTexture.gpuTexture!; + return (this._depthStencilTexture as WebGPUTexture).gpuTexture.gpuTexture!; } public get gpuDepthStencilTextureView (): GPUTextureView { - return (this._depthStencilTexture$ as WebGPUTexture).gpuTexture.gpuTexture!.createView(); + return (this._depthStencilTexture as WebGPUTexture).gpuTexture.gpuTexture!.createView(); } private _createTexture (width: number, height: number): WebGPUTexture { const device = WebGPUDeviceManager.instance; const gfxSwapchainFormat = device.swapchainFormat; const swapchainFormat = GFXFormatToWGPUFormat(gfxSwapchainFormat);// navigator.gpu.getPreferredCanvasFormat(); - if (!this._colorTexture$) { + if (!this._colorTexture) { const nativeDevice = device.nativeDevice as GPUDevice; const gpuConfig: GPUCanvasConfiguration = { device: nativeDevice, @@ -179,15 +179,15 @@ export class WebGPUSwapchain extends Swapchain { device.gpuConfig = gpuConfig; device.context.configure(gpuConfig); } - this._colorTexture$ = new WebGPUTexture(); - this._colorTexture$.initAsSwapchainTexture({ + this._colorTexture = new WebGPUTexture(); + this._colorTexture.initAsSwapchainTexture({ swapchain: this, format: gfxSwapchainFormat, width, height, }); - (this._colorTexture$ as WebGPUTexture).gpuTexture.gpuTexture = device.context.getCurrentTexture(); - return (this._colorTexture$ as WebGPUTexture); + (this._colorTexture as WebGPUTexture).gpuTexture.gpuTexture = device.context.getCurrentTexture(); + return (this._colorTexture as WebGPUTexture); } private _createDepthStencilTexture (width: number, height: number): WebGPUTexture { diff --git a/cocos/gfx/webgpu/webgpu-texture.ts b/cocos/gfx/webgpu/webgpu-texture.ts index bf26864da0e..2cc4bd2d8b3 100644 --- a/cocos/gfx/webgpu/webgpu-texture.ts +++ b/cocos/gfx/webgpu/webgpu-texture.ts @@ -84,19 +84,19 @@ export class WebGPUTexture extends Texture { const viewInfo = info as Readonly; if ('texture' in info) { texInfo = viewInfo.texture.info; - this._isTextureView$ = true; + this._isTextureView = true; } - this._info$.copy(texInfo); - this._isPowerOf2$ = IsPowerOf2(this._info$.width) && IsPowerOf2(this._info$.height); - this._size$ = FormatSurfaceSize( - this._info$.format, + this._info.copy(texInfo); + this._isPowerOf2 = IsPowerOf2(this._info.width) && IsPowerOf2(this._info.height); + this._size = FormatSurfaceSize( + this._info.format, this.width, this.height, this.depth, - this._info$.levelCount, - ) * this._info$.layerCount; - if (!this._isTextureView$) { + this._info.levelCount, + ) * this._info.layerCount; + if (!this._isTextureView) { this._gpuTexture = { type: texInfo.type, format: texInfo.format, @@ -104,12 +104,12 @@ export class WebGPUTexture extends Texture { width: texInfo.width, height: texInfo.height, depth: texInfo.depth, - size: this._size$, + size: this._size, arrayLayer: texInfo.layerCount, mipLevel: texInfo.levelCount, samples: texInfo.samples, flags: texInfo.flags, - isPowerOf2: this._isPowerOf2$, + isPowerOf2: this._isPowerOf2, // default value, filled in when texture is created. gpuTarget: '2d', @@ -130,27 +130,27 @@ export class WebGPUTexture extends Texture { if (!isSwapchainTexture) { const device = WebGPUDeviceManager.instance; WebGPUCmdFuncCreateTexture(device, this._gpuTexture); - device.memoryStatus.textureSize += this._size$; + device.memoryStatus.textureSize += this._size; } else { this._gpuTexture.gpuInternalFmt = GFXFormatToWGPUFormat(this._gpuTexture.format); this._gpuTexture.gpuFormat = this._gpuTexture.gpuInternalFmt; } - this._viewInfo$.texture = this; - this._viewInfo$.type = info.type; - this._viewInfo$.format = info.format; - this._viewInfo$.baseLevel = 0; - this._viewInfo$.levelCount = info.levelCount; - this._viewInfo$.baseLayer = 0; - this._viewInfo$.layerCount = info.layerCount; + this._viewInfo.texture = this; + this._viewInfo.type = info.type; + this._viewInfo.format = info.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = info.levelCount; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = info.layerCount; } else { - this._viewInfo$.copy(viewInfo); + this._viewInfo.copy(viewInfo); this._lodLevel = viewInfo.baseLevel; this._gpuTexture = (viewInfo.texture as WebGPUTexture)._gpuTexture; } } set gpuFormat (val: GPUTextureFormat) { - if (!this._isTextureView$ && this._gpuTexture && !this._gpuTexture.isSwapchainTexture) { + if (!this._isTextureView && this._gpuTexture && !this._gpuTexture.isSwapchainTexture) { WebGPUCmdFuncDestroyTexture(this._gpuTexture); const device = WebGPUDeviceManager.instance; this._gpuTexture.format = WGPUFormatToGFXFormat(val); @@ -174,30 +174,30 @@ export class WebGPUTexture extends Texture { } public destroy (): void { - if (this._isTextureView$ || (!this._isTextureView$ && !this._gpuTexture)) { + if (this._isTextureView || (!this._isTextureView && !this._gpuTexture)) { return; } WebGPUCmdFuncDestroyTexture(this._gpuTexture!); const device = WebGPUDeviceManager.instance; - device.memoryStatus.textureSize -= this._size$; + device.memoryStatus.textureSize -= this._size; this._gpuTexture = null; this._hasChange = true; } public resize (width: number, height: number): void { - if (this._info$.width === width && this._info$.height === height) { + if (this._info.width === width && this._info.height === height) { return; } - if (this._info$.levelCount === WebGPUTexture.getLevelCount(this._info$.width, this._info$.height)) { - this._info$.levelCount = WebGPUTexture.getLevelCount(width, height); - } else if (this._info$.levelCount > 1) { - this._info$.levelCount = Math.min(this._info$.levelCount, WebGPUTexture.getLevelCount(width, height)); + if (this._info.levelCount === WebGPUTexture.getLevelCount(this._info.width, this._info.height)) { + this._info.levelCount = WebGPUTexture.getLevelCount(width, height); + } else if (this._info.levelCount > 1) { + this._info.levelCount = Math.min(this._info.levelCount, WebGPUTexture.getLevelCount(width, height)); } this._hasChange = true; - const oldSize = this._size$; - this._info$.width = width; - this._info$.height = height; - this._size$ = FormatSurfaceSize( + const oldSize = this._size; + this._info.width = width; + this._info.height = height; + this._size = FormatSurfaceSize( this.info.format, this.width, this.height, @@ -205,15 +205,15 @@ export class WebGPUTexture extends Texture { this.info.levelCount, ) * this.info.layerCount; - if (!this._isTextureView$ && this._gpuTexture) { + if (!this._isTextureView && this._gpuTexture) { this._gpuTexture.width = width; this._gpuTexture.height = height; - this._gpuTexture.size = this._size$; + this._gpuTexture.size = this._size; if (!this._gpuTexture.isSwapchainTexture) { const device = WebGPUDeviceManager.instance; WebGPUCmdFuncResizeTexture(device, this._gpuTexture); device.memoryStatus.textureSize -= oldSize; - device.memoryStatus.textureSize += this._size$; + device.memoryStatus.textureSize += this._size; } } } diff --git a/cocos/input/input.ts b/cocos/input/input.ts index b2bb8f57e1b..47ab13464b3 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -52,10 +52,10 @@ export interface IEventDispatcher { class InputEventDispatcher implements IEventDispatcher { public priority: EventDispatcherPriority = EventDispatcherPriority.GLOBAL; - private declare _inputEventTarget$: EventTarget; + private declare _inputEventTarget: EventTarget; constructor (inputEventTarget: EventTarget) { - this._inputEventTarget$ = inputEventTarget; + this._inputEventTarget = inputEventTarget; } onThrowException (): void { @@ -63,7 +63,7 @@ class InputEventDispatcher implements IEventDispatcher { } public dispatchEvent (event: Event): boolean { - this._inputEventTarget$.emit(event.type, event); + this._inputEventTarget.emit(event.type, event); return true; } } @@ -133,33 +133,31 @@ export class Input { */ public static EventType = InputEventType; - private _eventTarget$: EventTarget = new EventTarget(); - private _touchInput$ = new TouchInputSource(); - private _mouseInput$ = new MouseInputSource(); - private _keyboardInput$ = new KeyboardInputSource(); - private _accelerometerInput$ = new AccelerometerInputSource(); - private _handleInput$ = new HandleInputDevice(); - private _hmdInput$ = new HMDInputDevice(); - private _handheldInput$ = new HandheldInputDevice(); - - private _eventTouchList$: EventTouch[] = []; - private _eventMouseList$: EventMouse[] = []; - private _eventKeyboardList$: EventKeyboard[] = []; - private _eventAccelerationList$: EventAcceleration[] = []; - private _eventGamepadList$: EventGamepad[] = []; - private _eventHandleList$: EventHandle[] = []; - private _eventHMDList$: EventHMD[] = []; - private _eventHandheldList$: EventHandheld[] = []; - - private _needSimulateTouchMoveEvent$ = false; - - private declare _inputEventDispatcher$: InputEventDispatcher; - private _eventDispatcherList$: IEventDispatcher[] = []; + private _eventTarget: EventTarget = new EventTarget(); + private _touchInput = new TouchInputSource(); + private _mouseInput = new MouseInputSource(); + private _keyboardInput = new KeyboardInputSource(); + private _accelerometerInput = new AccelerometerInputSource(); + private _handleInput = new HandleInputDevice(); + private _hmdInput = new HMDInputDevice(); + private _handheldInput = new HandheldInputDevice(); + + private _eventKeyboardList: EventKeyboard[] = []; + private _eventAccelerationList: EventAcceleration[] = []; + private _eventGamepadList: EventGamepad[] = []; + private _eventHandleList: EventHandle[] = []; + private _eventHMDList: EventHMD[] = []; + private _eventHandheldList: EventHandheld[] = []; + + private _needSimulateTouchMoveEvent = false; + + private declare _inputEventDispatcher: InputEventDispatcher; + private _eventDispatcherList: IEventDispatcher[] = []; constructor () { - this._registerEvent$(); - this._inputEventDispatcher$ = new InputEventDispatcher(this._eventTarget$); - this._registerEventDispatcher(this._inputEventDispatcher$); + this._registerEvent(); + this._inputEventDispatcher = new InputEventDispatcher(this._eventTarget); + this._registerEventDispatcher(this._inputEventDispatcher); GamepadInputDevice._init(); } @@ -167,38 +165,38 @@ export class Input { * This should be a private method, but it's exposed for Editor Only. */ private _dispatchMouseDownEvent (nativeMouseEvent: any): void { - this._mouseInput$.dispatchMouseDownEvent?.(nativeMouseEvent); + this._mouseInput.dispatchMouseDownEvent?.(nativeMouseEvent); } /** * This should be a private method, but it's exposed for Editor Only. */ private _dispatchMouseMoveEvent (nativeMouseEvent: any): void { - this._mouseInput$.dispatchMouseMoveEvent?.(nativeMouseEvent); + this._mouseInput.dispatchMouseMoveEvent?.(nativeMouseEvent); } /** * This should be a private method, but it's exposed for Editor Only. */ private _dispatchMouseUpEvent (nativeMouseEvent: any): void { - this._mouseInput$.dispatchMouseUpEvent?.(nativeMouseEvent); + this._mouseInput.dispatchMouseUpEvent?.(nativeMouseEvent); } /** * This should be a private method, but it's exposed for Editor Only. */ private _dispatchMouseScrollEvent (nativeMouseEvent: any): void { - this._mouseInput$.dispatchScrollEvent?.(nativeMouseEvent); + this._mouseInput.dispatchScrollEvent?.(nativeMouseEvent); } /** * This should be a private method, but it's exposed for Editor Only. */ private _dispatchKeyboardDownEvent (nativeKeyboardEvent: any): void { - this._keyboardInput$.dispatchKeyboardDownEvent?.(nativeKeyboardEvent); + this._keyboardInput.dispatchKeyboardDownEvent?.(nativeKeyboardEvent); } /** * This should be a private method, but it's exposed for Editor Only. */ private _dispatchKeyboardUpEvent (nativeKeyboardEvent: any): void { - this._keyboardInput$.dispatchKeyboardUpEvent?.(nativeKeyboardEvent); + this._keyboardInput.dispatchKeyboardUpEvent?.(nativeKeyboardEvent); } /** @@ -212,7 +210,7 @@ export class Input { * @param target - The event listener's target and callee */ public on (eventType: K, callback: InputEventMap[K], target?: any): InputEventMap[K] { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); return callback; } @@ -227,7 +225,7 @@ export class Input { * @param target - The event listener's target and callee */ public once (eventType: K, callback: InputEventMap[K], target?: any): InputEventMap[K] { - this._eventTarget$.once(eventType, callback, target); + this._eventTarget.once(eventType, callback, target); return callback; } @@ -245,7 +243,7 @@ export class Input { if (EDITOR_NOT_IN_PREVIEW) { return; } - this._eventTarget$.off(eventType, callback, target); + this._eventTarget.off(eventType, callback, target); } /** @@ -290,9 +288,9 @@ export class Input { return; } if (isEnable) { - this._accelerometerInput$.start(); + this._accelerometerInput.start(); } else { - this._accelerometerInput$.stop(); + this._accelerometerInput.stop(); } } @@ -307,10 +305,10 @@ export class Input { if (EDITOR_NOT_IN_PREVIEW) { return; } - this._accelerometerInput$.setInterval(intervalInMileSeconds); + this._accelerometerInput.setInterval(intervalInMileSeconds); } - private _simulateEventTouch$ (eventMouse: EventMouse): void { + private _simulateEventTouch (eventMouse: EventMouse): void { const eventType = pointerEventTypeMap[eventMouse.type]; const touchID = 0; const touch = touchManager.getOrCreateTouch(touchID, eventMouse.getLocationX(), eventMouse.getLocationY()); @@ -324,21 +322,21 @@ export class Input { if (eventType === InputEventType.TOUCH_END) { touchManager.releaseTouch(touchID); } - this._dispatchOrPushEventTouch$(eventTouch, this._eventTouchList$); + this._dispatchEventTouch(eventTouch); } /** * @engineInternal */ public _registerEventDispatcher (eventDispatcher: IEventDispatcher): void { - this._eventDispatcherList$.push(eventDispatcher); - this._eventDispatcherList$.sort((a, b): number => b.priority - a.priority); + this._eventDispatcherList.push(eventDispatcher); + this._eventDispatcherList.sort((a, b): number => b.priority - a.priority); } - private _emitEvent$ (event: Event): void { - const length = this._eventDispatcherList$.length; + private _emitEvent (event: Event): void { + const length = this._eventDispatcherList.length; for (let i = 0; i < length; ++i) { - const dispatcher = this._eventDispatcherList$[i]; + const dispatcher = this._eventDispatcherList[i]; try { if (!dispatcher.dispatchEvent(event)) { break; @@ -351,106 +349,104 @@ export class Input { } } - private _registerEvent$ (): void { + private _registerEvent (): void { if (sys.hasFeature(sys.Feature.INPUT_TOUCH)) { - const eventTouchList = this._eventTouchList$; - this._touchInput$.on(InputEventType.TOUCH_START, (event): void => { - this._dispatchOrPushEventTouch$(event, eventTouchList); + this._touchInput.on(InputEventType.TOUCH_START, (event): void => { + this._dispatchEventTouch(event); }); - this._touchInput$.on(InputEventType.TOUCH_MOVE, (event): void => { - this._dispatchOrPushEventTouch$(event, eventTouchList); + this._touchInput.on(InputEventType.TOUCH_MOVE, (event): void => { + this._dispatchEventTouch(event); }); - this._touchInput$.on(InputEventType.TOUCH_END, (event): void => { - this._dispatchOrPushEventTouch$(event, eventTouchList); + this._touchInput.on(InputEventType.TOUCH_END, (event): void => { + this._dispatchEventTouch(event); }); - this._touchInput$.on(InputEventType.TOUCH_CANCEL, (event): void => { - this._dispatchOrPushEventTouch$(event, eventTouchList); + this._touchInput.on(InputEventType.TOUCH_CANCEL, (event): void => { + this._dispatchEventTouch(event); }); } if (sys.hasFeature(sys.Feature.EVENT_MOUSE)) { - const eventMouseList = this._eventMouseList$; - this._mouseInput$.on(InputEventType.MOUSE_DOWN, (event): void => { - this._needSimulateTouchMoveEvent$ = true; - this._simulateEventTouch$(event); - this._dispatchOrPushEvent$(event, eventMouseList); + this._mouseInput.on(InputEventType.MOUSE_DOWN, (event): void => { + this._needSimulateTouchMoveEvent = true; + this._simulateEventTouch(event); + this._dispatchEventMouse(event); }); - this._mouseInput$.on(InputEventType.MOUSE_MOVE, (event): void => { - if (this._needSimulateTouchMoveEvent$) { - this._simulateEventTouch$(event); + this._mouseInput.on(InputEventType.MOUSE_MOVE, (event): void => { + if (this._needSimulateTouchMoveEvent) { + this._simulateEventTouch(event); } - this._dispatchOrPushEvent$(event, eventMouseList); + this._dispatchEventMouse(event); }); - this._mouseInput$.on(InputEventType.MOUSE_UP, (event): void => { - this._needSimulateTouchMoveEvent$ = false; - this._simulateEventTouch$(event); - this._dispatchOrPushEvent$(event, eventMouseList); + this._mouseInput.on(InputEventType.MOUSE_UP, (event): void => { + this._needSimulateTouchMoveEvent = false; + this._simulateEventTouch(event); + this._dispatchEventMouse(event); }); - this._mouseInput$.on(InputEventType.MOUSE_WHEEL, (event): void => { - this._dispatchOrPushEvent$(event, eventMouseList); + this._mouseInput.on(InputEventType.MOUSE_WHEEL, (event): void => { + this._dispatchEventMouse(event); }); - this._mouseInput$.on(InputEventType.MOUSE_LEAVE, (event): void => { - this._dispatchOrPushEvent$(event, eventMouseList); + this._mouseInput.on(InputEventType.MOUSE_LEAVE, (event): void => { + this._dispatchEventMouse(event); }); - this._mouseInput$.on(InputEventType.MOUSE_ENTER, (event): void => { - this._dispatchOrPushEvent$(event, eventMouseList); + this._mouseInput.on(InputEventType.MOUSE_ENTER, (event): void => { + this._dispatchEventMouse(event); }); } if (sys.hasFeature(sys.Feature.EVENT_KEYBOARD)) { - const eventKeyboardList = this._eventKeyboardList$; - this._keyboardInput$.on(InputEventType.KEY_DOWN, (event): void => { - this._dispatchOrPushEvent$(event, eventKeyboardList); + const eventKeyboardList = this._eventKeyboardList; + this._keyboardInput.on(InputEventType.KEY_DOWN, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); }); - this._keyboardInput$.on(InputEventType.KEY_PRESSING, (event): void => { - this._dispatchOrPushEvent$(event, eventKeyboardList); + this._keyboardInput.on(InputEventType.KEY_PRESSING, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); }); - this._keyboardInput$.on(InputEventType.KEY_UP, (event): void => { - this._dispatchOrPushEvent$(event, eventKeyboardList); + this._keyboardInput.on(InputEventType.KEY_UP, (event): void => { + this._dispatchOrPushEvent(event, eventKeyboardList); }); } if (sys.hasFeature(sys.Feature.EVENT_ACCELEROMETER)) { - const eventAccelerationList = this._eventAccelerationList$; - this._accelerometerInput$.on(InputEventType.DEVICEMOTION, (event): void => { - this._dispatchOrPushEvent$(event, eventAccelerationList); + const eventAccelerationList = this._eventAccelerationList; + this._accelerometerInput.on(InputEventType.DEVICEMOTION, (event): void => { + this._dispatchOrPushEvent(event, eventAccelerationList); }); } if (sys.hasFeature(sys.Feature.EVENT_GAMEPAD)) { - const eventGamepadList = this._eventGamepadList$; + const eventGamepadList = this._eventGamepadList; GamepadInputDevice._on(InputEventType.GAMEPAD_CHANGE, (event): void => { - this._dispatchOrPushEvent$(event, eventGamepadList); + this._dispatchOrPushEvent(event, eventGamepadList); }); GamepadInputDevice._on(InputEventType.GAMEPAD_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventGamepadList); + this._dispatchOrPushEvent(event, eventGamepadList); }); GamepadInputDevice._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventGamepadList); + this._dispatchOrPushEvent(event, eventGamepadList); }); } if (sys.hasFeature(sys.Feature.EVENT_HANDLE)) { - const eventHandleList = this._eventHandleList$; - this._handleInput$._on(InputEventType.HANDLE_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventHandleList); + const eventHandleList = this._eventHandleList; + this._handleInput._on(InputEventType.HANDLE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandleList); }); - this._handleInput$._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventHandleList); + this._handleInput._on(InputEventType.HANDLE_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandleList); }); } if (sys.hasFeature(sys.Feature.EVENT_HMD)) { - const eventHMDList = this._eventHMDList$; - this._hmdInput$._on(InputEventType.HMD_POSE_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventHMDList); + const eventHMDList = this._eventHMDList; + this._hmdInput._on(InputEventType.HMD_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHMDList); }); } if (sys.hasFeature(sys.Feature.EVENT_HANDHELD)) { - const eventHandheldList = this._eventHandheldList$; - this._handheldInput$._on(InputEventType.HANDHELD_POSE_INPUT, (event): void => { - this._dispatchOrPushEvent$(event, eventHandheldList); + const eventHandheldList = this._eventHandheldList; + this._handheldInput._on(InputEventType.HANDHELD_POSE_INPUT, (event): void => { + this._dispatchOrPushEvent(event, eventHandheldList); }); } } @@ -459,34 +455,32 @@ export class Input { * @engineInternal */ public _clearEvents (): void { - this._eventMouseList$.length = 0; - this._eventTouchList$.length = 0; - this._eventKeyboardList$.length = 0; - this._eventAccelerationList$.length = 0; - this._eventGamepadList$.length = 0; - this._eventHandleList$.length = 0; - this._eventHMDList$.length = 0; + this._eventKeyboardList.length = 0; + this._eventAccelerationList.length = 0; + this._eventGamepadList.length = 0; + this._eventHandleList.length = 0; + this._eventHMDList.length = 0; } - private _dispatchOrPushEvent$ (event: Event, eventList: Event[]): void { + private _dispatchOrPushEvent (event: Event, eventList: Event[]): void { if (dispatchImmediately) { - this._emitEvent$(event); + this._emitEvent(event); } else { eventList.push(event); } } - private _dispatchOrPushEventTouch$ (eventTouch: EventTouch, touchEventList: EventTouch[]): void { - if (dispatchImmediately) { - const touches = eventTouch.getTouches(); - const touchesLength = touches.length; - for (let i = 0; i < touchesLength; ++i) { - eventTouch.touch = touches[i]; - eventTouch.propagationStopped = eventTouch.propagationImmediateStopped = false; - this._emitEvent$(eventTouch); - } - } else { - touchEventList.push(eventTouch); + private _dispatchEventMouse (event: Event): void { + this._emitEvent(event); + } + + private _dispatchEventTouch (eventTouch: EventTouch): void { + const touches = eventTouch.getTouches(); + const touchesLength = touches.length; + for (let i = 0; i < touchesLength; ++i) { + eventTouch.touch = touches[i]; + eventTouch.propagationStopped = eventTouch.propagationImmediateStopped = false; + this._emitEvent(eventTouch); } } @@ -495,66 +489,49 @@ export class Input { */ public _frameDispatchEvents (): void { if (dispatchImmediately) return; - const eventHMDList = this._eventHMDList$; + const eventHMDList = this._eventHMDList; // TODO: culling event queue for (let i = 0, length = eventHMDList.length; i < length; ++i) { const eventHMD = eventHMDList[i]; - this._emitEvent$(eventHMD); + this._emitEvent(eventHMD); } - const eventHandheldList = this._eventHandheldList$; + const eventHandheldList = this._eventHandheldList; // TODO: culling event queue for (let i = 0, length = eventHandheldList.length; i < length; ++i) { const eventHandheld = eventHandheldList[i]; - this._emitEvent$(eventHandheld); - } - - const eventMouseList = this._eventMouseList$; - // TODO: culling event queue - for (let i = 0, length = eventMouseList.length; i < length; ++i) { - const eventMouse = eventMouseList[i]; - this._emitEvent$(eventMouse); + this._emitEvent(eventHandheld); } - const eventTouchList = this._eventTouchList$; - // TODO: culling event queue - for (let i = 0, length = eventTouchList.length; i < length; ++i) { - const eventTouch = eventTouchList[i]; - const touches = eventTouch.getTouches(); - const touchesLength = touches.length; - for (let j = 0; j < touchesLength; ++j) { - eventTouch.touch = touches[j]; - eventTouch.propagationStopped = eventTouch.propagationImmediateStopped = false; - this._emitEvent$(eventTouch); - } - } + this._mouseInput.dispatchEventsInCache(); + this._touchInput.dispatchEventsInCache(); - const eventKeyboardList = this._eventKeyboardList$; + const eventKeyboardList = this._eventKeyboardList; // TODO: culling event queue for (let i = 0, length = eventKeyboardList.length; i < length; ++i) { const eventKeyboard = eventKeyboardList[i]; - this._emitEvent$(eventKeyboard); + this._emitEvent(eventKeyboard); } - const eventAccelerationList = this._eventAccelerationList$; + const eventAccelerationList = this._eventAccelerationList; // TODO: culling event queue for (let i = 0, length = eventAccelerationList.length; i < length; ++i) { const eventAcceleration = eventAccelerationList[i]; - this._emitEvent$(eventAcceleration); + this._emitEvent(eventAcceleration); } - const eventGamepadList = this._eventGamepadList$; + const eventGamepadList = this._eventGamepadList; // TODO: culling event queue for (let i = 0, length = eventGamepadList.length; i < length; ++i) { const eventGamepad = eventGamepadList[i]; - this._emitEvent$(eventGamepad); + this._emitEvent(eventGamepad); } - const eventHandleList = this._eventHandleList$; + const eventHandleList = this._eventHandleList; // TODO: culling event queue for (let i = 0, length = eventHandleList.length; i < length; ++i) { const eventHandle = eventHandleList[i]; - this._emitEvent$(eventHandle); + this._emitEvent(eventHandle); } this._clearEvents(); diff --git a/cocos/input/types/event/event-keyboard.ts b/cocos/input/types/event/event-keyboard.ts index c39960cf427..60bdf969ee4 100644 --- a/cocos/input/types/event/event-keyboard.ts +++ b/cocos/input/types/event/event-keyboard.ts @@ -54,13 +54,13 @@ export class EventKeyboard extends Event { */ public rawEvent?: KeyboardEvent; - private declare _isPressed$: boolean; + private declare _isPressed: boolean; /** * @en Indicates whether the current key is being pressed * @zh 表示当前按键是否正在被按下 */ public get isPressed (): boolean { - return this._isPressed$; + return this._isPressed; } /** @@ -81,7 +81,7 @@ export class EventKeyboard extends Event { eventType = isPressed ? SystemEventType.KEY_DOWN : SystemEventType.KEY_UP; } super(eventType, bubbles); - this._isPressed$ = eventType !== SystemEventType.KEY_UP; + this._isPressed = eventType !== SystemEventType.KEY_UP; if (typeof keyCode === 'number') { this.keyCode = keyCode; diff --git a/cocos/input/types/event/event-touch.ts b/cocos/input/types/event/event-touch.ts index 48e2da31132..0c931151d40 100644 --- a/cocos/input/types/event/event-touch.ts +++ b/cocos/input/types/event/event-touch.ts @@ -74,11 +74,11 @@ export class EventTouch extends Event { */ public preventSwallow = false; - private declare _eventCode$: SystemEventTypeUnion; // deprecated since v3.3 + private declare _eventCode: SystemEventTypeUnion; // deprecated since v3.3 - private declare _touches$: Touch[]; + private declare _touches: Touch[]; - private declare _allTouches$: Touch[]; + private declare _allTouches: Touch[]; /** * @param touches - An array of current touches @@ -87,9 +87,9 @@ export class EventTouch extends Event { */ constructor (changedTouches: Touch[], bubbles: boolean, eventType: SystemEventTypeUnion, touches: Touch[] = []) { super(eventType, bubbles); - this._eventCode$ = eventType; - this._touches$ = changedTouches || []; - this._allTouches$ = touches; + this._eventCode = eventType; + this._touches = changedTouches || []; + this._allTouches = touches; } /** @@ -99,7 +99,7 @@ export class EventTouch extends Event { * @deprecated since v3.3, please use EventTouch.prototype.type instead. */ public getEventCode (): string { - return this._eventCode$; + return this._eventCode; } /** @@ -109,7 +109,7 @@ export class EventTouch extends Event { * 如果需要获取全部手指的信息,请使用 `getAllTouches`。 */ public getTouches (): Touch[] { - return this._touches$; + return this._touches; } /** @@ -118,7 +118,7 @@ export class EventTouch extends Event { * 注意:如果手指行为是 touch end,这个时候列表是没有该手指信息的。如需知道该手指信息,可通过 `getTouches` 获取识别。 */ public getAllTouches (): Touch[] { - return this._allTouches$; + return this._allTouches; } /** diff --git a/cocos/input/types/touch.ts b/cocos/input/types/touch.ts index 10b847d10b1..e2778d5fa33 100644 --- a/cocos/input/types/touch.ts +++ b/cocos/input/types/touch.ts @@ -32,15 +32,15 @@ const _vec2 = new Vec2(); * @zh 封装了触点相关的信息。 */ export class Touch { - private _point$: Vec2 = new Vec2(); - private _prevPoint$: Vec2 = new Vec2(); - private _lastModified$ = 0; + private _point: Vec2 = new Vec2(); + private _prevPoint: Vec2 = new Vec2(); + private _lastModified = 0; private _id = 0; - private _startPoint$: Vec2 = new Vec2(); - private _startPointCaptured$ = false; + private _startPoint: Vec2 = new Vec2(); + private _startPointCaptured = false; get lastModified (): number { - return this._lastModified$; + return this._lastModified; } /** @@ -62,7 +62,7 @@ export class Touch { out = new Vec2(); } - out.set(this._point$.x, this._point$.y); + out.set(this._point.x, this._point.y); return out; } @@ -71,7 +71,7 @@ export class Touch { * @zh 获取当前触点 X 轴位置。 */ public getLocationX (): number { - return this._point$.x; + return this._point.x; } /** @@ -79,7 +79,7 @@ export class Touch { * @zh 获取当前触点 Y 轴位置。 */ public getLocationY (): number { - return this._point$.y; + return this._point.y; } /** @@ -92,7 +92,7 @@ export class Touch { out = new Vec2(); } - out.set(this._point$.x, this._point$.y); + out.set(this._point.x, this._point.y); (cclegacy.view as View)._convertToUISpace(out); return out; } @@ -104,7 +104,7 @@ export class Touch { public getUILocationX (): number { const view = cclegacy.view as View; const viewport = view.getViewportRect(); - return (this._point$.x - viewport.x) / view.getScaleX(); + return (this._point.x - viewport.x) / view.getScaleX(); } /** @@ -114,7 +114,7 @@ export class Touch { public getUILocationY (): number { const view = cclegacy.view as View; const viewport = view.getViewportRect(); - return (this._point$.y - viewport.y) / view.getScaleY(); + return (this._point.y - viewport.y) / view.getScaleY(); } /** @@ -127,7 +127,7 @@ export class Touch { out = new Vec2(); } - out.set(this._prevPoint$.x, this._prevPoint$.y); + out.set(this._prevPoint.x, this._prevPoint.y); return out; } @@ -141,7 +141,7 @@ export class Touch { out = new Vec2(); } - out.set(this._prevPoint$.x, this._prevPoint$.y); + out.set(this._prevPoint.x, this._prevPoint.y); (cclegacy.view as View)._convertToUISpace(out); return out; } @@ -156,7 +156,7 @@ export class Touch { out = new Vec2(); } - out.set(this._startPoint$.x, this._startPoint$.y); + out.set(this._startPoint.x, this._startPoint.y); return out; } @@ -170,7 +170,7 @@ export class Touch { out = new Vec2(); } - out.set(this._startPoint$.x, this._startPoint$.y); + out.set(this._startPoint.x, this._startPoint.y); (cclegacy.view as View)._convertToUISpace(out); return out; } @@ -185,8 +185,8 @@ export class Touch { out = new Vec2(); } - out.set(this._point$); - out.subtract(this._prevPoint$); + out.set(this._point); + out.subtract(this._prevPoint); return out; } @@ -200,8 +200,8 @@ export class Touch { out = new Vec2(); } - _vec2.set(this._point$); - _vec2.subtract(this._prevPoint$); + _vec2.set(this._point); + _vec2.subtract(this._prevPoint); const view = cclegacy.view as View; out.set(view.getScaleX(), view.getScaleY()); Vec2.divide(out, _vec2, out); @@ -218,7 +218,7 @@ export class Touch { out = new Vec2(); } - out.set(this._point$.x, (cclegacy.view as View)._designResolutionSize.height - this._point$.y); + out.set(this._point.x, (cclegacy.view as View)._designResolutionSize.height - this._point.y); return out; } @@ -232,7 +232,7 @@ export class Touch { out = new Vec2(); } - out.set(this._prevPoint$.x, (cclegacy.view as View)._designResolutionSize.height - this._prevPoint$.y); + out.set(this._prevPoint.x, (cclegacy.view as View)._designResolutionSize.height - this._prevPoint.y); return out; } @@ -246,7 +246,7 @@ export class Touch { out = new Vec2(); } - out.set(this._startPoint$.x, (cclegacy.view as View)._designResolutionSize.height - this._startPoint$.y); + out.set(this._startPoint.x, (cclegacy.view as View)._designResolutionSize.height - this._startPoint.y); return out; } @@ -266,12 +266,12 @@ export class Touch { * @param y - y position of the touch point */ public setTouchInfo (id: number = 0, x: number = 0, y: number = 0): void { - this._prevPoint$ = this._point$; - this._point$ = new Vec2(x || 0, y || 0); + this._prevPoint = this._point; + this._point = new Vec2(x || 0, y || 0); this._id = id; - if (!this._startPointCaptured$) { - this._startPoint$ = new Vec2(this._point$); - this._startPointCaptured$ = true; + if (!this._startPointCaptured) { + this._startPoint = new Vec2(this._point); + this._startPointCaptured = true; } } @@ -292,13 +292,13 @@ export class Touch { public setPoint (x: number | Vec2, y?: number): void { if (typeof x === 'object') { - this._point$.x = x.x; - this._point$.y = x.y; + this._point.x = x.x; + this._point.y = x.y; } else { - this._point$.x = x || 0; - this._point$.y = y || 0; + this._point.x = x || 0; + this._point.y = y || 0; } - this._lastModified$ = cclegacy.game.frameStartTime; + this._lastModified = cclegacy.game.frameStartTime; } /** @@ -318,11 +318,11 @@ export class Touch { public setPrevPoint (x: number | Vec2, y?: number): void { if (typeof x === 'object') { - this._prevPoint$ = new Vec2(x.x, x.y); + this._prevPoint = new Vec2(x.x, x.y); } else { - this._prevPoint$ = new Vec2(x || 0, y || 0); + this._prevPoint = new Vec2(x || 0, y || 0); } - this._lastModified$ = cclegacy.game.frameStartTime; + this._lastModified = cclegacy.game.frameStartTime; } /** diff --git a/cocos/physics-2d/box2d-wasm/physics-world.ts b/cocos/physics-2d/box2d-wasm/physics-world.ts index f00ff3c0dde..4cfdc56cf75 100644 --- a/cocos/physics-2d/box2d-wasm/physics-world.ts +++ b/cocos/physics-2d/box2d-wasm/physics-world.ts @@ -345,7 +345,7 @@ export class B2PhysicsWorld implements IPhysicsWorld { } } - public _updateBodyType$ (body: B2RigidBody2D): void { + public _updateBodyType (body: B2RigidBody2D): void { const animatedBodies = this._animatedBodies; const comp = body.rigidBody; if (comp.type !== ERigidBody2DType.Animated) { diff --git a/cocos/physics-2d/box2d-wasm/rigid-body.ts b/cocos/physics-2d/box2d-wasm/rigid-body.ts index 2e5a7ef0e1a..9a74ed4864b 100644 --- a/cocos/physics-2d/box2d-wasm/rigid-body.ts +++ b/cocos/physics-2d/box2d-wasm/rigid-body.ts @@ -222,7 +222,7 @@ export class B2RigidBody2D implements IRigidBody2D { } setType (v: ERigidBody2DType): void { - (PhysicsSystem2D.instance.physicsWorld as B2PhysicsWorld)._updateBodyType$(this); + (PhysicsSystem2D.instance.physicsWorld as B2PhysicsWorld)._updateBodyType(this); if (v === ERigidBody2DType.Dynamic) { this._body!.SetType(B2.BodyType.b2_dynamicBody as B2.BodyType); } else if (v === ERigidBody2DType.Kinematic) { diff --git a/cocos/physics-2d/box2d/physics-world.ts b/cocos/physics-2d/box2d/physics-world.ts index 62dca2ec6d9..d8da3d0fb30 100644 --- a/cocos/physics-2d/box2d/physics-world.ts +++ b/cocos/physics-2d/box2d/physics-world.ts @@ -326,7 +326,7 @@ export class b2PhysicsWorld implements IPhysicsWorld { } } - public _updateBodyType$ (body: b2RigidBody2D): void { + public _updateBodyType (body: b2RigidBody2D): void { const animatedBodies = this._animatedBodies; const comp = body.rigidBody; if (comp.type !== ERigidBody2DType.Animated) { diff --git a/cocos/physics-2d/box2d/rigid-body.ts b/cocos/physics-2d/box2d/rigid-body.ts index d4c66f62638..ccdcf8352ef 100644 --- a/cocos/physics-2d/box2d/rigid-body.ts +++ b/cocos/physics-2d/box2d/rigid-body.ts @@ -208,7 +208,7 @@ export class b2RigidBody2D implements IRigidBody2D { } setType (v: ERigidBody2DType): void { - (PhysicsSystem2D.instance.physicsWorld as b2PhysicsWorld)._updateBodyType$(this); + (PhysicsSystem2D.instance.physicsWorld as b2PhysicsWorld)._updateBodyType(this); this._body!.SetType(v as number); } setLinearDamping (v: number): void { diff --git a/cocos/render-scene/core/material-instance.ts b/cocos/render-scene/core/material-instance.ts index 0fee61db354..e41bb37c753 100644 --- a/cocos/render-scene/core/material-instance.ts +++ b/cocos/render-scene/core/material-instance.ts @@ -40,25 +40,25 @@ export interface IMaterialInstanceInfo { */ export class MaterialInstance extends Material { get parent (): Material { - return this._parent$; + return this._parent; } get owner (): Renderer | null { - return this._owner$; + return this._owner; } protected _passes: PassInstance[] = []; - private declare _parent$: Material; - private declare _owner$: Renderer | null; - private _subModelIdx$ = 0; + private declare _parent: Material; + private declare _owner: Renderer | null; + private _subModelIdx = 0; constructor (info: IMaterialInstanceInfo) { super(); - this._parent$ = info.parent; - this._owner$ = info.owner || null; - this._subModelIdx$ = info.subModelIdx || 0; - this.copy(this._parent$); + this._parent = info.parent; + this._owner = info.owner || null; + this._subModelIdx = info.subModelIdx || 0; + this.copy(this._parent); } public recompileShaders (overrides: MacroRecord, passIdx?: number): void { @@ -96,14 +96,14 @@ export class MaterialInstance extends Material { public onPassStateChange (dontNotify: boolean): void { this._hash = Material.getHash(this); - if (!dontNotify && this._owner$) { - this._owner$._onRebuildPSO(this._subModelIdx$, this); + if (!dontNotify && this._owner) { + this._owner._onRebuildPSO(this._subModelIdx, this); } } protected _createPasses (): PassInstance[] { const passes: PassInstance[] = []; - const parentPasses = this._parent$.passes; + const parentPasses = this._parent.passes; if (!parentPasses) { return passes; } for (let k = 0; k < parentPasses.length; ++k) { passes.push(new PassInstance(parentPasses[k], this)); diff --git a/cocos/render-scene/core/memory-pools.ts b/cocos/render-scene/core/memory-pools.ts index 45d3c4d6570..f166f970bde 100644 --- a/cocos/render-scene/core/memory-pools.ts +++ b/cocos/render-scene/core/memory-pools.ts @@ -65,90 +65,90 @@ class BufferPool

implements IMemor // naming convension: // this._bufferViews[chunk][entry][element] - private declare _dataType$: BufferDataTypeManifest; - private declare _dataMembers$: BufferDataMembersManifest; - private declare _elementCount$: number; - private declare _entryBits$: number; - private declare _stride$: number; - private declare _entriesPerChunk$: number; - private declare _entryMask$: number; - private declare _chunkMask$: number; - private declare _poolFlag$: number; - private _arrayBuffers$: ArrayBuffer[] = []; - private _freeLists$: number[][] = []; - private _uint32BufferViews$: Uint32Array[][] = []; - private _float32BufferViews$: Float32Array[][] = []; - private _hasUint32$ = false; - private _hasFloat32$ = false; - private declare _nativePool$: NativeBufferPool; + private declare _dataType: BufferDataTypeManifest; + private declare _dataMembers: BufferDataMembersManifest; + private declare _elementCount: number; + private declare _entryBits: number; + private declare _stride: number; + private declare _entriesPerChunk: number; + private declare _entryMask: number; + private declare _chunkMask: number; + private declare _poolFlag: number; + private _arrayBuffers: ArrayBuffer[] = []; + private _freeLists: number[][] = []; + private _uint32BufferViews: Uint32Array[][] = []; + private _float32BufferViews: Float32Array[][] = []; + private _hasUint32 = false; + private _hasFloat32 = false; + private declare _nativePool: NativeBufferPool; constructor (poolType: P, dataType: BufferDataTypeManifest, dataMembers: BufferDataMembersManifest, enumType: E, entryBits = 8) { - this._elementCount$ = enumType.COUNT; - this._entryBits$ = entryBits; - this._dataType$ = dataType; - this._dataMembers$ = dataMembers; + this._elementCount = enumType.COUNT; + this._entryBits = entryBits; + this._dataType = dataType; + this._dataMembers = dataMembers; const bytesPerElement = 4; - this._stride$ = bytesPerElement * this._elementCount$; - this._entriesPerChunk$ = 1 << entryBits; - this._entryMask$ = this._entriesPerChunk$ - 1; - this._poolFlag$ = 1 << 30; - this._chunkMask$ = ~(this._entryMask$ | this._poolFlag$); - this._nativePool$ = new NativeBufferPool(poolType, entryBits, this._stride$); + this._stride = bytesPerElement * this._elementCount; + this._entriesPerChunk = 1 << entryBits; + this._entryMask = this._entriesPerChunk - 1; + this._poolFlag = 1 << 30; + this._chunkMask = ~(this._entryMask | this._poolFlag); + this._nativePool = new NativeBufferPool(poolType, entryBits, this._stride); let type: BufferDataType = BufferDataType.NEVER; let hasFloat32 = false; let hasUint32 = false; for (const e in dataType) { - hasFloat32 = this._hasFloat32$; - hasUint32 = this._hasUint32$; + hasFloat32 = this._hasFloat32; + hasUint32 = this._hasUint32; if (hasUint32 && hasFloat32) { break; } type = dataType[e as E[keyof E]]; if (!hasFloat32 && type === BufferDataType.FLOAT32) { - this._hasFloat32$ = true; + this._hasFloat32 = true; } else if (!hasUint32 && type === BufferDataType.UINT32) { - this._hasUint32$ = true; + this._hasUint32 = true; } } } public alloc (): IHandle

{ let i = 0; - for (; i < this._freeLists$.length; i++) { - const list = this._freeLists$[i]; + for (; i < this._freeLists.length; i++) { + const list = this._freeLists[i]; if (list.length) { const j = list[list.length - 1]; list.length--; - return (i << this._entryBits$) + j + this._poolFlag$ as unknown as IHandle

; + return (i << this._entryBits) + j + this._poolFlag as unknown as IHandle

; } } // add a new chunk - const buffer = this._nativePool$.allocateNewChunk(); + const buffer = this._nativePool.allocateNewChunk(); const float32BufferViews: Float32Array[] = []; const uint32BufferViews: Uint32Array[] = []; const freeList: number[] = []; - const hasFloat32 = this._hasFloat32$; - const hasUint32 = this._hasUint32$; - for (let j = 0; j < this._entriesPerChunk$; j++) { - if (hasFloat32) { float32BufferViews.push(new Float32Array(buffer, this._stride$ * j, this._elementCount$)); } - if (hasUint32) { uint32BufferViews.push(new Uint32Array(buffer, this._stride$ * j, this._elementCount$)); } + const hasFloat32 = this._hasFloat32; + const hasUint32 = this._hasUint32; + for (let j = 0; j < this._entriesPerChunk; j++) { + if (hasFloat32) { float32BufferViews.push(new Float32Array(buffer, this._stride * j, this._elementCount)); } + if (hasUint32) { uint32BufferViews.push(new Uint32Array(buffer, this._stride * j, this._elementCount)); } if (j) { freeList.push(j); } } - if (hasUint32) { this._uint32BufferViews$.push(uint32BufferViews); } - if (hasFloat32) { this._float32BufferViews$.push(float32BufferViews); } - this._freeLists$.push(freeList); - this._arrayBuffers$.push(buffer); - const handle = (i << this._entryBits$) + this._poolFlag$ as unknown as IHandle

; + if (hasUint32) { this._uint32BufferViews.push(uint32BufferViews); } + if (hasFloat32) { this._float32BufferViews.push(float32BufferViews); } + this._freeLists.push(freeList); + this._arrayBuffers.push(buffer); + const handle = (i << this._entryBits) + this._poolFlag as unknown as IHandle

; return handle; // guarantees the handle is always not zero } public getBuffer (handle: IHandle

): BufferArrayType { - const chunk = (this._chunkMask$ & handle as unknown as number) >> this._entryBits$; - const entry = this._entryMask$ & handle as unknown as number; - const bufferViews = this._hasFloat32$ ? this._float32BufferViews$ : this._uint32BufferViews$; + const chunk = (this._chunkMask & handle as unknown as number) >> this._entryBits; + const entry = this._entryMask & handle as unknown as number; + const bufferViews = this._hasFloat32 ? this._float32BufferViews : this._uint32BufferViews; if (DEBUG && (!handle || chunk < 0 || chunk >= bufferViews.length - || entry < 0 || entry >= this._entriesPerChunk$ || contains(this._freeLists$[chunk], entry))) { + || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { warn('invalid buffer pool handle'); return [] as unknown as BufferArrayType; } @@ -157,32 +157,32 @@ class BufferPool

implements IMemor } public getTypedArray (handle: IHandle

, element: K): BufferArrayType { - const chunk = (this._chunkMask$ & handle as unknown as number) >> this._entryBits$; - const entry = this._entryMask$ & handle as unknown as number; - const bufferViews = this._dataType$[element] === BufferDataType.UINT32 ? this._uint32BufferViews$ : this._float32BufferViews$; + const chunk = (this._chunkMask & handle as unknown as number) >> this._entryBits; + const entry = this._entryMask & handle as unknown as number; + const bufferViews = this._dataType[element] === BufferDataType.UINT32 ? this._uint32BufferViews : this._float32BufferViews; if (DEBUG && (!handle || chunk < 0 || chunk >= bufferViews.length - || entry < 0 || entry >= this._entriesPerChunk$ || contains(this._freeLists$[chunk], entry))) { + || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { warn('invalid buffer pool handle'); return [] as unknown as BufferArrayType; } const index = element as unknown as number; const view = bufferViews[chunk][entry]; - const count = this._dataMembers$[element]; + const count = this._dataMembers[element]; return view.subarray(index, index + count); } public free (handle: IHandle

): void { - const chunk = (this._chunkMask$ & handle as unknown as number) >> this._entryBits$; - const entry = this._entryMask$ & handle as unknown as number; - if (DEBUG && (!handle || chunk < 0 || chunk >= this._freeLists$.length - || entry < 0 || entry >= this._entriesPerChunk$ || contains(this._freeLists$[chunk], entry))) { + const chunk = (this._chunkMask & handle as unknown as number) >> this._entryBits; + const entry = this._entryMask & handle as unknown as number; + if (DEBUG && (!handle || chunk < 0 || chunk >= this._freeLists.length + || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { warn('invalid buffer pool handle'); return; } - const bufferViews = this._hasUint32$ ? this._uint32BufferViews$ : this._float32BufferViews$; + const bufferViews = this._hasUint32 ? this._uint32BufferViews : this._float32BufferViews; bufferViews[chunk][entry].fill(0); - this._freeLists$[chunk].push(entry); + this._freeLists[chunk].push(entry); } } diff --git a/cocos/render-scene/core/native-pools.ts b/cocos/render-scene/core/native-pools.ts index 42fbd68417d..c225de9109e 100644 --- a/cocos/render-scene/core/native-pools.ts +++ b/cocos/render-scene/core/native-pools.ts @@ -23,12 +23,12 @@ */ export class NativeBufferPool { - private _arrayBuffers$: ArrayBuffer[] = []; - private declare _chunkSize$: number; + private _arrayBuffers: ArrayBuffer[] = []; + private declare _chunkSize: number; constructor (dataType: number, entryBits: number, stride: number) { - this._chunkSize$ = stride * (1 << entryBits); + this._chunkSize = stride * (1 << entryBits); } - public allocateNewChunk (): ArrayBuffer { return new ArrayBuffer(this._chunkSize$); } + public allocateNewChunk (): ArrayBuffer { return new ArrayBuffer(this._chunkSize); } } export class NativeObjectPool { diff --git a/cocos/render-scene/core/pass-instance.ts b/cocos/render-scene/core/pass-instance.ts index 110c0f90dc8..0a5718fd5e4 100644 --- a/cocos/render-scene/core/pass-instance.ts +++ b/cocos/render-scene/core/pass-instance.ts @@ -36,27 +36,27 @@ export class PassInstance extends Pass { * @en The parent pass * @zh 相关联的原始 Pass */ - get parent (): Pass { return this._parent$; } + get parent (): Pass { return this._parent; } - private declare _parent$: Pass; + private declare _parent: Pass; - private declare _owner$: MaterialInstance; + private declare _owner: MaterialInstance; - private _dontNotify$ = false; + private _dontNotify = false; constructor (parent: Pass, owner: MaterialInstance) { super(parent.root); - this._parent$ = parent; - this._owner$ = owner; - this._doInit(this._parent$, true); // defines may change now + this._parent = parent; + this._owner = owner; + this._doInit(this._parent, true); // defines may change now for (let i = 0; i < this._shaderInfo.blocks.length; i++) { const u = this._shaderInfo.blocks[i]; const block = this._blocks[u.binding]; - const parentBlock = this._parent$.blocks[u.binding]; + const parentBlock = this._parent.blocks[u.binding]; block.set(parentBlock); } this._rootBufferDirty = true; - const paren = this._parent$ as PassInstance; + const paren = this._parent as PassInstance; for (let i = 0; i < this._shaderInfo.samplerTextures.length; i++) { const u = this._shaderInfo.samplerTextures[i]; for (let j = 0; j < u.count; j++) { @@ -102,7 +102,7 @@ export class PassInstance extends Pass { * @zh 开始静默修改 Pass 相关状态,不会通知材质去重新构建管线状态对象。 */ public beginChangeStatesSilently (): void { - this._dontNotify$ = true; + this._dontNotify = true; } /** @@ -110,7 +110,7 @@ export class PassInstance extends Pass { * @zh 结束静默状态修改,所有修改将会开始通知材质。 */ public endChangeStatesSilently (): void { - this._dontNotify$ = false; + this._dontNotify = false; } protected _syncBatchingScheme (): void { @@ -120,6 +120,6 @@ export class PassInstance extends Pass { protected _onStateChange (): void { this._hash = Pass.getPassHash(this); - this._owner$.onPassStateChange(this._dontNotify$); + this._owner.onPassStateChange(this._dontNotify); } } diff --git a/cocos/render-scene/core/pass.ts b/cocos/render-scene/core/pass.ts index 923e5afda41..225b5fa84fe 100644 --- a/cocos/render-scene/core/pass.ts +++ b/cocos/render-scene/core/pass.ts @@ -269,7 +269,7 @@ export class Pass { const binding = Pass.getBindingFromHandle(handle); const type = Pass.getTypeFromHandle(handle); const ofs = Pass.getOffsetFromHandle(handle); - const block = this._getBlockView$(type, binding); + const block = this._getBlockView(type, binding); if (DEBUG) { const validator = type2validator[type]; assertID(Boolean(validator && validator(value)), 12011, binding, Type[type]); @@ -288,7 +288,7 @@ export class Pass { const binding = Pass.getBindingFromHandle(handle); const type = Pass.getTypeFromHandle(handle); const ofs = Pass.getOffsetFromHandle(handle); - const block = this._getBlockView$(type, binding); + const block = this._getBlockView(type, binding); return type2reader[type](block, out, ofs) as T; } @@ -302,7 +302,7 @@ export class Pass { const binding = Pass.getBindingFromHandle(handle); const type = Pass.getTypeFromHandle(handle); const stride = GetTypeSize(type) >> 2; - const block = this._getBlockView$(type, binding); + const block = this._getBlockView(type, binding); let ofs = Pass.getOffsetFromHandle(handle); for (let i = 0; i < value.length; i++, ofs += stride) { if (value[i] === null) { continue; } @@ -412,7 +412,7 @@ export class Pass { const binding = Pass.getBindingFromHandle(handle); const ofs = Pass.getOffsetFromHandle(handle); const count = Pass.getCountFromHandle(handle); - const block = this._getBlockView$(type, binding); + const block = this._getBlockView(type, binding); const info = this._properties[name]; const givenDefault = info && info.value; const value = (givenDefault || getDefaultFromType(type)) as number[]; @@ -456,7 +456,7 @@ export class Pass { let ofs = 0; for (let j = 0; j < u.members.length; j++) { const cur = u.members[j]; - const block = this._getBlockView$(cur.type, u.binding); + const block = this._getBlockView(cur.type, u.binding); const info = this._properties[cur.name]; const givenDefault = info && info.value; const value = (givenDefault || getDefaultFromType(cur.type)) as number[]; @@ -693,9 +693,9 @@ export class Pass { if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { const programLib = (cclegacy.rendering.programLib as ProgramLibrary); const shaderInfo = programLib.getShaderInfo(this._phaseID, this.program); - this._buildMaterialUniformBlocks$(device, shaderInfo.blocks, blockSizes); + this._buildMaterialUniformBlocks(device, shaderInfo.blocks, blockSizes); } else { - this._buildUniformBlocks$(device, blocks, blockSizes); + this._buildUniformBlocks(device, blocks, blockSizes); } // store handles @@ -709,7 +709,7 @@ export class Pass { Object.assign(directHandleMap, indirectHandleMap); } - private _buildUniformBlocks$ (device: Device, blocks: EffectAsset.IBlockInfo[], blockSizes: number[]): void { + private _buildUniformBlocks (device: Device, blocks: EffectAsset.IBlockInfo[], blockSizes: number[]): void { const alignment = device.capabilities.uboOffsetAlignment; const startOffsets: number[] = []; let lastSize = 0; let lastOffset = 0; @@ -747,7 +747,7 @@ export class Pass { } } - private _buildMaterialUniformBlocks$ (device: Device, blocks: UniformBlock[], blockSizes: number[]): void { + private _buildMaterialUniformBlocks (device: Device, blocks: UniformBlock[], blockSizes: number[]): void { const alignment = device.capabilities.uboOffsetAlignment; const startOffsets: number[] = []; let lastSize = 0; let lastOffset = 0; @@ -808,7 +808,7 @@ export class Pass { } } - private _getBlockView$ (type: Type, binding: number): Int32Array | Float32Array { + private _getBlockView (type: Type, binding: number): Int32Array | Float32Array { return type < Type.FLOAT ? this._blocksInt[binding] : this._blocks[binding]; } diff --git a/cocos/render-scene/core/render-scene.ts b/cocos/render-scene/core/render-scene.ts index 642994c8b85..c0acfbe3ab6 100644 --- a/cocos/render-scene/core/render-scene.ts +++ b/cocos/render-scene/core/render-scene.ts @@ -70,7 +70,7 @@ export class RenderScene { * @zh 基础渲染管理器。 */ get root (): Root { - return this._root$; + return this._root; } /** @@ -78,7 +78,7 @@ export class RenderScene { * @zh 渲染场景的名称。 */ get name (): string { - return this._name$; + return this._name; } /** @@ -86,7 +86,7 @@ export class RenderScene { * @zh 渲染场景管理的所有相机。 */ get cameras (): Camera[] { - return this._cameras$; + return this._cameras; } /** @@ -94,7 +94,7 @@ export class RenderScene { * @zh 渲染场景管理的主方向光源。 */ get mainLight (): DirectionalLight | null { - return this._mainLight$; + return this._mainLight; } /** @@ -102,7 +102,7 @@ export class RenderScene { * @zh 渲染场景管理的所有球面光源。 */ get sphereLights (): Readonly { - return this._sphereLights$; + return this._sphereLights; } /** @@ -110,7 +110,7 @@ export class RenderScene { * @zh 渲染场景管理的所有聚光灯光源。 */ get spotLights (): Readonly { - return this._spotLights$; + return this._spotLights; } /** @@ -118,7 +118,7 @@ export class RenderScene { * @zh 渲染场景管理的所有点光源。 */ get pointLights (): Readonly { - return this._pointLights$; + return this._pointLights; } /** @@ -126,7 +126,7 @@ export class RenderScene { * @zh 渲染场景管理的所有范围平行光光源。 */ get rangedDirLights (): Readonly { - return this._rangedDirLights$; + return this._rangedDirLights; } /** @@ -134,7 +134,7 @@ export class RenderScene { * @zh 渲染场景管理的所有模型。 */ get models (): Model[] { - return this._models$; + return this._models; } /** @@ -142,7 +142,7 @@ export class RenderScene { * @zh 渲染场景管理的所有 2D 渲染批次对象。 */ get batches (): DrawBatch2D[] { - return this._batches$; + return this._batches; } /** @@ -150,22 +150,22 @@ export class RenderScene { * @en All LOD groups of the render scene. * @zh 渲染场景管理的所有 LOD 组。 */ - get lodGroups (): readonly LODGroup[] { return this._lodGroups$; } + get lodGroups (): readonly LODGroup[] { return this._lodGroups; } - private declare _root$: Root; - private _name$ = ''; - private _cameras$: Camera[] = []; - private _models$: Model[] = []; - private _lodGroups$: LODGroup[] = []; // LOD Group gathered - private _batches$: DrawBatch2D[] = []; - private _directionalLights$: DirectionalLight[] = []; - private _sphereLights$: SphereLight[] = []; - private _spotLights$: SpotLight[] = []; - private _pointLights$: PointLight[] = []; - private _rangedDirLights$: RangedDirectionalLight[] = []; - private _mainLight$: DirectionalLight | null = null; - private _modelId$ = 0; - private _lodStateCache$: LodStateCache = null!; + private declare _root: Root; + private _name = ''; + private _cameras: Camera[] = []; + private _models: Model[] = []; + private _lodGroups: LODGroup[] = []; // LOD Group gathered + private _batches: DrawBatch2D[] = []; + private _directionalLights: DirectionalLight[] = []; + private _sphereLights: SphereLight[] = []; + private _spotLights: SpotLight[] = []; + private _pointLights: PointLight[] = []; + private _rangedDirLights: RangedDirectionalLight[] = []; + private _mainLight: DirectionalLight | null = null; + private _modelId = 0; + private _lodStateCache: LodStateCache = null!; /** * Register the creation function of the render scene to root. @@ -176,7 +176,7 @@ export class RenderScene { } constructor (root: Root) { - this._root$ = root; + this._root = root; } /** @@ -185,8 +185,8 @@ export class RenderScene { * @returns Successful */ public initialize (info: IRenderSceneInfo): boolean { - this._name$ = info.name; - this._lodStateCache$ = new LodStateCache(this); + this._name = info.name; + this._lodStateCache = new LodStateCache(this); return true; } @@ -197,36 +197,36 @@ export class RenderScene { * @returns void */ public update (stamp: number): void { - const mainLight = this._mainLight$; + const mainLight = this._mainLight; if (mainLight) { mainLight.update(); } - const sphereLights = this._sphereLights$; + const sphereLights = this._sphereLights; for (let i = 0; i < sphereLights.length; i++) { const light = sphereLights[i]; light.update(); } - const spotLights = this._spotLights$; + const spotLights = this._spotLights; for (let i = 0; i < spotLights.length; i++) { const light = spotLights[i]; light.update(); } - const pointLights = this._pointLights$; + const pointLights = this._pointLights; for (let i = 0; i < pointLights.length; i++) { const light = pointLights[i]; light.update(); } - const rangedDirLights = this._rangedDirLights$; + const rangedDirLights = this._rangedDirLights; for (let i = 0; i < rangedDirLights.length; i++) { const light = rangedDirLights[i]; light.update(); } - const models = this._models$; + const models = this._models; for (let i = 0; i < models.length; i++) { const model = models[i]; @@ -235,7 +235,7 @@ export class RenderScene { model.updateUBOs(stamp); } } - this._lodStateCache$.updateLodState(); + this._lodStateCache.updateLodState(); } /** @@ -249,11 +249,11 @@ export class RenderScene { this.removeRangedDirLights(); this.removeModels(); this.removeLODGroups(); - this._lodStateCache$.clearCache(); + this._lodStateCache.clearCache(); } public isCulledByLod (camera: Camera, model: Model): boolean { - return this._lodStateCache$.isLodModelCulled(camera, model); + return this._lodStateCache.isLodModelCulled(camera, model); } /** @@ -262,8 +262,8 @@ export class RenderScene { */ public addCamera (cam: Camera): void { cam.attachToScene(this); - this._cameras$.push(cam); - this._lodStateCache$.addCamera(cam); + this._cameras.push(cam); + this._lodStateCache.addCamera(cam); } /** @@ -271,11 +271,11 @@ export class RenderScene { * @zh 从渲染场景移除一个相机 */ public removeCamera (camera: Camera): void { - for (let i = 0; i < this._cameras$.length; ++i) { - if (this._cameras$[i] === camera) { - this._cameras$.splice(i, 1); + for (let i = 0; i < this._cameras.length; ++i) { + if (this._cameras[i] === camera) { + this._cameras.splice(i, 1); camera.detachFromScene(); - this._lodStateCache$.removeCamera(camera); + this._lodStateCache.removeCamera(camera); return; } } @@ -286,11 +286,11 @@ export class RenderScene { * @zh 从渲染场景移除所有相机 */ public removeCameras (): void { - for (const camera of this._cameras$) { + for (const camera of this._cameras) { camera.detachFromScene(); - this._lodStateCache$.removeCamera(camera); + this._lodStateCache.removeCamera(camera); } - this._cameras$.splice(0); + this._cameras.splice(0); } /** @@ -299,8 +299,8 @@ export class RenderScene { * @param dl The main directional light source */ public setMainLight (dl: DirectionalLight | null): void { - this._mainLight$ = dl; - if (this._mainLight$) this._mainLight$.activate(); + this._mainLight = dl; + if (this._mainLight) this._mainLight.activate(); } /** @@ -309,12 +309,12 @@ export class RenderScene { * @param dl The main directional light source, if it's not the actual main light, nothing happens. */ public unsetMainLight (dl: DirectionalLight): void { - if (this._mainLight$ === dl) { - const dlList = this._directionalLights$; + if (this._mainLight === dl) { + const dlList = this._directionalLights; if (dlList.length) { this.setMainLight(dlList[dlList.length - 1]); - if (this._mainLight$.node) { // trigger update - this._mainLight$.node.hasChangedFlags |= TransformBit.ROTATION; + if (this._mainLight.node) { // trigger update + this._mainLight.node.hasChangedFlags |= TransformBit.ROTATION; } return; } @@ -329,7 +329,7 @@ export class RenderScene { */ public addDirectionalLight (dl: DirectionalLight): void { dl.attachToScene(this); - this._directionalLights$.push(dl); + this._directionalLights.push(dl); } /** @@ -338,10 +338,10 @@ export class RenderScene { * @param dl The directional light. */ public removeDirectionalLight (dl: DirectionalLight): void { - for (let i = 0; i < this._directionalLights$.length; ++i) { - if (this._directionalLights$[i] === dl) { + for (let i = 0; i < this._directionalLights.length; ++i) { + if (this._directionalLights[i] === dl) { dl.detachFromScene(); - this._directionalLights$.splice(i, 1); + this._directionalLights.splice(i, 1); return; } } @@ -354,7 +354,7 @@ export class RenderScene { */ public addSphereLight (pl: SphereLight): void { pl.attachToScene(this); - this._sphereLights$.push(pl); + this._sphereLights.push(pl); } /** @@ -363,10 +363,10 @@ export class RenderScene { * @param pl The sphere light. */ public removeSphereLight (pl: SphereLight): void { - for (let i = 0; i < this._sphereLights$.length; ++i) { - if (this._sphereLights$[i] === pl) { + for (let i = 0; i < this._sphereLights.length; ++i) { + if (this._sphereLights[i] === pl) { pl.detachFromScene(); - this._sphereLights$.splice(i, 1); + this._sphereLights.splice(i, 1); return; } @@ -380,7 +380,7 @@ export class RenderScene { */ public addSpotLight (sl: SpotLight): void { sl.attachToScene(this); - this._spotLights$.push(sl); + this._spotLights.push(sl); } /** @@ -389,10 +389,10 @@ export class RenderScene { * @param sl The spot light. */ public removeSpotLight (sl: SpotLight): void { - for (let i = 0; i < this._spotLights$.length; ++i) { - if (this._spotLights$[i] === sl) { + for (let i = 0; i < this._spotLights.length; ++i) { + if (this._spotLights[i] === sl) { sl.detachFromScene(); - this._spotLights$.splice(i, 1); + this._spotLights.splice(i, 1); return; } @@ -404,10 +404,10 @@ export class RenderScene { * @zh 删除所有球面光源。 */ public removeSphereLights (): void { - for (let i = 0; i < this._sphereLights$.length; ++i) { - this._sphereLights$[i].detachFromScene(); + for (let i = 0; i < this._sphereLights.length; ++i) { + this._sphereLights[i].detachFromScene(); } - this._sphereLights$.length = 0; + this._sphereLights.length = 0; } /** @@ -415,10 +415,10 @@ export class RenderScene { * @zh 删除所有聚光灯光源。 */ public removeSpotLights (): void { - for (let i = 0; i < this._spotLights$.length; ++i) { - this._spotLights$[i].detachFromScene(); + for (let i = 0; i < this._spotLights.length; ++i) { + this._spotLights[i].detachFromScene(); } - this._spotLights$.length = 0; + this._spotLights.length = 0; } /** @@ -428,7 +428,7 @@ export class RenderScene { */ public addPointLight (pl: PointLight): void { pl.attachToScene(this); - this._pointLights$.push(pl); + this._pointLights.push(pl); } /** @@ -437,10 +437,10 @@ export class RenderScene { * @param pl @en The point light. @zh 点光源。 */ public removePointLight (pl: PointLight): void { - for (let i = 0; i < this._pointLights$.length; ++i) { - if (this._pointLights$[i] === pl) { + for (let i = 0; i < this._pointLights.length; ++i) { + if (this._pointLights[i] === pl) { pl.detachFromScene(); - this._pointLights$.splice(i, 1); + this._pointLights.splice(i, 1); return; } } @@ -451,10 +451,10 @@ export class RenderScene { * @zh 删除所有点光源。 */ public removePointLights (): void { - for (let i = 0; i < this._pointLights$.length; ++i) { - this._pointLights$[i].detachFromScene(); + for (let i = 0; i < this._pointLights.length; ++i) { + this._pointLights[i].detachFromScene(); } - this._pointLights$.length = 0; + this._pointLights.length = 0; } /** @@ -464,7 +464,7 @@ export class RenderScene { */ public addRangedDirLight (l: RangedDirectionalLight): void { l.attachToScene(this); - this._rangedDirLights$.push(l); + this._rangedDirLights.push(l); } /** @@ -473,10 +473,10 @@ export class RenderScene { * @param l @en The ranged directional light. @zh 范围平行光。 */ public removeRangedDirLight (l: RangedDirectionalLight): void { - for (let i = 0; i < this._rangedDirLights$.length; ++i) { - if (this._rangedDirLights$[i] === l) { + for (let i = 0; i < this._rangedDirLights.length; ++i) { + if (this._rangedDirLights[i] === l) { l.detachFromScene(); - this._rangedDirLights$.splice(i, 1); + this._rangedDirLights.splice(i, 1); return; } } @@ -487,10 +487,10 @@ export class RenderScene { * @zh 删除所有范围平行光源。 */ public removeRangedDirLights (): void { - for (let i = 0; i < this._rangedDirLights$.length; ++i) { - this._rangedDirLights$[i].detachFromScene(); + for (let i = 0; i < this._rangedDirLights.length; ++i) { + this._rangedDirLights[i].detachFromScene(); } - this._rangedDirLights$.length = 0; + this._rangedDirLights.length = 0; } /** @@ -500,7 +500,7 @@ export class RenderScene { */ public addModel (m: Model): void { m.attachToScene(this); - this._models$.push(m); + this._models.push(m); } /** @@ -509,11 +509,11 @@ export class RenderScene { * @param m The model. */ public removeModel (model: Model): void { - for (let i = 0; i < this._models$.length; ++i) { - if (this._models$[i] === model) { - this._lodStateCache$.removeModel(model); + for (let i = 0; i < this._models.length; ++i) { + if (this._models[i] === model) { + this._lodStateCache.removeModel(model); model.detachFromScene(); - this._models$.splice(i, 1); + this._models.splice(i, 1); return; } @@ -525,12 +525,12 @@ export class RenderScene { * @zh 删除所有模型。 */ public removeModels (): void { - for (const m of this._models$) { - this._lodStateCache$.removeModel(m); + for (const m of this._models) { + this._lodStateCache.removeModel(m); m.detachFromScene(); m.destroy(); } - this._models$.length = 0; + this._models.length = 0; } /** @@ -541,7 +541,7 @@ export class RenderScene { * @deprecated since v3.6.0, this is an engine private interface that will be removed in the future. */ public addBatch (batch: DrawBatch2D): void { - this._batches$.push(batch); + this._batches.push(batch); } /** @@ -552,9 +552,9 @@ export class RenderScene { * @deprecated since v3.6.0, this is an engine private interface that will be removed in the future. */ public removeBatch (batch: DrawBatch2D): void { - for (let i = 0; i < this._batches$.length; ++i) { - if (this._batches$[i] === batch) { - this._batches$.splice(i, 1); + for (let i = 0; i < this._batches.length; ++i) { + if (this._batches[i] === batch) { + this._batches.splice(i, 1); return; } } @@ -567,7 +567,7 @@ export class RenderScene { * @deprecated since v3.6.0, this is an engine private interface that will be removed in the future. */ public removeBatches (): void { - this._batches$.length = 0; + this._batches.length = 0; } /** @@ -577,9 +577,9 @@ export class RenderScene { * @param lodGroup the LOD group */ addLODGroup (lodGroup: LODGroup): void { - this._lodGroups$.push(lodGroup); + this._lodGroups.push(lodGroup); lodGroup.attachToScene(this); - this._lodStateCache$.addLodGroup(lodGroup); + this._lodStateCache.addLodGroup(lodGroup); } /** @@ -589,11 +589,11 @@ export class RenderScene { * @param lodGroup the LOD group */ removeLODGroup (lodGroup: LODGroup): void { - const index = this._lodGroups$.indexOf(lodGroup); + const index = this._lodGroups.indexOf(lodGroup); if (index >= 0) { - this._lodGroups$.splice(index, 1); + this._lodGroups.splice(index, 1); lodGroup.detachFromScene(); - this._lodStateCache$.removeLodGroup(lodGroup); + this._lodStateCache.removeLodGroup(lodGroup); } } @@ -603,10 +603,10 @@ export class RenderScene { * @zh 删除所有LOD 组。 */ removeLODGroups (): void { - for (const group of this._lodGroups$) { - this._lodStateCache$.removeLodGroup(group); + for (const group of this._lodGroups) { + this._lodStateCache.removeLodGroup(group); } - this._lodGroups$.length = 0; + this._lodGroups.length = 0; } /** @@ -614,7 +614,7 @@ export class RenderScene { * @zh 通知所有模型全局管线状态已更新,需要更新自身状态。 */ public onGlobalPipelineStateChanged (): void { - for (const m of this._models$) { + for (const m of this._models) { m.onGlobalPipelineStateChanged(); } } @@ -625,7 +625,7 @@ export class RenderScene { * @returns The model id */ public generateModelId (): number { - return this._modelId$++; + return this._modelId++; } } @@ -646,16 +646,16 @@ class LODInfo { */ class LodStateCache { constructor (scene: RenderScene) { - this._renderScene$ = scene; + this._renderScene = scene; } addCamera (camera: Camera): void { const needRegisterChanged = false; - for (const lodGroup of this._renderScene$.lodGroups) { + for (const lodGroup of this._renderScene.lodGroups) { const layer = lodGroup.node.layer; if ((camera.visibility & layer) === layer) { - if (!this._lodStateInCamera$.has(camera)) { - this._lodStateInCamera$.set(camera, new Map()); + if (!this._lodStateInCamera.has(camera)) { + this._lodStateInCamera.set(camera, new Map()); } break; } @@ -663,21 +663,21 @@ class LodStateCache { } removeCamera (camera: Camera): void { - if (this._lodStateInCamera$.has(camera)) { - this._lodStateInCamera$.delete(camera); + if (this._lodStateInCamera.has(camera)) { + this._lodStateInCamera.delete(camera); } } addLodGroup (lodGroup: LODGroup): void { - this._newAddedLodGroupVec$.push(lodGroup); + this._newAddedLodGroupVec.push(lodGroup); - for (const camera of this._renderScene$.cameras) { - if (this._lodStateInCamera$.has(camera)) { + for (const camera of this._renderScene.cameras) { + if (this._lodStateInCamera.has(camera)) { continue; } const layer = lodGroup.node.layer; if ((camera.visibility & layer) === layer) { - this._lodStateInCamera$.set(camera, new Map()); + this._lodStateInCamera.set(camera, new Map()); } } } @@ -686,29 +686,29 @@ class LodStateCache { for (let index = 0; index < lodGroup.lodCount; index++) { const lod = lodGroup.lodDataArray[index]; for (const model of lod.models) { - this._modelsInLODGroup$.delete(model); + this._modelsInLODGroup.delete(model); } } - for (const visibleCamera of this._lodStateInCamera$) { + for (const visibleCamera of this._lodStateInCamera) { visibleCamera[1].delete(lodGroup); } - this._levelModels$.delete(lodGroup); + this._levelModels.delete(lodGroup); } removeModel (model: Model): void { - if (this._modelsInLODGroup$.has(model)) { - this._modelsInLODGroup$.delete(model); + if (this._modelsInLODGroup.has(model)) { + this._modelsInLODGroup.delete(model); } } // Update list of visible cameras on _modelsInLODGroup and update lod usage level under specified camera. updateLodState (): void { // insert vecAddedLodGroup's model into modelsByAnyLODGroup - for (const addedLodGroup of this._newAddedLodGroupVec$) { - let levelModels = this._levelModels$.get(addedLodGroup); + for (const addedLodGroup of this._newAddedLodGroupVec) { + let levelModels = this._levelModels.get(addedLodGroup); if (!levelModels) { levelModels = new Map>(); - this._levelModels$.set(addedLodGroup, levelModels); + this._levelModels.set(addedLodGroup, levelModels); } for (let index = 0; index < addedLodGroup.lodCount; index++) { let lodModels = levelModels.get(index); @@ -717,20 +717,20 @@ class LodStateCache { } const lod = addedLodGroup.lodDataArray[index]; for (const model of lod.models) { - let modelInfo = this._modelsInLODGroup$.get(model); + let modelInfo = this._modelsInLODGroup.get(model); if (!modelInfo) { modelInfo = new Map(); } - this._modelsInLODGroup$.set(model, modelInfo); + this._modelsInLODGroup.set(model, modelInfo); lodModels.push(model); } levelModels.set(index, lodModels); } } - this._newAddedLodGroupVec$.length = 0; + this._newAddedLodGroupVec.length = 0; // update current visible lod index & model's visible cameras list - for (const lodGroup of this._renderScene$.lodGroups) { + for (const lodGroup of this._renderScene.lodGroups) { if (lodGroup.enabled) { const lodLevels = lodGroup.getLockedLODLevels(); const count = lodLevels.length; @@ -740,7 +740,7 @@ class LodStateCache { // Update the dirty flag to make it easier to update the visible // index of lod after lifting the forced use of lod. if (lodGroup.node.hasChangedFlags > 0) { - for (const visibleCamera of this._lodStateInCamera$) { + for (const visibleCamera of this._lodStateInCamera) { let lodInfo = visibleCamera[1].get(lodGroup); if (!lodInfo) { lodInfo = new LODInfo(); @@ -754,11 +754,11 @@ class LodStateCache { if (lodGroup.isLockLevelChanged()) { lodGroup.resetLockChangeFlag(); - const lodModels = this._levelModels$.get(lodGroup); + const lodModels = this._levelModels.get(lodGroup); if (lodModels) { lodModels.forEach((vecArray, index): void => { vecArray.forEach((model): void => { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (modelInfo) { modelInfo.clear(); } @@ -769,9 +769,9 @@ class LodStateCache { const vecModels = lodModels.get(visibleIndex); if (vecModels) { vecModels.forEach((model): void => { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (modelInfo && model.node && model.node.active) { - for (const visibleCamera of this._lodStateInCamera$) { + for (const visibleCamera of this._lodStateInCamera) { modelInfo.set(visibleCamera[0], true); } } @@ -785,7 +785,7 @@ class LodStateCache { // Normal Process, no LOD is forced. let hasUpdated = false; - for (const visibleCamera of this._lodStateInCamera$) { + for (const visibleCamera of this._lodStateInCamera) { let lodInfo = visibleCamera[1].get(lodGroup); if (!lodInfo) { lodInfo = new LODInfo(); @@ -809,7 +809,7 @@ class LodStateCache { } } - const lodModels = this._levelModels$.get(lodGroup); + const lodModels = this._levelModels.get(lodGroup); if (!lodModels) { continue; } @@ -821,7 +821,7 @@ class LodStateCache { lodModels.forEach((vecArray, index): void => { vecArray.forEach((model): void => { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (modelInfo) { modelInfo.clear(); } @@ -829,13 +829,13 @@ class LodStateCache { }); hasUpdated = true; } else if (hasUpdated) { - this._lodStateInCamera$.forEach((lodState, camera): void => { + this._lodStateInCamera.forEach((lodState, camera): void => { const lodInfo = lodState.get(lodGroup); if (lodInfo && lodInfo.usedLevel !== lodInfo.lastUsedLevel) { const vecModels = lodModels.get(lodInfo.lastUsedLevel); if (vecModels) { vecModels.forEach((model): void => { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (modelInfo) { modelInfo.clear(); } @@ -846,14 +846,14 @@ class LodStateCache { } if (hasUpdated) { - this._lodStateInCamera$.forEach((lodState, camera): void => { + this._lodStateInCamera.forEach((lodState, camera): void => { const lodInfo = lodState.get(lodGroup); if (lodInfo) { const usedLevel = lodInfo.usedLevel; const vecModels = lodModels.get(usedLevel); if (vecModels) { vecModels.forEach((model): void => { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (modelInfo && model.node && model.node.active) { modelInfo.set(camera, true); } @@ -867,7 +867,7 @@ class LodStateCache { } isLodModelCulled (camera: Camera, model: Model): boolean { - const modelInfo = this._modelsInLODGroup$.get(model); + const modelInfo = this._modelsInLODGroup.get(model); if (!modelInfo) { return false; } @@ -876,37 +876,37 @@ class LodStateCache { } clearCache (): void { - this._levelModels$.clear(); - this._modelsInLODGroup$.clear(); - this._lodStateInCamera$.clear(); - this._newAddedLodGroupVec$.length = 0; + this._levelModels.clear(); + this._modelsInLODGroup.clear(); + this._lodStateInCamera.clear(); + this._newAddedLodGroupVec.length = 0; } - private isLodGroupVisibleByCamera$ (lodGroup: LODGroup, camera: Camera): boolean { + private isLodGroupVisibleByCamera (lodGroup: LODGroup, camera: Camera): boolean { const layer = lodGroup.node.layer; return (camera.visibility & layer) === layer; } - private _renderScene$: RenderScene = null!; + private _renderScene: RenderScene = null!; /** * @zh LOD使用的model集合以及每个model当前能被看到的相机列表;包含每个LODGroup的每一级LOD * @en The set of models used by the LOD and the list of cameras that each models can currently be seen, * contains each level of LOD for each LODGroup. */ - private _modelsInLODGroup$: Map> = new Map>(); + private _modelsInLODGroup: Map> = new Map>(); /** * @zh 指定相机下,LODGroup使用哪一级的LOD * @en Specify which level of LOD is used by the LODGroup under the camera. */ - private _lodStateInCamera$: Map> = new Map>(); + private _lodStateInCamera: Map> = new Map>(); /** * @zh 上一帧添加的lodgroup * @en The lodgroup added in the previous frame. */ - private _newAddedLodGroupVec$: Array = new Array(); + private _newAddedLodGroupVec: Array = new Array(); - private _levelModels$: Map>> = new Map>>(); + private _levelModels: Map>> = new Map>>(); } diff --git a/cocos/render-scene/core/texture-buffer-pool.ts b/cocos/render-scene/core/texture-buffer-pool.ts index 8c0f89983f6..7c10978de84 100644 --- a/cocos/render-scene/core/texture-buffer-pool.ts +++ b/cocos/render-scene/core/texture-buffer-pool.ts @@ -63,64 +63,64 @@ function roundUp (n: number, alignment: number): number { } export class TextureBufferPool { - private declare _device$: Device; - private _format$ = Format.UNKNOWN; - private _formatSize$ = 0; - private _chunks$: ITextureBuffer[] = []; - private _chunkCount$ = 0; - private _handles$: ITextureBufferHandle[] = []; - private _region0$ = new BufferTextureCopy(); - private _region1$ = new BufferTextureCopy(); - private _region2$ = new BufferTextureCopy(); - private _roundUpFn$: ((targetSize: number, formatSize: number) => number) | null = null; - private _bufferViewCtor$: TypedArrayConstructor = Uint8Array; - private _channels$ = 4; - private _alignment$ = 1; + private declare _device: Device; + private _format = Format.UNKNOWN; + private _formatSize = 0; + private _chunks: ITextureBuffer[] = []; + private _chunkCount = 0; + private _handles: ITextureBufferHandle[] = []; + private _region0 = new BufferTextureCopy(); + private _region1 = new BufferTextureCopy(); + private _region2 = new BufferTextureCopy(); + private _roundUpFn: ((targetSize: number, formatSize: number) => number) | null = null; + private _bufferViewCtor: TypedArrayConstructor = Uint8Array; + private _channels = 4; + private _alignment = 1; public constructor (device: Device) { - this._device$ = device; + this._device = device; } public initialize (info: ITextureBufferPoolInfo): void { const formatInfo = FormatInfos[info.format]; - this._format$ = info.format; - this._formatSize$ = formatInfo.size; - this._channels$ = formatInfo.count; - this._bufferViewCtor$ = getTypedArrayConstructor(formatInfo); - this._roundUpFn$ = info.roundUpFn || null; - this._alignment$ = info.alignment || 1; - if (info.inOrderFree) { this.alloc = this._McDonaldAlloc$; } + this._format = info.format; + this._formatSize = formatInfo.size; + this._channels = formatInfo.count; + this._bufferViewCtor = getTypedArrayConstructor(formatInfo); + this._roundUpFn = info.roundUpFn || null; + this._alignment = info.alignment || 1; + if (info.inOrderFree) { this.alloc = this._McDonaldAlloc; } } public destroy (): void { - for (let i = 0; i < this._chunkCount$; ++i) { - const chunk = this._chunks$[i]; + for (let i = 0; i < this._chunkCount; ++i) { + const chunk = this._chunks[i]; chunk.texture.destroy(); } - this._chunks$.length = 0; - this._handles$.length = 0; + this._chunks.length = 0; + this._handles.length = 0; } public alloc (size: number, chunkIdx?: number): ITextureBufferHandle { - size = roundUp(size, this._alignment$); + size = roundUp(size, this._alignment); let index = -1; let start = -1; if (chunkIdx !== undefined) { index = chunkIdx; - start = this._findAvailableSpace$(size, index); + start = this._findAvailableSpace(size, index); } if (start < 0) { - for (let i = 0; i < this._chunkCount$; ++i) { + for (let i = 0; i < this._chunkCount; ++i) { index = i; - start = this._findAvailableSpace$(size, index); + start = this._findAvailableSpace(size, index); if (start >= 0) { break; } } } if (start >= 0) { - const chunk = this._chunks$[index]; + const chunk = this._chunks[index]; chunk.start += size; const handle: ITextureBufferHandle = { chunkIdx: index, @@ -128,45 +128,45 @@ export class TextureBufferPool { end: start + size, texture: chunk.texture, }; - this._handles$.push(handle); + this._handles.push(handle); return handle; } // create a new one - const targetSize = Math.sqrt(size / this._formatSize$); - const texLength = this._roundUpFn$ && this._roundUpFn$(targetSize, this._formatSize$) || Math.max(1024, nearestPOT(targetSize)); - const newChunk = this._chunks$[this.createChunk(texLength)]; + const targetSize = Math.sqrt(size / this._formatSize); + const texLength = this._roundUpFn && this._roundUpFn(targetSize, this._formatSize) || Math.max(1024, nearestPOT(targetSize)); + const newChunk = this._chunks[this.createChunk(texLength)]; newChunk.start += size; const texHandle: ITextureBufferHandle = { - chunkIdx: this._chunkCount$ - 1, + chunkIdx: this._chunkCount - 1, start: 0, end: size, texture: newChunk.texture, }; - this._handles$.push(texHandle); + this._handles.push(texHandle); return texHandle; } public free (handle: ITextureBufferHandle): void { - for (let i = 0; i < this._handles$.length; ++i) { - if (this._handles$[i] === handle) { - this._chunks$[handle.chunkIdx].end = handle.end; - this._handles$.splice(i, 1); + for (let i = 0; i < this._handles.length; ++i) { + if (this._handles[i] === handle) { + this._chunks[handle.chunkIdx].end = handle.end; + this._handles.splice(i, 1); return; } } } public createChunk (length: number): number { - const texSize = length * length * this._formatSize$; + const texSize = length * length * this._formatSize; - debug(`TextureBufferPool: Allocate chunk ${this._chunkCount$}, size: ${texSize}, format: ${this._format$}`); + debug(`TextureBufferPool: Allocate chunk ${this._chunkCount}, size: ${texSize}, format: ${this._format}`); - const texture: Texture = this._device$.createTexture(new TextureInfo( + const texture: Texture = this._device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST, - this._format$, + this._format, length, length, )); @@ -177,29 +177,29 @@ export class TextureBufferPool { start: 0, end: texSize, }; - this._chunks$[this._chunkCount$] = chunk; - return this._chunkCount$++; + this._chunks[this._chunkCount] = chunk; + return this._chunkCount++; } public update (handle: ITextureBufferHandle, buffer: ArrayBuffer): void { const buffers: ArrayBufferView[] = []; const regions: BufferTextureCopy[] = []; - const start = handle.start / this._formatSize$; + const start = handle.start / this._formatSize; - let remainSize = buffer.byteLength / this._formatSize$; + let remainSize = buffer.byteLength / this._formatSize; let offsetX = start % handle.texture.width; let offsetY = Math.floor(start / handle.texture.width); let copySize = Math.min(handle.texture.width - offsetX, remainSize); let begin = 0; if (offsetX > 0) { - this._region0$.texOffset.x = offsetX; - this._region0$.texOffset.y = offsetY; - this._region0$.texExtent.width = copySize; - this._region0$.texExtent.height = 1; + this._region0.texOffset.x = offsetX; + this._region0.texOffset.y = offsetY; + this._region0.texExtent.width = copySize; + this._region0.texExtent.height = 1; - buffers.push(new this._bufferViewCtor$(buffer, begin * this._formatSize$, copySize * this._channels$)); - regions.push(this._region0$); + buffers.push(new this._bufferViewCtor(buffer, begin * this._formatSize, copySize * this._channels)); + regions.push(this._region0); offsetX = 0; offsetY += 1; @@ -208,50 +208,50 @@ export class TextureBufferPool { } if (remainSize > 0) { - this._region1$.texOffset.x = offsetX; - this._region1$.texOffset.y = offsetY; + this._region1.texOffset.x = offsetX; + this._region1.texOffset.y = offsetY; if (remainSize > handle.texture.width) { - this._region1$.texExtent.width = handle.texture.width; - this._region1$.texExtent.height = Math.floor(remainSize / handle.texture.width); - copySize = this._region1$.texExtent.width * this._region1$.texExtent.height; + this._region1.texExtent.width = handle.texture.width; + this._region1.texExtent.height = Math.floor(remainSize / handle.texture.width); + copySize = this._region1.texExtent.width * this._region1.texExtent.height; } else { copySize = remainSize; - this._region1$.texExtent.width = copySize; - this._region1$.texExtent.height = 1; + this._region1.texExtent.width = copySize; + this._region1.texExtent.height = 1; } - buffers.push(new this._bufferViewCtor$(buffer, begin * this._formatSize$, copySize * this._channels$)); - regions.push(this._region1$); + buffers.push(new this._bufferViewCtor(buffer, begin * this._formatSize, copySize * this._channels)); + regions.push(this._region1); offsetX = 0; - offsetY += this._region1$.texExtent.height; + offsetY += this._region1.texExtent.height; remainSize -= copySize; begin += copySize; } if (remainSize > 0) { - this._region2$.texOffset.x = offsetX; - this._region2$.texOffset.y = offsetY; - this._region2$.texExtent.width = remainSize; - this._region2$.texExtent.height = 1; + this._region2.texOffset.x = offsetX; + this._region2.texOffset.y = offsetY; + this._region2.texExtent.width = remainSize; + this._region2.texExtent.height = 1; - buffers.push(new this._bufferViewCtor$(buffer, begin * this._formatSize$, remainSize * this._channels$)); - regions.push(this._region2$); + buffers.push(new this._bufferViewCtor(buffer, begin * this._formatSize, remainSize * this._channels)); + regions.push(this._region2); } - this._device$.copyBuffersToTexture(buffers, handle.texture, regions); + this._device.copyBuffersToTexture(buffers, handle.texture, regions); } - private _findAvailableSpace$ (size: number, chunkIdx: number): number { - const chunk = this._chunks$[chunkIdx]; + private _findAvailableSpace (size: number, chunkIdx: number): number { + const chunk = this._chunks[chunkIdx]; let isFound = false; let start = chunk.start; if ((start + size) <= chunk.size) { isFound = true; } else { start = 0; // try to find from head again - const handles = this._handles$.filter((h): boolean => h.chunkIdx === chunkIdx).sort((a, b): number => a.start - b.start); + const handles = this._handles.filter((h): boolean => h.chunkIdx === chunkIdx).sort((a, b): number => a.start - b.start); for (let i = 0; i < handles.length; i++) { const handle = handles[i]; if ((start + size) <= handle.start) { @@ -268,11 +268,11 @@ export class TextureBufferPool { } // [McDonald 12] Efficient Buffer Management - private _McDonaldAlloc$ (size: number): ITextureBufferHandle { - size = roundUp(size, this._alignment$); + private _McDonaldAlloc (size: number): ITextureBufferHandle { + size = roundUp(size, this._alignment); - for (let i = 0; i < this._chunkCount$; ++i) { - const chunk = this._chunks$[i]; + for (let i = 0; i < this._chunkCount; ++i) { + const chunk = this._chunks[i]; let isFound = false; let start = chunk.start; if ((start + size) <= chunk.end) { @@ -300,24 +300,24 @@ export class TextureBufferPool { end: start + size, texture: chunk.texture, }; - this._handles$.push(handle); + this._handles.push(handle); return handle; } } // create a new one - const targetSize = Math.sqrt(size / this._formatSize$); - const texLength = this._roundUpFn$ && this._roundUpFn$(targetSize, this._formatSize$) || Math.max(1024, nearestPOT(targetSize)); - const newChunk = this._chunks$[this.createChunk(texLength)]; + const targetSize = Math.sqrt(size / this._formatSize); + const texLength = this._roundUpFn && this._roundUpFn(targetSize, this._formatSize) || Math.max(1024, nearestPOT(targetSize)); + const newChunk = this._chunks[this.createChunk(texLength)]; newChunk.start += size; const texHandle: ITextureBufferHandle = { - chunkIdx: this._chunkCount$, + chunkIdx: this._chunkCount, start: 0, end: size, texture: newChunk.texture, }; - this._handles$.push(texHandle); + this._handles.push(texHandle); return texHandle; } } diff --git a/cocos/render-scene/scene/camera.ts b/cocos/render-scene/scene/camera.ts index 6f01cc5a728..1d29ec9ba66 100644 --- a/cocos/render-scene/scene/camera.ts +++ b/cocos/render-scene/scene/camera.ts @@ -427,7 +427,7 @@ export class Camera { * @zh 相机的名称 */ get name (): string | null { - return this._name$; + return this._name; } /** @@ -435,7 +435,7 @@ export class Camera { * @zh 相机所挂载的场景 */ get scene (): RenderScene | null { - return this._scene$; + return this._scene; } /** @@ -443,10 +443,10 @@ export class Camera { * @zh 相机绑定的节点,决定了它在世界空间的变换矩阵 */ set node (val: Node) { - this._node$ = val; + this._node = val; } get node (): Node { - return this._node$!; + return this._node!; } /** @@ -454,7 +454,7 @@ export class Camera { * @zh 相机关联的渲染窗口ID */ get systemWindowId (): number { - return this._windowId$; + return this._windowId; } /** @@ -462,10 +462,10 @@ export class Camera { * @zh 相机关联的渲染窗口 */ set window (val) { - this._window$ = val; + this._window = val; } get window (): RenderWindow { - return this._window$!; + return this._window!; } /** @@ -473,10 +473,10 @@ export class Camera { * @zh 相机是否启用,未启用的相机不会被渲染 */ set enabled (val) { - this._enabled$ = val; + this._enabled = val; } get enabled (): boolean { - return this._enabled$; + return this._enabled; } /** @@ -484,10 +484,10 @@ export class Camera { * @zh 相机的可见性掩码,声明在当前相机中可见的节点层级集合。 */ set visibility (vis: number) { - this._visibility$ = vis; + this._visibility = vis; } get visibility (): number { - return this._visibility$; + return this._visibility; } /** @@ -495,11 +495,11 @@ export class Camera { * @zh 相机的渲染优先级,值越小越优先渲染。 */ get priority (): number { - return this._priority$; + return this._priority; } set priority (val: number) { - this._priority$ = val; + this._priority = val; } /** @@ -507,7 +507,7 @@ export class Camera { * @zh 相机的视图宽度 */ get width (): number { - return this._width$; + return this._width; } /** @@ -515,7 +515,7 @@ export class Camera { * @zh 相机的视图高度 */ get height (): number { - return this._height$; + return this._height; } /** @@ -523,10 +523,10 @@ export class Camera { * @zh 相机的世界坐标 */ set position (val) { - this._position$ = val; + this._position = val; } get position (): Vec3 { - return this._position$; + return this._position; } /** @@ -534,10 +534,10 @@ export class Camera { * @zh 指向相机观察方向的向量 */ set forward (val) { - this._forward$ = val; + this._forward = val; } get forward (): Vec3 { - return this._forward$; + return this._forward; } /** @@ -545,12 +545,12 @@ export class Camera { * @zh 相机光圈,影响相机的曝光参数。 */ set aperture (val: CameraAperture) { - this._aperture$ = val; - this._apertureValue$ = FSTOPS[this._aperture$]; - this.updateExposure$(); + this._aperture = val; + this._apertureValue = FSTOPS[this._aperture]; + this.updateExposure(); } get aperture (): CameraAperture { - return this._aperture$; + return this._aperture; } /** @@ -558,7 +558,7 @@ export class Camera { * @zh 相机光圈值。 */ get apertureValue (): number { - return this._apertureValue$; + return this._apertureValue; } /** @@ -566,12 +566,12 @@ export class Camera { * @zh 相机快门,影响相机的曝光参数。 */ set shutter (val: CameraShutter) { - this._shutter$ = val; - this._shutterValue$ = SHUTTERS[this._shutter$]; - this.updateExposure$(); + this._shutter = val; + this._shutterValue = SHUTTERS[this._shutter]; + this.updateExposure(); } get shutter (): CameraShutter { - return this._shutter$; + return this._shutter; } /** @@ -579,7 +579,7 @@ export class Camera { * @zh 相机快门值。 */ get shutterValue (): number { - return this._shutterValue$; + return this._shutterValue; } /** @@ -588,8 +588,8 @@ export class Camera { */ set iso (val: CameraISO) { this._iso = val; - this._isoValue$ = ISOS[this._iso]; - this.updateExposure$(); + this._isoValue = ISOS[this._iso]; + this.updateExposure(); } get iso (): CameraISO { return this._iso; @@ -600,7 +600,7 @@ export class Camera { * @zh 相机感光度值。 */ get isoValue (): number { - return this._isoValue$; + return this._isoValue; } /** @@ -608,7 +608,7 @@ export class Camera { * @zh 相机的曝光参数 */ get exposure (): number { - return this._exposure$; + return this._exposure; } /** @@ -616,10 +616,10 @@ export class Camera { * @zh 相机的缓冲清除标志位,指定帧缓冲的哪部分要每帧清除。 */ get clearFlag (): ClearFlags { - return this._clearFlag$; + return this._clearFlag; } set clearFlag (flag: ClearFlags) { - this._clearFlag$ = flag; + this._clearFlag = flag; } /** @@ -627,13 +627,13 @@ export class Camera { * @zh 相机的颜色缓冲默认值。 */ set clearColor (val) { - this._clearColor$.x = val.x; - this._clearColor$.y = val.y; - this._clearColor$.z = val.z; - this._clearColor$.w = val.w; + this._clearColor.x = val.x; + this._clearColor.y = val.y; + this._clearColor.z = val.z; + this._clearColor.w = val.w; } get clearColor (): IVec4Like { - return this._clearColor$ as IVec4Like; + return this._clearColor as IVec4Like; } /** @@ -641,10 +641,10 @@ export class Camera { * @zh 相机的深度缓冲默认值。 */ get clearDepth (): number { - return this._clearDepth$; + return this._clearDepth; } set clearDepth (depth: number) { - this._clearDepth$ = depth; + this._clearDepth = depth; } /** @@ -652,10 +652,10 @@ export class Camera { * @zh 相机的模板缓冲默认值。 */ get clearStencil (): number { - return this._clearStencil$; + return this._clearStencil; } set clearStencil (stencil: number) { - this._clearStencil$ = stencil; + this._clearStencil = stencil; } /** @@ -663,11 +663,11 @@ export class Camera { * @zh 相机的投影类型。 */ set projectionType (val) { - this._proj$ = val; - this._isProjDirty$ = true; + this._proj = val; + this._isProjDirty = true; } get projectionType (): CameraProjection { - return this._proj$; + return this._proj; } /** @@ -675,7 +675,7 @@ export class Camera { * @zh 相机视图的长宽比 */ get aspect (): number { - return this._aspect$; + return this._aspect; } /** @@ -683,11 +683,11 @@ export class Camera { * @zh 正交相机的视角高度。 */ set orthoHeight (val) { - this._orthoHeight$ = val; - this._isProjDirty$ = true; + this._orthoHeight = val; + this._isProjDirty = true; } get orthoHeight (): number { - return this._orthoHeight$; + return this._orthoHeight; } /** @@ -695,11 +695,11 @@ export class Camera { * @zh 指定视角的固定轴向,在此轴上不会跟随屏幕长宽比例变化。 */ set fovAxis (axis) { - this._fovAxis$ = axis; - this._isProjDirty$ = true; + this._fovAxis = axis; + this._isProjDirty = true; } get fovAxis (): CameraFOVAxis { - return this._fovAxis$; + return this._fovAxis; } /** @@ -707,11 +707,11 @@ export class Camera { * @zh 相机的视角大小。 */ set fov (fov) { - this._fov$ = fov; - this._isProjDirty$ = true; + this._fov = fov; + this._isProjDirty = true; } get fov (): number { - return this._fov$; + return this._fov; } /** @@ -719,11 +719,11 @@ export class Camera { * @zh 相机的近裁剪距离,应在可接受范围内尽量取最大。 */ set nearClip (nearClip) { - this._nearClip$ = nearClip; - this._isProjDirty$ = true; + this._nearClip = nearClip; + this._isProjDirty = true; } get nearClip (): number { - return this._nearClip$; + return this._nearClip; } /** @@ -731,11 +731,11 @@ export class Camera { * @zh 相机的远裁剪距离,应在可接受范围内尽量取最小。 */ set farClip (farClip) { - this._farClip$ = farClip; - this._isProjDirty$ = true; + this._farClip = farClip; + this._isProjDirty = true; } get farClip (): number { - return this._farClip$; + return this._farClip; } /** @@ -743,7 +743,7 @@ export class Camera { * @zh 相机的视口矩形,如果设备允许的话,这个视口会永远保持竖屏状态,由渲染流程保障旋转的正确。 */ get viewport (): Rect { - return this._viewport$; + return this._viewport; } set viewport (val) { warnID(8302); @@ -755,10 +755,10 @@ export class Camera { * @zh 相机的视锥体 */ set frustum (val) { - this._frustum$ = val; + this._frustum = val; } get frustum (): Frustum { - return this._frustum$; + return this._frustum; } /** @@ -766,7 +766,7 @@ export class Camera { * @zh 相机的视图矩阵 */ get matView (): Mat4 { - return this._matView$; + return this._matView; } /** @@ -774,7 +774,7 @@ export class Camera { * @zh 相机的投影矩阵 */ get matProj (): Mat4 { - return this._matProj$; + return this._matProj; } /** @@ -782,7 +782,7 @@ export class Camera { * @zh 相机的逆投影矩阵 */ get matProjInv (): Mat4 { - return this._matProjInv$; + return this._matProjInv; } /** @@ -790,7 +790,7 @@ export class Camera { * @zh 相机的视图投影矩阵 */ get matViewProj (): Mat4 { - return this._matViewProj$; + return this._matViewProj; } /** @@ -798,12 +798,12 @@ export class Camera { * @zh 相机的逆视图投影矩阵 */ get matViewProjInv (): Mat4 { - return this._matViewProjInv$; + return this._matViewProjInv; } /** @engineInternal */ get cameraId (): number { - return this._cameraId$; + return this._cameraId; } /** @@ -824,60 +824,60 @@ export class Camera { public pipeline = ''; public pipelineSettings: object | null = null; - private declare _device$: Device; - private _scene$: RenderScene | null = null; - private _node$: Node | null = null; - private _name$: string | null = null; - private _enabled$ = false; - private _proj$: CameraProjection = -1 as CameraProjection; - private _aspect$: number = 1; - private _orthoHeight$ = 10.0; - private _fovAxis$ = CameraFOVAxis.VERTICAL; - private _fov$: number = toRadian(45); - private _nearClip$ = 1.0; - private _farClip$ = 1000.0; - private _clearColor$ = new Color(0.2, 0.2, 0.2, 1); - private _viewport$: Rect = rect(0, 0, 1, 1); - private _orientedViewport$: Rect = rect(0, 0, 1, 1); - private _curTransform$ = SurfaceTransform.IDENTITY; - private _isProjDirty$ = true; - private _matView$: Mat4 = mat4(); - private _matProj$: Mat4 = mat4(); - private _matProjInv$: Mat4 = mat4(); - private _matViewProj$: Mat4 = mat4(); - private _matViewProjInv$: Mat4 = mat4(); - private _frustum$: geometry.Frustum = new geometry.Frustum(); - private _forward$: Vec3 = v3(); - private _position$: Vec3 = v3(); - private _priority$ = 0; - private _aperture$: CameraAperture = CameraAperture.F16_0; - private declare _apertureValue$: number; - private _shutter$: CameraShutter = CameraShutter.D125; - private _shutterValue$ = 0.0; + private declare _device: Device; + private _scene: RenderScene | null = null; + private _node: Node | null = null; + private _name: string | null = null; + private _enabled = false; + private _proj: CameraProjection = -1 as CameraProjection; + private _aspect: number = 1; + private _orthoHeight = 10.0; + private _fovAxis = CameraFOVAxis.VERTICAL; + private _fov: number = toRadian(45); + private _nearClip = 1.0; + private _farClip = 1000.0; + private _clearColor = new Color(0.2, 0.2, 0.2, 1); + private _viewport: Rect = rect(0, 0, 1, 1); + private _orientedViewport: Rect = rect(0, 0, 1, 1); + private _curTransform = SurfaceTransform.IDENTITY; + private _isProjDirty = true; + private _matView: Mat4 = mat4(); + private _matProj: Mat4 = mat4(); + private _matProjInv: Mat4 = mat4(); + private _matViewProj: Mat4 = mat4(); + private _matViewProjInv: Mat4 = mat4(); + private _frustum: geometry.Frustum = new geometry.Frustum(); + private _forward: Vec3 = v3(); + private _position: Vec3 = v3(); + private _priority = 0; + private _aperture: CameraAperture = CameraAperture.F16_0; + private declare _apertureValue: number; + private _shutter: CameraShutter = CameraShutter.D125; + private _shutterValue = 0.0; private _iso: CameraISO = CameraISO.ISO100; - private _isoValue$ = 0.0; - private _window$: RenderWindow | null = null; - private _width$ = 1; - private _height$ = 1; - private _clearFlag$ = ClearFlagBit.NONE; - private _clearDepth$ = 1.0; - private _visibility$ = CAMERA_DEFAULT_MASK; - private _exposure$ = 0; - private _clearStencil$ = 0; - private _geometryRenderer$: GeometryRenderer | null = null; - private _windowId$ = 0; - private _cameraType$: CameraType = CameraType.DEFAULT; - private _trackingType$: TrackingType = TrackingType.NO_TRACKING; - private _usage$: CameraUsage = CameraUsage.GAME; - private _cameraId$ = _cameraCount++; + private _isoValue = 0.0; + private _window: RenderWindow | null = null; + private _width = 1; + private _height = 1; + private _clearFlag = ClearFlagBit.NONE; + private _clearDepth = 1.0; + private _visibility = CAMERA_DEFAULT_MASK; + private _exposure = 0; + private _clearStencil = 0; + private _geometryRenderer: GeometryRenderer | null = null; + private _windowId = 0; + private _cameraType: CameraType = CameraType.DEFAULT; + private _trackingType: TrackingType = TrackingType.NO_TRACKING; + private _usage: CameraUsage = CameraUsage.GAME; + private _cameraId = _cameraCount++; constructor (device: Device) { - this._device$ = device; - this._apertureValue$ = FSTOPS[this._aperture$]; - this._shutterValue$ = SHUTTERS[this._shutter$]; - this._isoValue$ = ISOS[this._iso]; + this._device = device; + this._apertureValue = FSTOPS[this._aperture]; + this._shutterValue = SHUTTERS[this._shutter]; + this._isoValue = ISOS[this._iso]; - this._frustum$.accurate = true; + this._frustum.accurate = true; if (!correctionMatrices.length) { const ySign = device.capabilities.clipSpaceSignY; @@ -888,15 +888,15 @@ export class Camera { } } - private _updateAspect$ (oriented = true): void { - this._aspect$ = (this.window.width * this._viewport$.width) / (this.window.height * this._viewport$.height); + private _updateAspect (oriented = true): void { + this._aspect = (this.window.width * this._viewport.width) / (this.window.height * this._viewport.height); // window size/viewport is pre-rotated, but aspect should be oriented to acquire the correct projection if (oriented) { const swapchain = this.window.swapchain; const orientation = swapchain && swapchain.surfaceTransform || SurfaceTransform.IDENTITY; - if (orientation % 2) this._aspect$ = 1 / this._aspect$; + if (orientation % 2) this._aspect = 1 / this._aspect; } - this._isProjDirty$ = true; + this._isProjDirty = true; } /** @@ -905,27 +905,27 @@ export class Camera { */ public initialize (info: ICameraInfo): void { if (info.usage !== undefined) { - this._usage$ = info.usage; + this._usage = info.usage; } else { - this.setDefaultUsage$(); + this.setDefaultUsage(); } if (info.trackingType !== undefined) { - this._trackingType$ = info.trackingType; + this._trackingType = info.trackingType; } if (info.cameraType !== undefined) { - this._cameraType$ = info.cameraType; + this._cameraType = info.cameraType; } this.node = info.node; - this._width$ = 1; - this._height$ = 1; + this._width = 1; + this._height = 1; this.clearFlag = ClearFlagBit.NONE; this.clearDepth = 1.0; this.visibility = CAMERA_DEFAULT_MASK; - this._name$ = info.name; - this._proj$ = info.projection; - this._priority$ = info.priority || 0; - this._aspect$ = this.screenScale = 1; - this.updateExposure$(); + this._name = info.name; + this._proj = info.projection; + this._priority = info.priority || 0; + this._aspect = this.screenScale = 1; + this.updateExposure(); this.changeTargetWindow(info.window); } @@ -934,14 +934,14 @@ export class Camera { * @zh 销毁相机,开发者不应该使用这个方法,销毁流程是由 RenderScene 管理的。 */ public destroy (): void { - this._node$ = null; + this._node = null; this.detachFromScene(); - if (this._window$) { - this._window$.detachCamera(this); + if (this._window) { + this._window.detachCamera(this); this.window = null!; } - this._name$ = null; - this._geometryRenderer$?.destroy(); + this._name = null; + this._geometryRenderer?.destroy(); } /** @@ -950,8 +950,8 @@ export class Camera { * @param scene @en The render scene @zh 渲染场景 */ public attachToScene (scene: RenderScene): void { - this._enabled$ = true; - this._scene$ = scene; + this._enabled = true; + this._scene = scene; } /** @@ -959,8 +959,8 @@ export class Camera { * @zh 将相机从之前设置的渲染场景移除,之后将不会再被渲染。 */ public detachFromScene (): void { - this._enabled$ = false; - this._scene$ = null; + this._enabled = false; + this._scene = null; } /** @@ -970,12 +970,12 @@ export class Camera { * @param height The height of the view size */ public resize (width: number, height: number): void { - if (!this._window$) return; + if (!this._window) return; - this._width$ = width; - this._height$ = height; - this._aspect$ = (width * this._viewport$.width) / (height * this._viewport$.height); - this._isProjDirty$ = true; + this._width = width; + this._height = height; + this._aspect = (width * this._viewport.width) / (height * this._viewport.height); + this._isProjDirty = true; } /** @@ -985,9 +985,9 @@ export class Camera { * @param height The height of the view size */ public setFixedSize (width: number, height: number): void { - this._width$ = width; - this._height$ = height; - this._updateAspect$(); + this._width = width; + this._height = height; + this._updateAspect(); this.isWindowSize = false; } @@ -999,10 +999,10 @@ export class Camera { if (EDITOR) { this.position = camera.position; this.forward = camera.forward; - this._matView$ = camera.matView; - this._matProj$ = camera.matProj; - this._matProjInv$ = camera.matProjInv; - this._matViewProj$ = camera.matViewProj; + this._matView = camera.matView; + this._matProj = camera.matProj; + this._matProjInv = camera.matProjInv; + this._matViewProj = camera.matViewProj; } } @@ -1012,82 +1012,82 @@ export class Camera { * @param forceUpdate If force update, then dirty flag will be ignored */ public update (forceUpdate = false): void { // for lazy eval situations like the in-editor preview - if (!this._node$) return; + if (!this._node) return; let viewProjDirty = false; const xr = globalThis.__globalXR; if (xr && xr.isWebXR && xr.webXRWindowMap && xr.updateViewport) { const x = xr.webXRMatProjs ? 1 / xr.webXRMatProjs.length : 1; - const wndXREye = xr.webXRWindowMap.get(this._window$); + const wndXREye = xr.webXRWindowMap.get(this._window); this.setViewportInOrientedSpace(new Rect(x * wndXREye, 0, x, 1)); } // view matrix - if (this._node$.hasChangedFlags || forceUpdate) { - Mat4.invert(this._matView$, this._node$.worldMatrix); - this._forward$.x = -this._matView$.m02; - this._forward$.y = -this._matView$.m06; - this._forward$.z = -this._matView$.m10; + if (this._node.hasChangedFlags || forceUpdate) { + Mat4.invert(this._matView, this._node.worldMatrix); + this._forward.x = -this._matView.m02; + this._forward.y = -this._matView.m06; + this._forward.z = -this._matView.m10; // Remove scale - Mat4.multiply(this._matView$, new Mat4().scale(this._node$.worldScale), this._matView$); - this._node$.getWorldPosition(this._position$); + Mat4.multiply(this._matView, new Mat4().scale(this._node.worldScale), this._matView); + this._node.getWorldPosition(this._position); viewProjDirty = true; } // projection matrix const swapchain = this.window?.swapchain; const orientation = swapchain && swapchain.surfaceTransform || SurfaceTransform.IDENTITY; - if (this._isProjDirty$ || this._curTransform$ !== orientation) { - this._curTransform$ = orientation; - const projectionSignY = this._device$.capabilities.clipSpaceSignY; + if (this._isProjDirty || this._curTransform !== orientation) { + this._curTransform = orientation; + const projectionSignY = this._device.capabilities.clipSpaceSignY; // Only for rendertexture processing - if (this._proj$ === CameraProjection.PERSPECTIVE) { + if (this._proj === CameraProjection.PERSPECTIVE) { if (xr && xr.isWebXR && xr.webXRWindowMap && xr.webXRMatProjs) { - const wndXREye = xr.webXRWindowMap.get(this._window$); - this._matProj$.set(xr.webXRMatProjs[wndXREye] as Mat4); + const wndXREye = xr.webXRWindowMap.get(this._window); + this._matProj.set(xr.webXRMatProjs[wndXREye] as Mat4); } else { Mat4.perspective( - this._matProj$, - this._fov$, - this._aspect$, - this._nearClip$, - this._farClip$, - this._fovAxis$ === CameraFOVAxis.VERTICAL, - this._device$.capabilities.clipSpaceMinZ, + this._matProj, + this._fov, + this._aspect, + this._nearClip, + this._farClip, + this._fovAxis === CameraFOVAxis.VERTICAL, + this._device.capabilities.clipSpaceMinZ, projectionSignY, orientation, ); } } else { - const x = this._orthoHeight$ * this._aspect$; - const y = this._orthoHeight$; + const x = this._orthoHeight * this._aspect; + const y = this._orthoHeight; Mat4.ortho( - this._matProj$, + this._matProj, -x, x, -y, y, - this._nearClip$, - this._farClip$, - this._device$.capabilities.clipSpaceMinZ, + this._nearClip, + this._farClip, + this._device.capabilities.clipSpaceMinZ, projectionSignY, orientation, ); } - Mat4.invert(this._matProjInv$, this._matProj$); + Mat4.invert(this._matProjInv, this._matProj); viewProjDirty = true; - this._isProjDirty$ = false; + this._isProjDirty = false; } // view-projection if (viewProjDirty) { - Mat4.multiply(this._matViewProj$, this._matProj$, this._matView$); - Mat4.invert(this._matViewProjInv$, this._matViewProj$); - this._frustum$.update(this._matViewProj$, this._matViewProjInv$); + Mat4.multiply(this._matViewProj, this._matProj, this._matView); + Mat4.invert(this._matViewProjInv, this._matViewProj); + this._frustum.update(this._matViewProj, this._matViewProjInv); } } get surfaceTransform (): SurfaceTransform { - return this._curTransform$; + return this._curTransform; } /** @@ -1096,43 +1096,43 @@ export class Camera { */ public setViewportInOrientedSpace (val: Rect): void { const { x, width, height } = val; - const y = this._device$.capabilities.screenSpaceSignY < 0 ? 1 - val.y - height : val.y; + const y = this._device.capabilities.screenSpaceSignY < 0 ? 1 - val.y - height : val.y; const swapchain = this.window?.swapchain; const orientation = swapchain && swapchain.surfaceTransform || SurfaceTransform.IDENTITY; switch (orientation) { case SurfaceTransform.ROTATE_90: - this._viewport$.x = 1 - y - height; - this._viewport$.y = x; - this._viewport$.width = height; - this._viewport$.height = width; + this._viewport.x = 1 - y - height; + this._viewport.y = x; + this._viewport.width = height; + this._viewport.height = width; break; case SurfaceTransform.ROTATE_180: - this._viewport$.x = 1 - x - width; - this._viewport$.y = 1 - y - height; - this._viewport$.width = width; - this._viewport$.height = height; + this._viewport.x = 1 - x - width; + this._viewport.y = 1 - y - height; + this._viewport.width = width; + this._viewport.height = height; break; case SurfaceTransform.ROTATE_270: - this._viewport$.x = y; - this._viewport$.y = 1 - x - width; - this._viewport$.width = height; - this._viewport$.height = width; + this._viewport.x = y; + this._viewport.y = 1 - x - width; + this._viewport.width = height; + this._viewport.height = width; break; case SurfaceTransform.IDENTITY: - this._viewport$.x = x; - this._viewport$.y = y; - this._viewport$.width = width; - this._viewport$.height = height; + this._viewport.x = x; + this._viewport.y = y; + this._viewport.width = width; + this._viewport.height = height; break; default: } - this._orientedViewport$.x = x; - this._orientedViewport$.y = y; - this._orientedViewport$.width = width; - this._orientedViewport$.height = height; + this._orientedViewport.x = x; + this._orientedViewport.y = y; + this._orientedViewport.width = width; + this._orientedViewport.height = height; this.resize(this.width, this.height); } @@ -1142,10 +1142,10 @@ export class Camera { * @zh 创建这个摄像机的几何体渲染器 */ public initGeometryRenderer (): void { - if (!this._geometryRenderer$) { + if (!this._geometryRenderer) { const GeometryRenderer = cclegacy.internal.GeometryRenderer; - this._geometryRenderer$ = GeometryRenderer ? new GeometryRenderer() : null; - this._geometryRenderer$?.activate(this._device$); + this._geometryRenderer = GeometryRenderer ? new GeometryRenderer() : null; + this._geometryRenderer?.activate(this._device); } } @@ -1155,31 +1155,31 @@ export class Camera { * @returns @en return the geometry renderer @zh 返回几何体渲染器 */ get geometryRenderer (): GeometryRenderer | null { - return this._geometryRenderer$; + return this._geometryRenderer; } get cameraType (): CameraType { - return this._cameraType$; + return this._cameraType; } set cameraType (type: CameraType) { - this._cameraType$ = type; + this._cameraType = type; } get trackingType (): TrackingType { - return this._trackingType$; + return this._trackingType; } set trackingType (type: TrackingType) { - this._trackingType$ = type; + this._trackingType = type; } get cameraUsage (): CameraUsage { - return this._usage$; + return this._usage; } set cameraUsage (usage: CameraUsage) { - this._usage$ = usage; + this._usage = usage; } /** @@ -1188,8 +1188,8 @@ export class Camera { * @param window The target render window, could be null */ public changeTargetWindow (window: RenderWindow | null = null): void { - if (this._window$) { - this._window$.detachCamera(this); + if (this._window) { + this._window.detachCamera(this); } const win = window || (cclegacy.director.root as Root).mainWindow; if (win) { @@ -1209,8 +1209,8 @@ export class Camera { * @zh 将 camera 从渲染窗口移除 */ public detachCamera (): void { - if (this._window$) { - this._window$.detachCamera(this); + if (this._window) { + this._window.detachCamera(this); } } @@ -1223,17 +1223,17 @@ export class Camera { * @returns the resulting ray */ public screenPointToRay (out: geometry.Ray, x: number, y: number): geometry.Ray { - if (!this._node$) return null!; + if (!this._node) return null!; const width = this.width; const height = this.height; - const cx = this._orientedViewport$.x * width; - const cy = this._orientedViewport$.y * height; - const cw = this._orientedViewport$.width * width; - const ch = this._orientedViewport$.height * height; - const isProj = this._proj$ === CameraProjection.PERSPECTIVE; - const ySign = this._device$.capabilities.clipSpaceSignY; - const preTransform = preTransforms[this._curTransform$]; + const cx = this._orientedViewport.x * width; + const cy = this._orientedViewport.y * height; + const cw = this._orientedViewport.width * width; + const ch = this._orientedViewport.height * height; + const isProj = this._proj === CameraProjection.PERSPECTIVE; + const ySign = this._device.capabilities.clipSpaceSignY; + const preTransform = preTransforms[this._curTransform]; Vec3.set(v_a, (x - cx) / cw * 2 - 1, (y - cy) / ch * 2 - 1, isProj ? 1 : -1); @@ -1241,14 +1241,14 @@ export class Camera { v_a.x = ox * preTransform[0] + oy * preTransform[2] * ySign; v_a.y = ox * preTransform[1] + oy * preTransform[3] * ySign; - Vec3.transformMat4(isProj ? v_a : out.o, v_a, this._matViewProjInv$); + Vec3.transformMat4(isProj ? v_a : out.o, v_a, this._matViewProjInv); if (isProj) { // camera origin - this._node$.getWorldPosition(v_b); + this._node.getWorldPosition(v_b); geometry.Ray.fromPoints(out, v_b, v_a); } else { - Vec3.transformQuat(out.d, Vec3.FORWARD, this._node$.worldRotation); + Vec3.transformQuat(out.d, Vec3.FORWARD, this._node.worldRotation); } return out; @@ -1264,14 +1264,14 @@ export class Camera { public screenToWorld (out: Vec3, screenPos: Vec3): Vec3 { const width = this.width; const height = this.height; - const cx = this._orientedViewport$.x * width; - const cy = this._orientedViewport$.y * height; - const cw = this._orientedViewport$.width * width; - const ch = this._orientedViewport$.height * height; - const ySign = this._device$.capabilities.clipSpaceSignY; - const preTransform = preTransforms[this._curTransform$]; - - if (this._proj$ === CameraProjection.PERSPECTIVE) { + const cx = this._orientedViewport.x * width; + const cy = this._orientedViewport.y * height; + const cw = this._orientedViewport.width * width; + const ch = this._orientedViewport.height * height; + const ySign = this._device.capabilities.clipSpaceSignY; + const preTransform = preTransforms[this._curTransform]; + + if (this._proj === CameraProjection.PERSPECTIVE) { // calculate screen pos in far clip plane Vec3.set( out, @@ -1284,12 +1284,12 @@ export class Camera { const { x, y } = out; out.x = x * preTransform[0] + y * preTransform[2] * ySign; out.y = x * preTransform[1] + y * preTransform[3] * ySign; - Vec3.transformMat4(out, out, this._matViewProjInv$); + Vec3.transformMat4(out, out, this._matViewProjInv); // lerp to depth z - if (this._node$) { this._node$.getWorldPosition(v_a); } + if (this._node) { this._node.getWorldPosition(v_a); } - Vec3.lerp(out, v_a, out, lerp(this._nearClip$ / this._farClip$, 1, screenPos.z)); + Vec3.lerp(out, v_a, out, lerp(this._nearClip / this._farClip, 1, screenPos.z)); } else { Vec3.set( out, @@ -1302,7 +1302,7 @@ export class Camera { const { x, y } = out; out.x = x * preTransform[0] + y * preTransform[2] * ySign; out.y = x * preTransform[1] + y * preTransform[3] * ySign; - Vec3.transformMat4(out, out, this._matViewProjInv$); + Vec3.transformMat4(out, out, this._matViewProjInv); } return out; @@ -1316,10 +1316,10 @@ export class Camera { * @returns the resulting vector */ public worldToScreen (out: Vec3, worldPos: Vec3 | Readonly): Vec3 { - const ySign = this._device$.capabilities.clipSpaceSignY; - const preTransform = preTransforms[this._curTransform$]; + const ySign = this._device.capabilities.clipSpaceSignY; + const preTransform = preTransforms[this._curTransform]; - Vec3.transformMat4(out, worldPos, this._matViewProj$); + Vec3.transformMat4(out, worldPos, this._matViewProj); const { x, y } = out; out.x = x * preTransform[0] + y * preTransform[2] * ySign; @@ -1327,10 +1327,10 @@ export class Camera { const width = this.width; const height = this.height; - const cx = this._orientedViewport$.x * width; - const cy = this._orientedViewport$.y * height; - const cw = this._orientedViewport$.width * width; - const ch = this._orientedViewport$.height * height; + const cx = this._orientedViewport.x * width; + const cy = this._orientedViewport.y * height; + const cw = this._orientedViewport.width * width; + const ch = this._orientedViewport.height * height; out.x = cx + (out.x + 1) * 0.5 * cw; out.y = cy + (out.y + 1) * 0.5 * ch; @@ -1349,8 +1349,8 @@ export class Camera { * @returns the resulting matrix */ public worldMatrixToScreen (out: Mat4, worldMatrix: Mat4, width: number, height: number): Mat4 { - Mat4.multiply(out, this._matViewProj$, worldMatrix); - Mat4.multiply(out, correctionMatrices[this._curTransform$], out); + Mat4.multiply(out, this._matViewProj, worldMatrix); + Mat4.multiply(out, correctionMatrices[this._curTransform], out); const halfWidth = width / 2; const halfHeight = height / 2; @@ -1370,22 +1370,22 @@ export class Camera { */ public calculateObliqueMat (viewSpacePlane: Vec4): void { const clipFar = new Vec4(Math.sign(viewSpacePlane.x), Math.sign(viewSpacePlane.y), 1.0, 1.0); - const viewFar = clipFar.transformMat4(this._matProjInv$); + const viewFar = clipFar.transformMat4(this._matProjInv); - const m4 = new Vec4(this._matProj$.m03, this._matProj$.m07, this._matProj$.m11, this._matProj$.m15); + const m4 = new Vec4(this._matProj.m03, this._matProj.m07, this._matProj.m11, this._matProj.m15); const scale = 2.0 / Vec4.dot(viewSpacePlane, viewFar); const newViewSpaceNearPlane = viewSpacePlane.multiplyScalar(scale); const m3 = newViewSpaceNearPlane.subtract(m4); - this._matProj$.m02 = m3.x; - this._matProj$.m06 = m3.y; - this._matProj$.m10 = m3.z; - this._matProj$.m14 = m3.w; + this._matProj.m02 = m3.x; + this._matProj.m06 = m3.y; + this._matProj.m10 = m3.z; + this._matProj.m14 = m3.w; } public getClipSpaceMinz (): number { - return this._device$.capabilities.clipSpaceMinZ; + return this._device.capabilities.clipSpaceMinZ; } /** @@ -1394,23 +1394,23 @@ export class Camera { * @param ev100 */ protected setExposure (ev100): void { - this._exposure$ = 0.833333 / (2.0 ** ev100); + this._exposure = 0.833333 / (2.0 ** ev100); } - private updateExposure$ (): void { - const ev100 = Math.log2((this._apertureValue$ * this._apertureValue$) / this._shutterValue$ * 100.0 / this._isoValue$); + private updateExposure (): void { + const ev100 = Math.log2((this._apertureValue * this._apertureValue) / this._shutterValue * 100.0 / this._isoValue); this.setExposure(ev100); } - private setDefaultUsage$ (): void { + private setDefaultUsage (): void { if (EDITOR) { if (cclegacy.GAME_VIEW) { - this._usage$ = CameraUsage.GAME_VIEW; + this._usage = CameraUsage.GAME_VIEW; } else { - this._usage$ = CameraUsage.EDITOR; + this._usage = CameraUsage.EDITOR; } } else { - this._usage$ = CameraUsage.GAME; + this._usage = CameraUsage.GAME; } } } diff --git a/cocos/render-scene/scene/light.ts b/cocos/render-scene/scene/light.ts index c7f678025a8..b36e72421cd 100644 --- a/cocos/render-scene/scene/light.ts +++ b/cocos/render-scene/scene/light.ts @@ -93,7 +93,7 @@ export class Light { */ set color (color: Vec3) { this._color.set(color); - if (this._useColorTemperature) { Vec3.multiply(this._finalColor$, this._color, this._colorTempRGB); } + if (this._useColorTemperature) { Vec3.multiply(this._finalColor, this._color, this._colorTempRGB); } } get color (): Vec3 { @@ -106,7 +106,7 @@ export class Light { */ set useColorTemperature (enable: boolean) { this._useColorTemperature = enable; - if (enable) { Vec3.multiply(this._finalColor$, this._color, this._colorTempRGB); } + if (enable) { Vec3.multiply(this._finalColor, this._color, this._colorTempRGB); } } get useColorTemperature (): boolean { @@ -120,7 +120,7 @@ export class Light { set colorTemperature (val: number) { this._colorTemp = val; ColorTemperatureToRGB(this._colorTempRGB, this._colorTemp); - if (this._useColorTemperature) { Vec3.multiply(this._finalColor$, this._color, this._colorTempRGB); } + if (this._useColorTemperature) { Vec3.multiply(this._finalColor, this._color, this._colorTempRGB); } } get colorTemperature (): number { @@ -136,7 +136,7 @@ export class Light { } get finalColor (): Readonly { - return this._finalColor$; + return this._finalColor; } /** @@ -202,7 +202,7 @@ export class Light { protected _colorTempRGB: Vec3 = v3(1, 1, 1); - private _finalColor$: Vec3 = v3(1, 1, 1); + private _finalColor: Vec3 = v3(1, 1, 1); protected _scene: RenderScene | null = null; diff --git a/cocos/render-scene/scene/lod-group.ts b/cocos/render-scene/scene/lod-group.ts index 990caa0ab55..ccd83276c2a 100644 --- a/cocos/render-scene/scene/lod-group.ts +++ b/cocos/render-scene/scene/lod-group.ts @@ -35,25 +35,25 @@ export class LODData { // Range in [0, 1]. screenUsagePercentage = 1.0; - private _models$: Model[] = []; + private _models: Model[] = []; get models (): readonly Model[] { - return this._models$; + return this._models; } public addModel (model: Model): void { - this._models$.splice(0, 0, model); + this._models.splice(0, 0, model); } public eraseModel (model: Model): void { - const removeIndex = this._models$.indexOf(model); + const removeIndex = this._models.indexOf(model); if (removeIndex >= 0) { - this._models$.splice(removeIndex, 1); + this._models.splice(removeIndex, 1); } } public clearModels (): void { - this._models$.length = 0; + this._models.length = 0; } } @@ -69,7 +69,7 @@ export class LODGroup { public enabled = true; - private _localBoundaryCenter$: Vec3 = v3(0, 0, 0); + private _localBoundaryCenter: Vec3 = v3(0, 0, 0); /** * @en Object Size in local space, may be auto-calculated value from object bounding box or value from user input. @@ -86,15 +86,15 @@ export class LODGroup { */ protected _lockedLODLevelVec: number[] = []; - private _isLockLevelChanged$ = false; + private _isLockLevelChanged = false; constructor () { this._device = deviceManager.gfxDevice; } - set localBoundaryCenter (val: Readonly) { this._localBoundaryCenter$.set(val); } + set localBoundaryCenter (val: Readonly) { this._localBoundaryCenter.set(val); } - get localBoundaryCenter (): Readonly { return this._localBoundaryCenter$.clone(); } + get localBoundaryCenter (): Readonly { return this._localBoundaryCenter.clone(); } get lodCount (): number { return this._lodDataArray.length; } @@ -115,13 +115,13 @@ export class LODGroup { lockLODLevels (lockLev: number[]): void { if (lockLev.length !== this._lockedLODLevelVec.length) { - this._isLockLevelChanged$ = true; + this._isLockLevelChanged = true; } else { const size = lockLev.length; let index = 0; for (; index < size; index++) { if (lockLev[index] !== this._lockedLODLevelVec[index]) { - this._isLockLevelChanged$ = true; + this._isLockLevelChanged = true; break; } } @@ -130,11 +130,11 @@ export class LODGroup { } isLockLevelChanged (): boolean { - return this._isLockLevelChanged$; + return this._isLockLevelChanged; } resetLockChangeFlag (): void { - this._isLockLevelChanged$ = false; + this._isLockLevelChanged = false; } getLockedLODLevels (): readonly number[] { @@ -189,10 +189,10 @@ export class LODGroup { distance = Vec3.len(this.localBoundaryCenter.transformMat4(this.node.worldMatrix).subtract(camera.node.worldPosition)); } - return this.distanceToScreenUsagePercentage$(camera, distance, this.getWorldSpaceSize$()); + return this.distanceToScreenUsagePercentage(camera, distance, this.getWorldSpaceSize()); } - private distanceToScreenUsagePercentage$ (camera: Camera, distance: number | undefined, size: number): number { + private distanceToScreenUsagePercentage (camera: Camera, distance: number | undefined, size: number): number { if (camera.projectionType === CameraProjection.PERSPECTIVE) { assertIsTrue(typeof distance === 'number', 'distance must be present for perspective projection'); return (size * camera.matProj.m05) / (distance * 2.0); // note: matProj.m11 is 1 / tan(fov / 2.0) @@ -201,7 +201,7 @@ export class LODGroup { } } - private getWorldSpaceSize$ (): number { + private getWorldSpaceSize (): number { const scale = this.node.scale; const maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z)); return maxScale * this.objectSize; diff --git a/cocos/render-scene/scene/model.ts b/cocos/render-scene/scene/model.ts index ad2ea177771..d7d7d70a5d3 100644 --- a/cocos/render-scene/scene/model.ts +++ b/cocos/render-scene/scene/model.ts @@ -182,11 +182,11 @@ export class Model { * @zh 光照探针开关 */ get useLightProbe (): boolean { - return this._useLightProbe$; + return this._useLightProbe; } set useLightProbe (val) { - this._useLightProbe$ = val; + this._useLightProbe = val; this.onMacroPatchesStateChanged(); } @@ -195,11 +195,11 @@ export class Model { * @zh 模型所处的四面体索引 */ get tetrahedronIndex (): number { - return this._tetrahedronIndex$; + return this._tetrahedronIndex; } set tetrahedronIndex (index: number) { - this._tetrahedronIndex$ = index; + this._tetrahedronIndex = index; } /** @@ -493,16 +493,16 @@ export class Model { */ protected _localSHBuffer: Buffer | null = null; - private _lightmap$: Texture2D | null = null; - private _lightmapUVParam$: Vec4 = v4(); + private _lightmap: Texture2D | null = null; + private _lightmapUVParam: Vec4 = v4(); /** * @en located tetrahedron index * @zh 所处的四面体索引 */ - private _tetrahedronIndex$ = -1; - private _lastWorldBoundCenter$ = v3(Infinity, Infinity, Infinity); - private _useLightProbe$ = false; + private _tetrahedronIndex = -1; + private _lastWorldBoundCenter = v3(Infinity, Infinity, Infinity); + private _useLightProbe = false; /** * @en World AABB buffer @@ -752,11 +752,11 @@ export class Model { } public showTetrahedron (): boolean { - return this.isLightProbeAvailable$(); + return this.isLightProbeAvailable(); } - private isLightProbeAvailable$ (): boolean { - if (!this._useLightProbe$) { + private isLightProbeAvailable (): boolean { + if (!this._useLightProbe) { return false; } @@ -772,7 +772,7 @@ export class Model { return true; } - private updateSHBuffer$ (): void { + private updateSHBuffer (): void { if (!this._localSHData) { return; } @@ -807,7 +807,7 @@ export class Model { this._localSHData[i] = 0.0; } - this.updateSHBuffer$(); + this.updateSHBuffer(); } /** @@ -815,12 +815,12 @@ export class Model { * @zh 更新模型的球谐 ubo */ public updateSHUBOs (): void { - if (!this.isLightProbeAvailable$()) { + if (!this.isLightProbeAvailable()) { return; } const center = this._worldBounds!.center; - if (!EDITOR && center.equals(this._lastWorldBoundCenter$, EPSILON)) { + if (!EDITOR && center.equals(this._lastWorldBoundCenter, EPSILON)) { return; } @@ -828,9 +828,9 @@ export class Model { const weights = new Vec4(); const lightProbes = (cclegacy.director.root.pipeline.pipelineSceneData as PipelineSceneData).lightProbes; - this._lastWorldBoundCenter$.set(center); - this._tetrahedronIndex$ = lightProbes.data!.getInterpolationWeights(center, this._tetrahedronIndex$, weights); - const result = lightProbes.data!.getInterpolationSHCoefficients(this._tetrahedronIndex$, weights, coefficients); + this._lastWorldBoundCenter.set(center); + this._tetrahedronIndex = lightProbes.data!.getInterpolationWeights(center, this._tetrahedronIndex, weights); + const result = lightProbes.data!.getInterpolationSHCoefficients(this._tetrahedronIndex, weights, coefficients); if (!result) { return; } @@ -842,7 +842,7 @@ export class Model { const SHCls: typeof SH = cclegacy.internal.SH; SHCls.reduceRinging(coefficients, lightProbes.reduceRinging); SHCls.updateUBOData(this._localSHData, UBOSHEnum.SH_LINEAR_CONST_R_OFFSET, coefficients); - this.updateSHBuffer$(); + this.updateSHBuffer(); } /** @@ -859,7 +859,7 @@ export class Model { this._worldBounds.copy(this._modelBounds); } - private _createSubModel$ (): SubModel { + private _createSubModel (): SubModel { return new SubModel(); } @@ -874,7 +874,7 @@ export class Model { this.initialize(); if (this._subModels[idx] == null) { - this._subModels[idx] = this._createSubModel$(); + this._subModels[idx] = this._createSubModel(); } else { this._subModels[idx].destroy(); } @@ -942,8 +942,8 @@ export class Model { * because the lighting map will influence the shader */ public initLightingmap (texture: Texture2D | null, uvParam: Vec4): void { - this._lightmap$ = texture; - this._lightmapUVParam$ = uvParam; + this._lightmap = texture; + this._lightmapUVParam = uvParam; } /** @@ -955,8 +955,8 @@ export class Model { public updateLightingmap (texture: Texture2D | null, uvParam: Vec4): void { Vec4.toArray(this._localData, uvParam, UBOLocalEnum.LIGHTINGMAP_UVPARAM); this._localDataUpdated = true; - this._lightmap$ = texture; - this._lightmapUVParam$ = uvParam; + this._lightmap = texture; + this._lightmapUVParam = uvParam; this.onMacroPatchesStateChanged(); @@ -1171,7 +1171,7 @@ export class Model { */ public getMacroPatches (subModelIndex: number): IMacroPatch[] | null { let patches = this.receiveShadow ? shadowMapPatches : null; - if (this._lightmap$ != null) { + if (this._lightmap != null) { if (this.node && this.node.scene && !this.node.scene.globals.disableLightmap) { const mainLightIsStationary = this.node.scene.globals.bakedWithStationaryMainLight; const lightmapPathes = mainLightIsStationary ? stationaryLightMapPatches : staticLightMapPatches; @@ -1183,7 +1183,7 @@ export class Model { } } } - if (this._useLightProbe$) { + if (this._useLightProbe) { patches = patches ? patches.concat(lightProbePatches) : lightProbePatches; } const reflectionProbePatches: IMacroPatch[] = [ @@ -1248,7 +1248,7 @@ export class Model { } protected _initLocalSHDescriptors (subModelIndex: number): void { - if (!EDITOR && !this._useLightProbe$) { + if (!EDITOR && !this._useLightProbe) { return; } diff --git a/cocos/render-scene/scene/point-light.ts b/cocos/render-scene/scene/point-light.ts index 8397d36420b..24dd9465474 100644 --- a/cocos/render-scene/scene/point-light.ts +++ b/cocos/render-scene/scene/point-light.ts @@ -45,13 +45,13 @@ export class PointLight extends Light { * @zh 点光源的光照范围。 */ set range (range: number) { - this._range$ = range; + this._range = range; - this._needUpdate$ = true; + this._needUpdate = true; } get range (): number { - return this._range$; + return this._range; } /** @@ -61,9 +61,9 @@ export class PointLight extends Light { get luminance (): number { const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; if (isHDR) { - return this._luminanceHDR$; + return this._luminanceHDR; } else { - return this._luminanceLDR$; + return this._luminanceLDR; } } set luminance (value: number) { @@ -80,10 +80,10 @@ export class PointLight extends Light { * @zh HDR 模式下光源的亮度。 */ get luminanceHDR (): number { - return this._luminanceHDR$; + return this._luminanceHDR; } set luminanceHDR (value: number) { - this._luminanceHDR$ = value; + this._luminanceHDR = value; } /** @@ -91,7 +91,7 @@ export class PointLight extends Light { * @zh LDR 模式下光源的亮度。 */ set luminanceLDR (value: number) { - this._luminanceLDR$ = value; + this._luminanceLDR = value; } /** @@ -102,10 +102,10 @@ export class PointLight extends Light { return this._aabb; } - private _needUpdate$ = false; - private _range$ = 1.0; - private _luminanceHDR$ = 0; - private _luminanceLDR$ = 0; + private _needUpdate = false; + private _range = 1.0; + private _luminanceHDR = 0; + private _luminanceLDR = 0; private _pos: Vec3 = v3(); private _aabb: AABB = AABB.create(); @@ -127,11 +127,11 @@ export class PointLight extends Light { * @zh 更新光源影响范围。 */ public update (): void { - if (this._node && (this._node.hasChangedFlags || this._needUpdate$)) { + if (this._node && (this._node.hasChangedFlags || this._needUpdate)) { this._node.getWorldPosition(this._pos); - const range = this._range$; + const range = this._range; AABB.set(this._aabb, this._pos.x, this._pos.y, this._pos.z, range, range, range); - this._needUpdate$ = false; + this._needUpdate = false; } } } diff --git a/cocos/render-scene/scene/ranged-directional-light.ts b/cocos/render-scene/scene/ranged-directional-light.ts index 9f51af263d6..121e6fb7d37 100644 --- a/cocos/render-scene/scene/ranged-directional-light.ts +++ b/cocos/render-scene/scene/ranged-directional-light.ts @@ -36,8 +36,8 @@ export class RangedDirectionalLight extends Light { private _pos: Vec3 = new Vec3(0, 0, 0); private _scale: Vec3 = new Vec3(1, 1, 1); private _right: Vec3 = new Vec3(1, 0, 0); - private _illuminanceHDR$: number = Ambient.SUN_ILLUM; - private _illuminanceLDR$ = 1.0; + private _illuminanceHDR: number = Ambient.SUN_ILLUM; + private _illuminanceLDR = 1.0; /** * @en The direction vector of the light @@ -78,9 +78,9 @@ export class RangedDirectionalLight extends Light { get illuminance (): number { const isHDR = cclegacy.director.root.pipeline.pipelineSceneData.isHDR; if (isHDR) { - return this._illuminanceHDR$; + return this._illuminanceHDR; } else { - return this._illuminanceLDR$; + return this._illuminanceLDR; } } set illuminance (value: number) { @@ -97,10 +97,10 @@ export class RangedDirectionalLight extends Light { * @zh HDR 模式下光源的辐照度 */ get illuminanceHDR (): number { - return this._illuminanceHDR$; + return this._illuminanceHDR; } set illuminanceHDR (value: number) { - this._illuminanceHDR$ = value; + this._illuminanceHDR = value; } /** @@ -108,10 +108,10 @@ export class RangedDirectionalLight extends Light { * @zh LDR 模式下光源的辐照度 */ get illuminanceLDR (): number { - return this._illuminanceLDR$; + return this._illuminanceLDR; } set illuminanceLDR (value: number) { - this._illuminanceLDR$ = value; + this._illuminanceLDR = value; } constructor () { diff --git a/cocos/render-scene/scene/reflection-probe.ts b/cocos/render-scene/scene/reflection-probe.ts index 2bfb3deb4bc..4a0d23cf437 100644 --- a/cocos/render-scene/scene/reflection-probe.ts +++ b/cocos/render-scene/scene/reflection-probe.ts @@ -68,45 +68,45 @@ export class ReflectionProbe { * @en Render cubemap's camera * @zh 渲染cubemap的相机 */ - private _camera$: Camera | null = null; + private _camera: Camera | null = null; /** * @en Unique id of probe. * @zh probe的唯一id */ - private _probeId$ = 0; + private _probeId = 0; - private _needRefresh$ = false; + private _needRefresh = false; - private _needRender$ = false; + private _needRender = false; - private _node$: Node | null = null; + private _node: Node | null = null; - private _cameraNode$: Node | null = null; + private _cameraNode: Node | null = null; /** * @en The AABB bounding box and probe only render the objects inside the bounding box. * @zh AABB包围盒,probe只渲染包围盒内的物体 */ - private _boundingBox$: geometry.AABB | null = null; + private _boundingBox: geometry.AABB | null = null; /** * @en The position of the camera in world space. * @zh 世界空间相机的位置 */ - private _cameraWorldPos$ = v3(); + private _cameraWorldPos = v3(); /** * @en The rotation of the camera in world space. * @zh 世界空间相机的旋转 */ - private _cameraWorldRotation$ = quat(); + private _cameraWorldRotation = quat(); /** * @en The forward direction vertor of the camera in world space. * @zh 世界空间相机朝前的方向向量 */ - private _forward$ = v3(); + private _forward = v3(); /** * @en The up direction vertor of the camera in world space. * @zh 世界空间相机朝上的方向向量 @@ -181,7 +181,7 @@ export class ReflectionProbe { } set visibility (val) { this._visibility = val; - this._camera$!.visibility = this._visibility; + this._camera!.visibility = this._visibility; } /** @@ -192,7 +192,7 @@ export class ReflectionProbe { this._size.set(value); const pos = this.node.getWorldPosition(); - geometry.AABB.set(this._boundingBox$!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); + geometry.AABB.set(this._boundingBox!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); } get size (): Vec3 { return this._size; @@ -211,11 +211,11 @@ export class ReflectionProbe { * @zh probe绑定的节点 */ get node (): Node { - return this._node$!; + return this._node!; } get camera (): Camera { - return this._camera$!; + return this._camera!; } /** @@ -223,29 +223,29 @@ export class ReflectionProbe { * @zh 刷新使用该probe的物体 */ set needRefresh (value: boolean) { - this._needRefresh$ = value; + this._needRefresh = value; } get needRefresh (): boolean { - return this._needRefresh$; + return this._needRefresh; } set needRender (value: boolean) { - this._needRender$ = value; + this._needRender = value; } get needRender (): boolean { - return this._needRender$; + return this._needRender; } get boundingBox (): geometry.AABB | null { - return this._boundingBox$; + return this._boundingBox; } set cameraNode (node: Node) { - this._cameraNode$ = node; + this._cameraNode = node; } get cameraNode (): Node { - return this._cameraNode$!; + return this._cameraNode!; } /** @@ -274,21 +274,21 @@ export class ReflectionProbe { } constructor (id: number) { - this._probeId$ = id; + this._probeId = id; } public initialize (node: Node, cameraNode: Node): void { - this._node$ = node; - this._cameraNode$ = cameraNode; + this._node = node; + this._cameraNode = cameraNode; const pos = this.node.getWorldPosition(); - this._boundingBox$ = geometry.AABB.create(pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); - this._createCamera$(cameraNode); + this._boundingBox = geometry.AABB.create(pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); + this._createCamera(cameraNode); } public initBakedTextures (): void { if (this.bakedCubeTextures.length === 0) { for (let i = 0; i < 6; i++) { - const renderTexture = this._createTargetTexture$(this._resolution, this._resolution); + const renderTexture = this._createTargetTexture(this._resolution, this._resolution); this.bakedCubeTextures.push(renderTexture); } } @@ -296,8 +296,8 @@ export class ReflectionProbe { public captureCubemap (): void { this.initBakedTextures(); - this._resetCameraParams$(); - this._needRender$ = true; + this._resetCameraParams(); + this._needRender = true; } /** @@ -309,28 +309,28 @@ export class ReflectionProbe { if (!sourceCamera) return; if (!this.realtimePlanarTexture) { const canvasSize = cclegacy.view.getDesignResolutionSize() as Size; - this.realtimePlanarTexture = this._createTargetTexture$(canvasSize.width, canvasSize.height); + this.realtimePlanarTexture = this._createTargetTexture(canvasSize.width, canvasSize.height); cclegacy.internal.reflectionProbeManager.updatePlanarMap(this, this.realtimePlanarTexture.getGFXTexture()); } - this._syncCameraParams$(sourceCamera); - this._transformReflectionCamera$(sourceCamera); - this._needRender$ = true; + this._syncCameraParams(sourceCamera); + this._transformReflectionCamera(sourceCamera); + this._needRender = true; } public switchProbeType (type: ProbeType, sourceCamera: Camera | null): void { if (type === ProbeType.CUBE) { - this._needRender$ = false; + this._needRender = false; } else if (sourceCamera !== null) { this.renderPlanarReflection(sourceCamera); } } public getProbeId (): number { - return this._probeId$; + return this._probeId; } public updateProbeId (id): void { - this._probeId$ = id; + this._probeId = id; } public renderArea (): Vec2 { @@ -350,9 +350,9 @@ export class ReflectionProbe { } public destroy (): void { - if (this._camera$) { - this._camera$.destroy(); - this._camera$ = null; + if (this._camera) { + this._camera.destroy(); + this._camera = null; } for (let i = 0; i < this.bakedCubeTextures.length; i++) { this.bakedCubeTextures[i].destroy(); @@ -379,7 +379,7 @@ export class ReflectionProbe { public updateBoundingBox (): void { if (this.node) { const pos = this.node.getWorldPosition(); - geometry.AABB.set(this._boundingBox$!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); + geometry.AABB.set(this._boundingBox!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); } } @@ -406,7 +406,7 @@ export class ReflectionProbe { return true; } - private _syncCameraParams$ (camera: Camera): void { + private _syncCameraParams (camera: Camera): void { this.camera.projectionType = camera.projectionType; this.camera.orthoHeight = camera.orthoHeight; this.camera.nearClip = camera.nearClip; @@ -418,12 +418,12 @@ export class ReflectionProbe { this.camera.resize(camera.width, camera.height); } - private _createCamera$ (cameraNode: Node): Camera | null { + private _createCamera (cameraNode: Node): Camera | null { const root = cclegacy.director.root; - if (!this._camera$) { - this._camera$ = root.createCamera(); - if (!this._camera$) return null; - this._camera$.initialize({ + if (!this._camera) { + this._camera = root.createCamera(); + if (!this._camera) return null; + this._camera.initialize({ name: cameraNode.name, node: cameraNode, projection: CameraProjection.PERSPECTIVE, @@ -433,24 +433,24 @@ export class ReflectionProbe { trackingType: TrackingType.NO_TRACKING, }); } - this._camera$.setViewportInOrientedSpace(new Rect(0, 0, 1, 1)); - this._camera$.fovAxis = CameraFOVAxis.VERTICAL; - this._camera$.fov = toRadian(90); - this._camera$.orthoHeight = 10; - this._camera$.nearClip = 1; - this._camera$.farClip = 1000; - this._camera$.clearColor = this._backgroundColor; - this._camera$.clearDepth = 1.0; - this._camera$.clearStencil = 0.0; - this._camera$.clearFlag = this._clearFlag; - this._camera$.visibility = this._visibility; - this._camera$.aperture = CameraAperture.F16_0; - this._camera$.shutter = CameraShutter.D125; - this._camera$.iso = CameraISO.ISO100; - return this._camera$; - } - - private _resetCameraParams$ (): void { + this._camera.setViewportInOrientedSpace(new Rect(0, 0, 1, 1)); + this._camera.fovAxis = CameraFOVAxis.VERTICAL; + this._camera.fov = toRadian(90); + this._camera.orthoHeight = 10; + this._camera.nearClip = 1; + this._camera.farClip = 1000; + this._camera.clearColor = this._backgroundColor; + this._camera.clearDepth = 1.0; + this._camera.clearStencil = 0.0; + this._camera.clearFlag = this._clearFlag; + this._camera.visibility = this._visibility; + this._camera.aperture = CameraAperture.F16_0; + this._camera.shutter = CameraShutter.D125; + this._camera.iso = CameraISO.ISO100; + return this._camera; + } + + private _resetCameraParams (): void { this.camera.projectionType = CameraProjection.PERSPECTIVE; this.camera.orthoHeight = 10; this.camera.nearClip = 1; @@ -468,29 +468,29 @@ export class ReflectionProbe { this.camera.update(true); } - private _createTargetTexture$ (width: number, height: number): RenderTexture { + private _createTargetTexture (width: number, height: number): RenderTexture { const rt = new RenderTexture(); rt.reset({ width, height }); return rt; } - private _transformReflectionCamera$ (sourceCamera: Camera): void { + private _transformReflectionCamera (sourceCamera: Camera): void { const offset = Vec3.dot(this.node.worldPosition, this.node.up); - this._reflect$(this._cameraWorldPos$, sourceCamera.node.worldPosition, this.node.up, offset); - this.cameraNode.worldPosition = this._cameraWorldPos$; + this._reflect(this._cameraWorldPos, sourceCamera.node.worldPosition, this.node.up, offset); + this.cameraNode.worldPosition = this._cameraWorldPos; - Vec3.transformQuat(this._forward$, Vec3.FORWARD, sourceCamera.node.worldRotation); - this._reflect$(this._forward$, this._forward$, this.node.up, 0); - this._forward$.normalize(); - this._forward$.negative(); + Vec3.transformQuat(this._forward, Vec3.FORWARD, sourceCamera.node.worldRotation); + this._reflect(this._forward, this._forward, this.node.up, 0); + this._forward.normalize(); + this._forward.negative(); Vec3.transformQuat(this._up, Vec3.UP, sourceCamera.node.worldRotation); - this._reflect$(this._up, this._up, this.node.up, 0); + this._reflect(this._up, this._up, this.node.up, 0); this._up.normalize(); - Quat.fromViewUp(this._cameraWorldRotation$, this._forward$, this._up); + Quat.fromViewUp(this._cameraWorldRotation, this._forward, this._up); - this.cameraNode.worldRotation = this._cameraWorldRotation$; + this.cameraNode.worldRotation = this._cameraWorldRotation; this.camera.update(true); @@ -500,7 +500,7 @@ export class ReflectionProbe { this.camera.calculateObliqueMat(viewSpaceProbe); } - private _reflect$ (out: Vec3, point: Vec3, normal: Vec3, offset: number): Vec3 { + private _reflect (out: Vec3, point: Vec3, normal: Vec3, offset: number): Vec3 { const n = Vec3.clone(normal); n.normalize(); const dist = Vec3.dot(n, point) - offset; diff --git a/cocos/root.ts b/cocos/root.ts index 269249cb178..73b0ac7042a 100644 --- a/cocos/root.ts +++ b/cocos/root.ts @@ -68,7 +68,7 @@ export class Root { * @zh GFX 设备 */ public get device (): Device { - return this._device$; + return this._device; } /** @@ -76,7 +76,7 @@ export class Root { * @zh 主窗口 */ public get mainWindow (): RenderWindow | null { - return this._mainWindow$; + return this._mainWindow; } /** @@ -84,11 +84,11 @@ export class Root { * @zh 当前激活的窗口 */ public set curWindow (window: RenderWindow | null) { - this._curWindow$ = window; + this._curWindow = window; } public get curWindow (): RenderWindow | null { - return this._curWindow$; + return this._curWindow; } /** @@ -97,11 +97,11 @@ export class Root { * @internal */ public set tempWindow (window: RenderWindow | null) { - this._tempWindow$ = window; + this._tempWindow = window; } public get tempWindow (): RenderWindow | null { - return this._tempWindow$; + return this._tempWindow; } /** @@ -109,7 +109,7 @@ export class Root { * @zh 窗口列表 */ public get windows (): RenderWindow[] { - return this._windows$; + return this._windows; } /** @@ -117,7 +117,7 @@ export class Root { * 启用自定义渲染管线 */ public get usesCustomPipeline (): boolean { - return this._usesCustomPipeline$; + return this._usesCustomPipeline; } /** @@ -125,7 +125,7 @@ export class Root { * @zh 渲染管线 */ public get pipeline (): PipelineRuntime { - return this._pipeline$!; + return this._pipeline!; } /** @@ -133,7 +133,7 @@ export class Root { * @zh 自定义渲染管线 */ public get customPipeline (): BasicPipeline { - return this._customPipeline$!; + return this._customPipeline!; } /** @@ -141,7 +141,7 @@ export class Root { * @zh 渲染管线事件 */ public get pipelineEvent (): IPipelineEvent { - return this._pipelineEvent$!; + return this._pipelineEvent!; } /** @@ -149,7 +149,7 @@ export class Root { * @zh 2D UI 渲染合批管理器,引擎内部使用,用户无需使用此接口 */ public get batcher2D (): Batcher2D { - return this._batcher$ as Batcher2D; + return this._batcher as Batcher2D; } /** @@ -157,7 +157,7 @@ export class Root { * @zh 渲染场景列表 */ public get scenes (): RenderScene[] { - return this._scenes$; + return this._scenes; } /** @@ -165,7 +165,7 @@ export class Root { * @zh 渲染调试管理器 */ public get debugView (): DebugView { - return this._debugView$; + return this._debugView; } /** @@ -173,7 +173,7 @@ export class Root { * @zh 累计时间(秒)。 */ public get cumulativeTime (): number { - return this._cumulativeTime$; + return this._cumulativeTime; } /** @@ -181,7 +181,7 @@ export class Root { * @zh 帧时间(秒)。 */ public get frameTime (): number { - return this._frameTime$; + return this._frameTime; } /** @@ -189,7 +189,7 @@ export class Root { * @zh 一秒内的累计帧数 */ public get frameCount (): number { - return this._frameCount$; + return this._frameCount; } /** @@ -197,7 +197,7 @@ export class Root { * @zh 当前每秒帧率 */ public get fps (): number { - return this._fps$; + return this._fps; } /** @@ -206,19 +206,19 @@ export class Root { */ public set fixedFPS (fps: number) { if (fps > 0) { - this._fixedFPS$ = fps; + this._fixedFPS = fps; } } public get fixedFPS (): number { - return this._fixedFPS$; + return this._fixedFPS; } /** * @internal */ public get dataPoolManager (): DataPoolManager { - return this._dataPoolMgr$; + return this._dataPoolMgr; } /** @@ -226,11 +226,11 @@ export class Root { * @zh 是否启用内置延迟渲染管线 */ public get useDeferredPipeline (): boolean { - return this._useDeferredPipeline$; + return this._useDeferredPipeline; } public get cameraList (): Camera[] { - return this._cameraList$; + return this._cameraList; } /** @@ -242,32 +242,32 @@ export class Root { */ public _createWindowFun: (root: Root) => RenderWindow = null!; - private declare _device$: Device; - private _windows$: RenderWindow[] = []; - private _mainWindow$: RenderWindow | null = null; - private _curWindow$: RenderWindow | null = null; - private _tempWindow$: RenderWindow | null = null; - private _usesCustomPipeline$ = true; - private _pipeline$: PipelineRuntime | null = null; - private _pipelineEvent$: IPipelineEvent | null = new PipelineEventProcessor(); - private _classicPipeline$: (PipelineRuntime & IPipelineEvent) | null = null; - private _customPipeline$: BasicPipeline | null = null; - private _batcher$: Batcher2D | null = null; - private declare _dataPoolMgr$: DataPoolManager; - private _scenes$: RenderScene[] = []; - private _modelPools$ = new Map, Pool>(); - private _cameraPool$: Pool | null = null; - private _lightPools$ = new Map, Pool>(); - private _debugView$ = new DebugView(); - private _fpsTime$ = 0; - private _frameCount$ = 0; - private _fps$ = 0; - private _fixedFPS$ = 0; - private _useDeferredPipeline$ = false; - private _cumulativeTime$ = 0; - private _frameTime$ = 0; + private declare _device: Device; + private _windows: RenderWindow[] = []; + private _mainWindow: RenderWindow | null = null; + private _curWindow: RenderWindow | null = null; + private _tempWindow: RenderWindow | null = null; + private _usesCustomPipeline = true; + private _pipeline: PipelineRuntime | null = null; + private _pipelineEvent: IPipelineEvent | null = new PipelineEventProcessor(); + private _classicPipeline: (PipelineRuntime & IPipelineEvent) | null = null; + private _customPipeline: BasicPipeline | null = null; + private _batcher: Batcher2D | null = null; + private declare _dataPoolMgr: DataPoolManager; + private _scenes: RenderScene[] = []; + private _modelPools = new Map, Pool>(); + private _cameraPool: Pool | null = null; + private _lightPools = new Map, Pool>(); + private _debugView = new DebugView(); + private _fpsTime = 0; + private _frameCount = 0; + private _fps = 0; + private _fixedFPS = 0; + private _useDeferredPipeline = false; + private _cumulativeTime = 0; + private _frameTime = 0; private declare _naitveObj: any; - private _cameraList$: Camera[] = []; + private _cameraList: Camera[] = []; /** * @en The constructor of the root, user shouldn't create the root instance, it's managed by the [[Director]]. @@ -275,13 +275,13 @@ export class Root { * @param device GFX device */ constructor (device: Device) { - this._device$ = device; - this._dataPoolMgr$ = cclegacy.internal.DataPoolManager && new cclegacy.internal.DataPoolManager(device) as DataPoolManager; + this._device = device; + this._dataPoolMgr = cclegacy.internal.DataPoolManager && new cclegacy.internal.DataPoolManager(device) as DataPoolManager; RenderScene.registerCreateFunc(this); RenderWindow.registerCreateFunc(this); - this._cameraPool$ = new Pool((): Camera => new Camera(this._device$), 4, (cam): void => cam.destroy()); + this._cameraPool = new Pool((): Camera => new Camera(this._device), 4, (cam): void => cam.destroy()); } /** @@ -299,19 +299,19 @@ export class Root { depthStencilAttachment.stencilStoreOp = StoreOp.DISCARD; const renderPassInfo = new RenderPassInfo([colorAttachment], depthStencilAttachment); - this._mainWindow$ = this.createWindow({ + this._mainWindow = this.createWindow({ title: 'rootMainWindow', width: swapchain.width, height: swapchain.height, renderPassInfo, swapchain, }); - this._curWindow$ = this._mainWindow$; + this._curWindow = this._mainWindow; const customJointTextureLayouts = settings.querySettings( SettingsCategory.ANIMATION, 'customJointTextureLayouts', ) as ICustomJointTextureLayout[] || []; - this._dataPoolMgr$?.jointTexturePool.registerCustomTextureLayouts(customJointTextureLayouts); + this._dataPoolMgr?.jointTexturePool.registerCustomTextureLayouts(customJointTextureLayouts); this._resizeMaxJointForDS(); } @@ -322,19 +322,19 @@ export class Root { public destroy (): void { this.destroyScenes(); - if (this._pipeline$) { - this._pipeline$.destroy(); - this._pipeline$ = null; - this._pipelineEvent$ = null; + if (this._pipeline) { + this._pipeline.destroy(); + this._pipeline = null; + this._pipelineEvent = null; } - if (this._batcher$) { - this._batcher$.destroy(); - this._batcher$ = null; + if (this._batcher) { + this._batcher.destroy(); + this._batcher = null; } - this._curWindow$ = null; - this._mainWindow$ = null; + this._curWindow = null; + this._mainWindow = null; this.dataPoolManager.clear(); if (cclegacy.rendering) { @@ -350,7 +350,7 @@ export class Root { * @param windowId The system window ID, optional for now. */ public resize (width: number, height: number, windowId?: number): void { - for (const window of this._windows$) { + for (const window of this._windows) { if (window.swapchain) { window.resize(width, height); } @@ -374,9 +374,9 @@ export class Root { //----------------------------------------------- let isCreateDefaultPipeline = false; if (useCustomPipeline) { - this._customPipeline$ = rendering.createCustomPipeline(); + this._customPipeline = rendering.createCustomPipeline(); isCreateDefaultPipeline = true; - this._pipeline$ = this._customPipeline$!; + this._pipeline = this._customPipeline!; // Use default _pipelineEvent log(`Using custom pipeline: ${macro.CUSTOM_PIPELINE_NAME}`); } else { @@ -384,22 +384,22 @@ export class Root { isCreateDefaultPipeline = true; log(`Using legacy pipeline`); - this._classicPipeline$ = rppl!; - this._pipeline$ = this._classicPipeline$; - this._pipelineEvent$ = this._classicPipeline$; // Use forward pipeline's pipeline event - this._usesCustomPipeline$ = false; + this._classicPipeline = rppl!; + this._pipeline = this._classicPipeline; + this._pipelineEvent = this._classicPipeline; // Use forward pipeline's pipeline event + this._usesCustomPipeline = false; } const renderMode = settings.querySettings(SettingsCategory.RENDERING, 'renderMode'); - if (renderMode !== LegacyRenderMode.HEADLESS || this._classicPipeline$) { - if (!this._pipeline$.activate(this._mainWindow$!.swapchain)) { + if (renderMode !== LegacyRenderMode.HEADLESS || this._classicPipeline) { + if (!this._pipeline.activate(this._mainWindow!.swapchain)) { if (isCreateDefaultPipeline) { - this._pipeline$.destroy(); + this._pipeline.destroy(); } - this._classicPipeline$ = null; - this._customPipeline$ = null; - this._pipeline$ = null; - this._pipelineEvent$ = null; + this._classicPipeline = null; + this._customPipeline = null; + this._pipeline = null; + this._pipelineEvent = null; return false; } @@ -414,9 +414,9 @@ export class Root { } this.onGlobalPipelineStateChanged(); - if (!this._batcher$ && internal.Batcher2D) { - this._batcher$ = new internal.Batcher2D(this); - if (!this._batcher$!.initialize()) { + if (!this._batcher && internal.Batcher2D) { + this._batcher = new internal.Batcher2D(this); + if (!this._batcher!.initialize()) { this.destroy(); return false; } @@ -430,15 +430,15 @@ export class Root { * @zh 通知渲染管线和所有场景全局管线状态已更新,需要更新自身状态。 */ public onGlobalPipelineStateChanged (): void { - for (let i = 0; i < this._scenes$.length; i++) { - this._scenes$[i].onGlobalPipelineStateChanged(); + for (let i = 0; i < this._scenes.length; i++) { + this._scenes[i].onGlobalPipelineStateChanged(); } - if (this._pipeline$!.pipelineSceneData.skybox.enabled) { - this._pipeline$!.pipelineSceneData.skybox.model!.onGlobalPipelineStateChanged(); + if (this._pipeline!.pipelineSceneData.skybox.enabled) { + this._pipeline!.pipelineSceneData.skybox.model!.onGlobalPipelineStateChanged(); } - this._pipeline$!.onGlobalPipelineStateChanged(); + this._pipeline!.onGlobalPipelineStateChanged(); } /** @@ -447,7 +447,7 @@ export class Root { * @param window The render window to be activated */ public activeWindow (window: RenderWindow): void { - this._curWindow$ = window; + this._curWindow = window; } /** @@ -455,7 +455,7 @@ export class Root { * @zh 重置累计时间 */ public resetCumulativeTime (): void { - this._cumulativeTime$ = 0; + this._cumulativeTime = 0; } /** @@ -464,15 +464,15 @@ export class Root { * @param deltaTime @en The delta time since last update. @zh 距离上一帧间隔时间 */ public frameMove (deltaTime: number): void { - this._frameTime$ = deltaTime; - - ++this._frameCount$; - this._cumulativeTime$ += deltaTime; - this._fpsTime$ += deltaTime; - if (this._fpsTime$ > 1.0) { - this._fps$ = this._frameCount$; - this._frameCount$ = 0; - this._fpsTime$ = 0.0; + this._frameTime = deltaTime; + + ++this._frameCount; + this._cumulativeTime += deltaTime; + this._fpsTime += deltaTime; + if (this._fpsTime > 1.0) { + this._fps = this._frameCount; + this._frameCount = 0; + this._fpsTime = 0.0; } if (globalThis.__globalXR?.isWebXR) { @@ -492,7 +492,7 @@ export class Root { public createWindow (info: IRenderWindowInfo): RenderWindow | null { const window = this._createWindowFun(this); window.initialize(this.device, info); - this._windows$.push(window); + this._windows.push(window); return window; } @@ -502,10 +502,10 @@ export class Root { * @param window The render window to be destroyed */ public destroyWindow (window: RenderWindow): void { - for (let i = 0; i < this._windows$.length; ++i) { - if (this._windows$[i] === window) { + for (let i = 0; i < this._windows.length; ++i) { + if (this._windows[i] === window) { window.destroy(); - this._windows$.splice(i, 1); + this._windows.splice(i, 1); return; } } @@ -516,10 +516,10 @@ export class Root { * @zh 销毁全部窗口 */ public destroyWindows (): void { - for (const window of this._windows$) { + for (const window of this._windows) { window.destroy(); } - this._windows$.length = 0; + this._windows.length = 0; } /** @@ -530,7 +530,7 @@ export class Root { public createScene (info: IRenderSceneInfo): RenderScene { const scene: RenderScene = this._createSceneFun(this); scene.initialize(info); - this._scenes$.push(scene); + this._scenes.push(scene); return scene; } @@ -540,10 +540,10 @@ export class Root { * @param scene @en The render scene to be destroyed. @zh 要销毁的渲染场景 */ public destroyScene (scene: RenderScene): void { - for (let i = 0; i < this._scenes$.length; ++i) { - if (this._scenes$[i] === scene) { + for (let i = 0; i < this._scenes.length; ++i) { + if (this._scenes[i] === scene) { scene.destroy(); - this._scenes$.splice(i, 1); + this._scenes.splice(i, 1); return; } } @@ -554,10 +554,10 @@ export class Root { * @zh 销毁全部场景。 */ public destroyScenes (): void { - for (const scene of this._scenes$) { + for (const scene of this._scenes) { scene.destroy(); } - this._scenes$.length = 0; + this._scenes.length = 0; } /** @@ -567,10 +567,10 @@ export class Root { * @returns The model created */ public createModel (ModelCtor: typeof Model): T { - let p = this._modelPools$.get(ModelCtor); + let p = this._modelPools.get(ModelCtor); if (!p) { - this._modelPools$.set(ModelCtor, new Pool((): Model => new ModelCtor(), 10, (obj): void => obj.destroy())); - p = this._modelPools$.get(ModelCtor)!; + this._modelPools.set(ModelCtor, new Pool((): Model => new ModelCtor(), 10, (obj): void => obj.destroy())); + p = this._modelPools.get(ModelCtor)!; } const model = p.alloc() as T; model.initialize(); @@ -583,7 +583,7 @@ export class Root { * @param m @en The model to be destroyed @zh 要销毁的模型 */ public destroyModel (m: Model): void { - const p = this._modelPools$.get(m.constructor as Constructor); + const p = this._modelPools.get(m.constructor as Constructor); if (p) { p.free(m); if (m.scene) { @@ -601,7 +601,7 @@ export class Root { * @returns The camera created. */ public createCamera (): Camera { - return this._cameraPool$!.alloc(); + return this._cameraPool!.alloc(); } /** @@ -611,10 +611,10 @@ export class Root { * @returns The light created */ public createLight (LightCtor: new () => T): T { - let l = this._lightPools$.get(LightCtor); + let l = this._lightPools.get(LightCtor); if (!l) { - this._lightPools$.set(LightCtor, new Pool((): T => new LightCtor(), 4, (obj): void => obj.destroy())); - l = this._lightPools$.get(LightCtor)!; + this._lightPools.set(LightCtor, new Pool((): T => new LightCtor(), 4, (obj): void => obj.destroy())); + l = this._lightPools.get(LightCtor)!; } const light = l.alloc() as T; light.initialize(); @@ -657,7 +657,7 @@ export class Root { * @param l @en The light to be recycled @zh 要回收的光源 */ public recycleLight (l: Light): void { - const p = this._lightPools$.get(l.constructor as Constructor); + const p = this._lightPools.get(l.constructor as Constructor); if (p) { p.free(l); if (l.scene) { @@ -690,8 +690,8 @@ export class Root { return; } - const windows = this._windows$; - const cameraList = this._cameraList$; + const windows = this._windows; + const cameraList = this._cameraList; const viewCount = xr.webXRMatProjs ? xr.webXRMatProjs.length : 1; if (!xr.webXRWindowMap) { xr.webXRWindowMap = new Map(); @@ -751,31 +751,31 @@ export class Root { } private _frameMoveBegin (): void { - for (let i = 0; i < this._scenes$.length; ++i) { - this._scenes$[i].removeBatches(); + for (let i = 0; i < this._scenes.length; ++i) { + this._scenes[i].removeBatches(); } - this._cameraList$.length = 0; + this._cameraList.length = 0; } private _frameMoveProcess (): void { const { director } = cclegacy; - const windows = this._windows$; - const cameraList = this._cameraList$; + const windows = this._windows; + const cameraList = this._cameraList; for (let i = 0; i < windows.length; i++) { const window = windows[i]; window.extractRenderCameras(cameraList); } - if (this._pipeline$ && cameraList.length > 0) { - this._device$.acquire([deviceManager.swapchain]); - const scenes = this._scenes$; + if (this._pipeline && cameraList.length > 0) { + this._device.acquire([deviceManager.swapchain]); + const scenes = this._scenes; const stamp = director.getTotalFrames() as number; - if (this._batcher$) { - this._batcher$.update(); - this._batcher$.uploadBuffers(); + if (this._batcher) { + this._batcher.update(); + this._batcher.uploadBuffers(); } for (let i = 0; i < scenes.length; i++) { @@ -786,8 +786,8 @@ export class Root { private _frameMoveEnd (): void { const { director, Director } = cclegacy; - const cameraList = this._cameraList$; - if (this._pipeline$ && cameraList.length > 0) { + const cameraList = this._cameraList; + if (this._pipeline && cameraList.length > 0) { director.emit(Director.EVENT_BEFORE_COMMIT); cameraList.sort((a: Camera, b: Camera): number => a.priority - b.priority); @@ -795,12 +795,12 @@ export class Root { cameraList[i].geometryRenderer?.update(); } director.emit(Director.EVENT_BEFORE_RENDER); - this._pipeline$.render(cameraList); + this._pipeline.render(cameraList); director.emit(Director.EVENT_AFTER_RENDER); - this._device$.present(); + this._device.present(); } - if (this._batcher$) this._batcher$.reset(); + if (this._batcher) this._batcher.reset(); } private _resizeMaxJointForDS (): void { diff --git a/cocos/scene-graph/node-event-processor.ts b/cocos/scene-graph/node-event-processor.ts index edff9d248f6..da4c3875535 100644 --- a/cocos/scene-graph/node-event-processor.ts +++ b/cocos/scene-graph/node-event-processor.ts @@ -157,7 +157,7 @@ export class NodeEventProcessor { const node = this.node; const children = node.children; if (value) { - this._attachMask$(); + this._attachMask(); } NodeEventProcessor.callbacksInvoker.emit(DispatcherEventType.MARK_LIST_DIRTY); if (recursive && children.length > 0) { @@ -196,26 +196,26 @@ export class NodeEventProcessor { } public on (type: NodeEventType, callback: AnyFunction, target?: unknown, useCapture?: boolean): AnyFunction { - this._tryEmittingAddEvent$(type); + this._tryEmittingAddEvent(type); useCapture = !!useCapture; let invoker: CallbacksInvoker; if (useCapture) { - invoker = this.capturingTarget ??= this._newCallbacksInvoker$(); + invoker = this.capturingTarget ??= this._newCallbacksInvoker(); } else { - invoker = this.bubblingTarget ??= this._newCallbacksInvoker$(); + invoker = this.bubblingTarget ??= this._newCallbacksInvoker(); } invoker.on(type, callback, target); return callback; } public once (type: NodeEventType, callback: AnyFunction, target?: unknown, useCapture?: boolean): AnyFunction { - this._tryEmittingAddEvent$(type); + this._tryEmittingAddEvent(type); useCapture = !!useCapture; let invoker: CallbacksInvoker; if (useCapture) { - invoker = this.capturingTarget ??= this._newCallbacksInvoker$(); + invoker = this.capturingTarget ??= this._newCallbacksInvoker(); } else { - invoker = this.bubblingTarget ??= this._newCallbacksInvoker$(); + invoker = this.bubblingTarget ??= this._newCallbacksInvoker(); } invoker.on(type, callback, target, true); @@ -238,13 +238,13 @@ export class NodeEventProcessor { this.bubblingTarget?.removeAll(target); // emit event - if (this.shouldHandleEventTouch && !this._hasTouchListeners$()) { + if (this.shouldHandleEventTouch && !this._hasTouchListeners()) { this.shouldHandleEventTouch = false; } - if (this.shouldHandleEventMouse && !this._hasMouseListeners$()) { + if (this.shouldHandleEventMouse && !this._hasMouseListeners()) { this.shouldHandleEventMouse = false; } - if (!this._hasPointerListeners$()) { + if (!this._hasPointerListeners()) { NodeEventProcessor.callbacksInvoker.emit(DispatcherEventType.REMOVE_POINTER_EVENT_PROCESSOR, this); } } @@ -394,21 +394,21 @@ export class NodeEventProcessor { return null; } - private _attachMask$ (): void { + private _attachMask (): void { this.maskList = this._searchComponentsInParent(NodeEventProcessor._maskComp); } - private _isTouchEvent$ (type: NodeEventType): boolean { + private _isTouchEvent (type: NodeEventType): boolean { const index = _touchEvents.indexOf(type); return index !== -1; } - private _isMouseEvent$ (type: NodeEventType): boolean { + private _isMouseEvent (type: NodeEventType): boolean { const index = _mouseEvents.indexOf(type); return index !== -1; } - private _hasTouchListeners$ (): boolean { + private _hasTouchListeners (): boolean { for (let i = 0; i < _touchEvents.length; ++i) { const eventType = _touchEvents[i]; if (this.hasEventListener(eventType)) { @@ -418,7 +418,7 @@ export class NodeEventProcessor { return false; } - private _hasMouseListeners$ (): boolean { + private _hasMouseListeners (): boolean { for (let i = 0; i < _mouseEvents.length; ++i) { const eventType = _mouseEvents[i]; if (this.hasEventListener(eventType)) { @@ -428,23 +428,23 @@ export class NodeEventProcessor { return false; } - private _hasPointerListeners$ (): boolean { - const has = this._hasTouchListeners$(); + private _hasPointerListeners (): boolean { + const has = this._hasTouchListeners(); if (has) { return true; } - return this._hasMouseListeners$(); + return this._hasMouseListeners(); } - private _tryEmittingAddEvent$ (typeToAdd: NodeEventType): void { - const isTouchEvent = this._isTouchEvent$(typeToAdd); - const isMouseEvent = this._isMouseEvent$(typeToAdd); + private _tryEmittingAddEvent (typeToAdd: NodeEventType): void { + const isTouchEvent = this._isTouchEvent(typeToAdd); + const isMouseEvent = this._isMouseEvent(typeToAdd); if (isTouchEvent) { this.shouldHandleEventTouch = true; } else if (isMouseEvent) { this.shouldHandleEventMouse = true; } - if ((isTouchEvent || isMouseEvent) && !this._hasPointerListeners$()) { + if ((isTouchEvent || isMouseEvent) && !this._hasPointerListeners()) { NodeEventProcessor.callbacksInvoker.emit(DispatcherEventType.ADD_POINTER_EVENT_PROCESSOR, this); } } @@ -454,16 +454,16 @@ export class NodeEventProcessor { * We need to inject some nodeEventProcessor's logic into the `callbacksInvoker.off` method. * @returns {CallbacksInvoker} decorated callbacks invoker */ - private _newCallbacksInvoker$ (): CallbacksInvoker { + private _newCallbacksInvoker (): CallbacksInvoker { const callbacksInvoker = new CallbacksInvoker(); callbacksInvoker._registerOffCallback(() => { - if (this.shouldHandleEventTouch && !this._hasTouchListeners$()) { + if (this.shouldHandleEventTouch && !this._hasTouchListeners()) { this.shouldHandleEventTouch = false; } - if (this.shouldHandleEventMouse && !this._hasMouseListeners$()) { + if (this.shouldHandleEventMouse && !this._hasMouseListeners()) { this.shouldHandleEventMouse = false; } - if (!this._hasPointerListeners$()) { + if (!this._hasPointerListeners()) { NodeEventProcessor.callbacksInvoker.emit(DispatcherEventType.REMOVE_POINTER_EVENT_PROCESSOR, this); } }); @@ -478,23 +478,23 @@ export class NodeEventProcessor { public _handleEventMouse (eventMouse: EventMouse): boolean { switch (eventMouse.type) { case InputEventType.MOUSE_DOWN: - return this._handleMouseDown$(eventMouse); + return this._handleMouseDown(eventMouse); case InputEventType.MOUSE_MOVE: - return this._handleMouseMove$(eventMouse); + return this._handleMouseMove(eventMouse); case InputEventType.MOUSE_UP: - return this._handleMouseUp$(eventMouse); + return this._handleMouseUp(eventMouse); case InputEventType.MOUSE_WHEEL: - return this._handleMouseWheel$(eventMouse); + return this._handleMouseWheel(eventMouse); case InputEventType.MOUSE_LEAVE: - return this._handleMouseLeave$(eventMouse); + return this._handleMouseLeave(eventMouse); case InputEventType.MOUSE_ENTER: - return this._handleMouseEnter$(eventMouse); + return this._handleMouseEnter(eventMouse); default: return false; } } - private _handleMouseDown$ (event: EventMouse): boolean { + private _handleMouseDown (event: EventMouse): boolean { const node = this._node; if (!node || !node._uiProps.uiTransformComp) { return false; @@ -512,7 +512,7 @@ export class NodeEventProcessor { return false; } - private _handleMouseMove$ (event: EventMouse): boolean { + private _handleMouseMove (event: EventMouse): boolean { const node = this._node; if (!node || !node._uiProps.uiTransformComp || this._isMouseLeaveWindow) { return false; @@ -548,7 +548,7 @@ export class NodeEventProcessor { return false; } - private _handleMouseUp$ (event: EventMouse): boolean { + private _handleMouseUp (event: EventMouse): boolean { const node = this._node; if (!node || !node._uiProps.uiTransformComp) { return false; @@ -566,7 +566,7 @@ export class NodeEventProcessor { return false; } - private _handleMouseWheel$ (event: EventMouse): boolean { + private _handleMouseWheel (event: EventMouse): boolean { const node = this._node; if (!node || !node._uiProps.uiTransformComp) { return false; @@ -585,7 +585,7 @@ export class NodeEventProcessor { return false; } - private _handleMouseLeave$ (event: EventMouse): boolean { + private _handleMouseLeave (event: EventMouse): boolean { this._isMouseLeaveWindow = true; if (this.previousMouseIn) { event.type = NodeEventType.MOUSE_LEAVE; @@ -596,7 +596,7 @@ export class NodeEventProcessor { return false; } - private _handleMouseEnter$ (event: EventMouse): boolean { + private _handleMouseEnter (event: EventMouse): boolean { this._isMouseLeaveWindow = false; return false; } @@ -612,13 +612,13 @@ export class NodeEventProcessor { try { switch (eventTouch.type) { case InputEventType.TOUCH_START: - return this._handleTouchStart$(eventTouch); + return this._handleTouchStart(eventTouch); case InputEventType.TOUCH_MOVE: - return this._handleTouchMove$(eventTouch); + return this._handleTouchMove(eventTouch); case InputEventType.TOUCH_END: - return this._handleTouchEnd$(eventTouch); + return this._handleTouchEnd(eventTouch); case InputEventType.TOUCH_CANCEL: - return this._handleTouchCancel$(eventTouch); + return this._handleTouchCancel(eventTouch); default: return false; } @@ -628,7 +628,7 @@ export class NodeEventProcessor { } } - private _handleTouchStart$ (event: EventTouch): boolean { + private _handleTouchStart (event: EventTouch): boolean { const node = this.node; if (!node || !node._uiProps.uiTransformComp) { return false; @@ -647,7 +647,7 @@ export class NodeEventProcessor { return false; } - private _handleTouchMove$ (event: EventTouch): boolean { + private _handleTouchMove (event: EventTouch): boolean { const node = this.node; if (!node || !node._uiProps.uiTransformComp) { return false; @@ -660,7 +660,7 @@ export class NodeEventProcessor { return true; } - private _handleTouchEnd$ (event: EventTouch): void { + private _handleTouchEnd (event: EventTouch): void { const node = this.node; if (!node || !node._uiProps.uiTransformComp) { return; @@ -678,7 +678,7 @@ export class NodeEventProcessor { this._dispatchingTouch = null; } - private _handleTouchCancel$ (event: EventTouch): void { + private _handleTouchCancel (event: EventTouch): void { const node = this.node; if (!node || !node._uiProps.uiTransformComp) { return; diff --git a/cocos/scene-graph/node-ui-properties.ts b/cocos/scene-graph/node-ui-properties.ts index 4b4f0f4d1a6..d620f173df1 100644 --- a/cocos/scene-graph/node-ui-properties.ts +++ b/cocos/scene-graph/node-ui-properties.ts @@ -39,7 +39,7 @@ export class NodeUIProperties { */ get uiTransformComp (): UITransform | null { if (!this._uiTransformComp) { - this._uiTransformComp = this._node$.getComponent('cc.UITransform') as UITransform; + this._uiTransformComp = this._node.getComponent('cc.UITransform') as UITransform; } return this._uiTransformComp; @@ -53,54 +53,54 @@ export class NodeUIProperties { * @zh UI 基类组件 */ get uiComp (): UIMeshRenderer | UIRenderer | null { - return this._uiComp$; + return this._uiComp; } set uiComp (comp: UIMeshRenderer | UIRenderer | null) { - if (this._uiComp$ && comp) { + if (this._uiComp && comp) { warnID(12002); return; } - this._uiComp$ = comp; + this._uiComp = comp; } - private _uiComp$: UIMeshRenderer | UIRenderer | null = null; + private _uiComp: UIMeshRenderer | UIRenderer | null = null; /** * @en The opacity of the UI node for final rendering * @zh 最终显示的 UI 透明度,受父节点透明度影响 */ - private _opacity$ = 1; + private _opacity = 1; /** * NOTE: engineInternal tag cannot only mark opacity setter as internal. * @engineInternal */ - public setOpacity (v: number): void { this._opacity$ = v; } - public get opacity (): number { return this._opacity$; } + public setOpacity (v: number): void { this._opacity = v; } + public get opacity (): number { return this._opacity; } /** * @en The opacity of the UI node itself * @zh 本节点的 UI 透明度 */ - private _localOpacity$ = 1; - get localOpacity (): number { return this._localOpacity$; } + private _localOpacity = 1; + get localOpacity (): number { return this._localOpacity; } set localOpacity (val) { - this._localOpacity$ = val; + this._localOpacity = val; this.colorDirty = true; } public colorDirty = true; protected _uiTransformComp: UITransform | null = null; - private declare _node$: Node; + private declare _node: Node; constructor (node: Node) { - this._node$ = node; + this._node = node; } /** * @deprecated since v3.4 */ public applyOpacity (effectOpacity: number): void { - this._opacity$ = this._localOpacity$ * effectOpacity; + this._opacity = this._localOpacity * effectOpacity; } /** diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index 397d3facdba..c3710626f84 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -1495,8 +1495,8 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * @en Counter to clear node array * @zh 清除节点数组计时器 */ - private static ClearFrame$ = 0; - private static ClearRound$ = 1000; + private static ClearFrame = 0; + private static ClearRound = 1000; /** * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. @@ -2666,10 +2666,10 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * 清除节点数组 */ public static clearNodeArray (): void { - if (Node.ClearFrame$ < Node.ClearRound$ && !EDITOR) { - Node.ClearFrame$++; + if (Node.ClearFrame < Node.ClearRound && !EDITOR) { + Node.ClearFrame++; } else { - Node.ClearFrame$ = 0; + Node.ClearFrame = 0; dirtyNodes.length = 0; } } diff --git a/cocos/scene-graph/prefab/prefab.ts b/cocos/scene-graph/prefab/prefab.ts index 1dff1520633..1eddabb7bb1 100644 --- a/cocos/scene-graph/prefab/prefab.ts +++ b/cocos/scene-graph/prefab/prefab.ts @@ -112,8 +112,8 @@ export class Prefab extends Asset { public persistent = false; // Cache function to optimize instance creation. - private _createFunction$: ((...arg: any[]) => Node) | null = null; - private _instantiatedTimes$: number = 0; + private _createFunction: ((...arg: any[]) => Node) | null = null; + private _instantiatedTimes: number = 0; constructor () { super(); } @@ -136,7 +136,7 @@ export class Prefab extends Asset { */ public compileCreateFunction (): void { if (SUPPORT_JIT) { - this._createFunction$ = compile(this.data); + this._createFunction = compile(this.data); } } @@ -151,10 +151,10 @@ export class Prefab extends Asset { // temp guard code warnID(3700); } - if (!this._createFunction$) { + if (!this._createFunction) { this.compileCreateFunction(); } - return this._createFunction$!(rootToRedirect); // this.data._instantiate(); + return this._createFunction!(rootToRedirect); // this.data._instantiate(); } private _instantiate (): Node { @@ -167,7 +167,7 @@ export class Prefab extends Asset { useJit = true; } else { // auto - useJit = (this._instantiatedTimes$ + 1) >= Prefab.OptimizationPolicyThreshold; + useJit = (this._instantiatedTimes + 1) >= Prefab.OptimizationPolicyThreshold; } } if (useJit) { @@ -179,7 +179,7 @@ export class Prefab extends Asset { // instantiate node node = this.data._instantiate(); } - ++this._instantiatedTimes$; + ++this._instantiatedTimes; return node; } diff --git a/cocos/scene-graph/scene-globals.ts b/cocos/scene-graph/scene-globals.ts index 39c40015ddd..1b81b400aa8 100644 --- a/cocos/scene-graph/scene-globals.ts +++ b/cocos/scene-graph/scene-globals.ts @@ -1433,15 +1433,15 @@ export class LightProbeInfo { } public onProbeBakeFinished (): void { - this.onProbeBakingChanged$(this._scene); + this.onProbeBakingChanged(this._scene); } public onProbeBakeCleared (): void { this.clearSHCoefficients(); - this.onProbeBakingChanged$(this._scene); + this.onProbeBakingChanged(this._scene); } - private onProbeBakingChanged$ (node: Node | null): void { + private onProbeBakingChanged (node: Node | null): void { if (!node) { return; } @@ -1450,7 +1450,7 @@ export class LightProbeInfo { for (let i = 0; i < node.children.length; i++) { const child = node.children[i]; - this.onProbeBakingChanged$(child); + this.onProbeBakingChanged(child); } } @@ -1464,7 +1464,7 @@ export class LightProbeInfo { probes[i].coefficients.length = 0; } - this.clearAllSHUBOs$(); + this.clearAllSHUBOs(); } public isUniqueNode (): boolean { @@ -1542,7 +1542,7 @@ export class LightProbeInfo { const pointCount = points.length; if (pointCount < 4) { - this.resetAllTetraIndices$(); + this.resetAllTetraIndices(); this._data!.reset(); return; } @@ -1550,12 +1550,12 @@ export class LightProbeInfo { this._data!.updateProbes(points); if (updateTet) { - this.resetAllTetraIndices$(); + this.resetAllTetraIndices(); this._data!.updateTetrahedrons(); } } - private clearAllSHUBOs$ (): void { + private clearAllSHUBOs (): void { if (!this._scene) { return; } @@ -1571,7 +1571,7 @@ export class LightProbeInfo { } } - private resetAllTetraIndices$ (): void { + private resetAllTetraIndices (): void { if (!this._scene) { return; } diff --git a/cocos/serialization/ccon.ts b/cocos/serialization/ccon.ts index 30656b84555..8d30642bd1e 100644 --- a/cocos/serialization/ccon.ts +++ b/cocos/serialization/ccon.ts @@ -32,20 +32,20 @@ const CHUNK_ALIGN_AS = 8; export class CCON { constructor (document: unknown, chunks: Uint8Array[]) { - this._document$ = document; - this._chunks$ = chunks; + this._document = document; + this._chunks = chunks; } get document (): unknown { - return this._document$; + return this._document; } get chunks (): Uint8Array[] { - return this._chunks$; + return this._chunks; } - private declare _document$: unknown; - private declare _chunks$: Uint8Array[]; + private declare _document: unknown; + private declare _chunks: Uint8Array[]; } interface CCONPreface { @@ -214,20 +214,20 @@ function decodeJson (data: Uint8Array): string { export class InvalidCCONError extends Error { } export class BufferBuilder { - private _viewOrPaddings$: (ArrayBufferView | number)[] = []; - private _length$ = 0; + private _viewOrPaddings: (ArrayBufferView | number)[] = []; + private _length = 0; get byteLength (): number { - return this._length$; + return this._length; } public alignAs (align: number): number { if (align !== 0) { - const remainder = this._length$ % align; + const remainder = this._length % align; if (remainder !== 0) { const padding = align - remainder; - this._viewOrPaddings$.push(padding); - this._length$ += padding; + this._viewOrPaddings.push(padding); + this._length += padding; return padding; } } @@ -235,16 +235,16 @@ export class BufferBuilder { } public append (view: ArrayBufferView): number { - const result = this._length$; - this._viewOrPaddings$.push(view); - this._length$ += view.byteLength; + const result = this._length; + this._viewOrPaddings.push(view); + this._length += view.byteLength; return result; } public get (): Uint8Array { - const result = new Uint8Array(this._length$); + const result = new Uint8Array(this._length); let counter = 0; - this._viewOrPaddings$.forEach((viewOrPadding) => { + this._viewOrPaddings.forEach((viewOrPadding) => { if (typeof viewOrPadding === 'number') { counter += viewOrPadding; } else { diff --git a/cocos/serialization/deserialize-dynamic.ts b/cocos/serialization/deserialize-dynamic.ts index b93959a67dc..7e0d8a9fced 100644 --- a/cocos/serialization/deserialize-dynamic.ts +++ b/cocos/serialization/deserialize-dynamic.ts @@ -385,37 +385,37 @@ class _Deserializer { public declare customEnv: unknown; public deserializedList: Array | undefined> = []; public deserializedData: any = null; - private declare _classFinder$: ClassFinder; - private declare _reportMissingClass$: ReportMissingClass; - private declare _onDereferenced$: ClassFinder['onDereferenced']; + private declare _classFinder: ClassFinder; + private declare _reportMissingClass: ReportMissingClass; + private declare _onDereferenced: ClassFinder['onDereferenced']; /** * @engineInternal */ - public get ignoreEditorOnly (): unknown { return this._ignoreEditorOnly$; } - private declare _ignoreEditorOnly$: unknown; - private declare _mainBinChunk$: Uint8Array; - private declare _serializedData$: SerializedObject | SerializedObject[]; - private declare _context$: DeserializationContext; + public get ignoreEditorOnly (): unknown { return this._ignoreEditorOnly; } + private declare _ignoreEditorOnly: unknown; + private declare _mainBinChunk: Uint8Array; + private declare _serializedData: SerializedObject | SerializedObject[]; + private declare _context: DeserializationContext; constructor (result: Details, classFinder: ClassFinder, reportMissingClass: ReportMissingClass, customEnv: unknown, ignoreEditorOnly: unknown) { this.result = result; this.customEnv = customEnv; - this._classFinder$ = classFinder; - this._reportMissingClass$ = reportMissingClass; - this._onDereferenced$ = classFinder?.onDereferenced; + this._classFinder = classFinder; + this._reportMissingClass = reportMissingClass; + this._onDereferenced = classFinder?.onDereferenced; if (DEV) { - this._ignoreEditorOnly$ = ignoreEditorOnly; + this._ignoreEditorOnly = ignoreEditorOnly; } } public reset (result: Details, classFinder: ClassFinder, reportMissingClass: ReportMissingClass, customEnv: unknown, ignoreEditorOnly: unknown): void { this.result = result; this.customEnv = customEnv; - this._classFinder$ = classFinder; - this._reportMissingClass$ = reportMissingClass; - this._onDereferenced$ = classFinder?.onDereferenced; + this._classFinder = classFinder; + this._reportMissingClass = reportMissingClass; + this._onDereferenced = classFinder?.onDereferenced; if (DEV) { - this._ignoreEditorOnly$ = ignoreEditorOnly; + this._ignoreEditorOnly = ignoreEditorOnly; } } @@ -424,9 +424,9 @@ class _Deserializer { this.customEnv = null; this.deserializedList.length = 0; this.deserializedData = null; - this._classFinder$ = null!; - this._reportMissingClass$ = null!; - this._onDereferenced$ = null!; + this._classFinder = null!; + this._reportMissingClass = null!; + this._onDereferenced = null!; } public deserialize (serializedData: SerializedData | CCON): any { @@ -437,28 +437,28 @@ class _Deserializer { jsonObj = serializedData.document as SerializedData; if (serializedData.chunks.length > 0) { assertIsTrue(serializedData.chunks.length === 1); - this._mainBinChunk$ = serializedData.chunks[0]; + this._mainBinChunk = serializedData.chunks[0]; } } else { jsonObj = serializedData; } - this._serializedData$ = jsonObj; - this._context$ = { + this._serializedData = jsonObj; + this._context = { fromCCON, }; const serializedRootObject = Array.isArray(jsonObj) ? jsonObj[0] : jsonObj; if (EDITOR || TEST) { - this.deserializedData = this._deserializeObject$(serializedRootObject, 0, this.deserializedList, `${0}`); + this.deserializedData = this._deserializeObject(serializedRootObject, 0, this.deserializedList, `${0}`); } else { - this.deserializedData = this._deserializeObject$(serializedRootObject, 0); + this.deserializedData = this._deserializeObject(serializedRootObject, 0); } - this._serializedData$ = undefined!; - this._mainBinChunk$ = undefined!; - this._context$ = undefined!; + this._serializedData = undefined!; + this._mainBinChunk = undefined!; + this._context = undefined!; // eslint-disable-next-line @typescript-eslint/no-unsafe-return return this.deserializedData; @@ -470,7 +470,7 @@ class _Deserializer { * @param owner - Tracing purpose. * @param propName - Tracing purpose. */ - private _deserializeObject$ ( + private _deserializeObject ( serialized: SerializedObject, globalIndex: number, owner?: Record | unknown[], @@ -478,36 +478,36 @@ class _Deserializer { ): Record | null { switch (serialized.__type__) { case 'TypedArray': - return this._deserializeTypedArrayView$(serialized); + return this._deserializeTypedArrayView(serialized); case 'TypedArrayRef': - return this._deserializeTypedArrayViewRef$(serialized); + return this._deserializeTypedArrayViewRef(serialized); default: // NOTE: when 'strictNullCheck' is false, TS can't infer serialized as SerializedGeneralTypedObject if ((serialized as unknown as SerializedGeneralTypedObject).__type__) { // Typed object (including CCClass) - return this._deserializeTypeTaggedObject$(serialized, globalIndex, owner, propName); + return this._deserializeTypeTaggedObject(serialized, globalIndex, owner, propName); } else if (!Array.isArray(serialized)) { // Embedded primitive javascript object - return this._deserializePlainObject$(serialized); + return this._deserializePlainObject(serialized); } else { // Array - return this._deserializeArray$(serialized); + return this._deserializeArray(serialized); } } } - private _deserializeTypedArrayView$ (value: SerializedTypedArray): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array { + private _deserializeTypedArrayView (value: SerializedTypedArray): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array { return globalThis[value.ctor].from(value.array); } - private _deserializeTypedArrayViewRef$ (value: SerializedTypedArrayRef): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array { + private _deserializeTypedArrayViewRef (value: SerializedTypedArrayRef): Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array { const { offset, length, ctor: constructorName } = value; const obj = new globalThis[constructorName]( - this._mainBinChunk$.buffer, - this._mainBinChunk$.byteOffset + offset, + this._mainBinChunk.buffer, + this._mainBinChunk.byteOffset + offset, length, ); return obj; } - private _deserializeArray$ (value: SerializedValue[]): unknown[] { + private _deserializeArray (value: SerializedValue[]): unknown[] { const obj = new Array(value.length); let prop: unknown; for (let i = 0; i < value.length; i++) { @@ -525,13 +525,13 @@ class _Deserializer { return obj; } - private _deserializePlainObject$ (value: Record): Record { + private _deserializePlainObject (value: Record): Record { const obj = {}; this._fillPlainObject(obj, value); return obj; } - private _deserializeTypeTaggedObject$ ( + private _deserializeTypeTaggedObject ( value: SerializedGeneralTypedObject, globalIndex: number, owner?: Record | unknown[], @@ -539,11 +539,11 @@ class _Deserializer { ): Record | null { const type = value.__type__ as unknown as string; - const klass = this._classFinder$(type, value, owner, propName); + const klass = this._classFinder(type, value, owner, propName); if (!klass) { - const notReported = this._classFinder$ === js.getClassById; + const notReported = this._classFinder === js.getClassById; if (notReported) { - this._reportMissingClass$(type); + this._reportMissingClass(type); } return null; } @@ -559,32 +559,32 @@ class _Deserializer { if (!(EDITOR && js.isChildClassOf(klass, cclegacy.Component))) { const obj = createObject(klass); - this._deserializeInto$(value, obj, klass); + this._deserializeInto(value, obj, klass); return obj; } else { try { const obj = createObject(klass); - this._deserializeInto$(value, obj, klass); + this._deserializeInto(value, obj, klass); return obj; } catch (e: unknown) { if (DEBUG) { error(`Deserialize ${klass.name} failed, ${(e as { stack: string; }).stack}`); } const obj = createObject(MissingScript); - this._deserializeInto$(value, obj, MissingScript); + this._deserializeInto(value, obj, MissingScript); return obj; } } } - private _deserializeInto$ ( + private _deserializeInto ( value: SerializedGeneralTypedObject, object: Record, constructor: deserialize.SerializableClassConstructor, skipCustomized = false, ): void { if (!skipCustomized && (object as Partial)[deserializeTag]) { - this._runCustomizedDeserialize$( + this._runCustomizedDeserialize( value, object as Record & CustomSerializable, constructor, @@ -600,13 +600,13 @@ class _Deserializer { } if (cclegacy.Class._isCCClass(constructor)) { - this._deserializeFireClass$(object, value, constructor as CCClassConstructor); + this._deserializeFireClass(object, value, constructor as CCClassConstructor); } else { this._deserializeFastDefinedObject(object, value, constructor); } } - private _runCustomizedDeserialize$ ( + private _runCustomizedDeserialize ( value: SerializedGeneralTypedObject, object: Record & CustomSerializable, constructor: deserialize.SerializableClassConstructor, @@ -617,26 +617,26 @@ class _Deserializer { if (typeof serializedField !== 'object' || !serializedField) { return serializedField as unknown; } else { - return this._deserializeObjectField$(serializedField) as unknown; + return this._deserializeObjectField(serializedField) as unknown; } }, readThis: () => { - this._deserializeInto$(value, object, constructor, true); + this._deserializeInto(value, object, constructor, true); }, readSuper: () => { const superConstructor = js.getSuper(constructor); if (superConstructor) { - this._deserializeInto$(value, object, superConstructor); + this._deserializeInto(value, object, superConstructor); } }, }; - object[deserializeTag]!(serializationInput, this._context$); + object[deserializeTag]!(serializationInput, this._context); } - private _deserializeFireClass$ (obj: Record, serialized: SerializedGeneralTypedObject, klass: CCClassConstructor): void { + private _deserializeFireClass (obj: Record, serialized: SerializedGeneralTypedObject, klass: CCClassConstructor): void { let deserialize: CompiledDeserializeFn; // eslint-disable-next-line no-prototype-builtins if (klass.hasOwnProperty('__deserialize__')) { @@ -691,13 +691,13 @@ class _Deserializer { obj[propName] = field; } else { // TODO: assertion - const source = (this._serializedData$ as SerializedObject[])[id]; + const source = (this._serializedData as SerializedObject[])[id]; if (EDITOR || TEST) { - obj[propName] = this._deserializeObject$(source, id, obj, propName); + obj[propName] = this._deserializeObject(source, id, obj, propName); } else { - obj[propName] = this._deserializeObject$(source, id, undefined, propName); + obj[propName] = this._deserializeObject(source, id, undefined, propName); } - this._onDereferenced$?.(this.deserializedList, id, obj, propName); + this._onDereferenced?.(this.deserializedList, id, obj, propName); } } else { const uuid = (serializedField as Partial).__uuid__; @@ -705,15 +705,15 @@ class _Deserializer { const expectedType = (serializedField as SerializedUUIDReference).__expectedType__; this.result.push(obj, propName, uuid, expectedType); } else if (EDITOR || TEST) { - obj[propName] = this._deserializeObject$(serializedField as SerializedObject, -1, obj, propName); + obj[propName] = this._deserializeObject(serializedField as SerializedObject, -1, obj, propName); } else { - obj[propName] = this._deserializeObject$(serializedField as SerializedObject, -1); + obj[propName] = this._deserializeObject(serializedField as SerializedObject, -1); } } return false; } - private _deserializeObjectField$ (serializedField: SerializedFieldObjectValue): Record | null { + private _deserializeObjectField (serializedField: SerializedFieldObjectValue): Record | null { const id = (serializedField as Partial).__id__; if (typeof id === 'number') { const field = this.deserializedList[id]; @@ -721,8 +721,8 @@ class _Deserializer { return field; } else { // TODO: assertion - const source = (this._serializedData$ as SerializedObject[])[id]; - const field = this._deserializeObject$(source, id, undefined, undefined); + const source = (this._serializedData as SerializedObject[])[id]; + const field = this._deserializeObject(source, id, undefined, undefined); return field; } } else { @@ -731,7 +731,7 @@ class _Deserializer { const _expectedType = (serializedField as SerializedUUIDReference).__expectedType__; throw new Error(`Asset reference field serialization is currently not supported in custom serialization.`); } else { - return this._deserializeObject$(serializedField as SerializedObject, -1); + return this._deserializeObject(serializedField as SerializedObject, -1); } } } diff --git a/cocos/sorting/sorting-layers.ts b/cocos/sorting/sorting-layers.ts index 0c001f7c9f7..58b1ce23a21 100644 --- a/cocos/sorting/sorting-layers.ts +++ b/cocos/sorting/sorting-layers.ts @@ -48,7 +48,7 @@ game.on(Game.EVENT_POST_SUBSYSTEM_INIT, () => { * In the sorting component, layer has higher sorting priority than sortingOrder. * */ export class SortingLayers { - private static nameMap$ = new Map(); + private static nameMap = new Map(); private static indexMap = new Map(); /** @@ -94,8 +94,8 @@ export class SortingLayers { */ public static getLayerName (layer = 0): string { let name = ''; - if (this.nameMap$.has(layer)) { - name = this.nameMap$.get(layer)!; + if (this.nameMap.has(layer)) { + name = this.nameMap.get(layer)!; } else { errorID(2105); } @@ -107,12 +107,12 @@ export class SortingLayers { * @en Get Layer id by name */ public static getLayerByName (name: string): number { - const count = this.nameMap$.size; - const keyIterator = this.nameMap$.keys(); + const count = this.nameMap.size; + const keyIterator = this.nameMap.keys(); let key = 0; for (let i = 0; i < count; i++) { key = keyIterator.next().value; - if (this.nameMap$.get(key) === name) return key; + if (this.nameMap.get(key) === name) return key; } errorID(2106); return 0; @@ -179,7 +179,7 @@ export class SortingLayers { * @engineInternal */ public static setLayer (layer: number, layerName: string, layerIndex: number): void { - this.nameMap$.set(layer, layerName); + this.nameMap.set(layer, layerName); this.indexMap.set(layer, layerIndex); } @@ -193,6 +193,6 @@ export class SortingLayers { delete SortingLayers.Enum[oldItem[i]]; } SortingLayers.indexMap.clear(); - SortingLayers.nameMap$.clear(); + SortingLayers.nameMap.clear(); } } diff --git a/cocos/ui/button.ts b/cocos/ui/button.ts index 8b3f473a619..be888dc1dce 100644 --- a/cocos/ui/button.ts +++ b/cocos/ui/button.ts @@ -570,17 +570,17 @@ export class Button extends Component { protected _zoomScale = 1.2; @serializable protected _target: Node | null = null; - private _pressed$ = false; - private _hovered$ = false; - private _fromColor$: Color = new Color(); - private _toColor$: Color = new Color(); - private _time$ = 0; - private _transitionFinished$ = true; - private _fromScale$: Vec3 = v3(); - private _toScale$: Vec3 = v3(); - private _originalScale$: Vec3 | null = null; - private _sprite$: Sprite | null = null; - private _targetScale$: Vec3 = v3(); + private _pressed = false; + private _hovered = false; + private _fromColor: Color = new Color(); + private _toColor: Color = new Color(); + private _time = 0; + private _transitionFinished = true; + private _fromScale: Vec3 = v3(); + private _toScale: Vec3 = v3(); + private _originalScale: Vec3 | null = null; + private _sprite: Sprite | null = null; + private _targetScale: Vec3 = v3(); constructor () { super(); @@ -603,7 +603,7 @@ export class Button extends Component { } else { this.node.on(SpriteEventType.SPRITE_FRAME_CHANGED, (comp: Sprite) => { if (this._transition === Transition.SPRITE) { - this._setCurrentStateSpriteFrame$(comp.spriteFrame); + this._setCurrentStateSpriteFrame(comp.spriteFrame); } else { // avoid serialization data loss when in no-sprite mode this._normalSprite = null; @@ -633,7 +633,7 @@ export class Button extends Component { public update (dt: number): void { const target = this.target; - if (this._transitionFinished$ || !target) { + if (this._transitionFinished || !target) { return; } @@ -641,10 +641,10 @@ export class Button extends Component { return; } - this._time$ += dt; + this._time += dt; let ratio = 1.0; if (this._duration > 0) { - ratio = this._time$ / this._duration; + ratio = this._time / this._duration; } if (ratio >= 1) { @@ -653,19 +653,19 @@ export class Button extends Component { if (this._transition === Transition.COLOR) { const renderComp = target._uiProps.uiComp as UIRenderer; - Color.lerp(_tempColor, this._fromColor$, this._toColor$, ratio); + Color.lerp(_tempColor, this._fromColor, this._toColor, ratio); if (renderComp) { renderComp.color = _tempColor; } } else if (this.transition === Transition.SCALE) { - target.getScale(this._targetScale$); - this._targetScale$.x = lerp(this._fromScale$.x, this._toScale$.x, ratio); - this._targetScale$.y = lerp(this._fromScale$.y, this._toScale$.y, ratio); - target.setScale(this._targetScale$); + target.getScale(this._targetScale); + this._targetScale.x = lerp(this._fromScale.x, this._toScale.x, ratio); + this._targetScale.y = lerp(this._fromScale.y, this._toScale.y, ratio); + target.setScale(this._targetScale); } if (ratio === 1) { - this._transitionFinished$ = true; + this._transitionFinished = true; } } @@ -680,8 +680,8 @@ export class Button extends Component { } protected _resetState (): void { - this._pressed$ = false; - this._hovered$ = false; + this._pressed = false; + this._hovered = false; // Restore button status const target = this.target; if (!target) { @@ -693,10 +693,10 @@ export class Button extends Component { if (renderComp) { renderComp.color = this._normalColor; } - } else if (transition === Transition.SCALE && this._originalScale$) { - target.setScale(this._originalScale$); + } else if (transition === Transition.SCALE && this._originalScale) { + target.setScale(this._originalScale); } - this._transitionFinished$ = true; + this._transitionFinished = true; } protected _registerNodeEvent (): void { @@ -708,18 +708,18 @@ export class Button extends Component { this.node.on(NodeEventType.MOUSE_ENTER, this._onMouseMoveIn, this); this.node.on(NodeEventType.MOUSE_LEAVE, this._onMouseMoveOut, this); - this.node.on(XrUIPressEventType.XRUI_HOVER_ENTERED, this._xrHoverEnter$, this); - this.node.on(XrUIPressEventType.XRUI_HOVER_EXITED, this._xrHoverExit$, this); - this.node.on(XrUIPressEventType.XRUI_CLICK, this._xrClick$, this); - this.node.on(XrUIPressEventType.XRUI_UNCLICK, this._xrUnClick$, this); + this.node.on(XrUIPressEventType.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.on(XrUIPressEventType.XRUI_HOVER_EXITED, this._xrHoverExit, this); + this.node.on(XrUIPressEventType.XRUI_CLICK, this._xrClick, this); + this.node.on(XrUIPressEventType.XRUI_UNCLICK, this._xrUnClick, this); } protected _registerTargetEvent (target): void { if (EDITOR_NOT_IN_PREVIEW) { - target.on(SpriteEventType.SPRITE_FRAME_CHANGED, this._onTargetSpriteFrameChanged$, this); - target.on(NodeEventType.COLOR_CHANGED, this._onTargetColorChanged$, this); + target.on(SpriteEventType.SPRITE_FRAME_CHANGED, this._onTargetSpriteFrameChanged, this); + target.on(NodeEventType.COLOR_CHANGED, this._onTargetColorChanged, this); } - target.on(NodeEventType.TRANSFORM_CHANGED, this._onTargetTransformChanged$, this); + target.on(NodeEventType.TRANSFORM_CHANGED, this._onTargetTransformChanged, this); } protected _unregisterNodeEvent (): void { @@ -731,10 +731,10 @@ export class Button extends Component { this.node.off(NodeEventType.MOUSE_ENTER, this._onMouseMoveIn, this); this.node.off(NodeEventType.MOUSE_LEAVE, this._onMouseMoveOut, this); - this.node.off(XrUIPressEventType.XRUI_HOVER_ENTERED, this._xrHoverEnter$, this); - this.node.off(XrUIPressEventType.XRUI_HOVER_EXITED, this._xrHoverExit$, this); - this.node.off(XrUIPressEventType.XRUI_CLICK, this._xrClick$, this); - this.node.off(XrUIPressEventType.XRUI_UNCLICK, this._xrUnClick$, this); + this.node.off(XrUIPressEventType.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.off(XrUIPressEventType.XRUI_HOVER_EXITED, this._xrHoverExit, this); + this.node.off(XrUIPressEventType.XRUI_CLICK, this._xrClick, this); + this.node.off(XrUIPressEventType.XRUI_UNCLICK, this._xrUnClick, this); } protected _unregisterTargetEvent (target): void { @@ -755,22 +755,22 @@ export class Button extends Component { protected _applyTarget (): void { if (this.target) { - this._sprite$ = this._getTargetSprite(this.target); - if (!this._originalScale$) { - this._originalScale$ = new Vec3(); + this._sprite = this._getTargetSprite(this.target); + if (!this._originalScale) { + this._originalScale = new Vec3(); } - Vec3.copy(this._originalScale$, this.target.scale); + Vec3.copy(this._originalScale, this.target.scale); this._registerTargetEvent(this.target); } } - private _onTargetSpriteFrameChanged$ (comp: Sprite): void { + private _onTargetSpriteFrameChanged (comp: Sprite): void { if (this._transition === Transition.SPRITE) { - this._setCurrentStateSpriteFrame$(comp.spriteFrame); + this._setCurrentStateSpriteFrame(comp.spriteFrame); } } - private _setCurrentStateSpriteFrame$ (spriteFrame: SpriteFrame | null): void { + private _setCurrentStateSpriteFrame (spriteFrame: SpriteFrame | null): void { if (!spriteFrame) { return; } @@ -792,13 +792,13 @@ export class Button extends Component { } } - private _onTargetColorChanged$ (color: Color): void { + private _onTargetColorChanged (color: Color): void { if (this._transition === Transition.COLOR) { - this._setCurrentStateColor$(color); + this._setCurrentStateColor(color); } } - private _setCurrentStateColor$ (color: Color): void { + private _setCurrentStateColor (color: Color): void { switch (this._getButtonState()) { case State.NORMAL: this._normalColor = color; @@ -817,11 +817,11 @@ export class Button extends Component { } } - private _onTargetTransformChanged$ (transformBit: TransformBit): void { + private _onTargetTransformChanged (transformBit: TransformBit): void { // update originalScale - if ((transformBit & TransformBit.SCALE) && this._originalScale$ - && this._transition === Transition.SCALE && this._transitionFinished$) { - Vec3.copy(this._originalScale$, this.target.scale); + if ((transformBit & TransformBit.SCALE) && this._originalScale + && this._transition === Transition.SCALE && this._transitionFinished) { + Vec3.copy(this._originalScale, this.target.scale); } } @@ -829,7 +829,7 @@ export class Button extends Component { protected _onTouchBegan (event?: EventTouch): void { if (!this._interactable || !this.enabledInHierarchy) { return; } - this._pressed$ = true; + this._pressed = true; this._updateState(); if (event) { event.propagationStopped = true; @@ -837,7 +837,7 @@ export class Button extends Component { } protected _onTouchMove (event?: EventTouch): void { - if (!this._interactable || !this.enabledInHierarchy || !this._pressed$) { return; } + if (!this._interactable || !this.enabledInHierarchy || !this._pressed) { return; } // mobile phone will not emit _onMouseMoveOut, // so we have to do hit test when touch moving if (!event) { @@ -851,15 +851,15 @@ export class Button extends Component { const hit = this.node._uiProps.uiTransformComp!.hitTest(touch.getLocation(), event.windowId); - if (this._transition === Transition.SCALE && this.target && this._originalScale$) { + if (this._transition === Transition.SCALE && this.target && this._originalScale) { if (hit) { - Vec3.copy(this._fromScale$, this._originalScale$); - Vec3.multiplyScalar(this._toScale$, this._originalScale$, this._zoomScale); - this._transitionFinished$ = false; + Vec3.copy(this._fromScale, this._originalScale); + Vec3.multiplyScalar(this._toScale, this._originalScale, this._zoomScale); + this._transitionFinished = false; } else { - this._time$ = 0; - this._transitionFinished$ = true; - this.target.setScale(this._originalScale$); + this._time = 0; + this._transitionFinished = true; + this.target.setScale(this._originalScale); } } else { let state: State; @@ -881,11 +881,11 @@ export class Button extends Component { return; } - if (this._pressed$) { + if (this._pressed) { ComponentEventHandler.emitEvents(this.clickEvents, event); this.node.emit(ButtonEventType.CLICK, this); } - this._pressed$ = false; + this._pressed = false; this._updateState(); if (event) { @@ -896,23 +896,23 @@ export class Button extends Component { protected _onTouchCancel (event?: EventTouch): void { if (!this._interactable || !this.enabledInHierarchy) { return; } - this._pressed$ = false; + this._pressed = false; this._updateState(); } protected _onMouseMoveIn (event?: EventMouse): void { - if (this._pressed$ || !this.interactable || !this.enabledInHierarchy) { return; } + if (this._pressed || !this.interactable || !this.enabledInHierarchy) { return; } if (this._transition === Transition.SPRITE && !this._hoverSprite) { return; } - if (!this._hovered$) { - this._hovered$ = true; + if (!this._hovered) { + this._hovered = true; this._updateState(); } } protected _onMouseMoveOut (event?: EventMouse): void { - if (this._hovered$) { - this._hovered$ = false; + if (this._hovered) { + this._hovered = false; this._updateState(); } } @@ -927,16 +927,16 @@ export class Button extends Component { let state = State.NORMAL; if (!this._interactable) { state = State.DISABLED; - } else if (this._pressed$) { + } else if (this._pressed) { state = State.PRESSED; - } else if (this._hovered$) { + } else if (this._hovered) { state = State.HOVER; } return state; } protected _updateColorTransition (state: State): void { - const color = this._getColorByState$(state); + const color = this._getColorByState(state); const renderComp = this.target?.getComponent(UIRenderer); if (!renderComp) { @@ -945,19 +945,19 @@ export class Button extends Component { if (EDITOR_NOT_IN_PREVIEW || state === State.DISABLED) { renderComp.color = color; - this._transitionFinished$ = true; + this._transitionFinished = true; } else { - this._fromColor$ = renderComp.color.clone(); - this._toColor$ = color; - this._time$ = 0; - this._transitionFinished$ = false; + this._fromColor = renderComp.color.clone(); + this._toColor = color; + this._time = 0; + this._transitionFinished = false; } } protected _updateSpriteTransition (state: State): void { - const sprite = this._getSpriteFrameByState$(state); - if (this._sprite$ && sprite) { - this._sprite$.spriteFrame = sprite; + const sprite = this._getSpriteFrameByState(state); + if (this._sprite && sprite) { + this._sprite.spriteFrame = sprite; } } @@ -975,23 +975,23 @@ export class Button extends Component { protected _zoomUp (): void { // skip before __preload() - if (!this._originalScale$) { + if (!this._originalScale) { return; } - Vec3.copy(this._fromScale$, this._originalScale$); - Vec3.multiplyScalar(this._toScale$, this._originalScale$, this._zoomScale); - this._time$ = 0; - this._transitionFinished$ = false; + Vec3.copy(this._fromScale, this._originalScale); + Vec3.multiplyScalar(this._toScale, this._originalScale, this._zoomScale); + this._time = 0; + this._transitionFinished = false; } protected _zoomBack (): void { - if (!this.target || !this._originalScale$) { + if (!this.target || !this._originalScale) { return; } - Vec3.copy(this._fromScale$, this.target.scale); - Vec3.copy(this._toScale$, this._originalScale$); - this._time$ = 0; - this._transitionFinished$ = false; + Vec3.copy(this._fromScale, this.target.scale); + Vec3.copy(this._toScale, this._originalScale); + this._time = 0; + this._transitionFinished = false; } protected _applyTransition (state: State): void { @@ -1005,7 +1005,7 @@ export class Button extends Component { } } - private _getSpriteFrameByState$ (state: State): SpriteFrame | null { + private _getSpriteFrameByState (state: State): SpriteFrame | null { switch (state) { case State.NORMAL: return this._normalSprite; @@ -1024,7 +1024,7 @@ export class Button extends Component { } } - private _getColorByState$ (state: State): Color { + private _getColorByState (state: State): Color { switch (state) { case State.NORMAL: return this._normalColor; @@ -1043,35 +1043,35 @@ export class Button extends Component { } } - private _xrHoverEnter$ (): void { + private _xrHoverEnter (): void { this._onMouseMoveIn(); this._updateState(); } - private _xrHoverExit$ (): void { + private _xrHoverExit (): void { this._onMouseMoveOut(); - if (this._pressed$) { - this._pressed$ = false; + if (this._pressed) { + this._pressed = false; this._updateState(); } } - private _xrClick$ (): void { + private _xrClick (): void { if (!this._interactable || !this.enabledInHierarchy) { return; } - this._pressed$ = true; + this._pressed = true; this._updateState(); } - private _xrUnClick$ (): void { + private _xrUnClick (): void { if (!this._interactable || !this.enabledInHierarchy) { return; } - if (this._pressed$) { + if (this._pressed) { ComponentEventHandler.emitEvents(this.clickEvents, this); this.node.emit(ButtonEventType.CLICK, this); } - this._pressed$ = false; + this._pressed = false; this._updateState(); } } diff --git a/cocos/ui/editbox/edit-box-impl.ts b/cocos/ui/editbox/edit-box-impl.ts index 2493056440c..070efeb1ad3 100644 --- a/cocos/ui/editbox/edit-box-impl.ts +++ b/cocos/ui/editbox/edit-box-impl.ts @@ -90,20 +90,20 @@ export class EditBoxImpl extends EditBoxImplBase { * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ public _edTxt: HTMLInputElement | HTMLTextAreaElement | null = null; - private _isTextArea$ = false; - - private _textLabelFont$ = null; - private _textLabelFontSize$: number | null = null; - private _textLabelFontColor$ = null; - private _textLabelAlign$ = null; - private _placeholderLabelFont$ = null; - private _placeholderLabelFontSize$: number | null = null; - private _placeholderLabelFontColor$ = null; - private _placeholderLabelAlign$ = null; - private _placeholderLineHeight$ = null; - private _placeholderStyleSheet$: HTMLStyleElement | null = null; - private _domId$ = `EditBoxId_${++_domCount}`; - private _forceUpdate$: boolean = false; + private _isTextArea = false; + + private _textLabelFont = null; + private _textLabelFontSize: number | null = null; + private _textLabelFontColor = null; + private _textLabelAlign = null; + private _placeholderLabelFont = null; + private _placeholderLabelFontSize: number | null = null; + private _placeholderLabelFontColor = null; + private _placeholderLabelAlign = null; + private _placeholderLineHeight = null; + private _placeholderStyleSheet: HTMLStyleElement | null = null; + private _domId = `EditBoxId_${++_domCount}`; + private _forceUpdate: boolean = false; constructor () { super(); @@ -149,7 +149,7 @@ export class EditBoxImpl extends EditBoxImplBase { } private _resize (): void { - this._forceUpdate$ = true; + this._forceUpdate = true; } // The beforeDraw function should be used here. @@ -158,10 +158,10 @@ export class EditBoxImpl extends EditBoxImplBase { public beforeDraw (): void { if (!HTML5) return; const node = this._delegate!.node; - if (!node.hasChangedFlags && !this._forceUpdate$) { + if (!node.hasChangedFlags && !this._forceUpdate) { return; } - this._forceUpdate$ = false; + this._forceUpdate = false; this._updateMatrix(); } @@ -201,13 +201,13 @@ export class EditBoxImpl extends EditBoxImplBase { private _createInput (): void { if (!HTML5) return; - this._isTextArea$ = false; + this._isTextArea = false; this._edTxt = ccdocument.createElement('input'); } private _createTextArea (): void { if (!HTML5) return; - this._isTextArea$ = true; + this._isTextArea = true; this._edTxt = ccdocument.createElement('textarea'); } @@ -215,7 +215,7 @@ export class EditBoxImpl extends EditBoxImplBase { if (!HTML5) return; if (game.container && this._edTxt) { game.container.appendChild(this._edTxt); - ccdocument.head.appendChild(this._placeholderStyleSheet$!); + ccdocument.head.appendChild(this._placeholderStyleSheet!); } } @@ -225,13 +225,13 @@ export class EditBoxImpl extends EditBoxImplBase { if (hasElem && this._edTxt) { game.container!.removeChild(this._edTxt); } - const hasStyleSheet = contains(ccdocument.head, this._placeholderStyleSheet$); + const hasStyleSheet = contains(ccdocument.head, this._placeholderStyleSheet); if (hasStyleSheet) { - ccdocument.head.removeChild(this._placeholderStyleSheet$!); + ccdocument.head.removeChild(this._placeholderStyleSheet!); } this._edTxt = null; - this._placeholderStyleSheet$ = null; + this._placeholderStyleSheet = null; } private _showDom (): void { @@ -402,7 +402,7 @@ export class EditBoxImpl extends EditBoxImplBase { this._returnType = returnType; // FIX ME: TextArea actually dose not support password type. - if (this._isTextArea$) { + if (this._isTextArea) { // input flag let transform = 'none'; if (inputFlag === InputFlag.INITIAL_CAPS_ALL_CHARACTERS) { @@ -483,9 +483,9 @@ export class EditBoxImpl extends EditBoxImplBase { elem.style.left = `${LEFT_PADDING}px`; elem.className = 'cocosEditBox'; elem.style.fontFamily = 'Arial'; - elem.id = this._domId$; + elem.id = this._domId; - if (!this._isTextArea$) { + if (!this._isTextArea) { elem = elem as HTMLInputElement; elem.type = 'text'; elem.style['-moz-appearance'] = 'textfield'; @@ -494,7 +494,7 @@ export class EditBoxImpl extends EditBoxImplBase { elem.style.overflowY = 'scroll'; } - this._placeholderStyleSheet$ = ccdocument.createElement('style'); + this._placeholderStyleSheet = ccdocument.createElement('style'); } private _updateStyleSheet (): void { @@ -526,17 +526,17 @@ export class EditBoxImpl extends EditBoxImplBase { const fontSize = textLabel.fontSize * textLabel.node.scale.y; - if (this._textLabelFont$ === font - && this._textLabelFontSize$ === fontSize - && this._textLabelFontColor$ === textLabel.fontColor - && this._textLabelAlign$ === textLabel.horizontalAlign) { + if (this._textLabelFont === font + && this._textLabelFontSize === fontSize + && this._textLabelFontColor === textLabel.fontColor + && this._textLabelAlign === textLabel.horizontalAlign) { return; } - this._textLabelFont$ = font; - this._textLabelFontSize$ = fontSize; - this._textLabelFontColor$ = textLabel.fontColor; - this._textLabelAlign$ = textLabel.horizontalAlign; + this._textLabelFont = font; + this._textLabelFontSize = fontSize; + this._textLabelFontColor = textLabel.fontColor; + this._textLabelAlign = textLabel.horizontalAlign; if (!this._edTxt) { return; @@ -577,21 +577,21 @@ export class EditBoxImpl extends EditBoxImplBase { const fontSize = placeholderLabel.fontSize * placeholderLabel.node.scale.y; - if (this._placeholderLabelFont$ === font - && this._placeholderLabelFontSize$ === fontSize - && this._placeholderLabelFontColor$ === placeholderLabel.fontColor - && this._placeholderLabelAlign$ === placeholderLabel.horizontalAlign - && this._placeholderLineHeight$ === placeholderLabel.fontSize) { + if (this._placeholderLabelFont === font + && this._placeholderLabelFontSize === fontSize + && this._placeholderLabelFontColor === placeholderLabel.fontColor + && this._placeholderLabelAlign === placeholderLabel.horizontalAlign + && this._placeholderLineHeight === placeholderLabel.fontSize) { return; } - this._placeholderLabelFont$ = font; - this._placeholderLabelFontSize$ = fontSize; - this._placeholderLabelFontColor$ = placeholderLabel.fontColor; - this._placeholderLabelAlign$ = placeholderLabel.horizontalAlign; - this._placeholderLineHeight$ = placeholderLabel.fontSize; + this._placeholderLabelFont = font; + this._placeholderLabelFontSize = fontSize; + this._placeholderLabelFontColor = placeholderLabel.fontColor; + this._placeholderLabelAlign = placeholderLabel.horizontalAlign; + this._placeholderLineHeight = placeholderLabel.fontSize; - const styleEl = this._placeholderStyleSheet$; + const styleEl = this._placeholderStyleSheet; const fontColor = placeholderLabel.color.toCSS(); const lineHeight = placeholderLabel.fontSize; @@ -610,13 +610,13 @@ export class EditBoxImpl extends EditBoxImplBase { break; } - styleEl!.innerHTML = `#${this._domId$}::-webkit-input-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}` - + `#${this._domId$}::-moz-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}` - + `#${this._domId$}::-ms-input-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}`; + styleEl!.innerHTML = `#${this._domId}::-webkit-input-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}` + + `#${this._domId}::-moz-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}` + + `#${this._domId}::-ms-input-placeholder{text-transform: initial;-family: ${font};font-size: ${fontSize}px;color: ${fontColor};line-height: ${lineHeight}px;text-align: ${horizontalAlign};}`; // EDGE_BUG_FIX: hide clear button, because clearing input box in Edge does not emit input event // issue refference: https://github.com/angular/angular/issues/26307 if (sys.browserType === BrowserType.EDGE) { - styleEl!.innerHTML += `#${this._domId$}::-ms-clear{display: none;}`; + styleEl!.innerHTML += `#${this._domId}::-ms-clear{display: none;}`; } } @@ -665,7 +665,7 @@ export class EditBoxImpl extends EditBoxImplBase { e.propagationStopped = true; this._delegate!._editBoxEditingReturn(); - if (!this._isTextArea$) { + if (!this._isTextArea) { elem.blur(); } } else if (e.keyCode === KeyCode.TAB) { diff --git a/cocos/ui/sub-context-view.ts b/cocos/ui/sub-context-view.ts index 4657339dded..e2cac9207f9 100644 --- a/cocos/ui/sub-context-view.ts +++ b/cocos/ui/sub-context-view.ts @@ -101,51 +101,51 @@ export class SubContextView extends Component { return; } this._fps = value; - this._updateInterval$ = 1000 / value; + this._updateInterval = 1000 / value; } @serializable private _fps = 60; - private _sprite$: Sprite | null = null; - private _imageAsset$: ImageAsset = new ImageAsset(); - private _texture$: Texture2D = new Texture2D(); - private _updatedTime$ = 0; - private _updateInterval$ = 0; - private _openDataContext$: any = null; - private _content$: Node = new Node('content'); + private _sprite: Sprite | null = null; + private _imageAsset: ImageAsset = new ImageAsset(); + private _texture: Texture2D = new Texture2D(); + private _updatedTime = 0; + private _updateInterval = 0; + private _openDataContext: any = null; + private _content: Node = new Node('content'); @serializable private _designResolutionSize: Size = new Size(640, 960); constructor () { super(); - this._content$.hideFlags |= CCObject.Flags.DontSave | CCObject.Flags.HideInHierarchy; - this._updatedTime$ = performance.now(); + this._content.hideFlags |= CCObject.Flags.DontSave | CCObject.Flags.HideInHierarchy; + this._updatedTime = performance.now(); } public onLoad (): void { if (minigame.getOpenDataContext) { - this._updateInterval$ = 1000 / this._fps; - this._openDataContext$ = minigame.getOpenDataContext(); - this._initSharedCanvas$(); - this._initContentNode$(); - this._updateSubContextView$(); - this._updateContentLayer$(); + this._updateInterval = 1000 / this._fps; + this._openDataContext = minigame.getOpenDataContext(); + this._initSharedCanvas(); + this._initContentNode(); + this._updateSubContextView(); + this._updateContentLayer(); } else { this.enabled = false; } } public onEnable (): void { - this._registerNodeEvent$(); + this._registerNodeEvent(); } public onDisable (): void { - this._unregisterNodeEvent$(); + this._unregisterNodeEvent(); } - private _initSharedCanvas$ (): void { - if (this._openDataContext$) { - const sharedCanvas = this._openDataContext$.canvas; + private _initSharedCanvas (): void { + if (this._openDataContext) { + const sharedCanvas = this._openDataContext.canvas; let designWidth = this._designResolutionSize.width; let designHeight = this._designResolutionSize.height; if (WECHAT || WECHAT_MINI_PROGRAM) { @@ -165,41 +165,41 @@ export class SubContextView extends Component { } } - private _initContentNode$ (): void { - if (this._openDataContext$) { - const sharedCanvas = this._openDataContext$.canvas; + private _initContentNode (): void { + if (this._openDataContext) { + const sharedCanvas = this._openDataContext.canvas; - const image = this._imageAsset$; + const image = this._imageAsset; image.reset(sharedCanvas); - this._texture$.image = image; - this._texture$.create(sharedCanvas.width, sharedCanvas.height); + this._texture.image = image; + this._texture.create(sharedCanvas.width, sharedCanvas.height); - this._sprite$ = this._content$.getComponent(Sprite); - if (!this._sprite$) { - this._sprite$ = this._content$.addComponent(Sprite); + this._sprite = this._content.getComponent(Sprite); + if (!this._sprite) { + this._sprite = this._content.addComponent(Sprite); } - if (this._sprite$.spriteFrame) { - this._sprite$.spriteFrame.texture = this._texture$; + if (this._sprite.spriteFrame) { + this._sprite.spriteFrame.texture = this._texture; } else { const sp = new SpriteFrame(); - sp.texture = this._texture$; - this._sprite$.spriteFrame = sp; + sp.texture = this._texture; + this._sprite.spriteFrame = sp; } - this._content$.parent = this.node; + this._content.parent = this.node; } } - private _updateSubContextView$ (): void { - if (!this._openDataContext$) { + private _updateSubContextView (): void { + if (!this._openDataContext) { return; } // update subContextView size // use SHOW_ALL policy to adapt subContextView const nodeTrans = this.node.getComponent(UITransform) as UITransform; - const contentTrans = this._content$.getComponent(UITransform) as UITransform; + const contentTrans = this._content.getComponent(UITransform) as UITransform; const scaleX = nodeTrans.width / contentTrans.width; const scaleY = nodeTrans.height / contentTrans.height; @@ -219,7 +219,7 @@ export class SubContextView extends Component { const width = viewportRect.width * (box.width / visibleSize.width) / dpr; const height = viewportRect.height * (box.height / visibleSize.height) / dpr; - this._openDataContext$.postMessage({ + this._openDataContext.postMessage({ fromEngine: true, // compatible deprecated property type: 'engine', event: 'viewport', @@ -230,9 +230,9 @@ export class SubContextView extends Component { }); } - private _updateSubContextTexture$ (): void { - const img = this._imageAsset$; - if (!img || !this._openDataContext$) { + private _updateSubContextTexture (): void { + const img = this._imageAsset; + if (!img || !this._openDataContext) { return; } @@ -240,51 +240,51 @@ export class SubContextView extends Component { return; } - const sharedCanvas = this._openDataContext$.canvas; + const sharedCanvas = this._openDataContext.canvas; img.reset(sharedCanvas); if (sharedCanvas.width > img.width || sharedCanvas.height > img.height) { - this._texture$.create(sharedCanvas.width, sharedCanvas.height); + this._texture.create(sharedCanvas.width, sharedCanvas.height); } - this._texture$.uploadData(sharedCanvas); + this._texture.uploadData(sharedCanvas); } - private _registerNodeEvent$ (): void { - this.node.on(NodeEventType.TRANSFORM_CHANGED, this._updateSubContextView$, this); - this.node.on(NodeEventType.SIZE_CHANGED, this._updateSubContextView$, this); - this.node.on(NodeEventType.LAYER_CHANGED, this._updateContentLayer$, this); + private _registerNodeEvent (): void { + this.node.on(NodeEventType.TRANSFORM_CHANGED, this._updateSubContextView, this); + this.node.on(NodeEventType.SIZE_CHANGED, this._updateSubContextView, this); + this.node.on(NodeEventType.LAYER_CHANGED, this._updateContentLayer, this); } - private _unregisterNodeEvent$ (): void { - this.node.off(NodeEventType.TRANSFORM_CHANGED, this._updateSubContextView$, this); - this.node.off(NodeEventType.SIZE_CHANGED, this._updateSubContextView$, this); - this.node.off(NodeEventType.LAYER_CHANGED, this._updateContentLayer$, this); + private _unregisterNodeEvent (): void { + this.node.off(NodeEventType.TRANSFORM_CHANGED, this._updateSubContextView, this); + this.node.off(NodeEventType.SIZE_CHANGED, this._updateSubContextView, this); + this.node.off(NodeEventType.LAYER_CHANGED, this._updateContentLayer, this); } - private _updateContentLayer$ (): void { - this._content$.layer = this.node.layer; + private _updateContentLayer (): void { + this._content.layer = this.node.layer; } public update (dt?: number): void { const calledUpdateManually = (dt === undefined); if (calledUpdateManually) { - this._updateSubContextTexture$(); + this._updateSubContextTexture(); return; } const now = performance.now(); - const deltaTime = (now - this._updatedTime$); - if (deltaTime >= this._updateInterval$) { - this._updatedTime$ += this._updateInterval$; - this._updateSubContextTexture$(); + const deltaTime = (now - this._updatedTime); + if (deltaTime >= this._updateInterval) { + this._updatedTime += this._updateInterval; + this._updateSubContextTexture(); } } public onDestroy (): void { - this._content$.destroy(); - this._texture$.destroy(); - if (this._sprite$) { this._sprite$.destroy(); } - this._imageAsset$.destroy(); - this._openDataContext$ = null; + this._content.destroy(); + this._texture.destroy(); + if (this._sprite) { this._sprite.destroy(); } + this._imageAsset.destroy(); + this._openDataContext = null; } } diff --git a/cocos/ui/view.ts b/cocos/ui/view.ts index ad676ab24db..cb03636cf5b 100644 --- a/cocos/ui/view.ts +++ b/cocos/ui/view.ts @@ -68,20 +68,20 @@ export class View extends Eventify(System) { */ public _designResolutionSize: Size = size(0, 0); // resolution size, it is the size appropriate for the app resources. - private _scaleX$: number = 1; - private _scaleY$: number = 1; - private _viewportRect$: Rect = rect(); // Viewport is the container's rect related to content's coordinates in pixel - private _visibleRect$: Rect = rect(); // The visible rect in content's coordinate in point - private _autoFullScreen$: boolean = false; // Auto full screen disabled by default - private _retinaEnabled$: boolean = false; // Retina disabled by default - private _resizeCallback$: (() => void) | null = null; // Custom callback for resize event - private declare _resolutionPolicy$: ResolutionPolicy; - - private declare _rpExactFit$: ResolutionPolicy; - private declare _rpShowAll$: ResolutionPolicy; - private declare _rpNoBorder$: ResolutionPolicy; - private declare _rpFixedHeight$: ResolutionPolicy; - private declare _rpFixedWidth$: ResolutionPolicy; + private _scaleX: number = 1; + private _scaleY: number = 1; + private _viewportRect: Rect = rect(); // Viewport is the container's rect related to content's coordinates in pixel + private _visibleRect: Rect = rect(); // The visible rect in content's coordinate in point + private _autoFullScreen: boolean = false; // Auto full screen disabled by default + private _retinaEnabled: boolean = false; // Retina disabled by default + private _resizeCallback: (() => void) | null = null; // Custom callback for resize event + private declare _resolutionPolicy: ResolutionPolicy; + + private declare _rpExactFit: ResolutionPolicy; + private declare _rpShowAll: ResolutionPolicy; + private declare _rpNoBorder: ResolutionPolicy; + private declare _rpFixedHeight: ResolutionPolicy; + private declare _rpFixedWidth: ResolutionPolicy; constructor () { super(); @@ -90,12 +90,12 @@ export class View extends Eventify(System) { const _strategy = ContentStrategy; // Setup system default resolution policies - this._rpExactFit$ = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.EXACT_FIT); - this._rpShowAll$ = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.SHOW_ALL); - this._rpNoBorder$ = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.NO_BORDER); - this._rpFixedHeight$ = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_HEIGHT); - this._rpFixedWidth$ = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH); - this._resolutionPolicy$ = this._rpShowAll$; + this._rpExactFit = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.EXACT_FIT); + this._rpShowAll = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.SHOW_ALL); + this._rpNoBorder = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.NO_BORDER); + this._rpFixedHeight = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_HEIGHT); + this._rpFixedWidth = new ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH); + this._resolutionPolicy = this._rpShowAll; } // Call init at the time Game.EVENT_ENGINE_INITED @@ -105,15 +105,15 @@ export class View extends Eventify(System) { const h = windowSize.height; this._designResolutionSize.width = w; this._designResolutionSize.height = h; - this._viewportRect$.width = w; - this._viewportRect$.height = h; - this._visibleRect$.width = w; - this._visibleRect$.height = h; + this._viewportRect.width = w; + this._viewportRect.height = h; + this._visibleRect.width = w; + this._visibleRect.height = h; - localWinSize.width = this._visibleRect$.width; - localWinSize.height = this._visibleRect$.height; + localWinSize.width = this._visibleRect.width; + localWinSize.height = this._visibleRect.height; if (visibleRect) { - visibleRect.init(this._visibleRect$); + visibleRect.init(this._visibleRect); } if (!EDITOR) { @@ -129,8 +129,8 @@ export class View extends Eventify(System) { } // For now, the engine UI is adapted to resolution size, instead of window size. - screen.on('window-resize', this._updateAdaptResult$, this); - screen.on('fullscreen-change', this._updateAdaptResult$, this); + screen.on('window-resize', this._updateAdaptResult, this); + screen.on('fullscreen-change', this._updateAdaptResult, this); } /** @@ -161,7 +161,7 @@ export class View extends Eventify(System) { */ public setResizeCallback (callback: (() => void) | null): void { if (typeof callback === 'function' || callback == null) { - this._resizeCallback$ = callback; + this._resizeCallback = callback; } } @@ -212,7 +212,7 @@ export class View extends Eventify(System) { * @deprecated since v3.4.0 */ public enableRetina (enabled: boolean): void { - this._retinaEnabled$ = !!enabled; + this._retinaEnabled = !!enabled; } /** @@ -225,7 +225,7 @@ export class View extends Eventify(System) { * @deprecated since v3.4.0 */ public isRetinaEnabled (): boolean { - return this._retinaEnabled$; + return this._retinaEnabled; } /** @@ -240,10 +240,10 @@ export class View extends Eventify(System) { * @deprecated since v3.3, please use screen.requestFullScreen() instead. */ public enableAutoFullScreen (enabled: boolean): void { - if (enabled === this._autoFullScreen$) { + if (enabled === this._autoFullScreen) { return; } - this._autoFullScreen$ = enabled; + this._autoFullScreen = enabled; if (enabled) { screen.requestFullScreen().catch((e) => { // do nothing @@ -262,7 +262,7 @@ export class View extends Eventify(System) { * @deprecated since v3.3 */ public isAutoFullScreenEnabled (): boolean { - return this._autoFullScreen$; + return this._autoFullScreen; } /** @@ -342,7 +342,7 @@ export class View extends Eventify(System) { * @zh 返回视图窗口可见区域尺寸。 */ public getVisibleSize (): Size { - return new Size(this._visibleRect$.width, this._visibleRect$.height); + return new Size(this._visibleRect.width, this._visibleRect.height); } /** @@ -351,8 +351,8 @@ export class View extends Eventify(System) { */ public getVisibleSizeInPixel (): Size { return new Size( - this._visibleRect$.width * this._scaleX$, - this._visibleRect$.height * this._scaleY$, + this._visibleRect.width * this._scaleX, + this._visibleRect.height * this._scaleY, ); } @@ -361,7 +361,7 @@ export class View extends Eventify(System) { * @zh 返回视图窗口可见区域原点。 */ public getVisibleOrigin (): Vec2 { - return new Vec2(this._visibleRect$.x, this._visibleRect$.y); + return new Vec2(this._visibleRect.x, this._visibleRect.y); } /** @@ -370,8 +370,8 @@ export class View extends Eventify(System) { */ public getVisibleOriginInPixel (): Vec2 { return new Vec2( - this._visibleRect$.x * this._scaleX$, - this._visibleRect$.y * this._scaleY$, + this._visibleRect.x * this._scaleX, + this._visibleRect.y * this._scaleY, ); } @@ -381,29 +381,29 @@ export class View extends Eventify(System) { * @see [[ResolutionPolicy]] */ public getResolutionPolicy (): ResolutionPolicy { - return this._resolutionPolicy$; + return this._resolutionPolicy; } private _updateResolutionPolicy (resolutionPolicy: ResolutionPolicy|number): void { if (resolutionPolicy instanceof ResolutionPolicy) { - this._resolutionPolicy$ = resolutionPolicy; + this._resolutionPolicy = resolutionPolicy; } else { // Ensure compatibility with JSB const _locPolicy = ResolutionPolicy; if (resolutionPolicy === _locPolicy.EXACT_FIT) { - this._resolutionPolicy$ = this._rpExactFit$; + this._resolutionPolicy = this._rpExactFit; } if (resolutionPolicy === _locPolicy.SHOW_ALL) { - this._resolutionPolicy$ = this._rpShowAll$; + this._resolutionPolicy = this._rpShowAll; } if (resolutionPolicy === _locPolicy.NO_BORDER) { - this._resolutionPolicy$ = this._rpNoBorder$; + this._resolutionPolicy = this._rpNoBorder; } if (resolutionPolicy === _locPolicy.FIXED_HEIGHT) { - this._resolutionPolicy$ = this._rpFixedHeight$; + this._resolutionPolicy = this._rpFixedHeight; } if (resolutionPolicy === _locPolicy.FIXED_WIDTH) { - this._resolutionPolicy$ = this._rpFixedWidth$; + this._resolutionPolicy = this._rpFixedWidth; } } } @@ -440,7 +440,7 @@ export class View extends Eventify(System) { } this._updateResolutionPolicy(resolutionPolicy); - const policy = this._resolutionPolicy$; + const policy = this._resolutionPolicy; if (policy) { policy.preApply(this); } @@ -451,13 +451,13 @@ export class View extends Eventify(System) { const result = policy.apply(this, this._designResolutionSize); if (result.scale && result.scale.length === 2) { - this._scaleX$ = result.scale[0]; - this._scaleY$ = result.scale[1]; + this._scaleX = result.scale[0]; + this._scaleY = result.scale[1]; } if (result.viewport) { - const vp = this._viewportRect$; - const vb = this._visibleRect$; + const vp = this._viewportRect; + const vb = this._visibleRect; const rv = result.viewport; vp.x = rv.x; @@ -467,16 +467,16 @@ export class View extends Eventify(System) { vb.x = 0; vb.y = 0; - vb.width = rv.width / this._scaleX$; - vb.height = rv.height / this._scaleY$; + vb.width = rv.width / this._scaleX; + vb.height = rv.height / this._scaleY; } policy.postApply(this); - localWinSize.width = this._visibleRect$.width; - localWinSize.height = this._visibleRect$.height; + localWinSize.width = this._visibleRect.width; + localWinSize.height = this._visibleRect.height; if (visibleRect) { - visibleRect.init(this._visibleRect$); + visibleRect.init(this._visibleRect); } this.emit('design-resolution-changed'); @@ -525,7 +525,7 @@ export class View extends Eventify(System) { * @zh 返回视窗剪裁区域。 */ public getViewportRect (): Rect { - return this._viewportRect$; + return this._viewportRect; } /** @@ -533,7 +533,7 @@ export class View extends Eventify(System) { * @zh 返回横轴的缩放比,这个缩放比是将画布像素分辨率放到设计分辨率的比例。 */ public getScaleX (): number { - return this._scaleX$; + return this._scaleX; } /** @@ -541,7 +541,7 @@ export class View extends Eventify(System) { * @zh 返回纵轴的缩放比,这个缩放比是将画布像素分辨率缩放到设计分辨率的比例。 */ public getScaleY (): number { - return this._scaleY$; + return this._scaleY; } /** @@ -582,12 +582,12 @@ export class View extends Eventify(System) { * @engineInternal */ public _convertToUISpace (point: Vec2): void { - const viewport = this._viewportRect$; - point.x = (point.x - viewport.x) / this._scaleX$; - point.y = (point.y - viewport.y) / this._scaleY$; + const viewport = this._viewportRect; + point.x = (point.x - viewport.x) / this._scaleX; + point.y = (point.y - viewport.y) / this._scaleY; } - private _updateAdaptResult$ (width: number, height: number, windowId?: number): void { + private _updateAdaptResult (width: number, height: number, windowId?: number): void { // The default invalid windowId is 0 (cclegacy.director.root as Root).resize(width, height, (windowId === undefined || windowId === 0) ? 1 : windowId); // Frame size changed, do resize works @@ -595,13 +595,13 @@ export class View extends Eventify(System) { const h = this._designResolutionSize.height; if (width > 0 && height > 0) { - this.setDesignResolutionSize(w, h, this._resolutionPolicy$); + this.setDesignResolutionSize(w, h, this._resolutionPolicy); } else { assert(false, '_updateAdaptResult Invalid size.'); } this.emit('canvas-resize'); - this._resizeCallback$?.(); + this._resizeCallback?.(); } } @@ -643,7 +643,7 @@ class ContainerStrategy { * @param view * @param designedResolution */ - public apply$ (_view: View, designedResolution: Size): void { + public apply (_view: View, designedResolution: Size): void { // do nothing } @@ -713,7 +713,7 @@ class ContentStrategy { * @zh 策略应用前的操作 * @param view - The target view */ - public preApply$ (_view: View): void { + public preApply (_view: View): void { // do nothing } @@ -724,7 +724,7 @@ class ContentStrategy { * @zh 调用策略方法 * @return The result scale and viewport rect */ - public apply$ (_view: View, designedResolution: Size): AdaptResult { + public apply (_view: View, designedResolution: Size): AdaptResult { return { scale: [1, 1] }; } @@ -733,14 +733,14 @@ class ContentStrategy { * @zh 策略调用之后的操作 * @param view - The target view */ - public postApply$ (_view: View): void { + public postApply (_view: View): void { // do nothing } /** * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future. */ - public _buildResult$ (containerW: number, containerH: number, contentW: number, contentH: number, scaleX: number, scaleY: number): AdaptResult { + public _buildResult (containerW: number, containerH: number, contentW: number, contentH: number, scaleX: number, scaleY: number): AdaptResult { // Makes content fit better the canvas if (Math.abs(containerW - contentW) < 2) { contentW = containerW; @@ -775,7 +775,7 @@ class EqualToFrame extends ContainerStrategy { super(); } - public apply$ (_view, designedResolution): void { + public apply (_view, designedResolution): void { screenAdapter.isProportionalToFrame = false; this._setupCanvas(); } @@ -791,7 +791,7 @@ class ProportionalToFrame extends ContainerStrategy { super(); } - public apply$ (_view, designedResolution): void { + public apply (_view, designedResolution): void { screenAdapter.isProportionalToFrame = true; this._setupCanvas(); } @@ -811,14 +811,14 @@ class ExactFit extends ContentStrategy { this._strategy = ResolutionPolicy.EXACT_FIT; } - public apply$ (_view: View, designedResolution: Size): AdaptResult { + public apply (_view: View, designedResolution: Size): AdaptResult { const windowSize = screen.windowSize; const containerW = windowSize.width; const containerH = windowSize.height; const scaleX = containerW / designedResolution.width; const scaleY = containerH / designedResolution.height; - return this._buildResult$(containerW, containerH, containerW, containerH, scaleX, scaleY); + return this._buildResult(containerW, containerH, containerW, containerH, scaleX, scaleY); } } @@ -830,7 +830,7 @@ class ShowAll extends ContentStrategy { this._strategy = ResolutionPolicy.SHOW_ALL; } - public apply$ (_view, designedResolution): AdaptResult { + public apply (_view, designedResolution): AdaptResult { const windowSize = screen.windowSize; const containerW = windowSize.width; const containerH = windowSize.height; @@ -852,7 +852,7 @@ class ShowAll extends ContentStrategy { contentH = containerH; } - return this._buildResult$(containerW, containerH, contentW, contentH, scale, scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); } } @@ -864,7 +864,7 @@ class NoBorder extends ContentStrategy { this._strategy = ResolutionPolicy.NO_BORDER; } - public apply$ (_view, designedResolution): AdaptResult { + public apply (_view, designedResolution): AdaptResult { const windowSize = screen.windowSize; const containerW = windowSize.width; const containerH = windowSize.height; @@ -886,7 +886,7 @@ class NoBorder extends ContentStrategy { contentH = designH * scale; } - return this._buildResult$(containerW, containerH, contentW, contentH, scale, scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); } } @@ -898,7 +898,7 @@ class FixedHeight extends ContentStrategy { this._strategy = ResolutionPolicy.FIXED_HEIGHT; } - public apply$ (_view, designedResolution): AdaptResult { + public apply (_view, designedResolution): AdaptResult { const windowSize = screen.windowSize; const containerW = windowSize.width; const containerH = windowSize.height; @@ -907,7 +907,7 @@ class FixedHeight extends ContentStrategy { const contentW = containerW; const contentH = containerH; - return this._buildResult$(containerW, containerH, contentW, contentH, scale, scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); } } @@ -919,7 +919,7 @@ class FixedWidth extends ContentStrategy { this._strategy = ResolutionPolicy.FIXED_WIDTH; } - public apply$ (_view, designedResolution): AdaptResult { + public apply (_view, designedResolution): AdaptResult { const windowSize = screen.windowSize; const containerW = windowSize.width; const containerH = windowSize.height; @@ -928,7 +928,7 @@ class FixedWidth extends ContentStrategy { const contentW = containerW; const contentH = containerH; - return this._buildResult$(containerW, containerH, contentW, contentH, scale, scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); } } @@ -994,8 +994,8 @@ export class ResolutionPolicy { public name = 'ResolutionPolicy'; - private declare _containerStrategy$: ContainerStrategy; - private declare _contentStrategy$: ContentStrategy; + private declare _containerStrategy: ContainerStrategy; + private declare _contentStrategy: ContentStrategy; /** * Constructor of ResolutionPolicy @@ -1003,8 +1003,8 @@ export class ResolutionPolicy { * @param contentStg */ constructor (containerStg: ContainerStrategy, contentStg: ContentStrategy) { - this._containerStrategy$ = containerStg; - this._contentStrategy$ = contentStg; + this._containerStrategy = containerStg; + this._contentStrategy = contentStg; } get canvasSize (): Size { @@ -1017,7 +1017,7 @@ export class ResolutionPolicy { * @param _view The target view */ public preApply (_view: View): void { - this._contentStrategy$.preApply$(_view); + this._contentStrategy.preApply(_view); } /** @@ -1030,8 +1030,8 @@ export class ResolutionPolicy { * @return An object contains the scale X/Y values and the viewport rect */ public apply (_view: View, designedResolution: Size): AdaptResult { - this._containerStrategy$.apply$(_view, designedResolution); - return this._contentStrategy$.apply$(_view, designedResolution); + this._containerStrategy.apply(_view, designedResolution); + return this._contentStrategy.apply(_view, designedResolution); } /** @@ -1040,7 +1040,7 @@ export class ResolutionPolicy { * @param _view - The target view */ public postApply (_view: View): void { - this._contentStrategy$.postApply$(_view); + this._contentStrategy.postApply(_view); } /** @@ -1049,7 +1049,7 @@ export class ResolutionPolicy { * @param containerStg The container strategy */ public setContainerStrategy (containerStg: ContainerStrategy): void { - this._containerStrategy$ = containerStg; + this._containerStrategy = containerStg; } /** @@ -1058,7 +1058,7 @@ export class ResolutionPolicy { * @param contentStg The content strategy */ public setContentStrategy (contentStg: ContentStrategy): void { - this._contentStrategy$ = contentStg; + this._contentStrategy = contentStg; } /** @@ -1067,7 +1067,7 @@ export class ResolutionPolicy { * @returns ContentStrategy instance. */ public getContentStrategy (): ContentStrategy { - return this._contentStrategy$; + return this._contentStrategy; } } cclegacy.ResolutionPolicy = ResolutionPolicy; diff --git a/pal/audio/minigame/player-minigame.ts b/pal/audio/minigame/player-minigame.ts index 1df2310e6db..bb805d6ee81 100644 --- a/pal/audio/minigame/player-minigame.ts +++ b/pal/audio/minigame/player-minigame.ts @@ -32,36 +32,36 @@ import { enqueueOperation, OperationInfo, OperationQueueable } from '../operatio import { OS } from '../../system-info/enum-type'; export class OneShotAudioMinigame { - private _innerAudioContext$: InnerAudioContext; - private _onPlayCb$?: () => void; + private _innerAudioContext: InnerAudioContext; + private _onPlayCb?: () => void; get onPlay (): (() => void) | undefined { - return this._onPlayCb$; + return this._onPlayCb; } set onPlay (cb) { - this._onPlayCb$ = cb; + this._onPlayCb = cb; } - private _onEndCb$?: () => void; + private _onEndCb?: () => void; get onEnd (): (() => void) | undefined { - return this._onEndCb$; + return this._onEndCb; } set onEnd (cb) { - this._onEndCb$ = cb; + this._onEndCb = cb; } private constructor (nativeAudio: InnerAudioContext, volume: number) { - this._innerAudioContext$ = nativeAudio; + this._innerAudioContext = nativeAudio; nativeAudio.volume = volume; nativeAudio.onPlay(() => { - this._onPlayCb$?.(); + this._onPlayCb?.(); }); const endCallback = (): void => { - if (this._innerAudioContext$) { + if (this._innerAudioContext) { // NOTE: Type 'null' is not assignable to type 'InnerAudioContext'. - this._innerAudioContext$ = null as any; - systemInfo.off('hide', this._onInterruptedBegin$, this); - systemInfo.off('show', this._onInterruptedEnd$, this); - this._onEndCb$?.(); + this._innerAudioContext = null as any; + systemInfo.off('hide', this._onInterruptedBegin, this); + systemInfo.off('show', this._onInterruptedEnd, this); + this._onEndCb?.(); /**The destroy interface, in some platform implementations, internally invokes stop, * triggering the onStop callback, consequently leading to an infinite loop. **/ nativeAudio.destroy(); @@ -71,32 +71,32 @@ export class OneShotAudioMinigame { nativeAudio.onStop(endCallback);//OneShotAudio can not be reused. // event - systemInfo.on('hide', this._onInterruptedBegin$, this); - systemInfo.on('show', this._onInterruptedEnd$, this); + systemInfo.on('hide', this._onInterruptedBegin, this); + systemInfo.on('show', this._onInterruptedEnd, this); } - private _onInterruptedBegin$ (): void { - this._innerAudioContext$.pause(); + private _onInterruptedBegin (): void { + this._innerAudioContext.pause(); } - private _onInterruptedEnd$ (): void { - this._innerAudioContext$.play(); + private _onInterruptedEnd (): void { + this._innerAudioContext.play(); } public play (): void { - this._innerAudioContext$.play(); + this._innerAudioContext.play(); } public stop (): void { - this._innerAudioContext$.stop(); + this._innerAudioContext.stop(); } } export class AudioPlayerMinigame implements OperationQueueable { - private _innerAudioContext$: InnerAudioContext; - private _state$: AudioState = AudioState.INIT; - private _cacheTime$ = 0; - private _needSeek$ = false; - private _seeking$ = false; + private _innerAudioContext: InnerAudioContext; + private _state: AudioState = AudioState.INIT; + private _cacheTime = 0; + private _needSeek = false; + private _seeking = false; private _onPlay: () => void; private _onPause: () => void; @@ -106,11 +106,11 @@ export class AudioPlayerMinigame implements OperationQueueable { private _readyToHandleOnShow = false; private _resetSeekCache (): void { - this._cacheTime$ = 0; - this._needSeek$ = false; - this._seeking$ = false; - if ((HUAWEI || VIVO || OPPO) && this._innerAudioContext$) { - this._innerAudioContext$.startTime = 0; + this._cacheTime = 0; + this._needSeek = false; + this._seeking = false; + if ((HUAWEI || VIVO || OPPO) && this._innerAudioContext) { + this._innerAudioContext.startTime = 0; } } /** @@ -123,28 +123,28 @@ export class AudioPlayerMinigame implements OperationQueueable { public _operationQueue: OperationInfo[] = []; constructor (innerAudioContext: InnerAudioContext) { - this._innerAudioContext$ = innerAudioContext; + this._innerAudioContext = innerAudioContext; this._eventTarget = new EventTarget(); // event - systemInfo.on('hide', this._onInterruptedBegin$, this); - systemInfo.on('show', this._onInterruptedEnd$, this); + systemInfo.on('hide', this._onInterruptedBegin, this); + systemInfo.on('show', this._onInterruptedEnd, this); const eventTarget = this._eventTarget; this._onPlay = (): void => { - this._state$ = AudioState.PLAYING; + this._state = AudioState.PLAYING; eventTarget.emit(AudioEvent.PLAYED); - if (this._needSeek$) { + if (this._needSeek) { // eslint-disable-next-line @typescript-eslint/no-empty-function - this.seek(this._cacheTime$).catch((e) => {}); + this.seek(this._cacheTime).catch((e) => {}); } }; innerAudioContext.onPlay(this._onPlay); this._onPause = (): void => { - this._state$ = AudioState.PAUSED; + this._state = AudioState.PAUSED; try { - const currentTime = this._innerAudioContext$.currentTime; + const currentTime = this._innerAudioContext.currentTime; if (currentTime !== null && currentTime !== undefined) { - this._cacheTime$ = currentTime; + this._cacheTime = currentTime; } } catch { // Do nothing, cacheTime is not updated. @@ -153,7 +153,7 @@ export class AudioPlayerMinigame implements OperationQueueable { }; innerAudioContext.onPause(this._onPause); this._onStop = (): void => { - this._state$ = AudioState.STOPPED; + this._state = AudioState.STOPPED; // Reset all properties this._resetSeekCache(); eventTarget.emit(AudioEvent.STOPPED); @@ -161,66 +161,66 @@ export class AudioPlayerMinigame implements OperationQueueable { /**Unable to seek again after stop; After stop, regardless of whether the starttime has been set, the playback will always start from 0 again**/ } else { - const currentTime = this._innerAudioContext$ ? this._innerAudioContext$.currentTime : 0; + const currentTime = this._innerAudioContext ? this._innerAudioContext.currentTime : 0; if (currentTime !== 0) { - this._innerAudioContext$.seek(0); + this._innerAudioContext.seek(0); } } }; innerAudioContext.onStop(this._onStop); this._onSeeked = (): void => { eventTarget.emit(AudioEvent.SEEKED); - this._seeking$ = false; - if (this._needSeek$) { - this._needSeek$ = false; - if (this._cacheTime$.toFixed(2) !== this._innerAudioContext$.currentTime.toFixed(2)) { + this._seeking = false; + if (this._needSeek) { + this._needSeek = false; + if (this._cacheTime.toFixed(2) !== this._innerAudioContext.currentTime.toFixed(2)) { // eslint-disable-next-line @typescript-eslint/no-empty-function - this.seek(this._cacheTime$).catch((e) => {}); + this.seek(this._cacheTime).catch((e) => {}); } } }; innerAudioContext.onSeeked(this._onSeeked); this._onEnded = (): void => { - this._state$ = AudioState.INIT; + this._state = AudioState.INIT; this._resetSeekCache(); eventTarget.emit(AudioEvent.ENDED); }; innerAudioContext.onEnded(this._onEnded); } destroy (): void { - systemInfo.off('hide', this._onInterruptedBegin$, this); - systemInfo.off('show', this._onInterruptedEnd$, this); - if (this._innerAudioContext$) { + systemInfo.off('hide', this._onInterruptedBegin, this); + systemInfo.off('show', this._onInterruptedEnd, this); + if (this._innerAudioContext) { ['Play', 'Pause', 'Stop', 'Seeked', 'Ended'].forEach((event) => { - this._offEvent$(event); + this._offEvent(event); }); // NOTE: innerAudioContext might not stop the audio playing, have to call it explicitly. - this._innerAudioContext$.stop(); - this._innerAudioContext$.destroy(); + this._innerAudioContext.stop(); + this._innerAudioContext.destroy(); // NOTE: Type 'null' is not assignable to type 'InnerAudioContext' - this._innerAudioContext$ = null as any; + this._innerAudioContext = null as any; // Restore the state of the audio, otherwise it will cause 'destroy' to be called first and 'stop' to be called later. // this will cause a error. - this._state$ = AudioState.INIT; + this._state = AudioState.INIT; } } - private _onInterruptedBegin$ (): void { - if (this._state$ === AudioState.PLAYING) { + private _onInterruptedBegin (): void { + if (this._state === AudioState.PLAYING) { this.pause().then(() => { - this._state$ = AudioState.INTERRUPTED; + this._state = AudioState.INTERRUPTED; this._readyToHandleOnShow = true; this._eventTarget.emit(AudioEvent.INTERRUPTION_BEGIN); // eslint-disable-next-line @typescript-eslint/no-empty-function }).catch((e) => {}); } } - private _onInterruptedEnd$ (): void { + private _onInterruptedEnd (): void { // We don't know whether onShow or resolve callback in pause promise is called at first. if (!this._readyToHandleOnShow) { - this._eventTarget.once(AudioEvent.INTERRUPTION_END, this._onInterruptedEnd$, this); + this._eventTarget.once(AudioEvent.INTERRUPTION_END, this._onInterruptedEnd, this); return; } - if (this._state$ === AudioState.INTERRUPTED) { + if (this._state === AudioState.INTERRUPTED) { this.play().then(() => { this._eventTarget.emit(AudioEvent.INTERRUPTION_END); // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -228,15 +228,15 @@ export class AudioPlayerMinigame implements OperationQueueable { } this._readyToHandleOnShow = false; } - private _offEvent$ (eventName: string): void { + private _offEvent (eventName: string): void { if (this[`_on${eventName}`]) { - this._innerAudioContext$[`off${eventName}`](this[`_on${eventName}`]); + this._innerAudioContext[`off${eventName}`](this[`_on${eventName}`]); this[`_on${eventName}`] = null; } } get src (): string { - return this._innerAudioContext$ ? this._innerAudioContext$.src : ''; + return this._innerAudioContext ? this._innerAudioContext.src : ''; } get type (): AudioType { return AudioType.MINIGAME_AUDIO; @@ -288,34 +288,34 @@ export class AudioPlayerMinigame implements OperationQueueable { } get state (): AudioState { - return this._state$; + return this._state; } get loop (): boolean { - return this._innerAudioContext$.loop; + return this._innerAudioContext.loop; } set loop (val: boolean) { - this._innerAudioContext$.loop = val; + this._innerAudioContext.loop = val; } get volume (): number { - return this._innerAudioContext$.volume; + return this._innerAudioContext.volume; } set volume (val: number) { val = clamp01(val); - this._innerAudioContext$.volume = val; + this._innerAudioContext.volume = val; } get duration (): number { // KNOWN ISSUES: duration doesn't work well // On WeChat platform, duration is 0 at the time audio is loaded. - return this._innerAudioContext$.duration; + return this._innerAudioContext.duration; } get currentTime (): number { - if ((HUAWEI || VIVO || OPPO) && (this._state$ === AudioState.STOPPED || this._state$ === AudioState.INIT)) { - return this._innerAudioContext$.startTime; + if ((HUAWEI || VIVO || OPPO) && (this._state === AudioState.STOPPED || this._state === AudioState.INIT)) { + return this._innerAudioContext.startTime; } - if (this._state$ !== AudioState.PLAYING || this._needSeek$ || this._seeking$) { - return this._cacheTime$; + if (this._state !== AudioState.PLAYING || this._needSeek || this._seeking) { + return this._cacheTime; } - return this._innerAudioContext$.currentTime; + return this._innerAudioContext.currentTime; } get sampleRate (): number { @@ -330,19 +330,19 @@ export class AudioPlayerMinigame implements OperationQueueable { seek (time: number): Promise { return new Promise((resolve) => { // KNOWN ISSUES: on Baidu: currentTime returns without numbers on decimal places - if (this._state$ === AudioState.PLAYING && !this._seeking$) { + if (this._state === AudioState.PLAYING && !this._seeking) { time = clamp(time, 0, this.duration); - this._seeking$ = true; - this._cacheTime$ = time; + this._seeking = true; + this._cacheTime = time; this._eventTarget.once(AudioEvent.SEEKED, resolve); - this._innerAudioContext$.seek(time); + this._innerAudioContext.seek(time); } else { //Huawei, vivo, Oppo platform, after stop, regardless of whether the seek has been called, the playback will always start from 0 again - if ((HUAWEI || VIVO || OPPO) && (this._state$ === AudioState.STOPPED || this._state$ === AudioState.INIT)) { - this._innerAudioContext$.startTime = time; - } else if (this._cacheTime$ !== time) { // Skip the invalid seek - this._cacheTime$ = time; - this._needSeek$ = true; + if ((HUAWEI || VIVO || OPPO) && (this._state === AudioState.STOPPED || this._state === AudioState.INIT)) { + this._innerAudioContext.startTime = time; + } else if (this._cacheTime !== time) { // Skip the invalid seek + this._cacheTime = time; + this._needSeek = true; } resolve(); } @@ -353,7 +353,7 @@ export class AudioPlayerMinigame implements OperationQueueable { play (): Promise { return new Promise((resolve) => { this._eventTarget.once(AudioEvent.PLAYED, resolve); - this._innerAudioContext$.play(); + this._innerAudioContext.play(); }); } @@ -364,7 +364,7 @@ export class AudioPlayerMinigame implements OperationQueueable { resolve(); } else { this._eventTarget.once(AudioEvent.PAUSED, resolve); - this._innerAudioContext$.pause(); + this._innerAudioContext.pause(); } }); } @@ -372,13 +372,13 @@ export class AudioPlayerMinigame implements OperationQueueable { @enqueueOperation stop (): Promise { return new Promise((resolve) => { - if (AudioState.INIT === this._state$) { + if (AudioState.INIT === this._state) { this._resetSeekCache(); resolve(); return; } this._eventTarget.once(AudioEvent.STOPPED, resolve); - this._innerAudioContext$.stop(); + this._innerAudioContext.stop(); }); } diff --git a/pal/input/minigame/accelerometer-input.ts b/pal/input/minigame/accelerometer-input.ts index 59be6b4bc39..d278ff7933f 100644 --- a/pal/input/minigame/accelerometer-input.ts +++ b/pal/input/minigame/accelerometer-input.ts @@ -30,66 +30,66 @@ import { InputEventType } from '../../../cocos/input/types/event-enum'; import { errorID } from '../../../cocos/core/platform/debug'; export class AccelerometerInputSource { - private _isStarted$ = false; - private _accelMode$: AccelerometerIntervalMode = 'normal'; - private _eventTarget$: EventTarget = new EventTarget(); - private declare _didAccelerateFunc$: (event: AccelerometerData) => void; + private _isStarted = false; + private _accelMode: AccelerometerIntervalMode = 'normal'; + private _eventTarget: EventTarget = new EventTarget(); + private declare _didAccelerateFunc: (event: AccelerometerData) => void; constructor () { - this._didAccelerateFunc$ = this._didAccelerate$.bind(this); + this._didAccelerateFunc = this._didAccelerate.bind(this); } - private _registerEvent$ (): void { - minigame.onAccelerometerChange(this._didAccelerateFunc$); + private _registerEvent (): void { + minigame.onAccelerometerChange(this._didAccelerateFunc); } - private _unregisterEvent$ (): void { - minigame.offAccelerometerChange(this._didAccelerateFunc$); + private _unregisterEvent (): void { + minigame.offAccelerometerChange(this._didAccelerateFunc); } - private _didAccelerate$ (event: AccelerometerData): void { + private _didAccelerate (event: AccelerometerData): void { const timestamp = performance.now(); const acceleration = new Acceleration(event.x, event.y, event.z, timestamp); const eventAcceleration = new EventAcceleration(acceleration); - this._eventTarget$.emit(InputEventType.DEVICEMOTION, eventAcceleration); + this._eventTarget.emit(InputEventType.DEVICEMOTION, eventAcceleration); } public start (): void { - this._registerEvent$(); + this._registerEvent(); minigame.startAccelerometer({ - interval: this._accelMode$, + interval: this._accelMode, success: () => { - this._isStarted$ = true; + this._isStarted = true; }, }); } public stop (): void { minigame.stopAccelerometer({ success: () => { - this._isStarted$ = false; + this._isStarted = false; }, fail () { errorID(16305); }, }); - this._unregisterEvent$(); + this._unregisterEvent(); } public setInterval (intervalInMileseconds: number): void { // reference: https://developers.weixin.qq.com/minigame/dev/api/device/accelerometer/wx.startAccelerometer.html if (intervalInMileseconds >= 200) { - this._accelMode$ = 'normal'; + this._accelMode = 'normal'; } else if (intervalInMileseconds >= 60) { - this._accelMode$ = 'ui'; + this._accelMode = 'ui'; } else { - this._accelMode$ = 'game'; + this._accelMode = 'game'; } - if (this._isStarted$) { + if (this._isStarted) { // restart accelerometer this.stop(); this.start(); } } public on (eventType: InputEventType, callback: AccelerometerCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); } } diff --git a/pal/input/minigame/gamepad-input.ts b/pal/input/minigame/gamepad-input.ts index c79f92fc916..97ff9e90987 100644 --- a/pal/input/minigame/gamepad-input.ts +++ b/pal/input/minigame/gamepad-input.ts @@ -32,34 +32,34 @@ export class GamepadInputDevice { public static all: GamepadInputDevice[] = []; public static xr: (GamepadInputDevice | null) = null; - public get buttonNorth (): InputSourceButton { return this._buttonNorth$; } - public get buttonEast (): InputSourceButton { return this._buttonEast$; } - public get buttonWest (): InputSourceButton { return this._buttonWest$; } - public get buttonSouth (): InputSourceButton { return this._buttonSouth$; } - public get buttonL1 (): InputSourceButton { return this._buttonL1$; } - public get buttonL2 (): InputSourceButton { return this._buttonL2$; } - public get buttonL3 (): InputSourceButton { return this._buttonL3$; } - public get buttonR1 (): InputSourceButton { return this._buttonR1$; } - public get buttonR2 (): InputSourceButton { return this._buttonR2$; } - public get buttonR3 (): InputSourceButton { return this._buttonR3$; } + public get buttonNorth (): InputSourceButton { return this._buttonNorth; } + public get buttonEast (): InputSourceButton { return this._buttonEast; } + public get buttonWest (): InputSourceButton { return this._buttonWest; } + public get buttonSouth (): InputSourceButton { return this._buttonSouth; } + public get buttonL1 (): InputSourceButton { return this._buttonL1; } + public get buttonL2 (): InputSourceButton { return this._buttonL2; } + public get buttonL3 (): InputSourceButton { return this._buttonL3; } + public get buttonR1 (): InputSourceButton { return this._buttonR1; } + public get buttonR2 (): InputSourceButton { return this._buttonR2; } + public get buttonR3 (): InputSourceButton { return this._buttonR3; } // public get buttonTouchPad () { return this._buttonTouchPad; } // public get buttonHome () { return this._buttonHome; } - public get buttonShare (): InputSourceButton { return this._buttonShare$; } - public get buttonOptions (): InputSourceButton { return this._buttonOptions$; } - public get dpad (): InputSourceDpad { return this._dpad$; } - public get leftStick (): InputSourceStick { return this._leftStick$; } - public get rightStick (): InputSourceStick { return this._rightStick$; } - public get buttonStart (): InputSourceButton { return this._buttonStart$; } - public get gripLeft (): InputSourceButton { return this._gripLeft$; } - public get gripRight (): InputSourceButton { return this._gripRight$; } - public get handLeftPosition (): InputSourcePosition { return this._handLeftPosition$; } - public get handLeftOrientation (): InputSourceOrientation { return this._handLeftOrientation$; } - public get handRightPosition (): InputSourcePosition { return this._handRightPosition$; } - public get handRightOrientation (): InputSourceOrientation { return this._handRightOrientation$; } - public get aimLeftPosition (): InputSourcePosition { return this._aimLeftPosition$; } - public get aimLeftOrientation (): InputSourceOrientation { return this._aimLeftOrientation$; } - public get aimRightPosition (): InputSourcePosition { return this._aimRightPosition$; } - public get aimRightOrientation (): InputSourceOrientation { return this._aimRightOrientation$; } + public get buttonShare (): InputSourceButton { return this._buttonShare; } + public get buttonOptions (): InputSourceButton { return this._buttonOptions; } + public get dpad (): InputSourceDpad { return this._dpad; } + public get leftStick (): InputSourceStick { return this._leftStick; } + public get rightStick (): InputSourceStick { return this._rightStick; } + public get buttonStart (): InputSourceButton { return this._buttonStart; } + public get gripLeft (): InputSourceButton { return this._gripLeft; } + public get gripRight (): InputSourceButton { return this._gripRight; } + public get handLeftPosition (): InputSourcePosition { return this._handLeftPosition; } + public get handLeftOrientation (): InputSourceOrientation { return this._handLeftOrientation; } + public get handRightPosition (): InputSourcePosition { return this._handRightPosition; } + public get handRightOrientation (): InputSourceOrientation { return this._handRightOrientation; } + public get aimLeftPosition (): InputSourcePosition { return this._aimLeftPosition; } + public get aimLeftOrientation (): InputSourceOrientation { return this._aimLeftOrientation; } + public get aimRightPosition (): InputSourcePosition { return this._aimRightPosition; } + public get aimRightOrientation (): InputSourceOrientation { return this._aimRightOrientation; } public get deviceId (): number { return this._deviceId; @@ -68,43 +68,43 @@ export class GamepadInputDevice { return this._connected; } - private static _eventTarget$: EventTarget = new EventTarget(); - - private declare _buttonNorth$: InputSourceButton; - private declare _buttonEast$: InputSourceButton; - private declare _buttonWest$: InputSourceButton; - private declare _buttonSouth$: InputSourceButton; - private declare _buttonL1$: InputSourceButton; - private declare _buttonL2$: InputSourceButton; - private declare _buttonL3$: InputSourceButton; - private declare _buttonR1$: InputSourceButton; - private declare _buttonR2$: InputSourceButton; - private declare _buttonR3$: InputSourceButton; - // private declare buttonTouchPad$: InputSourceButton; - // private declare buttonHome$: InputSourceButton; - private declare _buttonShare$: InputSourceButton; - private declare _buttonOptions$: InputSourceButton; - private declare _dpad$: InputSourceDpad; - private declare _leftStick$: InputSourceStick; - private declare _rightStick$: InputSourceStick; - private declare _buttonStart$: InputSourceButton; - private declare _gripLeft$: InputSourceButton; - private declare _gripRight$: InputSourceButton; - private declare _handLeftPosition$: InputSourcePosition; - private declare _handLeftOrientation$: InputSourceOrientation; - private declare _handRightPosition$: InputSourcePosition; - private declare _handRightOrientation$: InputSourceOrientation; - private declare _aimLeftPosition$: InputSourcePosition; - private declare _aimLeftOrientation$: InputSourceOrientation; - private declare _aimRightPosition$: InputSourcePosition; - private declare _aimRightOrientation$: InputSourceOrientation; + private static _eventTarget: EventTarget = new EventTarget(); + + private declare _buttonNorth: InputSourceButton; + private declare _buttonEast: InputSourceButton; + private declare _buttonWest: InputSourceButton; + private declare _buttonSouth: InputSourceButton; + private declare _buttonL1: InputSourceButton; + private declare _buttonL2: InputSourceButton; + private declare _buttonL3: InputSourceButton; + private declare _buttonR1: InputSourceButton; + private declare _buttonR2: InputSourceButton; + private declare _buttonR3: InputSourceButton; + // private declare buttonTouchPad: InputSourceButton; + // private declare buttonHome: InputSourceButton; + private declare _buttonShare: InputSourceButton; + private declare _buttonOptions: InputSourceButton; + private declare _dpad: InputSourceDpad; + private declare _leftStick: InputSourceStick; + private declare _rightStick: InputSourceStick; + private declare _buttonStart: InputSourceButton; + private declare _gripLeft: InputSourceButton; + private declare _gripRight: InputSourceButton; + private declare _handLeftPosition: InputSourcePosition; + private declare _handLeftOrientation: InputSourceOrientation; + private declare _handRightPosition: InputSourcePosition; + private declare _handRightOrientation: InputSourceOrientation; + private declare _aimLeftPosition: InputSourcePosition; + private declare _aimLeftOrientation: InputSourceOrientation; + private declare _aimRightPosition: InputSourcePosition; + private declare _aimRightOrientation: InputSourceOrientation; private _deviceId = -1; private _connected = false; constructor (deviceId: number) { this._deviceId = deviceId; - this._initInputSource$(); + this._initInputSource(); } /** @@ -118,41 +118,41 @@ export class GamepadInputDevice { * @engineInternal */ public static _on (eventType: InputEventType, cb: GamepadCallback, target?: any): void { - GamepadInputDevice._eventTarget$.on(eventType, cb, target); + GamepadInputDevice._eventTarget.on(eventType, cb, target); } - private _initInputSource$ (): void { - this._buttonNorth$ = new InputSourceButton(); - this._buttonNorth$.getValue = (): number => 0; - this._buttonEast$ = new InputSourceButton(); - this._buttonEast$.getValue = (): number => 0; - this._buttonWest$ = new InputSourceButton(); - this._buttonWest$.getValue = (): number => 0; - this._buttonSouth$ = new InputSourceButton(); - this._buttonSouth$.getValue = (): number => 0; - - this._buttonL1$ = new InputSourceButton(); - this._buttonL1$.getValue = (): number => 0; - this._buttonL2$ = new InputSourceButton(); - this._buttonL2$.getValue = (): number => 0; - this._buttonL3$ = new InputSourceButton(); - this._buttonL3$.getValue = (): number => 0; - this._buttonR1$ = new InputSourceButton(); - this._buttonR1$.getValue = (): number => 0; - this._buttonR2$ = new InputSourceButton(); - this._buttonR2$.getValue = (): number => 0; - this._buttonR3$ = new InputSourceButton(); - this._buttonR3$.getValue = (): number => 0; + private _initInputSource (): void { + this._buttonNorth = new InputSourceButton(); + this._buttonNorth.getValue = (): number => 0; + this._buttonEast = new InputSourceButton(); + this._buttonEast.getValue = (): number => 0; + this._buttonWest = new InputSourceButton(); + this._buttonWest.getValue = (): number => 0; + this._buttonSouth = new InputSourceButton(); + this._buttonSouth.getValue = (): number => 0; + + this._buttonL1 = new InputSourceButton(); + this._buttonL1.getValue = (): number => 0; + this._buttonL2 = new InputSourceButton(); + this._buttonL2.getValue = (): number => 0; + this._buttonL3 = new InputSourceButton(); + this._buttonL3.getValue = (): number => 0; + this._buttonR1 = new InputSourceButton(); + this._buttonR1.getValue = (): number => 0; + this._buttonR2 = new InputSourceButton(); + this._buttonR2.getValue = (): number => 0; + this._buttonR3 = new InputSourceButton(); + this._buttonR3.getValue = (): number => 0; // this._buttonTouchPad = new InputSourceButton(); // this._buttonTouchPad.getValue = () => 0; // this._buttonHome = new InputSourceButton(); // this._buttonHome.getValue = () => 0; - this._buttonShare$ = new InputSourceButton(); - this._buttonShare$.getValue = (): number => 0; - this._buttonOptions$ = new InputSourceButton(); - this._buttonOptions$.getValue = (): number => 0; + this._buttonShare = new InputSourceButton(); + this._buttonShare.getValue = (): number => 0; + this._buttonOptions = new InputSourceButton(); + this._buttonOptions.getValue = (): number => 0; const dpadUp = new InputSourceButton(); dpadUp.getValue = (): number => 0; @@ -162,7 +162,7 @@ export class GamepadInputDevice { dpadLeft.getValue = (): number => 0; const dpadRight = new InputSourceButton(); dpadRight.getValue = (): number => 0; - this._dpad$ = new InputSourceDpad({ up: dpadUp, down: dpadDown, left: dpadLeft, right: dpadRight }); + this._dpad = new InputSourceDpad({ up: dpadUp, down: dpadDown, left: dpadLeft, right: dpadRight }); const leftStickUp = new InputSourceButton(); leftStickUp.getValue = (): number => 0; @@ -172,7 +172,7 @@ export class GamepadInputDevice { leftStickLeft.getValue = (): number => 0; const leftStickRight = new InputSourceButton(); leftStickRight.getValue = (): number => 0; - this._leftStick$ = new InputSourceStick({ up: leftStickUp, down: leftStickDown, left: leftStickLeft, right: leftStickRight }); + this._leftStick = new InputSourceStick({ up: leftStickUp, down: leftStickDown, left: leftStickLeft, right: leftStickRight }); const rightStickUp = new InputSourceButton(); rightStickUp.getValue = (): number => 0; @@ -182,34 +182,34 @@ export class GamepadInputDevice { rightStickLeft.getValue = (): number => 0; const rightStickRight = new InputSourceButton(); rightStickRight.getValue = (): number => 0; - this._rightStick$ = new InputSourceStick({ up: rightStickUp, down: rightStickDown, left: rightStickLeft, right: rightStickRight }); - - this._buttonStart$ = new InputSourceButton(); - this._buttonStart$.getValue = (): number => 0; - - this._gripLeft$ = new InputSourceButton(); - this._gripLeft$.getValue = (): number => 0; - this._gripRight$ = new InputSourceButton(); - this._gripRight$.getValue = (): number => 0; - - this._handLeftPosition$ = new InputSourcePosition(); - this._handLeftPosition$.getValue = (): Readonly => Vec3.ZERO; - this._handLeftOrientation$ = new InputSourceOrientation(); - this._handLeftOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._handRightPosition$ = new InputSourcePosition(); - this._handRightPosition$.getValue = (): Readonly => Vec3.ZERO; - this._handRightOrientation$ = new InputSourceOrientation(); - this._handRightOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._aimLeftPosition$ = new InputSourcePosition(); - this._aimLeftPosition$.getValue = (): Readonly => Vec3.ZERO; - this._aimLeftOrientation$ = new InputSourceOrientation(); - this._aimLeftOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._aimRightPosition$ = new InputSourcePosition(); - this._aimRightPosition$.getValue = (): Readonly => Vec3.ZERO; - this._aimRightOrientation$ = new InputSourceOrientation(); - this._aimRightOrientation$.getValue = (): Readonly => Quat.IDENTITY; + this._rightStick = new InputSourceStick({ up: rightStickUp, down: rightStickDown, left: rightStickLeft, right: rightStickRight }); + + this._buttonStart = new InputSourceButton(); + this._buttonStart.getValue = (): number => 0; + + this._gripLeft = new InputSourceButton(); + this._gripLeft.getValue = (): number => 0; + this._gripRight = new InputSourceButton(); + this._gripRight.getValue = (): number => 0; + + this._handLeftPosition = new InputSourcePosition(); + this._handLeftPosition.getValue = (): Readonly => Vec3.ZERO; + this._handLeftOrientation = new InputSourceOrientation(); + this._handLeftOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._handRightPosition = new InputSourcePosition(); + this._handRightPosition.getValue = (): Readonly => Vec3.ZERO; + this._handRightOrientation = new InputSourceOrientation(); + this._handRightOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._aimLeftPosition = new InputSourcePosition(); + this._aimLeftPosition.getValue = (): Readonly => Vec3.ZERO; + this._aimLeftOrientation = new InputSourceOrientation(); + this._aimLeftOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._aimRightPosition = new InputSourcePosition(); + this._aimRightPosition.getValue = (): Readonly => Vec3.ZERO; + this._aimRightOrientation = new InputSourceOrientation(); + this._aimRightOrientation.getValue = (): Readonly => Quat.IDENTITY; } } diff --git a/pal/input/minigame/handheld-input.ts b/pal/input/minigame/handheld-input.ts index 82beab9696d..4f5b6ba9201 100644 --- a/pal/input/minigame/handheld-input.ts +++ b/pal/input/minigame/handheld-input.ts @@ -29,13 +29,13 @@ import { InputSourcePosition, InputSourceOrientation } from '../input-source'; import { Quat, Vec3 } from '../../../cocos/core/math'; export class HandheldInputDevice { - public get handheldPosition (): InputSourcePosition { return this._handheldPosition$; } - public get handheldOrientation (): InputSourceOrientation { return this._handheldOrientation$; } + public get handheldPosition (): InputSourcePosition { return this._handheldPosition; } + public get handheldOrientation (): InputSourceOrientation { return this._handheldOrientation; } - private _eventTarget$: EventTarget = new EventTarget(); + private _eventTarget: EventTarget = new EventTarget(); - private declare _handheldPosition$: InputSourcePosition; - private declare _handheldOrientation$: InputSourceOrientation; + private declare _handheldPosition: InputSourcePosition; + private declare _handheldOrientation: InputSourceOrientation; constructor () { this._initInputSource(); @@ -45,13 +45,13 @@ export class HandheldInputDevice { * @engineInternal */ public _on (eventType: InputEventType, callback: HandheldCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); } private _initInputSource (): void { - this._handheldPosition$ = new InputSourcePosition(); - this._handheldPosition$.getValue = (): Readonly => Vec3.ZERO; - this._handheldOrientation$ = new InputSourceOrientation(); - this._handheldOrientation$.getValue = (): Readonly => Quat.IDENTITY; + this._handheldPosition = new InputSourcePosition(); + this._handheldPosition.getValue = (): Readonly => Vec3.ZERO; + this._handheldOrientation = new InputSourceOrientation(); + this._handheldOrientation.getValue = (): Readonly => Quat.IDENTITY; } } diff --git a/pal/input/minigame/handle-input.ts b/pal/input/minigame/handle-input.ts index 57a8ad608e6..8be6a55e045 100644 --- a/pal/input/minigame/handle-input.ts +++ b/pal/input/minigame/handle-input.ts @@ -29,76 +29,76 @@ import { InputSourceButton, InputSourceStick, InputSourcePosition, InputSourceOr import { Vec3, Quat } from '../../../cocos/core/math'; export class HandleInputDevice { - public get buttonNorth (): InputSourceButton { return this._buttonNorth$; } - public get buttonEast (): InputSourceButton { return this._buttonEast$; } - public get buttonWest (): InputSourceButton { return this._buttonWest$; } - public get buttonSouth (): InputSourceButton { return this._buttonSouth$; } - public get buttonTriggerLeft (): InputSourceButton { return this._buttonTriggerLeft$; } - public get buttonTriggerRight (): InputSourceButton { return this._buttonTriggerRight$; } - public get triggerLeft (): InputSourceButton { return this._triggerLeft$; } - public get triggerRight (): InputSourceButton { return this._triggerRight$; } - public get gripLeft (): InputSourceButton { return this._gripLeft$; } - public get gripRight (): InputSourceButton { return this._gripRight$; } - public get leftStick (): InputSourceStick { return this._leftStick$; } - public get rightStick (): InputSourceStick { return this._rightStick$; } - public get buttonLeftStick (): InputSourceButton { return this._buttonLeftStick$; } - public get buttonRightStick (): InputSourceButton { return this._buttonRightStick$; } - public get buttonOptions (): InputSourceButton { return this._buttonOptions$; } - public get buttonStart (): InputSourceButton { return this._buttonStart$; } - public get handLeftPosition (): InputSourcePosition { return this._handLeftPosition$; } - public get handLeftOrientation (): InputSourceOrientation { return this._handLeftOrientation$; } - public get handRightPosition (): InputSourcePosition { return this._handRightPosition$; } - public get handRightOrientation (): InputSourceOrientation { return this._handRightOrientation$; } - public get aimLeftPosition (): InputSourcePosition { return this._aimLeftPosition$; } - public get aimLeftOrientation (): InputSourceOrientation { return this._aimLeftOrientation$; } - public get aimRightPosition (): InputSourcePosition { return this._aimRightPosition$; } - public get aimRightOrientation (): InputSourceOrientation { return this._aimRightOrientation$; } - public get touchButtonA (): InputSourceTouch { return this._touchButtonA$; } - public get touchButtonB (): InputSourceTouch { return this._touchButtonB$; } - public get touchButtonX (): InputSourceTouch { return this._touchButtonX$; } - public get touchButtonY (): InputSourceTouch { return this._touchButtonY$; } - public get touchButtonTriggerLeft (): InputSourceTouch { return this._touchButtonTriggerLeft$; } - public get touchButtonTriggerRight (): InputSourceTouch { return this._touchButtonTriggerRight$; } - public get touchButtonThumbStickLeft (): InputSourceTouch { return this._touchButtonThumbStickLeft$; } - public get touchButtonThumbStickRight (): InputSourceTouch { return this._touchButtonThumbStickRight$; } + public get buttonNorth (): InputSourceButton { return this._buttonNorth; } + public get buttonEast (): InputSourceButton { return this._buttonEast; } + public get buttonWest (): InputSourceButton { return this._buttonWest; } + public get buttonSouth (): InputSourceButton { return this._buttonSouth; } + public get buttonTriggerLeft (): InputSourceButton { return this._buttonTriggerLeft; } + public get buttonTriggerRight (): InputSourceButton { return this._buttonTriggerRight; } + public get triggerLeft (): InputSourceButton { return this._triggerLeft; } + public get triggerRight (): InputSourceButton { return this._triggerRight; } + public get gripLeft (): InputSourceButton { return this._gripLeft; } + public get gripRight (): InputSourceButton { return this._gripRight; } + public get leftStick (): InputSourceStick { return this._leftStick; } + public get rightStick (): InputSourceStick { return this._rightStick; } + public get buttonLeftStick (): InputSourceButton { return this._buttonLeftStick; } + public get buttonRightStick (): InputSourceButton { return this._buttonRightStick; } + public get buttonOptions (): InputSourceButton { return this._buttonOptions; } + public get buttonStart (): InputSourceButton { return this._buttonStart; } + public get handLeftPosition (): InputSourcePosition { return this._handLeftPosition; } + public get handLeftOrientation (): InputSourceOrientation { return this._handLeftOrientation; } + public get handRightPosition (): InputSourcePosition { return this._handRightPosition; } + public get handRightOrientation (): InputSourceOrientation { return this._handRightOrientation; } + public get aimLeftPosition (): InputSourcePosition { return this._aimLeftPosition; } + public get aimLeftOrientation (): InputSourceOrientation { return this._aimLeftOrientation; } + public get aimRightPosition (): InputSourcePosition { return this._aimRightPosition; } + public get aimRightOrientation (): InputSourceOrientation { return this._aimRightOrientation; } + public get touchButtonA (): InputSourceTouch { return this._touchButtonA; } + public get touchButtonB (): InputSourceTouch { return this._touchButtonB; } + public get touchButtonX (): InputSourceTouch { return this._touchButtonX; } + public get touchButtonY (): InputSourceTouch { return this._touchButtonY; } + public get touchButtonTriggerLeft (): InputSourceTouch { return this._touchButtonTriggerLeft; } + public get touchButtonTriggerRight (): InputSourceTouch { return this._touchButtonTriggerRight; } + public get touchButtonThumbStickLeft (): InputSourceTouch { return this._touchButtonThumbStickLeft; } + public get touchButtonThumbStickRight (): InputSourceTouch { return this._touchButtonThumbStickRight; } private _eventTarget: EventTarget = new EventTarget(); - private declare _buttonNorth$: InputSourceButton; - private declare _buttonEast$: InputSourceButton; - private declare _buttonWest$: InputSourceButton; - private declare _buttonSouth$: InputSourceButton; - private declare _buttonTriggerLeft$: InputSourceButton; - private declare _buttonTriggerRight$: InputSourceButton; - private declare _triggerLeft$: InputSourceButton; - private declare _triggerRight$: InputSourceButton; - private declare _gripLeft$: InputSourceButton; - private declare _gripRight$: InputSourceButton; - private declare _leftStick$: InputSourceStick; - private declare _rightStick$: InputSourceStick; - private declare _buttonLeftStick$: InputSourceButton; - private declare _buttonRightStick$: InputSourceButton; - private declare _buttonOptions$: InputSourceButton; - private declare _buttonStart$: InputSourceButton; - private declare _handLeftPosition$: InputSourcePosition; - private declare _handLeftOrientation$: InputSourceOrientation; - private declare _handRightPosition$: InputSourcePosition; - private declare _handRightOrientation$: InputSourceOrientation; - private declare _aimLeftPosition$: InputSourcePosition; - private declare _aimLeftOrientation$: InputSourceOrientation; - private declare _aimRightPosition$: InputSourcePosition; - private declare _aimRightOrientation$: InputSourceOrientation; - private declare _touchButtonA$: InputSourceTouch; - private declare _touchButtonB$: InputSourceTouch; - private declare _touchButtonX$: InputSourceTouch; - private declare _touchButtonY$: InputSourceTouch; - private declare _touchButtonTriggerLeft$: InputSourceTouch; - private declare _touchButtonTriggerRight$: InputSourceTouch; - private declare _touchButtonThumbStickLeft$: InputSourceTouch; - private declare _touchButtonThumbStickRight$: InputSourceTouch; + private declare _buttonNorth: InputSourceButton; + private declare _buttonEast: InputSourceButton; + private declare _buttonWest: InputSourceButton; + private declare _buttonSouth: InputSourceButton; + private declare _buttonTriggerLeft: InputSourceButton; + private declare _buttonTriggerRight: InputSourceButton; + private declare _triggerLeft: InputSourceButton; + private declare _triggerRight: InputSourceButton; + private declare _gripLeft: InputSourceButton; + private declare _gripRight: InputSourceButton; + private declare _leftStick: InputSourceStick; + private declare _rightStick: InputSourceStick; + private declare _buttonLeftStick: InputSourceButton; + private declare _buttonRightStick: InputSourceButton; + private declare _buttonOptions: InputSourceButton; + private declare _buttonStart: InputSourceButton; + private declare _handLeftPosition: InputSourcePosition; + private declare _handLeftOrientation: InputSourceOrientation; + private declare _handRightPosition: InputSourcePosition; + private declare _handRightOrientation: InputSourceOrientation; + private declare _aimLeftPosition: InputSourcePosition; + private declare _aimLeftOrientation: InputSourceOrientation; + private declare _aimRightPosition: InputSourcePosition; + private declare _aimRightOrientation: InputSourceOrientation; + private declare _touchButtonA: InputSourceTouch; + private declare _touchButtonB: InputSourceTouch; + private declare _touchButtonX: InputSourceTouch; + private declare _touchButtonY: InputSourceTouch; + private declare _touchButtonTriggerLeft: InputSourceTouch; + private declare _touchButtonTriggerRight: InputSourceTouch; + private declare _touchButtonThumbStickLeft: InputSourceTouch; + private declare _touchButtonThumbStickRight: InputSourceTouch; constructor () { - this._initInputSource$(); + this._initInputSource(); } /** @@ -108,31 +108,31 @@ export class HandleInputDevice { this._eventTarget.on(eventType, callback, target); } - private _initInputSource$ (): void { - this._buttonNorth$ = new InputSourceButton(); - this._buttonNorth$.getValue = (): number => 0; - this._buttonEast$ = new InputSourceButton(); - this._buttonEast$.getValue = (): number => 0; - this._buttonWest$ = new InputSourceButton(); - this._buttonWest$.getValue = (): number => 0; - this._buttonSouth$ = new InputSourceButton(); - this._buttonSouth$.getValue = (): number => 0; - - this._buttonTriggerLeft$ = new InputSourceButton(); - this._buttonTriggerLeft$.getValue = (): number => 0; - this._buttonTriggerRight$ = new InputSourceButton(); - this._buttonTriggerRight$.getValue = (): number => 0; - this._triggerLeft$ = new InputSourceButton(); - this._triggerLeft$.getValue = (): number => 0; - this._triggerRight$ = new InputSourceButton(); - this._triggerRight$.getValue = (): number => 0; - this._gripLeft$ = new InputSourceButton(); - this._gripLeft$.getValue = (): number => 0; - this._gripRight$ = new InputSourceButton(); - this._gripRight$.getValue = (): number => 0; - - this._buttonLeftStick$ = new InputSourceButton(); - this._buttonLeftStick$.getValue = (): number => 0; + private _initInputSource (): void { + this._buttonNorth = new InputSourceButton(); + this._buttonNorth.getValue = (): number => 0; + this._buttonEast = new InputSourceButton(); + this._buttonEast.getValue = (): number => 0; + this._buttonWest = new InputSourceButton(); + this._buttonWest.getValue = (): number => 0; + this._buttonSouth = new InputSourceButton(); + this._buttonSouth.getValue = (): number => 0; + + this._buttonTriggerLeft = new InputSourceButton(); + this._buttonTriggerLeft.getValue = (): number => 0; + this._buttonTriggerRight = new InputSourceButton(); + this._buttonTriggerRight.getValue = (): number => 0; + this._triggerLeft = new InputSourceButton(); + this._triggerLeft.getValue = (): number => 0; + this._triggerRight = new InputSourceButton(); + this._triggerRight.getValue = (): number => 0; + this._gripLeft = new InputSourceButton(); + this._gripLeft.getValue = (): number => 0; + this._gripRight = new InputSourceButton(); + this._gripRight.getValue = (): number => 0; + + this._buttonLeftStick = new InputSourceButton(); + this._buttonLeftStick.getValue = (): number => 0; const leftStickUp = new InputSourceButton(); leftStickUp.getValue = (): number => 0; const leftStickDown = new InputSourceButton(); @@ -141,10 +141,10 @@ export class HandleInputDevice { leftStickLeft.getValue = (): number => 0; const leftStickRight = new InputSourceButton(); leftStickRight.getValue = (): number => 0; - this._leftStick$ = new InputSourceStick({ up: leftStickUp, down: leftStickDown, left: leftStickLeft, right: leftStickRight }); + this._leftStick = new InputSourceStick({ up: leftStickUp, down: leftStickDown, left: leftStickLeft, right: leftStickRight }); - this._buttonRightStick$ = new InputSourceButton(); - this._buttonRightStick$.getValue = (): number => 0; + this._buttonRightStick = new InputSourceButton(); + this._buttonRightStick.getValue = (): number => 0; const rightStickUp = new InputSourceButton(); rightStickUp.getValue = (): number => 0; const rightStickDown = new InputSourceButton(); @@ -153,48 +153,48 @@ export class HandleInputDevice { rightStickLeft.getValue = (): number => 0; const rightStickRight = new InputSourceButton(); rightStickRight.getValue = (): number => 0; - this._rightStick$ = new InputSourceStick({ up: rightStickUp, down: rightStickDown, left: rightStickLeft, right: rightStickRight }); - - this._buttonOptions$ = new InputSourceButton(); - this._buttonOptions$.getValue = (): number => 0; - this._buttonStart$ = new InputSourceButton(); - this._buttonStart$.getValue = (): number => 0; - - this._handLeftPosition$ = new InputSourcePosition(); - this._handLeftPosition$.getValue = (): Readonly => Vec3.ZERO; - this._handLeftOrientation$ = new InputSourceOrientation(); - this._handLeftOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._handRightPosition$ = new InputSourcePosition(); - this._handRightPosition$.getValue = (): Readonly => Vec3.ZERO; - this._handRightOrientation$ = new InputSourceOrientation(); - this._handRightOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._aimLeftPosition$ = new InputSourcePosition(); - this._aimLeftPosition$.getValue = (): Readonly => Vec3.ZERO; - this._aimLeftOrientation$ = new InputSourceOrientation(); - this._aimLeftOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._aimRightPosition$ = new InputSourcePosition(); - this._aimRightPosition$.getValue = (): Readonly => Vec3.ZERO; - this._aimRightOrientation$ = new InputSourceOrientation(); - this._aimRightOrientation$.getValue = (): Readonly => Quat.IDENTITY; - - this._touchButtonA$ = new InputSourceTouch(); - this._touchButtonA$.getValue = (): number => 0; - this._touchButtonB$ = new InputSourceTouch(); - this._touchButtonB$.getValue = (): number => 0; - this._touchButtonX$ = new InputSourceTouch(); - this._touchButtonX$.getValue = (): number => 0; - this._touchButtonY$ = new InputSourceTouch(); - this._touchButtonY$.getValue = (): number => 0; - this._touchButtonTriggerLeft$ = new InputSourceTouch(); - this._touchButtonTriggerLeft$.getValue = (): number => 0; - this._touchButtonTriggerRight$ = new InputSourceTouch(); - this._touchButtonTriggerRight$.getValue = (): number => 0; - this._touchButtonThumbStickLeft$ = new InputSourceTouch(); - this._touchButtonThumbStickLeft$.getValue = (): number => 0; - this._touchButtonThumbStickRight$ = new InputSourceTouch(); - this._touchButtonThumbStickRight$.getValue = (): number => 0; + this._rightStick = new InputSourceStick({ up: rightStickUp, down: rightStickDown, left: rightStickLeft, right: rightStickRight }); + + this._buttonOptions = new InputSourceButton(); + this._buttonOptions.getValue = (): number => 0; + this._buttonStart = new InputSourceButton(); + this._buttonStart.getValue = (): number => 0; + + this._handLeftPosition = new InputSourcePosition(); + this._handLeftPosition.getValue = (): Readonly => Vec3.ZERO; + this._handLeftOrientation = new InputSourceOrientation(); + this._handLeftOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._handRightPosition = new InputSourcePosition(); + this._handRightPosition.getValue = (): Readonly => Vec3.ZERO; + this._handRightOrientation = new InputSourceOrientation(); + this._handRightOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._aimLeftPosition = new InputSourcePosition(); + this._aimLeftPosition.getValue = (): Readonly => Vec3.ZERO; + this._aimLeftOrientation = new InputSourceOrientation(); + this._aimLeftOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._aimRightPosition = new InputSourcePosition(); + this._aimRightPosition.getValue = (): Readonly => Vec3.ZERO; + this._aimRightOrientation = new InputSourceOrientation(); + this._aimRightOrientation.getValue = (): Readonly => Quat.IDENTITY; + + this._touchButtonA = new InputSourceTouch(); + this._touchButtonA.getValue = (): number => 0; + this._touchButtonB = new InputSourceTouch(); + this._touchButtonB.getValue = (): number => 0; + this._touchButtonX = new InputSourceTouch(); + this._touchButtonX.getValue = (): number => 0; + this._touchButtonY = new InputSourceTouch(); + this._touchButtonY.getValue = (): number => 0; + this._touchButtonTriggerLeft = new InputSourceTouch(); + this._touchButtonTriggerLeft.getValue = (): number => 0; + this._touchButtonTriggerRight = new InputSourceTouch(); + this._touchButtonTriggerRight.getValue = (): number => 0; + this._touchButtonThumbStickLeft = new InputSourceTouch(); + this._touchButtonThumbStickLeft.getValue = (): number => 0; + this._touchButtonThumbStickRight = new InputSourceTouch(); + this._touchButtonThumbStickRight.getValue = (): number => 0; } } diff --git a/pal/input/minigame/hmd-input.ts b/pal/input/minigame/hmd-input.ts index 72b2ed2b233..20ebe8a167e 100644 --- a/pal/input/minigame/hmd-input.ts +++ b/pal/input/minigame/hmd-input.ts @@ -29,47 +29,47 @@ import { InputSourcePosition, InputSourceOrientation } from '../input-source'; import { Vec3, Quat } from '../../../cocos/core/math'; export class HMDInputDevice { - public get viewLeftPosition (): InputSourcePosition { return this._viewLeftPosition$; } - public get viewLeftOrientation (): InputSourceOrientation { return this._viewLeftOrientation$; } - public get viewRightPosition (): InputSourcePosition { return this._viewRightPosition$; } - public get viewRightOrientation (): InputSourceOrientation { return this._viewRightOrientation$; } - public get headMiddlePosition (): InputSourcePosition { return this._headMiddlePosition$; } - public get headMiddleOrientation (): InputSourceOrientation { return this._headMiddleOrientation$; } + public get viewLeftPosition (): InputSourcePosition { return this._viewLeftPosition; } + public get viewLeftOrientation (): InputSourceOrientation { return this._viewLeftOrientation; } + public get viewRightPosition (): InputSourcePosition { return this._viewRightPosition; } + public get viewRightOrientation (): InputSourceOrientation { return this._viewRightOrientation; } + public get headMiddlePosition (): InputSourcePosition { return this._headMiddlePosition; } + public get headMiddleOrientation (): InputSourceOrientation { return this._headMiddleOrientation; } - private _eventTarget$: EventTarget = new EventTarget(); + private _eventTarget: EventTarget = new EventTarget(); - private declare _viewLeftPosition$: InputSourcePosition; - private declare _viewLeftOrientation$: InputSourceOrientation; - private declare _viewRightPosition$: InputSourcePosition; - private declare _viewRightOrientation$: InputSourceOrientation; - private declare _headMiddlePosition$: InputSourcePosition; - private declare _headMiddleOrientation$: InputSourceOrientation; + private declare _viewLeftPosition: InputSourcePosition; + private declare _viewLeftOrientation: InputSourceOrientation; + private declare _viewRightPosition: InputSourcePosition; + private declare _viewRightOrientation: InputSourceOrientation; + private declare _headMiddlePosition: InputSourcePosition; + private declare _headMiddleOrientation: InputSourceOrientation; constructor () { - this._initInputSource$(); + this._initInputSource(); } /** * @engineInternal */ public _on (eventType: InputEventType, callback: HMDCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); } - private _initInputSource$ (): void { - this._viewLeftPosition$ = new InputSourcePosition(); - this._viewLeftPosition$.getValue = (): Readonly => Vec3.ZERO; - this._viewLeftOrientation$ = new InputSourceOrientation(); - this._viewLeftOrientation$.getValue = (): Readonly => Quat.IDENTITY; + private _initInputSource (): void { + this._viewLeftPosition = new InputSourcePosition(); + this._viewLeftPosition.getValue = (): Readonly => Vec3.ZERO; + this._viewLeftOrientation = new InputSourceOrientation(); + this._viewLeftOrientation.getValue = (): Readonly => Quat.IDENTITY; - this._viewRightPosition$ = new InputSourcePosition(); - this._viewRightPosition$.getValue = (): Readonly => Vec3.ZERO; - this._viewRightOrientation$ = new InputSourceOrientation(); - this._viewRightOrientation$.getValue = (): Readonly => Quat.IDENTITY; + this._viewRightPosition = new InputSourcePosition(); + this._viewRightPosition.getValue = (): Readonly => Vec3.ZERO; + this._viewRightOrientation = new InputSourceOrientation(); + this._viewRightOrientation.getValue = (): Readonly => Quat.IDENTITY; - this._headMiddlePosition$ = new InputSourcePosition(); - this._headMiddlePosition$.getValue = (): Readonly => Vec3.ZERO; - this._headMiddleOrientation$ = new InputSourceOrientation(); - this._headMiddleOrientation$.getValue = (): Readonly => Quat.IDENTITY; + this._headMiddlePosition = new InputSourcePosition(); + this._headMiddlePosition.getValue = (): Readonly => Vec3.ZERO; + this._headMiddleOrientation = new InputSourceOrientation(); + this._headMiddleOrientation.getValue = (): Readonly => Quat.IDENTITY; } } diff --git a/pal/input/minigame/keyboard-input.ts b/pal/input/minigame/keyboard-input.ts index 8bf5e0bb16f..c78f15e7414 100644 --- a/pal/input/minigame/keyboard-input.ts +++ b/pal/input/minigame/keyboard-input.ts @@ -138,44 +138,44 @@ function getKeyCode (code: string): KeyCode { } export class KeyboardInputSource { - private _eventTarget$: EventTarget = new EventTarget(); + private _eventTarget: EventTarget = new EventTarget(); // KeyboardEvent.repeat is not supported on Wechat PC platform. - private _keyStateMap$: Record = {}; + private _keyStateMap: Record = {}; constructor () { if (systemInfo.hasFeature(Feature.EVENT_KEYBOARD)) { - this._registerEvent$(); + this._registerEvent(); } } - private _registerEvent$ (): void { + private _registerEvent (): void { minigame.wx?.onKeyDown?.((res) => { const keyCode = getKeyCode(res.code); - if (!this._keyStateMap$[keyCode]) { - const eventKeyDown = this._getInputEvent$(res, InputEventType.KEY_DOWN); - this._eventTarget$.emit(InputEventType.KEY_DOWN, eventKeyDown); + if (!this._keyStateMap[keyCode]) { + const eventKeyDown = this._getInputEvent(res, InputEventType.KEY_DOWN); + this._eventTarget.emit(InputEventType.KEY_DOWN, eventKeyDown); } else { - const eventKeyPressing = this._getInputEvent$(res, InputEventType.KEY_PRESSING); - this._eventTarget$.emit(InputEventType.KEY_PRESSING, eventKeyPressing); + const eventKeyPressing = this._getInputEvent(res, InputEventType.KEY_PRESSING); + this._eventTarget.emit(InputEventType.KEY_PRESSING, eventKeyPressing); } - this._keyStateMap$[keyCode] = true; + this._keyStateMap[keyCode] = true; }); minigame.wx?.onKeyUp?.((res) => { const keyCode = getKeyCode(res.code); - const eventKeyUp = this._getInputEvent$(res, InputEventType.KEY_UP); - this._keyStateMap$[keyCode] = false; - this._eventTarget$.emit(InputEventType.KEY_UP, eventKeyUp); + const eventKeyUp = this._getInputEvent(res, InputEventType.KEY_UP); + this._keyStateMap[keyCode] = false; + this._eventTarget.emit(InputEventType.KEY_UP, eventKeyUp); }); } - private _getInputEvent$ (event: KeyboardEventData, eventType: InputEventType): EventKeyboard { + private _getInputEvent (event: KeyboardEventData, eventType: InputEventType): EventKeyboard { const keyCode = getKeyCode(event.code); const eventKeyboard = new EventKeyboard(keyCode, eventType); return eventKeyboard; } public on (eventType: InputEventType, callback: KeyboardCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); } } diff --git a/pal/input/minigame/mouse-input.ts b/pal/input/minigame/mouse-input.ts index 7cffe0fe027..f49355b7edd 100644 --- a/pal/input/minigame/mouse-input.ts +++ b/pal/input/minigame/mouse-input.ts @@ -33,17 +33,17 @@ import { InputEventType } from '../../../cocos/input/types/event-enum'; import { Feature } from '../../system-info/enum-type'; export class MouseInputSource { - private _eventTarget$: EventTarget = new EventTarget(); - private _isPressed$ = false; - private _preMousePos$: Vec2 = new Vec2(); + private _eventTarget: EventTarget = new EventTarget(); + private _isPressed = false; + private _preMousePos: Vec2 = new Vec2(); constructor () { if (systemInfo.hasFeature(Feature.EVENT_MOUSE)) { - this._registerEvent$(); + this._registerEvent(); } } - private _getLocation$ (event: MouseEventData): Vec2 { + private _getLocation (event: MouseEventData): Vec2 { const windowSize = screenAdapter.windowSize; const dpr = screenAdapter.devicePixelRatio; const x = event.x * dpr; @@ -51,26 +51,26 @@ export class MouseInputSource { return new Vec2(x, y); } - private _registerEvent$ (): void { - minigame.wx?.onMouseDown?.(this._createCallback$(InputEventType.MOUSE_DOWN)); - minigame.wx?.onMouseMove?.(this._createCallback$(InputEventType.MOUSE_MOVE)); - minigame.wx?.onMouseUp?.(this._createCallback$(InputEventType.MOUSE_UP)); - minigame.wx?.onWheel?.(this._handleMouseWheel$.bind(this)); + private _registerEvent (): void { + minigame.wx?.onMouseDown?.(this._createCallback(InputEventType.MOUSE_DOWN)); + minigame.wx?.onMouseMove?.(this._createCallback(InputEventType.MOUSE_MOVE)); + minigame.wx?.onMouseUp?.(this._createCallback(InputEventType.MOUSE_UP)); + minigame.wx?.onWheel?.(this._handleMouseWheel.bind(this)); } - private _createCallback$ (eventType: InputEventType) { + private _createCallback (eventType: InputEventType) { return (event: MouseEventData): void => { - const location = this._getLocation$(event); + const location = this._getLocation(event); let button = event.button; switch (eventType) { case InputEventType.MOUSE_DOWN: - this._isPressed$ = true; + this._isPressed = true; break; case InputEventType.MOUSE_UP: - this._isPressed$ = false; + this._isPressed = false; break; case InputEventType.MOUSE_MOVE: - if (!this._isPressed$) { + if (!this._isPressed) { button = EventMouse.BUTTON_MISSING; } break; @@ -78,36 +78,40 @@ export class MouseInputSource { break; } - const eventMouse = new EventMouse(eventType, false, this._preMousePos$); + const eventMouse = new EventMouse(eventType, false, this._preMousePos); eventMouse.setLocation(location.x, location.y); eventMouse.setButton(button); - eventMouse.movementX = location.x - this._preMousePos$.x; - eventMouse.movementY = this._preMousePos$.y - location.y; + eventMouse.movementX = location.x - this._preMousePos.x; + eventMouse.movementY = this._preMousePos.y - location.y; // update previous mouse position. - this._preMousePos$.set(location.x, location.y); - this._eventTarget$.emit(eventType, eventMouse); + this._preMousePos.set(location.x, location.y); + this._eventTarget.emit(eventType, eventMouse); }; } - private _handleMouseWheel$ (event: MouseWheelEventData): void { + private _handleMouseWheel (event: MouseWheelEventData): void { const eventType = InputEventType.MOUSE_WHEEL; - const location = this._getLocation$(event); + const location = this._getLocation(event); const button = event.button; - const eventMouse = new EventMouse(eventType, false, this._preMousePos$); + const eventMouse = new EventMouse(eventType, false, this._preMousePos); eventMouse.setLocation(location.x, location.y); eventMouse.setButton(button); - eventMouse.movementX = location.x - this._preMousePos$.x; - eventMouse.movementY = this._preMousePos$.y - location.y; + eventMouse.movementX = location.x - this._preMousePos.x; + eventMouse.movementY = this._preMousePos.y - location.y; eventMouse.setScrollData(event.deltaX, -event.deltaY); // update previous mouse position. - this._preMousePos$.set(location.x, location.y); - this._eventTarget$.emit(InputEventType.MOUSE_WHEEL, eventMouse); + this._preMousePos.set(location.x, location.y); + this._eventTarget.emit(InputEventType.MOUSE_WHEEL, eventMouse); } public on (eventType: InputEventType, callback: MouseCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); + } + + public dispatchEventsInCache (): void { + // Do nothing } } diff --git a/pal/input/minigame/touch-input.ts b/pal/input/minigame/touch-input.ts index cd5ce773b0b..4413922d5fd 100644 --- a/pal/input/minigame/touch-input.ts +++ b/pal/input/minigame/touch-input.ts @@ -34,22 +34,22 @@ import { InputEventType } from '../../../cocos/input/types/event-enum'; import { Feature } from '../../system-info/enum-type'; export class TouchInputSource { - private _eventTarget$: EventTarget = new EventTarget(); + private _eventTarget: EventTarget = new EventTarget(); constructor () { if (systemInfo.hasFeature(Feature.INPUT_TOUCH)) { - this._registerEvent$(); + this._registerEvent(); } } - private _registerEvent$ (): void { - minigame.onTouchStart(this._createCallback$(InputEventType.TOUCH_START)); - minigame.onTouchMove(this._createCallback$(InputEventType.TOUCH_MOVE)); - minigame.onTouchEnd(this._createCallback$(InputEventType.TOUCH_END)); - minigame.onTouchCancel(this._createCallback$(InputEventType.TOUCH_CANCEL)); + private _registerEvent (): void { + minigame.onTouchStart(this._createCallback(InputEventType.TOUCH_START)); + minigame.onTouchMove(this._createCallback(InputEventType.TOUCH_MOVE)); + minigame.onTouchEnd(this._createCallback(InputEventType.TOUCH_END)); + minigame.onTouchCancel(this._createCallback(InputEventType.TOUCH_CANCEL)); } - private _createCallback$ (eventType: InputEventType) { + private _createCallback (eventType: InputEventType) { return (event: TouchEvent): void => { const handleTouches: Touch[] = []; const windowSize = screenAdapter.windowSize; @@ -61,7 +61,7 @@ export class TouchInputSource { if (touchID === null) { continue; } - const location = this._getLocation$(changedTouch, windowSize, dpr); + const location = this._getLocation(changedTouch, windowSize, dpr); const touch = touchManager.getOrCreateTouch(touchID, location.x, location.y); if (!touch) { continue; @@ -78,18 +78,22 @@ export class TouchInputSource { eventType, touchManager.getAllTouches(), ); - this._eventTarget$.emit(eventType, eventTouch); + this._eventTarget.emit(eventType, eventTouch); } }; } - private _getLocation$ (touch: globalThis.Touch, windowSize: Size, dpr: number): Vec2 { + private _getLocation (touch: globalThis.Touch, windowSize: Size, dpr: number): Vec2 { const x = touch.clientX * dpr; const y = windowSize.height - touch.clientY * dpr; return new Vec2(x, y); } public on (eventType: InputEventType, callback: TouchCallback, target?: any): void { - this._eventTarget$.on(eventType, callback, target); + this._eventTarget.on(eventType, callback, target); + } + + public dispatchEventsInCache (): void { + // Do nothing } } diff --git a/pal/input/native/mouse-input.ts b/pal/input/native/mouse-input.ts index 1a68b86ce4b..227b4b3b053 100644 --- a/pal/input/native/mouse-input.ts +++ b/pal/input/native/mouse-input.ts @@ -32,23 +32,76 @@ export type MouseCallback = (res: EventMouse) => void; declare const jsb: any; +class MouseEventElement { + type: InputEventType | null = null; + mouseEvent = { + x: 0, + y: 0, + xDelta: 0, + yDelta: 0, + button: 0, + windowId: 0, + wheelDeltaX: 0, + wheelDeltaY: 0, + }; +} + +class MouseEventCache { + private _events: MouseEventElement[] = []; + private _length = 0; + + push (eventType: InputEventType, mouseEvent?: any): void { + const events = this._events; + const index = this._length; + if (index >= events.length) { + events.push(new MouseEventElement()); + } + const e = events[index]; + e.type = eventType; + const cachedEvent = e.mouseEvent; + if (mouseEvent) { + Object.assign(cachedEvent, mouseEvent); + } else { + cachedEvent.x = cachedEvent.y = cachedEvent.xDelta = cachedEvent.yDelta = 0; + cachedEvent.button = cachedEvent.windowId = cachedEvent.wheelDeltaX = cachedEvent.wheelDeltaY = 0; + } + + ++this._length; + } + + clear (): void { + this._length = 0; + } + + forEach (cb: ((e: MouseEventElement) => void)): void { + for (let i = 0, len = this._length; i < len; ++i) { + cb(this._events[i]); + } + } +} + export class MouseInputSource { private _eventTarget: EventTarget = new EventTarget(); private _preMousePos: Vec2 = new Vec2(); private _isPressed = false; private _windowManager: any; private _pointLocked = false; + private _cache = new MouseEventCache(); private _handleMouseDown: (mouseEvent: jsb.MouseEvent) => void; private _handleMouseMove: (mouseEvent: jsb.MouseEvent) => void; private _handleMouseUp: (mouseEvent: jsb.MouseEvent) => void; - private _boundedHandleMouseWheel: (mouseEvent: jsb.MouseWheelEvent) => void; + private _handleWindowLeave: () => void; + private _handleWindowEnter: () => void; + private _handleMouseWheel: (mouseEvent: jsb.MouseWheelEvent) => void; constructor () { - this._handleMouseDown = this._createCallback(InputEventType.MOUSE_DOWN); - this._handleMouseMove = this._createCallback(InputEventType.MOUSE_MOVE); - this._handleMouseUp = this._createCallback(InputEventType.MOUSE_UP); - this._boundedHandleMouseWheel = this._handleMouseWheel.bind(this); + this._handleMouseDown = this._createEventCacheCallback(InputEventType.MOUSE_DOWN); + this._handleMouseMove = this._createEventCacheCallback(InputEventType.MOUSE_MOVE); + this._handleMouseUp = this._createEventCacheCallback(InputEventType.MOUSE_UP); + this._handleWindowLeave = this._createEventCacheCallback(InputEventType.MOUSE_LEAVE); + this._handleWindowEnter = this._createEventCacheCallback(InputEventType.MOUSE_ENTER); + this._handleMouseWheel = this._createEventCacheCallback(InputEventType.MOUSE_WHEEL); this._registerEvent(); this._windowManager = jsb.ISystemWindowManager.getInstance(); } @@ -56,7 +109,7 @@ export class MouseInputSource { public dispatchMouseDownEvent (nativeMouseEvent: any): void { this._handleMouseDown(nativeMouseEvent as jsb.MouseEvent); } public dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._handleMouseMove(nativeMouseEvent as jsb.MouseEvent); } public dispatchMouseUpEvent (nativeMouseEvent: any): void { this._handleMouseUp(nativeMouseEvent as jsb.MouseEvent); } - public dispatchScrollEvent (nativeMouseEvent: any): void { this._boundedHandleMouseWheel(nativeMouseEvent as jsb.MouseWheelEvent); } + public dispatchScrollEvent (nativeMouseEvent: any): void { this._handleMouseWheel(nativeMouseEvent as jsb.MouseWheelEvent); } private _getLocation (event: jsb.MouseEvent): Vec2 { const window = this._windowManager.getWindow(event.windowId); @@ -71,49 +124,76 @@ export class MouseInputSource { jsb.onMouseDown = this._handleMouseDown; jsb.onMouseMove = this._handleMouseMove; jsb.onMouseUp = this._handleMouseUp; - jsb.onMouseWheel = this._boundedHandleMouseWheel; + jsb.onMouseWheel = this._handleMouseWheel; jsb.onPointerlockChange = (value: boolean): void => { this._pointLocked = value; }; // Treat window leave/enter events as mouse events as web. - jsb.onWindowLeave = this._handleWindowLeave.bind(this); - jsb.onWindowEnter = this._handleWindowEnter.bind(this); + jsb.onWindowLeave = this._handleWindowLeave; + jsb.onWindowEnter = this._handleWindowEnter; + } + + private _createEventCacheCallback (eventType: InputEventType) { + return (mouseEvent?: jsb.MouseEvent | jsb.MouseWheelEvent): void => { + this._cache.push(eventType, mouseEvent); + }; } - private _createCallback (eventType: InputEventType) { - return (mouseEvent: jsb.MouseEvent): void => { - const location = this._getLocation(mouseEvent); - let button = mouseEvent.button; - switch (eventType) { - case InputEventType.MOUSE_DOWN: - this._isPressed = true; + public dispatchEventsInCache (): void { + const cache = this._cache; + + cache.forEach((e: MouseEventElement) => { + switch (e.type) { + case InputEventType.MOUSE_LEAVE: + this._dispatchWindowLeave(); break; - case InputEventType.MOUSE_UP: - this._isPressed = false; + case InputEventType.MOUSE_ENTER: + this._dispatchWindowEnter(); break; - case InputEventType.MOUSE_MOVE: - if (!this._isPressed) { - button = EventMouse.BUTTON_MISSING; - } + case InputEventType.MOUSE_WHEEL: + this._dispatchMouseWheel(e.mouseEvent as jsb.MouseWheelEvent); break; default: + this._dispatchEvent(e.type!, e.mouseEvent); break; } + }); - const eventMouse = new EventMouse(eventType, false, this._preMousePos, mouseEvent.windowId); - eventMouse.setLocation(location.x, location.y); - eventMouse.setButton(button); - const dpr = screenAdapter.devicePixelRatio; - eventMouse.movementX = typeof mouseEvent.xDelta === 'undefined' ? 0 : mouseEvent.xDelta * dpr; - eventMouse.movementY = typeof mouseEvent.yDelta === 'undefined' ? 0 : mouseEvent.yDelta * dpr; - // update previous mouse position. - this._preMousePos.set(location.x, location.y); - this._eventTarget.emit(eventType, eventMouse); - }; + cache.clear(); + } + + private _dispatchEvent (eventType: InputEventType, mouseEvent: jsb.MouseEvent): void { + const location = this._getLocation(mouseEvent); + let button = mouseEvent.button; + switch (eventType) { + case InputEventType.MOUSE_DOWN: + this._isPressed = true; + break; + case InputEventType.MOUSE_UP: + this._isPressed = false; + break; + case InputEventType.MOUSE_MOVE: + if (!this._isPressed) { + button = EventMouse.BUTTON_MISSING; + } + break; + default: + break; + } + + const eventMouse = new EventMouse(eventType, false, this._preMousePos, mouseEvent.windowId); + eventMouse.setLocation(location.x, location.y); + eventMouse.setButton(button); + const dpr = screenAdapter.devicePixelRatio; + eventMouse.movementX = typeof mouseEvent.xDelta === 'undefined' ? 0 : mouseEvent.xDelta * dpr; + eventMouse.movementY = typeof mouseEvent.yDelta === 'undefined' ? 0 : mouseEvent.yDelta * dpr; + // update previous mouse position. + this._preMousePos.set(location.x, location.y); + this._eventTarget.emit(eventType, eventMouse); } - private _handleMouseWheel (mouseEvent: jsb.MouseWheelEvent): void { + private _dispatchMouseWheel (mouseEvent: jsb.MouseWheelEvent): void { const eventType = InputEventType.MOUSE_WHEEL; const location = this._getLocation(mouseEvent); const button = mouseEvent.button; @@ -136,13 +216,13 @@ export class MouseInputSource { } // Should include window id if supporting multiple windows. - private _handleWindowLeave (): void { + private _dispatchWindowLeave (): void { const eventType = InputEventType.MOUSE_LEAVE; const eventMouse = new EventMouse(eventType, false); this._eventTarget.emit(eventType, eventMouse); } - private _handleWindowEnter (): void { + private _dispatchWindowEnter (): void { const eventType = InputEventType.MOUSE_ENTER; const eventMouse = new EventMouse(eventType, false); this._eventTarget.emit(eventType, eventMouse); diff --git a/pal/input/native/touch-input.ts b/pal/input/native/touch-input.ts index 58bf2655964..8a2a751f6bb 100644 --- a/pal/input/native/touch-input.ts +++ b/pal/input/native/touch-input.ts @@ -25,63 +25,122 @@ import { screenAdapter } from 'pal/screen-adapter'; import { Size, Vec2 } from '../../../cocos/core/math'; import { EventTarget } from '../../../cocos/core/event'; -import { EventTouch, Touch } from '../../../cocos/input/types'; +import { EventTouch, Touch as CCTouch } from '../../../cocos/input/types'; import { touchManager } from '../touch-manager'; -import { macro } from '../../../cocos/core/platform/macro'; import { InputEventType } from '../../../cocos/input/types/event-enum'; export type TouchCallback = (res: EventTouch) => void; declare const jsb: any; +class TouchEventElement { + type: InputEventType | null = null; + changedTouches: Touch[] = []; + windowId: number = 0; +} + +class TouchEventCache { + private _events: TouchEventElement[] = []; + private _length = 0; + + push (eventType: InputEventType, changedTouches: Touch[], windowId: number): void { + const events = this._events; + const index = this._length; + if (index >= events.length) { + events.push(new TouchEventElement()); + } + const e = events[index]; + const cachedTouches = e.changedTouches; + e.type = eventType; + cachedTouches.length = changedTouches.length; + e.windowId = windowId; + + for (let i = 0, len = changedTouches.length; i < len; ++i) { + const src = changedTouches[i]; + let dst = cachedTouches[i] as any; + if (!dst) { + (cachedTouches[i] as any) = dst = {}; + } + Object.assign(dst, src); + } + + ++this._length; + } + + clear (): void { + this._length = 0; + } + + forEach (cb: ((e: TouchEventElement) => void)): void { + for (let i = 0, len = this._length; i < len; ++i) { + cb(this._events[i]); + } + } +} + export class TouchInputSource { private _eventTarget: EventTarget = new EventTarget(); private _windowManager: any; + private _cache = new TouchEventCache(); + constructor () { this._registerEvent(); this._windowManager = jsb.ISystemWindowManager.getInstance(); } private _registerEvent (): void { - jsb.onTouchStart = this._createCallback(InputEventType.TOUCH_START); - jsb.onTouchMove = this._createCallback(InputEventType.TOUCH_MOVE); - jsb.onTouchEnd = this._createCallback(InputEventType.TOUCH_END); - jsb.onTouchCancel = this._createCallback(InputEventType.TOUCH_CANCEL); + jsb.onTouchStart = this._createEventCacheCallback(InputEventType.TOUCH_START); + jsb.onTouchMove = this._createEventCacheCallback(InputEventType.TOUCH_MOVE); + jsb.onTouchEnd = this._createEventCacheCallback(InputEventType.TOUCH_END); + jsb.onTouchCancel = this._createEventCacheCallback(InputEventType.TOUCH_CANCEL); + } + + private _createEventCacheCallback (eventType: InputEventType) { + return (changedTouches: Touch[], windowId: number): void => { + this._cache.push(eventType, changedTouches, windowId); + }; } - private _createCallback (eventType: InputEventType) { - return (changedTouches: TouchList, windowId: number): void => { - const handleTouches: Touch[] = []; - const length = changedTouches.length; - const windowSize = this._windowManager.getWindow(windowId).getViewSize() as Size; - for (let i = 0; i < length; ++i) { - const changedTouch = changedTouches[i]; - const touchID = changedTouch.identifier; - if (touchID === null) { - continue; - } - const location = this._getLocation(changedTouch, windowSize); - const touch = touchManager.getOrCreateTouch(touchID, location.x, location.y); - if (!touch) { - continue; - } - if (eventType === InputEventType.TOUCH_END || eventType === InputEventType.TOUCH_CANCEL) { - touchManager.releaseTouch(touchID); - } - handleTouches.push(touch); + public dispatchEventsInCache (): void { + const cache = this._cache; + cache.forEach((e: TouchEventElement) => { + this._dispatchEvent(e.type!, e.changedTouches, e.windowId); + }); + + cache.clear(); + } + + private _dispatchEvent (eventType: InputEventType, changedTouches: Touch[], windowId: number): void { + const handleTouches: CCTouch[] = []; + const length = changedTouches.length; + const windowSize = this._windowManager.getWindow(windowId).getViewSize() as Size; + for (let i = 0; i < length; ++i) { + const changedTouch = changedTouches[i]; + const touchID = changedTouch.identifier; + if (touchID === null) { + continue; } - if (handleTouches.length > 0) { - const eventTouch = new EventTouch( - handleTouches, - false, - eventType, - touchManager.getAllTouches(), - ); - eventTouch.windowId = windowId; - this._eventTarget.emit(eventType, eventTouch); + const location = this._getLocation(changedTouch, windowSize); + const touch = touchManager.getOrCreateTouch(touchID, location.x, location.y); + if (!touch) { + continue; } - }; + if (eventType === InputEventType.TOUCH_END || eventType === InputEventType.TOUCH_CANCEL) { + touchManager.releaseTouch(touchID); + } + handleTouches.push(touch); + } + if (handleTouches.length > 0) { + const eventTouch = new EventTouch( + handleTouches, + false, + eventType, + touchManager.getAllTouches(), + ); + eventTouch.windowId = windowId; + this._eventTarget.emit(eventType, eventTouch); + } } private _getLocation (touch: globalThis.Touch, windowSize: Size): Vec2 { diff --git a/pal/input/touch-manager.ts b/pal/input/touch-manager.ts index 8cabb833a05..7fec3e6628e 100644 --- a/pal/input/touch-manager.ts +++ b/pal/input/touch-manager.ts @@ -33,8 +33,8 @@ class TouchManager { /** * A map from touch ID to touch object. */ - private _touchMap$: Map = new Map(); - private readonly _maxTouches$ = 8; + private _touchMap: Map = new Map(); + private readonly _maxTouches = 8; constructor () { } @@ -50,19 +50,19 @@ class TouchManager { * @param y The y-axis coordinate of the current touch point. * @return The Touch instance or undefined. */ - private _createTouch$ (touchID: number, x: number, y: number): Touch | undefined { - if (this._touchMap$.has(touchID)) { + private _createTouch (touchID: number, x: number, y: number): Touch | undefined { + if (this._touchMap.has(touchID)) { logID(2301); return undefined; } - const checkResult = this._checkTouchMapSizeMoreThanMax$(touchID); + const checkResult = this._checkTouchMapSizeMoreThanMax(touchID); if (checkResult) { logID(2300); return undefined; } const touch = new Touch(x, y, touchID); - this._touchMap$.set(touchID, touch); - this._updateTouch$(touch, x, y); + this._touchMap.set(touchID, touch); + this._updateTouch(touch, x, y); return touch; } @@ -72,10 +72,10 @@ class TouchManager { * @returns */ public releaseTouch (touchID: number): void { - if (!this._touchMap$.has(touchID)) { + if (!this._touchMap.has(touchID)) { return; } - this._touchMap$.delete(touchID); + this._touchMap.delete(touchID); } /** @@ -84,7 +84,7 @@ class TouchManager { * @returns */ public getTouch (touchID: number): Touch | undefined { - return this._touchMap$.get(touchID); + return this._touchMap.get(touchID); } /** @@ -95,9 +95,9 @@ class TouchManager { public getOrCreateTouch (touchID: number, x: number, y: number): Touch | undefined { let touch = this.getTouch(touchID); if (!touch) { - touch = this._createTouch$(touchID, x, y); + touch = this._createTouch(touchID, x, y); } else { - this._updateTouch$(touch, x, y); + this._updateTouch(touch, x, y); } return touch; } @@ -108,7 +108,7 @@ class TouchManager { */ public getAllTouches (): Touch[] { const touches: Touch[] = []; - this._touchMap$.forEach((touch) => { + this._touchMap.forEach((touch) => { if (touch) { touches.push(touch); } @@ -120,7 +120,7 @@ class TouchManager { * Get the number of touches. */ public getTouchCount (): number { - return this._touchMap$.size; + return this._touchMap.size; } /** @@ -129,30 +129,30 @@ class TouchManager { * @param x The current location X * @param y The current location Y */ - private _updateTouch$ (touch: Touch, x: number, y: number): void { + private _updateTouch (touch: Touch, x: number, y: number): void { touch.getLocation(tempVec2); touch.setPrevPoint(tempVec2); touch.setPoint(x, y); } - private _checkTouchMapSizeMoreThanMax$ (touchID: number): boolean { - if (this._touchMap$.has(touchID)) { + private _checkTouchMapSizeMoreThanMax (touchID: number): boolean { + if (this._touchMap.has(touchID)) { return false; } - const maxSize = macro.ENABLE_MULTI_TOUCH ? this._maxTouches$ : 1; - if (this._touchMap$.size < maxSize) { + const maxSize = macro.ENABLE_MULTI_TOUCH ? this._maxTouches : 1; + if (this._touchMap.size < maxSize) { return false; } // Handle when exceed the max number of touches const now = performance.now(); - this._touchMap$.forEach((touch) => { + this._touchMap.forEach((touch) => { if (now - touch.lastModified > macro.TOUCH_TIMEOUT) { logID(2302, touch.getID()); // TODO: need to handle touch cancel event when exceed the max number of touches ? this.releaseTouch(touch.getID()); } }); - return maxSize >= this._touchMap$.size; + return maxSize >= this._touchMap.size; } } diff --git a/pal/input/web/mouse-input.ts b/pal/input/web/mouse-input.ts index e7b20fa077b..d204c99fc25 100644 --- a/pal/input/web/mouse-input.ts +++ b/pal/input/web/mouse-input.ts @@ -31,6 +31,7 @@ import { EventTarget } from '../../../cocos/core/event'; import { Rect, Vec2 } from '../../../cocos/core/math'; import { InputEventType } from '../../../cocos/input/types/event-enum'; import { Feature } from '../../system-info/enum-type'; +import { warn } from '../../../cocos/core/platform/debug'; export class MouseInputSource { private _canvas?: HTMLCanvasElement; @@ -47,7 +48,7 @@ export class MouseInputSource { if (systemInfo.hasFeature(Feature.EVENT_MOUSE)) { this._canvas = document.getElementById('GameCanvas') as HTMLCanvasElement; if (!this._canvas && !TEST && !EDITOR) { - console.warn('failed to access canvas'); + warn('failed to access canvas'); } this._handleMouseDown = this._createCallback(InputEventType.MOUSE_DOWN); @@ -60,9 +61,9 @@ export class MouseInputSource { } } - public dispatchMouseDownEvent (nativeMouseEvent: any): void { this._handleMouseDown(nativeMouseEvent); } - public dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._handleMouseMove(nativeMouseEvent); } - public dispatchMouseUpEvent (nativeMouseEvent: any): void { this._handleMouseUp(nativeMouseEvent); } + public dispatchMouseDownEvent (nativeMouseEvent: any): void { this._handleMouseDown(nativeMouseEvent as MouseEvent); } + public dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._handleMouseMove(nativeMouseEvent as MouseEvent); } + public dispatchMouseUpEvent (nativeMouseEvent: any): void { this._handleMouseUp(nativeMouseEvent as MouseEvent); } public dispatchScrollEvent (nativeMouseEvent: WheelEvent): void { this._handleMouseWheel(nativeMouseEvent); } public on (eventType: InputEventType, callback: MouseCallback, target?: any): void { @@ -208,4 +209,8 @@ export class MouseInputSource { const eventMouse = new EventMouse(eventType, false); this._eventTarget.emit(eventType, eventMouse); } + + public dispatchEventsInCache (): void { + // Do nothing + } } diff --git a/pal/input/web/touch-input.ts b/pal/input/web/touch-input.ts index 48ccb8dffe8..ff95abc940a 100644 --- a/pal/input/web/touch-input.ts +++ b/pal/input/web/touch-input.ts @@ -131,4 +131,8 @@ export class TouchInputSource { public on (eventType: InputEventType, callback: TouchCallback, target?: any): void { this._eventTarget.on(eventType, callback, target); } + + public dispatchEventsInCache (): void { + // Do nothing + } } diff --git a/pal/pacer/pacer-minigame.ts b/pal/pacer/pacer-minigame.ts index 27903f9a85d..a3b99ab2fa7 100644 --- a/pal/pacer/pacer-minigame.ts +++ b/pal/pacer/pacer-minigame.ts @@ -27,32 +27,32 @@ import { assertIsTrue } from '../../cocos/core/data/utils/asserts'; import { checkPalIntegrity, withImpl } from '../integrity-check'; export class Pacer { - private _rafHandle$ = 0; - private _onTick$: (() => void) | null = null; - private declare _updateCallback$: () => void; - private _targetFrameRate$ = 60; - private _isPlaying$ = false; + private _rafHandle = 0; + private _onTick: (() => void) | null = null; + private declare _updateCallback: () => void; + private _targetFrameRate = 60; + private _isPlaying = false; constructor () { - this._updateCallback$ = (): void => { - if (this._isPlaying$) { - this._rafHandle$ = requestAnimationFrame(this._updateCallback$); + this._updateCallback = (): void => { + if (this._isPlaying) { + this._rafHandle = requestAnimationFrame(this._updateCallback); } - if (this._onTick$) { - this._onTick$(); + if (this._onTick) { + this._onTick(); } }; } get targetFrameRate (): number { - return this._targetFrameRate$; + return this._targetFrameRate; } set targetFrameRate (val: number) { - if (this._targetFrameRate$ !== val) { + if (this._targetFrameRate !== val) { assertIsTrue(val > 0); - this._targetFrameRate$ = val; - minigame.setPreferredFramesPerSecond(this._targetFrameRate$); - if (this._isPlaying$) { + this._targetFrameRate = val; + minigame.setPreferredFramesPerSecond(this._targetFrameRate); + if (this._isPlaying) { this.stop(); this.start(); } @@ -60,24 +60,24 @@ export class Pacer { } set onTick (val: (() => void) | null) { - this._onTick$ = val; + this._onTick = val; } get onTick (): (() => void) | null { - return this._onTick$; + return this._onTick; } start (): void { - if (this._isPlaying$) return; - this._rafHandle$ = requestAnimationFrame(this._updateCallback$); - this._isPlaying$ = true; + if (this._isPlaying) return; + this._rafHandle = requestAnimationFrame(this._updateCallback); + this._isPlaying = true; } stop (): void { - if (!this._isPlaying$) return; - cancelAnimationFrame(this._rafHandle$); - this._rafHandle$ = 0; - this._isPlaying$ = false; + if (!this._isPlaying) return; + cancelAnimationFrame(this._rafHandle); + this._rafHandle = 0; + this._isPlaying = false; } } diff --git a/pal/system-info/minigame/system-info.ts b/pal/system-info/minigame/system-info.ts index b6eaeb4e870..6c36c28a6ee 100644 --- a/pal/system-info/minigame/system-info.ts +++ b/pal/system-info/minigame/system-info.ts @@ -105,8 +105,8 @@ class SystemInfo extends EventTarget { public declare readonly browserType: BrowserType; public declare readonly browserVersion: string; public declare readonly isXR: boolean; - private declare _featureMap$: IFeatureMap; - private _initPromise$: Promise[] = []; + private declare _featureMap: IFeatureMap; + private _initPromise: Promise[] = []; constructor () { super(); @@ -190,7 +190,7 @@ class SystemInfo extends EventTarget { return false; })(); - this._featureMap$ = { + this._featureMap = { [Feature.WEBP]: false, // Initialize in Promise, [Feature.IMAGE_BITMAP]: false, [Feature.WEB_VIEW]: false, @@ -210,21 +210,21 @@ class SystemInfo extends EventTarget { [Feature.WASM]: supportWasm, }; - this._initPromise$.push(this._supportsWebpPromise$()); + this._initPromise.push(this._supportsWebpPromise()); - this._registerEvent$(); + this._registerEvent(); } - private _supportsWebpPromise$ (): Promise { + private _supportsWebpPromise (): Promise { if (!TEST) { - return this._supportsWebp$().then((isSupport) => { - this._setFeature$(Feature.WEBP, isSupport); + return this._supportsWebp().then((isSupport) => { + this._setFeature(Feature.WEBP, isSupport); }); } return Promise.resolve(); } - private _supportsWebp$ (): Promise { + private _supportsWebp (): Promise { return new Promise((resolve, reject) => { if (WECHAT_MINI_PROGRAM) { resolve(true); @@ -260,7 +260,7 @@ class SystemInfo extends EventTarget { }); } - private _registerEvent$ (): void { + private _registerEvent (): void { minigame.onHide((): void => { this.emit('hide'); }); @@ -269,16 +269,16 @@ class SystemInfo extends EventTarget { }); } - private _setFeature$ (feature: Feature, value: boolean): boolean { - return this._featureMap$[feature] = value; + private _setFeature (feature: Feature, value: boolean): boolean { + return this._featureMap[feature] = value; } public init (): Promise { - return Promise.all(this._initPromise$); + return Promise.all(this._initPromise); } public hasFeature (feature: Feature): boolean { - return this._featureMap$[feature]; + return this._featureMap[feature]; } public getBatteryLevel (): number { diff --git a/tests/asset-manager/finalizer.test.ts b/tests/asset-manager/finalizer.test.ts index 5caa61ebf5c..33145019bf3 100644 --- a/tests/asset-manager/finalizer.test.ts +++ b/tests/asset-manager/finalizer.test.ts @@ -28,7 +28,7 @@ describe('releaseManager', () => { assetManager.assets.add('AAA', tex); expect(isValid(tex, true)).toBeTruthy(); // @ts-ignore - releaseManager._free$(tex, false); + releaseManager._free(tex, false); expect(assetManager.assets.count).toBe(1); expect(isValid(tex, true)).toBeTruthy(); assetManager.releaseAsset(tex); @@ -46,7 +46,7 @@ describe('releaseManager', () => { assetManager.assets.add('BBB', texB); assetManager.dependUtil._depends.add('AAA', {deps: ['BBB']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(0); }); @@ -73,7 +73,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('CCC', {deps: ['AAA', 'DDD']}); assetManager.dependUtil._depends.add('DDD', {deps: ['BBB']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(0); }); @@ -101,7 +101,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('CCC', {deps: ['AAA', 'DDD']}); assetManager.dependUtil._depends.add('DDD', {deps: ['BBB']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(4); assetManager.releaseAll(); }); @@ -128,7 +128,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('CCC', {deps: ['AAA', 'BBB']}); assetManager.dependUtil._depends.add('DDD', {deps: ['AAA']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(0); }); @@ -154,7 +154,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('CCC', {deps: ['AAA', 'BBB']}); assetManager.dependUtil._depends.add('DDD', {deps: ['AAA']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(4); assetManager.releaseAll(); }); @@ -181,7 +181,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('CCC', {deps: ['DDD']}); assetManager.dependUtil._depends.add('DDD', {deps: ['AAA']}); // @ts-ignore - releaseManager._free$(texA); + releaseManager._free(texA); expect(assetManager.assets.count).toBe(0); assetManager.releaseAll(); @@ -215,7 +215,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('scene 2', {deps: ['BBB', 'CCC']}); releaseManager._autoRelease(scene1, scene2, {}); // @ts-expect-error set private property - releaseManager._freeAssets$(); + releaseManager._freeAssets(); expect(assetManager.assets.count).toBe(2); expect(texB.refCount).toBe(1); expect(texC.refCount).toBe(1); @@ -236,7 +236,7 @@ describe('releaseManager', () => { expect(assetManager.assets.count).toBe(1); releaseManager._autoRelease(scene1, scene2, {}); // @ts-expect-error set private property - releaseManager._freeAssets$(); + releaseManager._freeAssets(); expect(assetManager.assets.count).toBe(0); }); @@ -266,7 +266,7 @@ describe('releaseManager', () => { assetManager.dependUtil._depends.add('scene 2', {deps: []}); releaseManager._autoRelease(scene1, scene2, persistNodes); // @ts-expect-error set private property - releaseManager._freeAssets$(); + releaseManager._freeAssets(); expect(assetManager.assets.count).toBe(1); expect(assetManager.assets.get('AAA')).toBe(sp); expect(sp.refCount).toBe(2); @@ -274,7 +274,7 @@ describe('releaseManager', () => { expect(sp.refCount).toBe(1); releaseManager._autoRelease(scene2, scene3, {}); // @ts-expect-error set private property - releaseManager._freeAssets$(); + releaseManager._freeAssets(); expect(assetManager.assets.count).toBe(0); }); @@ -285,7 +285,7 @@ describe('releaseManager', () => { assetManager.assets.add('TestDontDestroy', tex); expect(isValid(tex, true)).toBeTruthy(); // @ts-ignore - releaseManager._free$(tex, false); + releaseManager._free(tex, false); expect(assetManager.assets.count).toBe(1); expect(isValid(tex, true)).toBeTruthy(); assetManager.releaseAsset(tex); diff --git a/tests/core/memop/container-manager.test.ts b/tests/core/memop/container-manager.test.ts index 42af5602747..f83cf10d3a6 100644 --- a/tests/core/memop/container-manager.test.ts +++ b/tests/core/memop/container-manager.test.ts @@ -9,55 +9,55 @@ class TestContainer extends ScalableContainer { test('container', () => { // @ts-expect-error - scalableContainerManager._pools$.length = 0; + scalableContainerManager._pools.length = 0; const testContainer = new TestContainer(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(1); + expect(scalableContainerManager._pools.length).toBe(1); expect(testContainer._poolHandle).toBe(0); scalableContainerManager.addContainer(testContainer); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(1); + expect(scalableContainerManager._pools.length).toBe(1); expect(testContainer._poolHandle).toBe(0); const testContainer1 = new TestContainer(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(2); + expect(scalableContainerManager._pools.length).toBe(2); expect(testContainer1._poolHandle).toBe(1); testContainer.destroy(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(1); + expect(scalableContainerManager._pools.length).toBe(1); expect(testContainer._poolHandle).toBe(-1); expect(testContainer1._poolHandle).toBe(0); const testContainer2 = new TestContainer(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(2); + expect(scalableContainerManager._pools.length).toBe(2); expect(testContainer2._poolHandle).toBe(1); testContainer2.destroy(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(1); + expect(scalableContainerManager._pools.length).toBe(1); expect(testContainer2._poolHandle).toBe(-1); expect(testContainer1._poolHandle).toBe(0); testContainer1.destroy(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(0); + expect(scalableContainerManager._pools.length).toBe(0); expect(testContainer2._poolHandle).toBe(-1); expect(testContainer1._poolHandle).toBe(-1); expect(testContainer._poolHandle).toBe(-1); scalableContainerManager.removeContainer(testContainer1); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBe(0); + expect(scalableContainerManager._pools.length).toBe(0); }); test('shrink', () => { // @ts-expect-error - scalableContainerManager._pools$.length = 0; + scalableContainerManager._pools.length = 0; const testContainer = new TestContainer(); expect(testContainer.calledTimes).toBe(0); diff --git a/tests/core/memop/pool.test.ts b/tests/core/memop/pool.test.ts index e56fe47bb80..a2f07a17ab1 100644 --- a/tests/core/memop/pool.test.ts +++ b/tests/core/memop/pool.test.ts @@ -57,7 +57,7 @@ test('shrink', () => { // Pool available size is 10, less than 30, so will not free any object. pool.tryShrink(); // @ts-expect-error - expect(pool._nextAvail$).toEqual(9); + expect(pool._nextAvail).toEqual(9); calledTimes = 0; @@ -69,7 +69,7 @@ test('shrink', () => { pool.freeArray(test); pool.tryShrink(); // @ts-expect-error - expect(pool._nextAvail$).toEqual(29); + expect(pool._nextAvail).toEqual(29); calledTimes = 30; // Pool available size is 50, but its length is 60, so it will shrink 10 elements. @@ -83,7 +83,7 @@ test('shrink', () => { pool.tryShrink(); calledTimes = 10; // @ts-expect-error - expect(pool._nextAvail$).toEqual(39); + expect(pool._nextAvail).toEqual(39); // No matter shrink how many times, pool size will not less then shrinkThreshold. pool.tryShrink(); @@ -91,21 +91,21 @@ test('shrink', () => { pool.tryShrink(); pool.tryShrink(); // @ts-expect-error - expect(pool._nextAvail$).toEqual(29); + expect(pool._nextAvail).toEqual(29); }); test('destroy', () => { calledTimes = 0; // @ts-expect-error - const beforeDestroy = pool._nextAvail$; + const beforeDestroy = pool._nextAvail; // @ts-expect-error - expect(pool._nextAvail$).toBeGreaterThan(0); + expect(pool._nextAvail).toBeGreaterThan(0); pool.destroy(); expect(calledTimes).toBe(beforeDestroy + 1); // @ts-expect-error - expect(pool._nextAvail$).toBe(-1); + expect(pool._nextAvail).toBe(-1); // @ts-expect-error - expect(pool._freePool$.length).toBe(0); + expect(pool._freePool.length).toBe(0); }); \ No newline at end of file diff --git a/tests/core/settings.test.ts b/tests/core/settings.test.ts index fd236d20734..680dbd11598 100644 --- a/tests/core/settings.test.ts +++ b/tests/core/settings.test.ts @@ -12,7 +12,7 @@ describe('Settings', () => { test('base', () => { const settings = new Settings(); // @ts-expect-error access private property - settings._settings$ = { + settings._settings = { assets: { preloadBundles: [{ bundle: 'asddda' }, { bundle: 'internal' }], preloadAssets: ['sdd1ssq', 'hjiepoqd'], diff --git a/tests/particle/renderer.test.ts b/tests/particle/renderer.test.ts index 72489310819..089584b3dd3 100644 --- a/tests/particle/renderer.test.ts +++ b/tests/particle/renderer.test.ts @@ -10,15 +10,15 @@ test('recycle pool release', () => { scene.addChild(node); game.step(); // @ts-expect-error access private property - const beforeLength = scalableContainerManager._pools$.length; + const beforeLength = scalableContainerManager._pools.length; const comp = node.addComponent(ParticleSystem); game.step(); // @ts-expect-error access private property - const currentLength = scalableContainerManager._pools$.length; + const currentLength = scalableContainerManager._pools.length; expect(currentLength).toBeGreaterThan(beforeLength); comp.destroy(); game.step(); // @ts-expect-error - expect(scalableContainerManager._pools$.length).toBeLessThan(currentLength); + expect(scalableContainerManager._pools.length).toBeLessThan(currentLength); }); \ No newline at end of file diff --git a/tests/tween/tween.test.ts b/tests/tween/tween.test.ts index cad49dde41f..323b5a06953 100644 --- a/tests/tween/tween.test.ts +++ b/tests/tween/tween.test.ts @@ -75,7 +75,7 @@ test('to/by ITweenOption no type', function () { test('different targets in parallel', function () { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -145,7 +145,7 @@ test('different targets in parallel', function () { test('Test different target in sequence', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -241,7 +241,7 @@ test('Test different target in sequence', function() { test('Test different target in then', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -331,7 +331,7 @@ test('Test different target in then', function() { test('Test different target in clone/then', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -457,7 +457,7 @@ test('Test different target in clone/then', function() { test('Test different target in clone2', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -523,7 +523,7 @@ test('Test different target in clone2', function() { test('Test different target in re-target', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -583,7 +583,7 @@ test('Test different target in re-target', function() { test('Test different target in nest sequence 1', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; @@ -813,7 +813,7 @@ test('Test different target, union, repeat with embed tween', function() { test('Test different target in nest sequence 2', function() { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const sys = new TweenSystem(); (TweenSystem.instance as any) = sys; diff --git a/tests/ui/sprite.test.ts b/tests/ui/sprite.test.ts index ecad900f0ac..b05a02d2ee8 100644 --- a/tests/ui/sprite.test.ts +++ b/tests/ui/sprite.test.ts @@ -8,7 +8,7 @@ import { Batcher2D } from "../../cocos/2d/renderer/batcher-2d"; test('sprite.updateWorldMatrix', () => { // @ts-expect-error - director.root!._batcher$ = new Batcher2D(director.root!); + director.root!._batcher = new Batcher2D(director.root!); const scene = new Scene('test'); director.runSceneImmediate(scene);