From 28a9dc71844f0275d7374e679c9250520e26ec4a Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 27 Dec 2024 19:25:48 +0800 Subject: [PATCH] issue #18056: [v3.8.6] Add @mangle jsDoc tag for gfx-webgl internal module. --- cocos/gfx/base/buffer.ts | 7 +++ cocos/gfx/base/command-buffer.ts | 5 ++ cocos/gfx/base/define.ts | 3 ++ cocos/gfx/base/descriptor-set-layout.ts | 3 ++ cocos/gfx/base/descriptor-set.ts | 6 ++- cocos/gfx/base/device.ts | 20 ++++++++ cocos/gfx/base/framebuffer.ts | 5 ++ cocos/gfx/base/input-assembler.ts | 8 ++- cocos/gfx/base/pipeline-layout.ts | 1 + cocos/gfx/base/pipeline-state.ts | 9 ++++ cocos/gfx/base/queue.ts | 1 + cocos/gfx/base/render-pass.ts | 4 ++ cocos/gfx/base/shader.ts | 5 ++ cocos/gfx/base/states/buffer-barrier.ts | 2 + cocos/gfx/base/states/general-barrier.ts | 2 + cocos/gfx/base/states/sampler.ts | 2 + cocos/gfx/base/states/texture-barrier.ts | 2 + cocos/gfx/base/swapchain.ts | 3 ++ cocos/gfx/base/texture.ts | 6 ++- cocos/gfx/webgl/webgl-command-buffer.ts | 49 ++++++++++--------- cocos/gfx/webgl/webgl-define.ts | 1 + cocos/gfx/webgl/webgl-device.ts | 2 + cocos/gfx/webgl/webgl-framebuffer.ts | 19 +++---- cocos/gfx/webgl/webgl-gpu-objects.ts | 32 +++++++++++- cocos/gfx/webgl/webgl-input-assembler.ts | 7 +-- .../gfx/webgl/webgl-primary-command-buffer.ts | 20 ++++---- cocos/gfx/webgl/webgl-swapchain.ts | 1 + cocos/gfx/webgl2/webgl2-commands.ts | 4 ++ 28 files changed, 178 insertions(+), 51 deletions(-) diff --git a/cocos/gfx/base/buffer.ts b/cocos/gfx/base/buffer.ts index 88e8a435a1f..98cd07f7459 100644 --- a/cocos/gfx/base/buffer.ts +++ b/cocos/gfx/base/buffer.ts @@ -85,12 +85,19 @@ export abstract class Buffer extends GFXObject { return this._flags; } + /** @mangle */ protected _usage: BufferUsage = BufferUsageBit.NONE; + /** @mangle */ protected _memUsage: MemoryUsage = MemoryUsageBit.NONE; + /** @mangle */ protected _size = 0; + /** @mangle */ protected _stride = 1; + /** @mangle */ protected _count = 0; + /** @mangle */ protected _flags: BufferFlags = BufferFlagBit.NONE; + /** @mangle */ protected _isBufferView = false; constructor () { diff --git a/cocos/gfx/base/command-buffer.ts b/cocos/gfx/base/command-buffer.ts index 332e0da1e83..94729392569 100644 --- a/cocos/gfx/base/command-buffer.ts +++ b/cocos/gfx/base/command-buffer.ts @@ -88,10 +88,15 @@ export abstract class CommandBuffer extends GFXObject { return this._numTris; } + /** @mangle */ protected _queue: Queue | null = null; + /** @mangle */ protected _type: CommandBufferType = CommandBufferType.PRIMARY; + /** @mangle */ protected _numDrawCalls = 0; + /** @mangle */ protected _numInstances = 0; + /** @mangle */ protected _numTris = 0; constructor () { diff --git a/cocos/gfx/base/define.ts b/cocos/gfx/base/define.ts index 1d8b60a3b8b..ef25e65537e 100644 --- a/cocos/gfx/base/define.ts +++ b/cocos/gfx/base/define.ts @@ -2017,8 +2017,11 @@ export class GFXObject extends GCObject { return this._typedID; } + /** @mangle */ protected _objectType = ObjectType.UNKNOWN; + /** @mangle */ protected _objectID = 0; + /** @mangle */ protected _typedID = 0; private static _idTable = Array(ObjectType.COUNT).fill(1 << 16); diff --git a/cocos/gfx/base/descriptor-set-layout.ts b/cocos/gfx/base/descriptor-set-layout.ts index 46eb21613a3..2f06dfdaf6b 100644 --- a/cocos/gfx/base/descriptor-set-layout.ts +++ b/cocos/gfx/base/descriptor-set-layout.ts @@ -41,8 +41,11 @@ export abstract class DescriptorSetLayout extends GFXObject { return this._descriptorIndices; } + /** @mangle */ protected _bindings: DescriptorSetLayoutBinding[] = []; + /** @mangle */ protected _bindingIndices: number[] = []; + /** @mangle */ protected _descriptorIndices: number[] = []; constructor () { diff --git a/cocos/gfx/base/descriptor-set.ts b/cocos/gfx/base/descriptor-set.ts index 3896f7bb8f6..78693689d98 100644 --- a/cocos/gfx/base/descriptor-set.ts +++ b/cocos/gfx/base/descriptor-set.ts @@ -37,11 +37,15 @@ export abstract class DescriptorSet extends GFXObject { return this._layout!; } + /** @mangle */ protected _layout: DescriptorSetLayout | null = null; + /** @mangle */ protected _buffers: Buffer[] = []; + /** @mangle */ protected _textures: Texture[] = []; + /** @mangle */ protected _samplers: Sampler[] = []; - + /** @mangle */ protected _isDirty = false; constructor () { diff --git a/cocos/gfx/base/device.ts b/cocos/gfx/base/device.ts index b0d87c2c26c..8b8eb016d31 100644 --- a/cocos/gfx/base/device.ts +++ b/cocos/gfx/base/device.ts @@ -149,25 +149,44 @@ export abstract class Device { return this._bindingMappingInfo; } + /** @mangle */ protected _gfxAPI = API.UNKNOWN; + /** @mangle */ protected _renderer = ''; + /** @mangle */ protected _vendor = ''; + /** @mangle */ protected _features = new Array(Feature.COUNT); + /** @mangle */ protected _formatFeatures = new Array(Format.COUNT); + /** @mangle */ protected _queue: Queue | null = null; + /** @mangle */ protected _cmdBuff: CommandBuffer | null = null; + /** @mangle */ protected _numDrawCalls = 0; + /** @mangle */ protected _numInstances = 0; + /** @mangle */ protected _numTris = 0; + /** @mangle */ protected _memoryStatus = new MemoryStatus(); + /** @mangle */ protected _caps = new DeviceCaps(); + /** @mangle */ protected _bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(); + /** @mangle */ protected _samplers = new Map(); + /** @mangle */ protected _generalBarrierss = new Map(); + /** @mangle */ protected _textureBarriers = new Map(); + /** @mangle */ protected _bufferBarriers = new Map(); + /** @mangle */ protected _swapchainFormat = Format.RGBA8; + /** @mangle */ public static canvas: HTMLCanvasElement; // Hack for WebGL device initialization process public abstract initialize (info: Readonly): boolean | Promise; @@ -383,6 +402,7 @@ export abstract class Device { } } +/** @mangle */ export class DefaultResource { private _texture2D: Texture | null = null; private _texture3D: Texture | null = null; diff --git a/cocos/gfx/base/framebuffer.ts b/cocos/gfx/base/framebuffer.ts index fa6f2c2e99e..bf96a4392ba 100644 --- a/cocos/gfx/base/framebuffer.ts +++ b/cocos/gfx/base/framebuffer.ts @@ -77,10 +77,15 @@ export abstract class Framebuffer extends GFXObject { return false; } + /** @mangle */ protected _renderPass: RenderPass | null = null; + /** @mangle */ protected _colorTextures: (Texture | null)[] = []; + /** @mangle */ protected _depthStencilTexture: Texture | null = null; + /** @mangle */ protected _width: number = 0; + /** @mangle */ protected _height: number = 0; constructor () { diff --git a/cocos/gfx/base/input-assembler.ts b/cocos/gfx/base/input-assembler.ts index 890b8b96477..215ede7d1b7 100644 --- a/cocos/gfx/base/input-assembler.ts +++ b/cocos/gfx/base/input-assembler.ts @@ -164,13 +164,17 @@ export abstract class InputAssembler extends GFXObject { return this._drawInfo; } + /** @mangle */ protected _attributes: Attribute[] = []; + /** @mangle */ protected _attributesHash = 0; - + /** @mangle */ protected _vertexBuffers: Buffer[] = []; + /** @mangle */ protected _indexBuffer: Buffer | null = null; + /** @mangle */ protected _indirectBuffer: Buffer | null = null; - + /** @mangle */ protected _drawInfo = new DrawInfo(); constructor () { diff --git a/cocos/gfx/base/pipeline-layout.ts b/cocos/gfx/base/pipeline-layout.ts index 677c4ac96d1..eb3b3c21744 100644 --- a/cocos/gfx/base/pipeline-layout.ts +++ b/cocos/gfx/base/pipeline-layout.ts @@ -34,6 +34,7 @@ export abstract class PipelineLayout extends GFXObject { return this._setLayouts; } + /** @mangle */ protected _setLayouts: DescriptorSetLayout[] = []; constructor () { diff --git a/cocos/gfx/base/pipeline-state.ts b/cocos/gfx/base/pipeline-state.ts index a7f5848b05a..3ea5de20488 100644 --- a/cocos/gfx/base/pipeline-state.ts +++ b/cocos/gfx/base/pipeline-state.ts @@ -132,14 +132,23 @@ export abstract class PipelineState extends GFXObject { return this._renderPass as RenderPass; } + /** @mangle */ protected _shader: Shader | null = null; + /** @mangle */ protected _pipelineLayout: PipelineLayout | null = null; + /** @mangle */ protected _primitive: PrimitiveMode = PrimitiveMode.TRIANGLE_LIST; + /** @mangle */ protected _is: InputState | null = null; + /** @mangle */ protected _rs: RasterizerState = new RasterizerState(); + /** @mangle */ protected _dss: DepthStencilState = new DepthStencilState(); + /** @mangle */ protected _bs: BlendState = new BlendState(); + /** @mangle */ protected _dynamicStates: DynamicStateFlags = DynamicStateFlagBit.NONE; + /** @mangle */ protected _renderPass: RenderPass | null = null; constructor () { diff --git a/cocos/gfx/base/queue.ts b/cocos/gfx/base/queue.ts index d80c02ed35a..c7d491ef194 100644 --- a/cocos/gfx/base/queue.ts +++ b/cocos/gfx/base/queue.ts @@ -38,6 +38,7 @@ export abstract class Queue extends GFXObject { return this._type; } + /** @mangle */ protected _type: QueueType = QueueType.GRAPHICS; constructor () { diff --git a/cocos/gfx/base/render-pass.ts b/cocos/gfx/base/render-pass.ts index 567a4061c0d..1546ce2f4a2 100644 --- a/cocos/gfx/base/render-pass.ts +++ b/cocos/gfx/base/render-pass.ts @@ -37,9 +37,13 @@ import { * @zh GFX 渲染过程。 */ export abstract class RenderPass extends GFXObject { + /** @mangle */ protected _colorInfos: ColorAttachment[] = []; + /** @mangle */ protected _depthStencilInfo: DepthStencilAttachment | null = null; + /** @mangle */ protected _subpasses: SubpassInfo[] = []; + /** @mangle */ protected _hash = 0; get colorAttachments (): Readonly { return this._colorInfos; } diff --git a/cocos/gfx/base/shader.ts b/cocos/gfx/base/shader.ts index 23554d40d22..8a8990e67f1 100644 --- a/cocos/gfx/base/shader.ts +++ b/cocos/gfx/base/shader.ts @@ -49,10 +49,15 @@ export abstract class Shader extends GFXObject { return this._stages; } + /** @mangle */ protected _name = ''; + /** @mangle */ protected _stages: ShaderStage[] = []; + /** @mangle */ protected _attributes: Attribute[] = []; + /** @mangle */ protected _blocks: UniformBlock[] = []; + /** @mangle */ protected _samplers: UniformSampler[] = []; constructor () { diff --git a/cocos/gfx/base/states/buffer-barrier.ts b/cocos/gfx/base/states/buffer-barrier.ts index 9e236c2ee1c..6dcde4cb350 100644 --- a/cocos/gfx/base/states/buffer-barrier.ts +++ b/cocos/gfx/base/states/buffer-barrier.ts @@ -33,7 +33,9 @@ export class BufferBarrier extends GFXObject { get info (): Readonly { return this._info; } get hash (): number { return this._hash; } + /** @mangle */ protected _info: BufferBarrierInfo = new BufferBarrierInfo(); + /** @mangle */ protected _hash = 0; constructor (info: Readonly, hash: number) { diff --git a/cocos/gfx/base/states/general-barrier.ts b/cocos/gfx/base/states/general-barrier.ts index 2c0505fc958..8efbdddf6d5 100644 --- a/cocos/gfx/base/states/general-barrier.ts +++ b/cocos/gfx/base/states/general-barrier.ts @@ -33,7 +33,9 @@ export class GeneralBarrier extends GFXObject { get info (): Readonly { return this._info; } get hash (): number { return this._hash; } + /** @mangle */ protected _info: GeneralBarrierInfo = new GeneralBarrierInfo(); + /** @mangle */ protected _hash = 0; constructor (info: Readonly, hash: number) { diff --git a/cocos/gfx/base/states/sampler.ts b/cocos/gfx/base/states/sampler.ts index 056699ac0be..411029e6c4d 100644 --- a/cocos/gfx/base/states/sampler.ts +++ b/cocos/gfx/base/states/sampler.ts @@ -32,7 +32,9 @@ export class Sampler extends GFXObject { get info (): Readonly { return this._info; } get hash (): number { return this._hash; } + /** @mangle */ protected _info: SamplerInfo = new SamplerInfo(); + /** @mangle */ protected _hash = 0; constructor (info: Readonly, hash: number) { diff --git a/cocos/gfx/base/states/texture-barrier.ts b/cocos/gfx/base/states/texture-barrier.ts index c2fafb876ff..965d5435e65 100644 --- a/cocos/gfx/base/states/texture-barrier.ts +++ b/cocos/gfx/base/states/texture-barrier.ts @@ -33,7 +33,9 @@ export class TextureBarrier extends GFXObject { get info (): Readonly { return this._info; } get hash (): number { return this._hash; } + /** @mangle */ protected _info: TextureBarrierInfo = new TextureBarrierInfo(); + /** @mangle */ protected _hash = 0; constructor (info: Readonly, hash: number) { diff --git a/cocos/gfx/base/swapchain.ts b/cocos/gfx/base/swapchain.ts index 1be61edf23a..839e9a1b61f 100644 --- a/cocos/gfx/base/swapchain.ts +++ b/cocos/gfx/base/swapchain.ts @@ -62,8 +62,11 @@ export abstract class Swapchain extends GFXObject { return this._colorTexture.height; } + /** @mangle */ protected _transform = SurfaceTransform.IDENTITY; + /** @mangle */ protected _colorTexture: Texture = null!; + /** @mangle */ protected _depthStencilTexture: Texture = null!; constructor () { diff --git a/cocos/gfx/base/texture.ts b/cocos/gfx/base/texture.ts index 81d4e10a792..b8c98032a5f 100644 --- a/cocos/gfx/base/texture.ts +++ b/cocos/gfx/base/texture.ts @@ -153,11 +153,15 @@ export abstract class Texture extends GFXObject { return this._isTextureView; } + /** @mangle */ protected _info: TextureInfo = new TextureInfo(); + /** @mangle */ protected _viewInfo: TextureViewInfo = new TextureViewInfo(); - + /** @mangle */ protected _isPowerOf2 = false; + /** @mangle */ protected _isTextureView = false; + /** @mangle */ protected _size = 0; constructor () { diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index c4557640c63..c99f5d18bd4 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -42,6 +42,7 @@ import { BufferBarrier } from '../base/states/buffer-barrier'; import { WebGLDeviceManager } from './webgl-define'; import { errorID } from '../../core/platform/debug'; +/** @mangle */ export class WebGLCommandBuffer extends CommandBuffer { protected _isInRenderPass = false; protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null; @@ -55,7 +56,7 @@ export class WebGLCommandBuffer extends CommandBuffer { super(); } - public initialize (info: Readonly): void { + public override initialize (info: Readonly): void { this._type = info.type; this._queue = info.queue; @@ -65,10 +66,10 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public destroy (): void { + public override destroy (): void { } - public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { + public override begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { this._curGPUPipelineState = null; this._curGPUInputAssembler = null; this._curGPUDescriptorSets.length = 0; @@ -77,7 +78,7 @@ export class WebGLCommandBuffer extends CommandBuffer { this._numTris = 0; } - public end (): void { + public override end (): void { if (this._isStateInvalied) { this.bindStates(); } @@ -85,7 +86,7 @@ export class WebGLCommandBuffer extends CommandBuffer { this._isInRenderPass = false; } - public beginRenderPass ( + public override beginRenderPass ( renderPass: RenderPass, framebuffer: Framebuffer, renderArea: Readonly, @@ -97,11 +98,11 @@ export class WebGLCommandBuffer extends CommandBuffer { this._isInRenderPass = true; } - public endRenderPass (): void { + public override endRenderPass (): void { this._isInRenderPass = false; } - public bindPipelineState (pipelineState: PipelineState): void { + public override bindPipelineState (pipelineState: PipelineState): void { const gpuPipelineState = (pipelineState as WebGLPipelineState).gpuPipelineState; if (gpuPipelineState !== this._curGPUPipelineState) { this._curGPUPipelineState = gpuPipelineState; @@ -109,7 +110,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: Readonly): void { + public override bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: Readonly): void { const gpuDescriptorSet = (descriptorSet as WebGLDescriptorSet).gpuDescriptorSet; if (gpuDescriptorSet !== this._curGPUDescriptorSets[set]) { this._curGPUDescriptorSets[set] = gpuDescriptorSet; @@ -126,13 +127,13 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public bindInputAssembler (inputAssembler: InputAssembler): void { - const gpuInputAssembler = (inputAssembler as WebGLInputAssembler).gpuInputAssembler; + public override bindInputAssembler (inputAssembler: InputAssembler): void { + const gpuInputAssembler = (inputAssembler as WebGLInputAssembler).getGpuInputAssembler(); this._curGPUInputAssembler = gpuInputAssembler; this._isStateInvalied = true; } - public setViewport (viewport: Readonly): void { + public override setViewport (viewport: Readonly): void { const cache = this._curDynamicStates.viewport; if (cache.left !== viewport.left || cache.top !== viewport.top @@ -150,7 +151,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setScissor (scissor: Readonly): void { + public override setScissor (scissor: Readonly): void { const cache = this._curDynamicStates.scissor; if (cache.x !== scissor.x || cache.y !== scissor.y @@ -164,14 +165,14 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setLineWidth (lineWidth: number): void { + public override setLineWidth (lineWidth: number): void { if (this._curDynamicStates.lineWidth !== lineWidth) { this._curDynamicStates.lineWidth = lineWidth; this._isStateInvalied = true; } } - public setDepthBias (depthBiasConstantFactor: number, depthBiasClamp: number, depthBiasSlopeFactor: number): void { + public override setDepthBias (depthBiasConstantFactor: number, depthBiasClamp: number, depthBiasSlopeFactor: number): void { const cache = this._curDynamicStates; if (cache.depthBiasConstant !== depthBiasConstantFactor || cache.depthBiasClamp !== depthBiasClamp @@ -183,7 +184,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setBlendConstants (blendConstants: Readonly): void { + public override setBlendConstants (blendConstants: Readonly): void { const cache = this._curDynamicStates.blendConstant; if (cache.x !== blendConstants.x || cache.y !== blendConstants.y @@ -194,7 +195,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setDepthBound (minDepthBounds: number, maxDepthBounds: number): void { + public override setDepthBound (minDepthBounds: number, maxDepthBounds: number): void { const cache = this._curDynamicStates; if (cache.depthMinBounds !== minDepthBounds || cache.depthMaxBounds !== maxDepthBounds) { @@ -204,7 +205,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setStencilWriteMask (face: StencilFace, writeMask: number): void { + public override setStencilWriteMask (face: StencilFace, writeMask: number): void { const front = this._curDynamicStates.stencilStatesFront; const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { @@ -221,7 +222,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public setStencilCompareMask (face: StencilFace, reference: number, compareMask: number): void { + public override setStencilCompareMask (face: StencilFace, reference: number, compareMask: number): void { const front = this._curDynamicStates.stencilStatesFront; const back = this._curDynamicStates.stencilStatesBack; if (face & StencilFace.FRONT) { @@ -242,23 +243,23 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public draw (infoOrAssembler: Readonly | Readonly): void { + public override draw (infoOrAssembler: Readonly | Readonly): void { errorID(16328); } - public updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { + public override updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { errorID(16329); } - public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { + public override copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { errorID(16330); } - public execute (cmdBuffs: Readonly, count: number): void { + public override execute (cmdBuffs: Readonly, count: number): void { errorID(16402); } - public pipelineBarrier ( + public override pipelineBarrier ( GeneralBarrier: Readonly, bufferBarriers?: Readonly, buffers?: Readonly, @@ -272,7 +273,7 @@ export class WebGLCommandBuffer extends CommandBuffer { errorID(16401); } - public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { + public override blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { errorID(16401); } } diff --git a/cocos/gfx/webgl/webgl-define.ts b/cocos/gfx/webgl/webgl-define.ts index 39db595f0da..9ed9dcbc3f6 100644 --- a/cocos/gfx/webgl/webgl-define.ts +++ b/cocos/gfx/webgl/webgl-define.ts @@ -97,6 +97,7 @@ export enum WebGLEXT { COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD, } +/** @mangle */ export interface IWebGLExtensions { EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null; EXT_blend_minmax: EXT_blend_minmax | null; diff --git a/cocos/gfx/webgl/webgl-device.ts b/cocos/gfx/webgl/webgl-device.ts index be354dd58a6..101ef3a6d01 100644 --- a/cocos/gfx/webgl/webgl-device.ts +++ b/cocos/gfx/webgl/webgl-device.ts @@ -109,6 +109,7 @@ export class WebGLDevice extends Device { private _context: WebGLRenderingContext | null = null; private _bindingMappings: IWebGLBindingMapping | null = null; + /** @mangle */ protected _textureExclusive = new Array(Format.COUNT); public initialize (info: Readonly): boolean { @@ -267,6 +268,7 @@ export class WebGLDevice extends Device { queue.clear(); } + /** @mangle */ protected initFormatFeatures (exts: IWebGLExtensions): void { const formatFeatures = this._formatFeatures; const textureExclusive = this._textureExclusive; diff --git a/cocos/gfx/webgl/webgl-framebuffer.ts b/cocos/gfx/webgl/webgl-framebuffer.ts index f5ac220faf8..a9c2c355db9 100644 --- a/cocos/gfx/webgl/webgl-framebuffer.ts +++ b/cocos/gfx/webgl/webgl-framebuffer.ts @@ -32,7 +32,7 @@ import { WebGLRenderPass } from './webgl-render-pass'; import { WebGLTexture as CCWebGLTexture } from './webgl-texture'; export class WebGLFramebuffer extends Framebuffer { - get gpuFramebuffer (): IWebGLGPUFramebuffer { + getGpuFramebuffer (): IWebGLGPUFramebuffer { return this._gpuFramebuffer!; } @@ -45,13 +45,14 @@ 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]) { + const gpuFramebuffer = this._gpuFramebuffer; + if (gpuFramebuffer) { + for (let i = 0; i < gpuFramebuffer.gpuColorTextures.length; i++) { + if (gpuFramebuffer.gpuColorTextures[i].glTexture !== this._gpuColorTextures[i]) { return true; } } - if (this.gpuFramebuffer.gpuDepthStencilTexture?.glTexture !== this._gpuDepthStencilTexture) { + if (gpuFramebuffer.gpuDepthStencilTexture?.glTexture !== this._gpuDepthStencilTexture) { return true; } } @@ -59,7 +60,7 @@ export class WebGLFramebuffer extends Framebuffer { return false; } - public initialize (info: Readonly): void { + public override initialize (info: Readonly): void { this._renderPass = info.renderPass; this._colorTextures = info.colorTextures || []; const depthStencilTexture: CCWebGLTexture = this._depthStencilTexture = info.depthStencilTexture as CCWebGLTexture || null; @@ -115,13 +116,13 @@ export class WebGLFramebuffer extends Framebuffer { }; WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); - this.gpuFramebuffer.gpuColorTextures.forEach((tex) => this._gpuColorTextures.push(tex.glTexture)); - this._gpuDepthStencilTexture = this.gpuFramebuffer.gpuDepthStencilTexture?.glTexture; + 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 { + public override destroy (): void { if (this._gpuFramebuffer) { WebGLCmdFuncDestroyFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); this._gpuFramebuffer = null; diff --git a/cocos/gfx/webgl/webgl-gpu-objects.ts b/cocos/gfx/webgl/webgl-gpu-objects.ts index e3ca7e116bc..5299f5acb1c 100644 --- a/cocos/gfx/webgl/webgl-gpu-objects.ts +++ b/cocos/gfx/webgl/webgl-gpu-objects.ts @@ -43,6 +43,7 @@ function createInt32Array (capacity: number): Int32Array { return new Int32Array(capacity); } +/** @mangle */ export class WebGLIndirectDrawInfos { public declare counts: Int32Array; public declare offsets: Int32Array; @@ -104,6 +105,7 @@ export class WebGLIndirectDrawInfos { } } +/** @mangle */ export interface IWebGLGPUUniformInfo { name: string; type: Type; @@ -113,12 +115,14 @@ export interface IWebGLGPUUniformInfo { isDirty: boolean; } +/** @mangle */ export interface IWebGLBindingMapping { blockOffsets: number[]; samplerTextureOffsets: number[]; flexibleSet: number; } +/** @mangle */ export interface IWebGLGPUBufferView { gpuBuffer: IWebGLGPUBuffer; offset: number; @@ -126,19 +130,29 @@ export interface IWebGLGPUBufferView { } export interface IWebGLGPUBuffer { + /** @mangle */ usage: BufferUsage; + /** @mangle */ memUsage: MemoryUsage; + /** @mangle */ size: number; + /** @mangle */ stride: number; + /** @mangle */ glTarget: GLenum; + /** @mangle */ glBuffer: WebGLBuffer | null; + /** @mangle */ buffer: ArrayBufferView | null; + // Should not mangle vf32 since there is a `if ('vf32' in gpuBuffer)` code in webgl-commands.ts vf32: Float32Array | null; + /** @mangle */ indirects: WebGLIndirectDrawInfos; } +/** @mangle */ export interface IWebGLGPUTexture { type: TextureType; format: Format; @@ -164,15 +178,16 @@ export interface IWebGLGPUTexture { glWrapT: GLenum; glMinFilter: GLenum; glMagFilter: GLenum; - isSwapchainTexture: boolean; } +/** @mangle */ export interface IWebGLGPURenderPass { colorAttachments: ColorAttachment[]; depthStencilAttachment: DepthStencilAttachment | null; } +/** @mangle */ export interface IWebGLGPUFramebuffer { gpuRenderPass: IWebGLGPURenderPass; gpuColorTextures: IWebGLGPUTexture[]; @@ -184,6 +199,7 @@ export interface IWebGLGPUFramebuffer { lodLevel: number; } +/** @mangle */ export interface IWebGLGPUSampler { glMinFilter: GLenum; glMagFilter: GLenum; @@ -192,6 +208,7 @@ export interface IWebGLGPUSampler { glWrapR: GLenum; } +/** @mangle */ export interface IWebGLGPUInput { binding: number; name: string; @@ -204,6 +221,7 @@ export interface IWebGLGPUInput { glLoc: GLint; } +/** @mangle */ export interface IWebGLGPUUniform { binding: number; name: string; @@ -218,6 +236,7 @@ export interface IWebGLGPUUniform { array: Int32Array | Float32Array; } +/** @mangle */ export interface IWebGLGPUUniformBlock { set: number; binding: number; @@ -227,6 +246,7 @@ export interface IWebGLGPUUniformBlock { glActiveUniforms: IWebGLGPUUniform[]; } +/** @mangle */ export interface IWebGLGPUUniformSamplerTexture { set: number; binding: number; @@ -240,12 +260,14 @@ export interface IWebGLGPUUniformSamplerTexture { glLoc: WebGLUniformLocation; } +/** @mangle */ export interface IWebGLGPUShaderStage { type: ShaderStageFlagBit; source: string; glShader: WebGLShader | null; } +/** @mangle */ export interface IWebGLGPUShader { name: string; blocks: UniformBlock[]; @@ -260,6 +282,7 @@ export interface IWebGLGPUShader { glSamplerTextures: IWebGLGPUUniformSamplerTexture[]; } +/** @mangle */ export interface IWebGLGPUDescriptorSetLayout { bindings: DescriptorSetLayoutBinding[]; dynamicBindings: number[]; @@ -267,6 +290,7 @@ export interface IWebGLGPUDescriptorSetLayout { descriptorCount: number; } +/** @mangle */ export interface IWebGLGPUPipelineLayout { gpuSetLayouts: IWebGLGPUDescriptorSetLayout[]; dynamicOffsetCount: number; @@ -274,6 +298,7 @@ export interface IWebGLGPUPipelineLayout { dynamicOffsetIndices: number[][]; } +/** @mangle */ export interface IWebGLGPUPipelineState { glPrimitive: GLenum; gpuShader: IWebGLGPUShader | null; @@ -285,6 +310,7 @@ export interface IWebGLGPUPipelineState { gpuRenderPass: IWebGLGPURenderPass | null; } +/** @mangle */ export interface IWebGLGPUDescriptor { type: DescriptorType; gpuBuffer: IWebGLGPUBuffer | IWebGLGPUBufferView | null; @@ -292,11 +318,13 @@ export interface IWebGLGPUDescriptor { gpuSampler: IWebGLGPUSampler | null; } +/** @mangle */ export interface IWebGLGPUDescriptorSet { gpuDescriptors: IWebGLGPUDescriptor[]; descriptorIndices: number[]; } +/** @mangle */ export interface IWebGLAttrib { name: string; glBuffer: WebGLBuffer | null; @@ -310,6 +338,7 @@ export interface IWebGLAttrib { offset: number; } +/** @mangle */ export interface IWebGLGPUInputAssembler { attributes: Attribute[]; gpuVertexBuffers: IWebGLGPUBuffer[]; @@ -321,6 +350,7 @@ export interface IWebGLGPUInputAssembler { glVAOs: Map; } +/** @mangle */ export class IWebGLBlitManager { private _gpuShader: IWebGLGPUShader | null = null; private _gpuDescriptorSetLayout: IWebGLGPUDescriptorSetLayout | null = null; diff --git a/cocos/gfx/webgl/webgl-input-assembler.ts b/cocos/gfx/webgl/webgl-input-assembler.ts index 1a810a4cd9b..7b2e942bad6 100644 --- a/cocos/gfx/webgl/webgl-input-assembler.ts +++ b/cocos/gfx/webgl/webgl-input-assembler.ts @@ -30,8 +30,9 @@ import { WebGLCmdFuncCreateInputAssember, WebGLCmdFuncDestroyInputAssembler } fr import { WebGLDeviceManager } from './webgl-define'; import { IWebGLGPUInputAssembler, IWebGLGPUBuffer } from './webgl-gpu-objects'; +/** @mangle */ export class WebGLInputAssembler extends InputAssembler { - get gpuInputAssembler (): IWebGLGPUInputAssembler { + getGpuInputAssembler (): IWebGLGPUInputAssembler { return this._gpuInputAssembler!; } @@ -41,7 +42,7 @@ export class WebGLInputAssembler extends InputAssembler { super(); } - public initialize (info: Readonly): void { + public override initialize (info: Readonly): void { if (info.vertexBuffers.length === 0) { errorID(16331); return; @@ -109,7 +110,7 @@ export class WebGLInputAssembler extends InputAssembler { WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler); } - public destroy (): void { + public override destroy (): void { const device = WebGLDeviceManager.instance; if (this._gpuInputAssembler && device.extensions.useVAO) { WebGLCmdFuncDestroyInputAssembler(device, this._gpuInputAssembler); diff --git a/cocos/gfx/webgl/webgl-primary-command-buffer.ts b/cocos/gfx/webgl/webgl-primary-command-buffer.ts index d15f749ee4d..404bcf09ad8 100644 --- a/cocos/gfx/webgl/webgl-primary-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-primary-command-buffer.ts @@ -42,7 +42,7 @@ import { error, errorID } from '../../core/platform/debug'; import { WebGLConstants } from '../gl-constants'; export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { - public beginRenderPass ( + public override beginRenderPass ( renderPass: RenderPass, framebuffer: Framebuffer, renderArea: Readonly, @@ -53,7 +53,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { WebGLCmdFuncBeginRenderPass( WebGLDeviceManager.instance, (renderPass as WebGLRenderPass).gpuRenderPass, - (framebuffer as WebGLFramebuffer).gpuFramebuffer, + (framebuffer as WebGLFramebuffer).getGpuFramebuffer(), renderArea, clearColors, clearDepth, @@ -62,7 +62,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { this._isInRenderPass = true; } - public draw (infoOrAssembler: DrawInfo | InputAssembler): void { + public override draw (infoOrAssembler: DrawInfo | InputAssembler): void { if (this._isInRenderPass) { if (this._isStateInvalied) { this.bindStates(); @@ -95,7 +95,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } - public setViewport (viewport: Readonly): void { + public override setViewport (viewport: Readonly): void { const { stateCache: cache, gl } = WebGLDeviceManager.instance; if (cache.viewport.left !== viewport.left @@ -111,7 +111,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } - public setScissor (scissor: Readonly): void { + public override setScissor (scissor: Readonly): void { const { stateCache: cache, gl } = WebGLDeviceManager.instance; if (cache.scissorRect.x !== scissor.x @@ -127,7 +127,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } - public updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { + public override updateBuffer (buffer: Buffer, data: Readonly, size?: number): void { if (!this._isInRenderPass) { const gpuBuffer = (buffer as WebGLBuffer).gpuBuffer; if (gpuBuffer) { @@ -147,7 +147,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } - public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { + public override copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void { if (!this._isInRenderPass) { const gpuTexture = (texture as WebGLTexture).gpuTexture; if (gpuTexture) { @@ -158,11 +158,11 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } - public execute (cmdBuffs: Readonly, count: number): void { + public override execute (cmdBuffs: Readonly, count: number): void { errorID(16402); } - protected bindStates (): void { + protected override bindStates (): void { WebGLCmdFuncBindStates( WebGLDeviceManager.instance, this._curGPUPipelineState, @@ -174,7 +174,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { this._isStateInvalied = false; } - public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { + public override blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void { const gpuTextureSrc = (srcTexture as WebGLTexture).gpuTexture; const gpuTextureDst = (dstTexture as WebGLTexture).gpuTexture; WebGLCmdFuncBlitTexture(WebGLDeviceManager.instance, gpuTextureSrc, gpuTextureDst, regions, filter); diff --git a/cocos/gfx/webgl/webgl-swapchain.ts b/cocos/gfx/webgl/webgl-swapchain.ts index 15d5ec7c7fd..acbba38a251 100644 --- a/cocos/gfx/webgl/webgl-swapchain.ts +++ b/cocos/gfx/webgl/webgl-swapchain.ts @@ -215,6 +215,7 @@ export function getContext (canvas: HTMLCanvasElement): WebGLRenderingContext | return context; } +/** @mangle */ export class WebGLSwapchain extends Swapchain { get extensions (): IWebGLExtensions { return this._extensions as IWebGLExtensions; diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index dfa678bf4f9..690e27e5a60 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -1811,9 +1811,13 @@ export function WebGL2CmdFuncDestroyInputAssembler (device: WebGL2Device, gpuInp } interface IWebGL2StateCache { + /** mangle */ gpuPipelineState: IWebGL2GPUPipelineState | null; + /** mangle */ gpuInputAssembler: IWebGL2GPUInputAssembler | null; + /** mangle */ glPrimitive: number; + /** mangle */ invalidateAttachments: GLenum[]; } const gfxStateCache: IWebGL2StateCache = {