From 24b76fb5285ec2d359136da2941f0721d370008d Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Wed, 31 Jul 2024 19:10:04 +0800 Subject: [PATCH] use const enum, simplify object pool (#17465) * serialization simplified * use const enum * pool updated --- cocos/rendering/custom/layout-graph.ts | 99 +++----------- cocos/rendering/custom/render-graph.ts | 174 +++++-------------------- cocos/rendering/custom/types.ts | 71 +++------- cocos/rendering/custom/web-pipeline.ts | 10 +- 4 files changed, 77 insertions(+), 277 deletions(-) diff --git a/cocos/rendering/custom/layout-graph.ts b/cocos/rendering/custom/layout-graph.ts index b9ea34b5494..2e43fe85f63 100644 --- a/cocos/rendering/custom/layout-graph.ts +++ b/cocos/rendering/custom/layout-graph.ts @@ -49,7 +49,7 @@ export class RenderPhase { readonly shaders: Set = new Set(); } -export enum RenderPassType { +export const enum RenderPassType { SINGLE_RENDER_PASS, RENDER_PASS, RENDER_SUBPASS, @@ -950,68 +950,9 @@ export class LayoutGraphData implements BidirectionalGraph constantMacros = ''; } -export class LayoutGraphObjectPoolSettings { - constructor (batchSize: number) { - this.descriptorDBBatchSize = batchSize; - this.renderPhaseBatchSize = batchSize; - this.layoutGraphBatchSize = batchSize; - this.uniformDataBatchSize = batchSize; - this.uniformBlockDataBatchSize = batchSize; - this.descriptorDataBatchSize = batchSize; - this.descriptorBlockDataBatchSize = batchSize; - this.descriptorSetLayoutDataBatchSize = batchSize; - this.descriptorSetDataBatchSize = batchSize; - this.pipelineLayoutDataBatchSize = batchSize; - this.shaderBindingDataBatchSize = batchSize; - this.shaderLayoutDataBatchSize = batchSize; - this.techniqueDataBatchSize = batchSize; - this.effectDataBatchSize = batchSize; - this.shaderProgramDataBatchSize = batchSize; - this.renderStageDataBatchSize = batchSize; - this.renderPhaseDataBatchSize = batchSize; - this.layoutGraphDataBatchSize = batchSize; - } - descriptorDBBatchSize = 16; - renderPhaseBatchSize = 16; - layoutGraphBatchSize = 16; - uniformDataBatchSize = 16; - uniformBlockDataBatchSize = 16; - descriptorDataBatchSize = 16; - descriptorBlockDataBatchSize = 16; - descriptorSetLayoutDataBatchSize = 16; - descriptorSetDataBatchSize = 16; - pipelineLayoutDataBatchSize = 16; - shaderBindingDataBatchSize = 16; - shaderLayoutDataBatchSize = 16; - techniqueDataBatchSize = 16; - effectDataBatchSize = 16; - shaderProgramDataBatchSize = 16; - renderStageDataBatchSize = 16; - renderPhaseDataBatchSize = 16; - layoutGraphDataBatchSize = 16; -} - export class LayoutGraphObjectPool { - constructor (settings: LayoutGraphObjectPoolSettings, renderCommon: RenderCommonObjectPool) { + constructor (renderCommon: RenderCommonObjectPool) { this.renderCommon = renderCommon; - this._descriptorDB = new RecyclePool(() => new DescriptorDB(), settings.descriptorDBBatchSize); - this._renderPhase = new RecyclePool(() => new RenderPhase(), settings.renderPhaseBatchSize); - this._layoutGraph = new RecyclePool(() => new LayoutGraph(), settings.layoutGraphBatchSize); - this._uniformData = new RecyclePool(() => new UniformData(), settings.uniformDataBatchSize); - this._uniformBlockData = new RecyclePool(() => new UniformBlockData(), settings.uniformBlockDataBatchSize); - this._descriptorData = new RecyclePool(() => new DescriptorData(), settings.descriptorDataBatchSize); - this._descriptorBlockData = new RecyclePool(() => new DescriptorBlockData(), settings.descriptorBlockDataBatchSize); - this._descriptorSetLayoutData = new RecyclePool(() => new DescriptorSetLayoutData(), settings.descriptorSetLayoutDataBatchSize); - this._descriptorSetData = new RecyclePool(() => new DescriptorSetData(), settings.descriptorSetDataBatchSize); - this._pipelineLayoutData = new RecyclePool(() => new PipelineLayoutData(), settings.pipelineLayoutDataBatchSize); - this._shaderBindingData = new RecyclePool(() => new ShaderBindingData(), settings.shaderBindingDataBatchSize); - this._shaderLayoutData = new RecyclePool(() => new ShaderLayoutData(), settings.shaderLayoutDataBatchSize); - this._techniqueData = new RecyclePool(() => new TechniqueData(), settings.techniqueDataBatchSize); - this._effectData = new RecyclePool(() => new EffectData(), settings.effectDataBatchSize); - this._shaderProgramData = new RecyclePool(() => new ShaderProgramData(), settings.shaderProgramDataBatchSize); - this._renderStageData = new RecyclePool(() => new RenderStageData(), settings.renderStageDataBatchSize); - this._renderPhaseData = new RecyclePool(() => new RenderPhaseData(), settings.renderPhaseDataBatchSize); - this._layoutGraphData = new RecyclePool(() => new LayoutGraphData(), settings.layoutGraphDataBatchSize); } reset (): void { this._descriptorDB.reset(); @@ -1142,24 +1083,24 @@ export class LayoutGraphObjectPool { return v; } public readonly renderCommon: RenderCommonObjectPool; - private readonly _descriptorDB: RecyclePool; - private readonly _renderPhase: RecyclePool; - private readonly _layoutGraph: RecyclePool; - private readonly _uniformData: RecyclePool; - private readonly _uniformBlockData: RecyclePool; - private readonly _descriptorData: RecyclePool; - private readonly _descriptorBlockData: RecyclePool; - private readonly _descriptorSetLayoutData: RecyclePool; - private readonly _descriptorSetData: RecyclePool; - private readonly _pipelineLayoutData: RecyclePool; - private readonly _shaderBindingData: RecyclePool; - private readonly _shaderLayoutData: RecyclePool; - private readonly _techniqueData: RecyclePool; - private readonly _effectData: RecyclePool; - private readonly _shaderProgramData: RecyclePool; - private readonly _renderStageData: RecyclePool; - private readonly _renderPhaseData: RecyclePool; - private readonly _layoutGraphData: RecyclePool; + private readonly _descriptorDB: RecyclePool = new RecyclePool(() => new DescriptorDB(), 16); + private readonly _renderPhase: RecyclePool = new RecyclePool(() => new RenderPhase(), 16); + private readonly _layoutGraph: RecyclePool = new RecyclePool(() => new LayoutGraph(), 16); + private readonly _uniformData: RecyclePool = new RecyclePool(() => new UniformData(), 16); + private readonly _uniformBlockData: RecyclePool = new RecyclePool(() => new UniformBlockData(), 16); + private readonly _descriptorData: RecyclePool = new RecyclePool(() => new DescriptorData(), 16); + private readonly _descriptorBlockData: RecyclePool = new RecyclePool(() => new DescriptorBlockData(), 16); + private readonly _descriptorSetLayoutData: RecyclePool = new RecyclePool(() => new DescriptorSetLayoutData(), 16); + private readonly _descriptorSetData: RecyclePool = new RecyclePool(() => new DescriptorSetData(), 16); + private readonly _pipelineLayoutData: RecyclePool = new RecyclePool(() => new PipelineLayoutData(), 16); + private readonly _shaderBindingData: RecyclePool = new RecyclePool(() => new ShaderBindingData(), 16); + private readonly _shaderLayoutData: RecyclePool = new RecyclePool(() => new ShaderLayoutData(), 16); + private readonly _techniqueData: RecyclePool = new RecyclePool(() => new TechniqueData(), 16); + private readonly _effectData: RecyclePool = new RecyclePool(() => new EffectData(), 16); + private readonly _shaderProgramData: RecyclePool = new RecyclePool(() => new ShaderProgramData(), 16); + private readonly _renderStageData: RecyclePool = new RecyclePool(() => new RenderStageData(), 16); + private readonly _renderPhaseData: RecyclePool = new RecyclePool(() => new RenderPhaseData(), 16); + private readonly _layoutGraphData: RecyclePool = new RecyclePool(() => new LayoutGraphData(), 16); } export function saveDescriptorDB (a: OutputArchive, v: DescriptorDB): void { diff --git a/cocos/rendering/custom/render-graph.ts b/cocos/rendering/custom/render-graph.ts index b6e5845db5b..c4fa70fb838 100644 --- a/cocos/rendering/custom/render-graph.ts +++ b/cocos/rendering/custom/render-graph.ts @@ -1071,7 +1071,7 @@ export class RenderQueue { viewport: Viewport | null = null; } -export enum CullingFlags { +export const enum CullingFlags { NONE = 0, CAMERA_FRUSTUM = 0x1, LIGHT_FRUSTUM = 0x2, @@ -1654,113 +1654,9 @@ export class RenderGraph implements BidirectionalGraph readonly sortedVertices: number[] = []; } -export class RenderGraphObjectPoolSettings { - constructor (batchSize: number) { - this.clearValueBatchSize = batchSize; - this.rasterViewBatchSize = batchSize; - this.computeViewBatchSize = batchSize; - this.resourceDescBatchSize = batchSize; - this.resourceTraitsBatchSize = batchSize; - this.renderSwapchainBatchSize = batchSize; - this.resourceStatesBatchSize = batchSize; - this.managedBufferBatchSize = batchSize; - this.persistentBufferBatchSize = batchSize; - this.managedTextureBatchSize = batchSize; - this.persistentTextureBatchSize = batchSize; - this.managedResourceBatchSize = batchSize; - this.subpassBatchSize = batchSize; - this.subpassGraphBatchSize = batchSize; - this.rasterSubpassBatchSize = batchSize; - this.computeSubpassBatchSize = batchSize; - this.rasterPassBatchSize = batchSize; - this.persistentRenderPassAndFramebufferBatchSize = batchSize; - this.formatViewBatchSize = batchSize; - this.subresourceViewBatchSize = batchSize; - this.resourceGraphBatchSize = batchSize; - this.computePassBatchSize = batchSize; - this.resolvePassBatchSize = batchSize; - this.copyPassBatchSize = batchSize; - this.movePassBatchSize = batchSize; - this.raytracePassBatchSize = batchSize; - this.clearViewBatchSize = batchSize; - this.renderQueueBatchSize = batchSize; - this.sceneDataBatchSize = batchSize; - this.dispatchBatchSize = batchSize; - this.blitBatchSize = batchSize; - this.renderDataBatchSize = batchSize; - this.renderGraphBatchSize = batchSize; - } - clearValueBatchSize = 16; - rasterViewBatchSize = 16; - computeViewBatchSize = 16; - resourceDescBatchSize = 16; - resourceTraitsBatchSize = 16; - renderSwapchainBatchSize = 16; - resourceStatesBatchSize = 16; - managedBufferBatchSize = 16; - persistentBufferBatchSize = 16; - managedTextureBatchSize = 16; - persistentTextureBatchSize = 16; - managedResourceBatchSize = 16; - subpassBatchSize = 16; - subpassGraphBatchSize = 16; - rasterSubpassBatchSize = 16; - computeSubpassBatchSize = 16; - rasterPassBatchSize = 16; - persistentRenderPassAndFramebufferBatchSize = 16; - formatViewBatchSize = 16; - subresourceViewBatchSize = 16; - resourceGraphBatchSize = 16; - computePassBatchSize = 16; - resolvePassBatchSize = 16; - copyPassBatchSize = 16; - movePassBatchSize = 16; - raytracePassBatchSize = 16; - clearViewBatchSize = 16; - renderQueueBatchSize = 16; - sceneDataBatchSize = 16; - dispatchBatchSize = 16; - blitBatchSize = 16; - renderDataBatchSize = 16; - renderGraphBatchSize = 16; -} - export class RenderGraphObjectPool { - constructor (settings: RenderGraphObjectPoolSettings, renderCommon: RenderCommonObjectPool) { + constructor (renderCommon: RenderCommonObjectPool) { this.renderCommon = renderCommon; - this._clearValue = new RecyclePool(() => new ClearValue(), settings.clearValueBatchSize); - this._rasterView = new RecyclePool(() => new RasterView(), settings.rasterViewBatchSize); - this._computeView = new RecyclePool(() => new ComputeView(), settings.computeViewBatchSize); - this._resourceDesc = new RecyclePool(() => new ResourceDesc(), settings.resourceDescBatchSize); - this._resourceTraits = new RecyclePool(() => new ResourceTraits(), settings.resourceTraitsBatchSize); - this._renderSwapchain = new RecyclePool(() => new RenderSwapchain(), settings.renderSwapchainBatchSize); - this._resourceStates = new RecyclePool(() => new ResourceStates(), settings.resourceStatesBatchSize); - this._managedBuffer = new RecyclePool(() => new ManagedBuffer(), settings.managedBufferBatchSize); - this._persistentBuffer = new RecyclePool(() => new PersistentBuffer(), settings.persistentBufferBatchSize); - this._managedTexture = new RecyclePool(() => new ManagedTexture(), settings.managedTextureBatchSize); - this._persistentTexture = new RecyclePool(() => new PersistentTexture(), settings.persistentTextureBatchSize); - this._managedResource = new RecyclePool(() => new ManagedResource(), settings.managedResourceBatchSize); - this._subpass = new RecyclePool(() => new Subpass(), settings.subpassBatchSize); - this._subpassGraph = new RecyclePool(() => new SubpassGraph(), settings.subpassGraphBatchSize); - this._rasterSubpass = new RecyclePool(() => new RasterSubpass(), settings.rasterSubpassBatchSize); - this._computeSubpass = new RecyclePool(() => new ComputeSubpass(), settings.computeSubpassBatchSize); - this._rasterPass = new RecyclePool(() => new RasterPass(), settings.rasterPassBatchSize); - this._persistentRenderPassAndFramebuffer = new RecyclePool(() => new PersistentRenderPassAndFramebuffer(), settings.persistentRenderPassAndFramebufferBatchSize); - this._formatView = new RecyclePool(() => new FormatView(), settings.formatViewBatchSize); - this._subresourceView = new RecyclePool(() => new SubresourceView(), settings.subresourceViewBatchSize); - this._resourceGraph = new RecyclePool(() => new ResourceGraph(), settings.resourceGraphBatchSize); - this._computePass = new RecyclePool(() => new ComputePass(), settings.computePassBatchSize); - this._resolvePass = new RecyclePool(() => new ResolvePass(), settings.resolvePassBatchSize); - this._copyPass = new RecyclePool(() => new CopyPass(), settings.copyPassBatchSize); - this._movePass = new RecyclePool(() => new MovePass(), settings.movePassBatchSize); - this._raytracePass = new RecyclePool(() => new RaytracePass(), settings.raytracePassBatchSize); - this._clearView = new RecyclePool(() => new ClearView(), settings.clearViewBatchSize); - this._renderQueue = new RecyclePool(() => new RenderQueue(), settings.renderQueueBatchSize); - this._sceneData = new RecyclePool(() => new SceneData(), settings.sceneDataBatchSize); - this._dispatch = new RecyclePool(() => new Dispatch(), settings.dispatchBatchSize); - this._blit = new RecyclePool(() => new Blit(), settings.blitBatchSize); - this._renderData = new RecyclePool(() => new RenderData(), settings.renderDataBatchSize); - this._renderGraph = new RecyclePool(() => new RenderGraph(), settings.renderGraphBatchSize); } reset (): void { this._clearValue.reset(); @@ -2028,37 +1924,37 @@ export class RenderGraphObjectPool { return v; } public readonly renderCommon: RenderCommonObjectPool; - private readonly _clearValue: RecyclePool; - private readonly _rasterView: RecyclePool; - private readonly _computeView: RecyclePool; - private readonly _resourceDesc: RecyclePool; - private readonly _resourceTraits: RecyclePool; - private readonly _renderSwapchain: RecyclePool; - private readonly _resourceStates: RecyclePool; - private readonly _managedBuffer: RecyclePool; - private readonly _persistentBuffer: RecyclePool; - private readonly _managedTexture: RecyclePool; - private readonly _persistentTexture: RecyclePool; - private readonly _managedResource: RecyclePool; - private readonly _subpass: RecyclePool; - private readonly _subpassGraph: RecyclePool; - private readonly _rasterSubpass: RecyclePool; - private readonly _computeSubpass: RecyclePool; - private readonly _rasterPass: RecyclePool; - private readonly _persistentRenderPassAndFramebuffer: RecyclePool; - private readonly _formatView: RecyclePool; - private readonly _subresourceView: RecyclePool; - private readonly _resourceGraph: RecyclePool; - private readonly _computePass: RecyclePool; - private readonly _resolvePass: RecyclePool; - private readonly _copyPass: RecyclePool; - private readonly _movePass: RecyclePool; - private readonly _raytracePass: RecyclePool; - private readonly _clearView: RecyclePool; - private readonly _renderQueue: RecyclePool; - private readonly _sceneData: RecyclePool; - private readonly _dispatch: RecyclePool; - private readonly _blit: RecyclePool; - private readonly _renderData: RecyclePool; - private readonly _renderGraph: RecyclePool; + private readonly _clearValue: RecyclePool = new RecyclePool(() => new ClearValue(), 16); + private readonly _rasterView: RecyclePool = new RecyclePool(() => new RasterView(), 16); + private readonly _computeView: RecyclePool = new RecyclePool(() => new ComputeView(), 16); + private readonly _resourceDesc: RecyclePool = new RecyclePool(() => new ResourceDesc(), 16); + private readonly _resourceTraits: RecyclePool = new RecyclePool(() => new ResourceTraits(), 16); + private readonly _renderSwapchain: RecyclePool = new RecyclePool(() => new RenderSwapchain(), 16); + private readonly _resourceStates: RecyclePool = new RecyclePool(() => new ResourceStates(), 16); + private readonly _managedBuffer: RecyclePool = new RecyclePool(() => new ManagedBuffer(), 16); + private readonly _persistentBuffer: RecyclePool = new RecyclePool(() => new PersistentBuffer(), 16); + private readonly _managedTexture: RecyclePool = new RecyclePool(() => new ManagedTexture(), 16); + private readonly _persistentTexture: RecyclePool = new RecyclePool(() => new PersistentTexture(), 16); + private readonly _managedResource: RecyclePool = new RecyclePool(() => new ManagedResource(), 16); + private readonly _subpass: RecyclePool = new RecyclePool(() => new Subpass(), 16); + private readonly _subpassGraph: RecyclePool = new RecyclePool(() => new SubpassGraph(), 16); + private readonly _rasterSubpass: RecyclePool = new RecyclePool(() => new RasterSubpass(), 16); + private readonly _computeSubpass: RecyclePool = new RecyclePool(() => new ComputeSubpass(), 16); + private readonly _rasterPass: RecyclePool = new RecyclePool(() => new RasterPass(), 16); + private readonly _persistentRenderPassAndFramebuffer: RecyclePool = new RecyclePool(() => new PersistentRenderPassAndFramebuffer(), 16); + private readonly _formatView: RecyclePool = new RecyclePool(() => new FormatView(), 16); + private readonly _subresourceView: RecyclePool = new RecyclePool(() => new SubresourceView(), 16); + private readonly _resourceGraph: RecyclePool = new RecyclePool(() => new ResourceGraph(), 16); + private readonly _computePass: RecyclePool = new RecyclePool(() => new ComputePass(), 16); + private readonly _resolvePass: RecyclePool = new RecyclePool(() => new ResolvePass(), 16); + private readonly _copyPass: RecyclePool = new RecyclePool(() => new CopyPass(), 16); + private readonly _movePass: RecyclePool = new RecyclePool(() => new MovePass(), 16); + private readonly _raytracePass: RecyclePool = new RecyclePool(() => new RaytracePass(), 16); + private readonly _clearView: RecyclePool = new RecyclePool(() => new ClearView(), 16); + private readonly _renderQueue: RecyclePool = new RecyclePool(() => new RenderQueue(), 16); + private readonly _sceneData: RecyclePool = new RecyclePool(() => new SceneData(), 16); + private readonly _dispatch: RecyclePool = new RecyclePool(() => new Dispatch(), 16); + private readonly _blit: RecyclePool = new RecyclePool(() => new Blit(), 16); + private readonly _renderData: RecyclePool = new RecyclePool(() => new RenderData(), 16); + private readonly _renderGraph: RecyclePool = new RecyclePool(() => new RenderGraph(), 16); } diff --git a/cocos/rendering/custom/types.ts b/cocos/rendering/custom/types.ts index 2b07c25deba..a1d7045370e 100644 --- a/cocos/rendering/custom/types.ts +++ b/cocos/rendering/custom/types.ts @@ -43,7 +43,7 @@ export enum UpdateFrequency { COUNT, } -export enum ParameterType { +export const enum ParameterType { CONSTANTS, CBV, UAV, @@ -91,7 +91,7 @@ export enum ResourceFlags { TRANSFER_DST = 0x200, } -export enum TaskType { +export const enum TaskType { SYNC, ASYNC, } @@ -120,13 +120,13 @@ export enum SceneFlags { ALL = 0xFFFFFFFF, } -export enum LightingMode { +export const enum LightingMode { NONE, DEFAULT, CLUSTERED, } -export enum AttachmentType { +export const enum AttachmentType { RENDER_TARGET, DEPTH_STENCIL, SHADING_RATE, @@ -138,7 +138,7 @@ export enum AccessType { WRITE, } -export enum ClearValueType { +export const enum ClearValueType { NONE, FLOAT_TYPE, INT_TYPE, @@ -163,7 +163,7 @@ export class LightInfo { culledByLight: boolean; } -export enum DescriptorTypeOrder { +export const enum DescriptorTypeOrder { UNIFORM_BUFFER, DYNAMIC_UNIFORM_BUFFER, SAMPLER_TEXTURE, @@ -230,7 +230,7 @@ export class DescriptorBlockIndex { visibility: ShaderStageFlagBit; } -export enum ResolveFlags { +export const enum ResolveFlags { NONE = 0, COLOR = 1 << 0, DEPTH = 1 << 1, @@ -444,43 +444,8 @@ export class PipelineStatistics { numInstancingUniformBlocks = 0; } -export class RenderCommonObjectPoolSettings { - constructor (batchSize: number) { - this.lightInfoBatchSize = batchSize; - this.descriptorBatchSize = batchSize; - this.descriptorBlockBatchSize = batchSize; - this.descriptorBlockFlattenedBatchSize = batchSize; - this.descriptorBlockIndexBatchSize = batchSize; - this.resolvePairBatchSize = batchSize; - this.copyPairBatchSize = batchSize; - this.uploadPairBatchSize = batchSize; - this.movePairBatchSize = batchSize; - this.pipelineStatisticsBatchSize = batchSize; - } - lightInfoBatchSize = 16; - descriptorBatchSize = 16; - descriptorBlockBatchSize = 16; - descriptorBlockFlattenedBatchSize = 16; - descriptorBlockIndexBatchSize = 16; - resolvePairBatchSize = 16; - copyPairBatchSize = 16; - uploadPairBatchSize = 16; - movePairBatchSize = 16; - pipelineStatisticsBatchSize = 16; -} - export class RenderCommonObjectPool { - constructor (settings: RenderCommonObjectPoolSettings) { - this._lightInfo = new RecyclePool(() => new LightInfo(), settings.lightInfoBatchSize); - this._descriptor = new RecyclePool(() => new Descriptor(), settings.descriptorBatchSize); - this._descriptorBlock = new RecyclePool(() => new DescriptorBlock(), settings.descriptorBlockBatchSize); - this._descriptorBlockFlattened = new RecyclePool(() => new DescriptorBlockFlattened(), settings.descriptorBlockFlattenedBatchSize); - this._descriptorBlockIndex = new RecyclePool(() => new DescriptorBlockIndex(), settings.descriptorBlockIndexBatchSize); - this._resolvePair = new RecyclePool(() => new ResolvePair(), settings.resolvePairBatchSize); - this._copyPair = new RecyclePool(() => new CopyPair(), settings.copyPairBatchSize); - this._uploadPair = new RecyclePool(() => new UploadPair(), settings.uploadPairBatchSize); - this._movePair = new RecyclePool(() => new MovePair(), settings.movePairBatchSize); - this._pipelineStatistics = new RecyclePool(() => new PipelineStatistics(), settings.pipelineStatisticsBatchSize); + constructor () { } reset (): void { this._lightInfo.reset(); @@ -591,16 +556,16 @@ export class RenderCommonObjectPool { v.reset(); return v; } - private readonly _lightInfo: RecyclePool; - private readonly _descriptor: RecyclePool; - private readonly _descriptorBlock: RecyclePool; - private readonly _descriptorBlockFlattened: RecyclePool; - private readonly _descriptorBlockIndex: RecyclePool; - private readonly _resolvePair: RecyclePool; - private readonly _copyPair: RecyclePool; - private readonly _uploadPair: RecyclePool; - private readonly _movePair: RecyclePool; - private readonly _pipelineStatistics: RecyclePool; + private readonly _lightInfo: RecyclePool = new RecyclePool(() => new LightInfo(), 16); + private readonly _descriptor: RecyclePool = new RecyclePool(() => new Descriptor(), 16); + private readonly _descriptorBlock: RecyclePool = new RecyclePool(() => new DescriptorBlock(), 16); + private readonly _descriptorBlockFlattened: RecyclePool = new RecyclePool(() => new DescriptorBlockFlattened(), 16); + private readonly _descriptorBlockIndex: RecyclePool = new RecyclePool(() => new DescriptorBlockIndex(), 16); + private readonly _resolvePair: RecyclePool = new RecyclePool(() => new ResolvePair(), 16); + private readonly _copyPair: RecyclePool = new RecyclePool(() => new CopyPair(), 16); + private readonly _uploadPair: RecyclePool = new RecyclePool(() => new UploadPair(), 16); + private readonly _movePair: RecyclePool = new RecyclePool(() => new MovePair(), 16); + private readonly _pipelineStatistics: RecyclePool = new RecyclePool(() => new PipelineStatistics(), 16); } export function saveLightInfo (a: OutputArchive, v: LightInfo): void { diff --git a/cocos/rendering/custom/web-pipeline.ts b/cocos/rendering/custom/web-pipeline.ts index 4515fd03359..6aa128f2500 100644 --- a/cocos/rendering/custom/web-pipeline.ts +++ b/cocos/rendering/custom/web-pipeline.ts @@ -27,8 +27,8 @@ import { systemInfo } from 'pal/system-info'; import { DEBUG, EDITOR } from 'internal:constants'; import { DescriptorSetLayout, Device, Feature, Format, FormatFeatureBit, Sampler, Swapchain, Texture, ClearFlagBit, DescriptorSet, deviceManager, Viewport, API, CommandBuffer, Type, SamplerInfo, Filter, Address, DescriptorSetInfo, LoadOp, StoreOp, ShaderStageFlagBit, BufferInfo, TextureInfo, TextureType, ResolveMode, SampleCount, Color, ComparisonFunc } from '../../gfx'; import { Vec4, assert, macro, cclegacy, RecyclePool } from '../../core'; -import { AccessType, AttachmentType, CopyPair, LightInfo, LightingMode, MovePair, QueueHint, RenderCommonObjectPool, RenderCommonObjectPoolSettings, ResolvePair, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency, UploadPair } from './types'; -import { ComputePass, CopyPass, MovePass, RasterPass, RasterSubpass, RenderData, RenderGraph, RenderGraphComponent, RenderGraphValue, RenderQueue, RenderSwapchain, ResourceDesc, ResourceGraph, ResourceGraphValue, ResourceStates, ResourceTraits, SceneData, Subpass, PersistentBuffer, RenderGraphObjectPool, RenderGraphObjectPoolSettings, CullingFlags, ManagedResource, ManagedBuffer } from './render-graph'; +import { AccessType, AttachmentType, CopyPair, LightInfo, LightingMode, MovePair, QueueHint, RenderCommonObjectPool, ResolvePair, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency, UploadPair } from './types'; +import { ComputePass, CopyPass, MovePass, RasterPass, RasterSubpass, RenderData, RenderGraph, RenderGraphComponent, RenderGraphValue, RenderQueue, RenderSwapchain, ResourceDesc, ResourceGraph, ResourceGraphValue, ResourceStates, ResourceTraits, SceneData, Subpass, PersistentBuffer, RenderGraphObjectPool, CullingFlags, ManagedResource, ManagedBuffer } from './render-graph'; import { ComputePassBuilder, ComputeQueueBuilder, BasicPipeline, RenderQueueBuilder, RenderSubpassBuilder, PipelineType, BasicRenderPassBuilder, PipelineCapabilities, BasicMultisampleRenderPassBuilder, Setter, SceneBuilder } from './pipeline'; import { PipelineSceneData } from '../pipeline-scene-data'; import { Model, Camera, PCFType, ProbeType } from '../../render-scene/scene'; @@ -64,8 +64,6 @@ const _samplerPointInfo = new SamplerInfo( Address.CLAMP, ); -const renderCommonObjectSetting = new RenderCommonObjectPoolSettings(16); -const renderGraphPoolSetting: RenderGraphObjectPoolSettings = new RenderGraphObjectPoolSettings(16); class PipelinePool { renderData = new RenderData(); layoutGraph = new LayoutGraphData(); @@ -85,8 +83,8 @@ class PipelinePool { computePassBuilder = new RecyclePool(() => new WebComputePassBuilder(this.renderData, this.rg, this.layoutGraph, this.resourceGraph, this.vertId, this.computePass, this.getPipelineSceneData()), 16); samplerInfo = new RecyclePool(() => new SamplerInfo(), 16); color = new RecyclePool(() => new Color(), 16); - renderCommonObjectPool = new RenderCommonObjectPool(renderCommonObjectSetting); - renderGraphPool = new RenderGraphObjectPool(renderGraphPoolSetting, this.renderCommonObjectPool); + renderCommonObjectPool = new RenderCommonObjectPool(); + renderGraphPool = new RenderGraphObjectPool(this.renderCommonObjectPool); viewport = new RecyclePool(() => new Viewport(), 16); getPipelineSceneData (): PipelineSceneData {