mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
V3.6.0 pipeline refactor (#10221)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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 管线的标签。
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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!;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user