diff --git a/cocos/core/pipeline/custom/legacy-pipeline.ts b/cocos/core/pipeline/custom/legacy-pipeline.ts deleted file mode 100644 index d6b3bb2650..0000000000 --- a/cocos/core/pipeline/custom/legacy-pipeline.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PipelineEventType, RenderPipeline } from '..'; -import { DescriptorSetLayout } from '../../gfx'; -import { MacroRecord } from '../../renderer'; -import { Model } from '../../renderer/scene'; -import { GlobalDSManager } from '../global-descriptor-set-manager'; -import { PipelineSceneData } from '../pipeline-scene-data'; -import { PipelineRuntime } from './pipeline'; - -export class LegacyPipelineRuntime extends PipelineRuntime { - constructor (pipeline: RenderPipeline) { - super(); - this._pipeline = pipeline; - } - public get macros (): MacroRecord { - return this._pipeline.macros; - } - public get globalDSManager (): GlobalDSManager { - return this._pipeline.globalDSManager; - } - public get descriptorSetLayout (): DescriptorSetLayout { - return this._pipeline.descriptorSetLayout; - } - public get pipelineSceneData (): PipelineSceneData { - return this._pipeline.pipelineSceneData; - } - public get constantMacros (): string { - return this._pipeline.constantMacros; - } - public get profiler (): Model | null { - return this._pipeline.profiler; - } - public set profiler (profiler: Model | null) { - this._pipeline.profiler = profiler; - } - public on (type: PipelineEventType, callback: any, target?: any, once?: boolean): typeof callback { - return this._pipeline.on(type, callback, target, once); - } - public off (type: PipelineEventType, callback?: any, target?: any): void { - this._pipeline.off(type, callback, target); - } - _pipeline: RenderPipeline; -} diff --git a/cocos/core/pipeline/render-pipeline.ts b/cocos/core/pipeline/render-pipeline.ts index 485d471ed1..dd81c4de6d 100644 --- a/cocos/core/pipeline/render-pipeline.ts +++ b/cocos/core/pipeline/render-pipeline.ts @@ -52,6 +52,7 @@ import { IPipelineEvent, PipelineEventProcessor, PipelineEventType } from './pip import { decideProfilerCamera } from './pipeline-funcs'; import { OS } from '../../../pal/system-info/enum-type'; import { macro } from '../platform/macro'; +import { PipelineRuntime } from './custom/pipeline'; /** * @en Render pipeline information descriptor @@ -107,7 +108,7 @@ export class PipelineInputAssemblerData { * 渲染流程函数 [[render]] 会由 [[Root]] 发起调用并对所有 [[Camera]] 执行预设的渲染流程。 */ @ccclass('cc.RenderPipeline') -export abstract class RenderPipeline extends Asset implements IPipelineEvent { +export abstract class RenderPipeline extends Asset implements IPipelineEvent, PipelineRuntime { /** * @en The tag of pipeline. * @zh 管线的标签。 diff --git a/cocos/core/renderer/core/program-lib.ts b/cocos/core/renderer/core/program-lib.ts index 1ca1e836f2..26aa1ea199 100644 --- a/cocos/core/renderer/core/program-lib.ts +++ b/cocos/core/renderer/core/program-lib.ts @@ -30,7 +30,7 @@ import { EffectAsset } from '../../assets/effect-asset'; import { SetIndex, IDescriptorSetLayoutInfo, globalDescriptorSetLayout, localDescriptorSetLayout } from '../../pipeline/define'; -import { RenderPipeline } from '../../pipeline/render-pipeline'; +import { PipelineRuntime } from '../../pipeline/custom/pipeline'; import { genHandle, MacroRecord } from './pass-utils'; import { legacyCC } from '../../global-exports'; import { PipelineLayoutInfo, Device, Attribute, UniformBlock, ShaderInfo, @@ -438,7 +438,7 @@ class ProgramLib { * @param pipeline The [[RenderPipeline]] which owns the render command * @param key The shader cache key, if already known */ - public getGFXShader (device: Device, name: string, defines: MacroRecord, pipeline: RenderPipeline, key?: string) { + public getGFXShader (device: Device, name: string, defines: MacroRecord, pipeline: PipelineRuntime, key?: string) { Object.assign(defines, pipeline.macros); if (!key) key = this.getKey(name, defines); const res = this._cache[key]; diff --git a/cocos/core/renderer/scene/submodel.ts b/cocos/core/renderer/scene/submodel.ts index 81ed8837d5..bb728b30ab 100644 --- a/cocos/core/renderer/scene/submodel.ts +++ b/cocos/core/renderer/scene/submodel.ts @@ -29,7 +29,6 @@ import { BatchingSchemes, IMacroPatch, Pass } from '../core/pass'; import { DescriptorSet, DescriptorSetInfo, Device, InputAssembler, Texture, TextureType, TextureUsageBit, TextureInfo, Format, Sampler, Filter, Address, Shader, SamplerInfo } from '../../gfx'; import { legacyCC } from '../../global-exports'; -import { ForwardPipeline } from '../../pipeline'; import { errorID } from '../../platform/debug'; import { getPhaseID } from '../../pipeline/pass-phase'; import { Root } from '../../root'; @@ -130,8 +129,8 @@ export class SubModel { this._inputAssembler = this._device.createInputAssembler(subMesh.iaInfo); this._descriptorSet = this._device.createDescriptorSet(_dsInfo); - const pipeline = legacyCC.director.root.pipeline; - const occlusionPass = pipeline.pipelineSceneData.getOcclusionQueryPass(); + const pipeline = (legacyCC.director.root as Root).pipeline; + const occlusionPass = pipeline.pipelineSceneData.getOcclusionQueryPass()!; const occlusionDSInfo = new DescriptorSetInfo(null!); occlusionDSInfo.layout = occlusionPass.localSetLayout; this._worldBoundDescriptorSet = this._device.createDescriptorSet(occlusionDSInfo); @@ -186,7 +185,7 @@ export class SubModel { // This is a temporary solution // It should not be written in a fixed way, or modified by the user public initPlanarShadowShader () { - const pipeline = legacyCC.director.root.pipeline as ForwardPipeline; + const pipeline = (legacyCC.director.root as Root).pipeline; const shadowInfo = pipeline.pipelineSceneData.shadows; this._planarShader = shadowInfo.getPlanarShader(this._patches); } @@ -194,7 +193,7 @@ export class SubModel { // This is a temporary solution // It should not be written in a fixed way, or modified by the user public initPlanarShadowInstanceShader () { - const pipeline = legacyCC.director.root.pipeline as ForwardPipeline; + const pipeline = (legacyCC.director.root as Root).pipeline; const shadowInfo = pipeline.pipelineSceneData.shadows; this._planarInstanceShader = shadowInfo.getPlanarInstanceShader(this._patches); } diff --git a/cocos/core/root.ts b/cocos/core/root.ts index fa3f7d57cc..932e80e50f 100644 --- a/cocos/core/root.ts +++ b/cocos/core/root.ts @@ -42,7 +42,7 @@ import { legacyCC } from './global-exports'; import { RenderWindow, IRenderWindowInfo } from './renderer/core/render-window'; import { ColorAttachment, DepthStencilAttachment, RenderPassInfo, StoreOp, Device, Swapchain, Feature } from './gfx'; import { warnID } from './platform/debug'; -import { Pipeline } from './pipeline/custom/pipeline'; +import { Pipeline, PipelineRuntime } from './pipeline/custom/pipeline'; import { createCustomPipeline } from './pipeline/custom'; /** @@ -118,7 +118,7 @@ export class Root { * @zh * 渲染管线 */ - public get pipeline (): RenderPipeline { + public get pipeline (): PipelineRuntime { return this._pipeline!; } diff --git a/cocos/core/scene-graph/scene-globals.ts b/cocos/core/scene-graph/scene-globals.ts index 67b85f9593..125709d259 100644 --- a/cocos/core/scene-graph/scene-globals.ts +++ b/cocos/core/scene-graph/scene-globals.ts @@ -933,7 +933,7 @@ export class SceneGlobals { public octree = new OctreeInfo(); public activate () { - const sceneData = legacyCC.director.root.pipeline.pipelineSceneData; + const sceneData = (legacyCC.director.root as Root).pipeline.pipelineSceneData; this.skybox.activate(sceneData.skybox); this.ambient.activate(sceneData.ambient); diff --git a/cocos/profiler/profiler.ts b/cocos/profiler/profiler.ts index 18212aa01d..fa9c641bea 100644 --- a/cocos/profiler/profiler.ts +++ b/cocos/profiler/profiler.ts @@ -38,7 +38,7 @@ import { Pass } from '../core/renderer'; import { preTransforms } from '../core/math/mat4'; import { JSB } from '../core/default-constants'; import { Root } from '../core/root'; -import { RenderPipeline } from '../core'; +import { PipelineRuntime } from '../core/pipeline/custom/pipeline'; const _characters = '0123456789. '; @@ -104,7 +104,7 @@ export class Profiler { private _rootNode: Node | null = null; private _device: Device | null = null; private _swapchain: Swapchain | null = null; - private _pipeline: RenderPipeline = null!; + private _pipeline: PipelineRuntime = null!; private _meshRenderer: MeshRenderer = null!; private readonly _canvas: HTMLCanvasElement | null = null; private readonly _ctx: CanvasRenderingContext2D | null = null; diff --git a/cocos/terrain/terrain.ts b/cocos/terrain/terrain.ts index 26f141e58a..52658ccd8b 100644 --- a/cocos/terrain/terrain.ts +++ b/cocos/terrain/terrain.ts @@ -1584,11 +1584,11 @@ export class Terrain extends Component { this._blocks[i].visible = true; } - legacyCC.director.root.pipeline.on(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); + (legacyCC.director.root as Root).pipeline.on(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); } public onDisable () { - legacyCC.director.root.pipeline.off(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); + (legacyCC.director.root as Root).pipeline.off(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); for (let i = 0; i < this._blocks.length; ++i) { this._blocks[i].visible = false;