diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 343d6ea0f86..e243ab1f049 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -129,14 +129,7 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - '@typescript-eslint/no-empty-function': [error, { - allow: [ - private-constructors, - protected-constructors, - decoratedFunctions, - overrideMethods, - ] - }] + '@typescript-eslint/no-empty-function': off # may become useful in some parent classes '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler diff --git a/cocos/gfx/base/descriptor-set.ts b/cocos/gfx/base/descriptor-set.ts index b29c0f4073e..3896f7bb8f6 100644 --- a/cocos/gfx/base/descriptor-set.ts +++ b/cocos/gfx/base/descriptor-set.ts @@ -26,7 +26,7 @@ import { Buffer } from './buffer'; import { DescriptorSetLayout } from './descriptor-set-layout'; import { Sampler } from './states/sampler'; import { Texture } from './texture'; -import { GFXObject, ObjectType, DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE, AccessFlags } from './define'; +import { GFXObject, ObjectType, DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE, AccessFlags, AccessFlagBit } from './define'; /** * @en GFX descriptor sets. @@ -96,7 +96,7 @@ export abstract class DescriptorSet extends GFXObject { * @param binding The target binding. * @param texture The texture to be bound. */ - public bindTexture (binding: number, texture: Texture, index = 0, flags?: AccessFlags): void { + 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; } if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { diff --git a/cocos/gfx/base/pipeline-state.ts b/cocos/gfx/base/pipeline-state.ts index e7e01c375c9..a7f5848b05a 100644 --- a/cocos/gfx/base/pipeline-state.ts +++ b/cocos/gfx/base/pipeline-state.ts @@ -26,21 +26,12 @@ import { PipelineLayout } from './pipeline-layout'; import { RenderPass } from './render-pass'; import { Shader } from './shader'; import { - BlendFactor, - BlendOp, - ColorMask, - ComparisonFunc, - CullMode, DynamicStateFlagBit, DynamicStateFlags, GFXObject, ObjectType, - PolygonMode, PrimitiveMode, - ShadeModel, - StencilOp, InputState, - Color, PipelineBindPoint, } from './define'; import { BlendState, BlendTarget, RasterizerState, DepthStencilState } from './pipeline-sub-state'; diff --git a/cocos/gfx/base/states/sampler.ts b/cocos/gfx/base/states/sampler.ts index 7dee689f6ed..887339117a0 100644 --- a/cocos/gfx/base/states/sampler.ts +++ b/cocos/gfx/base/states/sampler.ts @@ -43,13 +43,13 @@ export class Sampler extends GFXObject { static computeHash (info: Readonly): Filter { let hash = info.minFilter; - hash |= (info.magFilter << 2); - hash |= (info.mipFilter << 4); - hash |= (info.addressU << 6); - hash |= (info.addressV << 8); - hash |= (info.addressW << 10); + hash |= ((info.magFilter as number) << 2); + hash |= ((info.mipFilter as number) << 4); + hash |= ((info.addressU as number) << 6); + hash |= ((info.addressV as number) << 8); + hash |= ((info.addressW as number) << 10); hash |= (info.maxAnisotropy << 12); - hash |= (info.cmpFunc << 16); + hash |= ((info.cmpFunc as number) << 16); return hash; } diff --git a/cocos/gfx/empty/empty-command-buffer.ts b/cocos/gfx/empty/empty-command-buffer.ts index b3de2aadc95..4355538a03b 100644 --- a/cocos/gfx/empty/empty-command-buffer.ts +++ b/cocos/gfx/empty/empty-command-buffer.ts @@ -43,10 +43,16 @@ export class EmptyCommandBuffer extends CommandBuffer { this._queue = info.queue; } public destroy (): void {} - public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer): void {} + public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void {} public end (): void {} - public beginRenderPass (renderPass: RenderPass, framebuffer: Framebuffer, renderArea: Readonly, - clearColors: Readonly, clearDepth: number, clearStencil: number): void {} + public beginRenderPass ( + renderPass: RenderPass, + framebuffer: Framebuffer, + renderArea: Readonly, + clearColors: Readonly, + clearDepth: number, + clearStencil: number, + ): void {} public endRenderPass (): void {} public bindPipelineState (pipelineState: PipelineState): void {} public bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: Readonly): void {} @@ -63,9 +69,12 @@ export class EmptyCommandBuffer extends CommandBuffer { public updateBuffer (buffer: Buffer, data: Readonly, size?: number): void {} public copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: Readonly): void {} public execute (cmdBuffs: Readonly, count: number): void {} - public pipelineBarrier (GeneralBarrier: Readonly, bufferBarriers?: Readonly, + public pipelineBarrier ( + GeneralBarrier: Readonly, + bufferBarriers?: Readonly, buffers?: Readonly, textureBarriers?: Readonly, - textures?: Readonly): void {} + textures?: Readonly, + ): void {} public blitTexture (srcTexture: Readonly, dstTexture: Texture, regions: Readonly, filter: Filter): void {} } diff --git a/cocos/gfx/webgl/webgl-buffer.ts b/cocos/gfx/webgl/webgl-buffer.ts index 9f6c308dc61..66101b608d1 100644 --- a/cocos/gfx/webgl/webgl-buffer.ts +++ b/cocos/gfx/webgl/webgl-buffer.ts @@ -33,6 +33,7 @@ import { } from './webgl-commands'; import { IWebGLGPUBuffer, IWebGLGPUBufferView, WebGLIndirectDrawInfos } from './webgl-gpu-objects'; import { WebGLDeviceManager } from './webgl-define'; +import { warn } from '../../core'; export class WebGLBuffer extends Buffer { get gpuBuffer (): IWebGLGPUBuffer { @@ -112,7 +113,7 @@ export class WebGLBuffer extends Buffer { public resize (size: number): void { if (this._isBufferView) { - console.warn('cannot resize buffer views!'); + warn('cannot resize buffer views!'); return; } @@ -142,7 +143,7 @@ export class WebGLBuffer extends Buffer { public update (buffer: Readonly, size?: number): void { if (this._isBufferView) { - console.warn('cannot update through buffer views!'); + warn('cannot update through buffer views!'); return; } diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index c41205649d3..cbeed1907fc 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -47,6 +47,7 @@ import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; import { WebGLDeviceManager } from './webgl-define'; +import { error } from '../../core'; export class WebGLCommandBuffer extends CommandBuffer { public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage(); @@ -74,7 +75,7 @@ export class WebGLCommandBuffer extends CommandBuffer { this._cmdAllocator.clearCmds(this.cmdPackage); } - public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer): void { + public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { this._cmdAllocator.clearCmds(this.cmdPackage); this._curGPUPipelineState = null; this._curGPUInputAssembler = null; @@ -295,7 +296,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -331,7 +332,7 @@ export class WebGLCommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGLCmd.UPDATE_BUFFER); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -353,7 +354,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index 22844ba116d..e428927c9f8 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -501,9 +501,7 @@ export class WebGLCmdDraw extends WebGLCmdObject { super(WebGLCmd.DRAW); } - public clear (): void { - // - } + public clear (): void {} } export class WebGLCmdUpdateBuffer extends WebGLCmdObject { diff --git a/cocos/gfx/webgl/webgl-gpu-objects.ts b/cocos/gfx/webgl/webgl-gpu-objects.ts index 8abff6d139d..79058b028a1 100644 --- a/cocos/gfx/webgl/webgl-gpu-objects.ts +++ b/cocos/gfx/webgl/webgl-gpu-objects.ts @@ -341,12 +341,16 @@ export class IWebGLBlitManager { this._gpuShader = { name: 'Blit Pass', blocks: [ - new UniformBlock(0, 0, `BlitParams`, + new UniformBlock( + 0, + 0, + `BlitParams`, [ new Uniform(`tilingOffsetSrc`, Type.FLOAT4, 1), new Uniform(`tilingOffsetDst`, Type.FLOAT4, 1), ], - 1), + 1, + ), ], samplerTextures: [new UniformSamplerTexture(0, samplerOffset, 'textureSrc', Type.SAMPLER2D, 1)], subpassInputs: [], @@ -538,7 +542,7 @@ export class IWebGLBlitManager { descriptor.gpuSampler = filter === Filter.POINT ? this._gpuPointSampler : this._gpuLinearSampler; const formatInfo = FormatInfos[gpuTextureDst.format]; - let attachment = gl.COLOR_ATTACHMENT0; + let attachment: number = gl.COLOR_ATTACHMENT0; if (formatInfo.hasStencil) { attachment = gl.DEPTH_STENCIL_ATTACHMENT; } else if (formatInfo.hasDepth) { @@ -582,8 +586,13 @@ export class IWebGLBlitManager { this._uniformBuffer[6] = region.dstOffset.x / dstWidth; this._uniformBuffer[7] = region.dstOffset.y / dstHeight; - WebGLCmdFuncUpdateBuffer(device, this._gpuUniformBuffer, this._uniformBuffer, 0, - this._uniformBuffer.length * Float32Array.BYTES_PER_ELEMENT); + WebGLCmdFuncUpdateBuffer( + device, + this._gpuUniformBuffer, + this._uniformBuffer, + 0, + this._uniformBuffer.length * Float32Array.BYTES_PER_ELEMENT, + ); WebGLCmdFuncBindStates(device, this._gpuPipelineState, this._gpuInputAssembler, [this._gpuDescriptorSet], [], null!); WebGLCmdFuncDraw(device, this._drawInfo); } diff --git a/cocos/gfx/webgl2/webgl2-buffer.ts b/cocos/gfx/webgl2/webgl2-buffer.ts index a9f868dd156..c600d7f3380 100644 --- a/cocos/gfx/webgl2/webgl2-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-buffer.ts @@ -22,6 +22,7 @@ THE SOFTWARE. */ +import { warn } from '../../core'; import { Buffer } from '../base/buffer'; import { BufferUsageBit, BufferSource, BufferInfo, BufferViewInfo } from '../base/define'; import { @@ -101,7 +102,7 @@ export class WebGL2Buffer extends Buffer { public resize (size: number): void { if (this._isBufferView) { - console.warn('cannot resize buffer views!'); + warn('cannot resize buffer views!'); return; } @@ -123,7 +124,7 @@ export class WebGL2Buffer extends Buffer { public update (buffer: Readonly, size?: number): void { if (this._isBufferView) { - console.warn('cannot update through buffer views!'); + warn('cannot update through buffer views!'); return; } diff --git a/cocos/gfx/webgl2/webgl2-command-buffer.ts b/cocos/gfx/webgl2/webgl2-command-buffer.ts index 84a3f6bdd00..8f117fc8ca5 100644 --- a/cocos/gfx/webgl2/webgl2-command-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-command-buffer.ts @@ -60,6 +60,7 @@ import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; import { WebGL2DeviceManager } from './webgl2-define'; +import { error } from '../../core'; export class WebGL2CommandBuffer extends CommandBuffer { public cmdPackage: WebGL2CmdPackage = new WebGL2CmdPackage(); @@ -87,7 +88,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { this._cmdAllocator.clearCmds(this.cmdPackage); } - public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer): void { + public begin (renderPass?: RenderPass, subpass?: number, frameBuffer?: Framebuffer): void { this._cmdAllocator.clearCmds(this.cmdPackage); this._curGPUPipelineState = null; this._curGPUInputAssembler = null; @@ -307,7 +308,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -342,7 +343,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGL2Cmd.UPDATE_BUFFER); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -362,7 +363,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGL2Cmd.COPY_BUFFER_TO_TEXTURE); } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } }