mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
apply deferred pipeline to Framegraph (#9083)
* framegraph, port from dpc * fix sspr bug in android + vulkan * Revert "fix sspr bug in android + vulkan" This reverts commit dc8fad8bc8aec686888ec176d97809a102223a42.
This commit is contained in:
@@ -33,8 +33,7 @@ import { genSamplerHash, samplerLib } from '../../renderer/core/sampler-lib';
|
||||
import { builtinResMgr } from '../../builtin/builtin-res-mgr';
|
||||
import { Texture2D } from '../../assets/texture-2d';
|
||||
import { RenderPipeline, IRenderPipelineInfo } from '../render-pipeline';
|
||||
import { GbufferFlow } from './gbuffer-flow';
|
||||
import { LightingFlow } from './lighting-flow';
|
||||
import { MainFlow } from './main-flow';
|
||||
import { RenderTextureConfig } from '../pipeline-serialization';
|
||||
import { ShadowFlow } from '../shadow/shadow-flow';
|
||||
import { BufferUsageBit, Format, MemoryUsageBit, ClearFlagBit, ClearFlags, StoreOp, Filter, Address,
|
||||
@@ -120,13 +119,9 @@ export class DeferredPipeline extends RenderPipeline {
|
||||
shadowFlow.initialize(ShadowFlow.initInfo);
|
||||
this._flows.push(shadowFlow);
|
||||
|
||||
const gbufferFlow = new GbufferFlow();
|
||||
gbufferFlow.initialize(GbufferFlow.initInfo);
|
||||
this._flows.push(gbufferFlow);
|
||||
|
||||
const lightingFlow = new LightingFlow();
|
||||
lightingFlow.initialize(LightingFlow.initInfo);
|
||||
this._flows.push(lightingFlow);
|
||||
const mainFlow = new MainFlow();
|
||||
mainFlow.initialize(MainFlow.initInfo);
|
||||
this._flows.push(mainFlow);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -46,7 +46,6 @@ export enum DeferredStagePriority {
|
||||
*/
|
||||
export enum DeferredFlowPriority {
|
||||
SHADOW = 0,
|
||||
GBUFFER = 1,
|
||||
LIGHTING = 5,
|
||||
MAIN = 1,
|
||||
UI = 10,
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ import { DeferredStagePriority } from './enum';
|
||||
import { InstancedBuffer } from '../instanced-buffer';
|
||||
import { BatchedBuffer } from '../batched-buffer';
|
||||
import { BatchingSchemes } from '../../renderer/core/pass';
|
||||
import { GbufferFlow } from './gbuffer-flow';
|
||||
import { DeferredPipeline } from './deferred-pipeline';
|
||||
import { RenderQueueDesc, RenderQueueSortMode } from '../pipeline-serialization';
|
||||
import { MainFlow } from './main-flow';
|
||||
|
||||
const colors: Color[] = [new Color(0, 0, 0, 0), new Color(0, 0, 0, 0), new Color(0, 0, 0, 0), new Color(0, 0, 0, 0)];
|
||||
|
||||
@@ -96,7 +96,7 @@ export class GbufferStage extends RenderStage {
|
||||
return true;
|
||||
}
|
||||
|
||||
public activate (pipeline: DeferredPipeline, flow: GbufferFlow) {
|
||||
public activate (pipeline: DeferredPipeline, flow: MainFlow) {
|
||||
super.activate(pipeline, flow);
|
||||
for (let i = 0; i < this.renderQueues.length; i++) {
|
||||
this._renderQueues[i] = convertRenderQueue(this.renderQueues[i]);
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
Copyright (c) Huawei Technologies Co., Ltd. 2020-2021.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category pipeline
|
||||
*/
|
||||
|
||||
import { ccclass } from 'cc.decorator';
|
||||
import { Camera } from '../../renderer/scene';
|
||||
import { PIPELINE_FLOW_LIGHTING } from '../define';
|
||||
import { IRenderFlowInfo, RenderFlow } from '../render-flow';
|
||||
import { DeferredFlowPriority } from './enum';
|
||||
import { LightingStage } from './lighting-stage';
|
||||
import { RenderPipeline } from '../render-pipeline';
|
||||
|
||||
/**
|
||||
* @en The lighting flow in lighting render pipeline
|
||||
* @zh 前向渲染流程。
|
||||
*/
|
||||
@ccclass('LightingFlow')
|
||||
export class LightingFlow extends RenderFlow {
|
||||
/**
|
||||
* @en The shared initialization information of lighting render flow
|
||||
* @zh 共享的前向渲染流程初始化参数
|
||||
*/
|
||||
public static initInfo: IRenderFlowInfo = {
|
||||
name: PIPELINE_FLOW_LIGHTING,
|
||||
priority: DeferredFlowPriority.LIGHTING,
|
||||
stages: [],
|
||||
};
|
||||
|
||||
public initialize (info: IRenderFlowInfo): boolean {
|
||||
super.initialize(info);
|
||||
if (this._stages.length === 0) {
|
||||
const lightingStage = new LightingStage();
|
||||
lightingStage.initialize(LightingStage.initInfo);
|
||||
this._stages.push(lightingStage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public activate (pipeline: RenderPipeline) {
|
||||
super.activate(pipeline);
|
||||
}
|
||||
|
||||
public render (camera: Camera) {
|
||||
super.render(camera);
|
||||
}
|
||||
|
||||
public destroy () {
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import { Color, Rect, Shader, Buffer, BufferUsageBit, MemoryUsageBit, BufferInfo
|
||||
DescriptorSetLayout, DescriptorSetInfo, PipelineState, ClearFlagBit } from '../../gfx';
|
||||
import { IRenderStageInfo, RenderStage } from '../render-stage';
|
||||
import { DeferredStagePriority } from './enum';
|
||||
import { LightingFlow } from './lighting-flow';
|
||||
import { MainFlow } from './main-flow';
|
||||
import { DeferredPipeline } from './deferred-pipeline';
|
||||
import { PlanarShadowQueue } from '../planar-shadow-queue';
|
||||
import { Material } from '../../assets/material';
|
||||
@@ -178,7 +178,7 @@ export class LightingStage extends RenderStage {
|
||||
cmdBuff.updateBuffer(this._deferredLitsBufs, this._lightBufferData);
|
||||
}
|
||||
|
||||
public activate (pipeline: DeferredPipeline, flow: LightingFlow) {
|
||||
public activate (pipeline: DeferredPipeline, flow: MainFlow) {
|
||||
super.activate(pipeline, flow);
|
||||
|
||||
const device = pipeline.device;
|
||||
|
||||
+16
-7
@@ -29,25 +29,28 @@
|
||||
|
||||
import { ccclass } from 'cc.decorator';
|
||||
import { Camera } from '../../renderer/scene';
|
||||
import { PIPELINE_FLOW_GBUFFER } from '../define';
|
||||
import { PIPELINE_FLOW_MAIN } from '../define';
|
||||
import { IRenderFlowInfo, RenderFlow } from '../render-flow';
|
||||
import { DeferredFlowPriority } from './enum';
|
||||
import { GbufferStage } from './gbuffer-stage';
|
||||
import { LightingStage } from './lighting-stage';
|
||||
import { PostprocessStage } from './postprocess-stage';
|
||||
import { DeferredPipeline } from './deferred-pipeline';
|
||||
import { RenderPipeline } from '../render-pipeline';
|
||||
|
||||
/**
|
||||
* @en The gbuffer flow in deferred render pipeline
|
||||
* @en The main flow in deferred render pipeline
|
||||
* @zh 延迟渲染流程。
|
||||
*/
|
||||
@ccclass('GbufferFlow')
|
||||
export class GbufferFlow extends RenderFlow {
|
||||
@ccclass('MainFlow')
|
||||
export class MainFlow extends RenderFlow {
|
||||
/**
|
||||
* @en The shared initialization information of gbuffer render flow
|
||||
* @en The shared initialization information of main render flow
|
||||
* @zh 共享的延迟渲染流程初始化参数
|
||||
*/
|
||||
public static initInfo: IRenderFlowInfo = {
|
||||
name: PIPELINE_FLOW_GBUFFER,
|
||||
priority: DeferredFlowPriority.GBUFFER,
|
||||
name: PIPELINE_FLOW_MAIN,
|
||||
priority: DeferredFlowPriority.MAIN,
|
||||
stages: [],
|
||||
};
|
||||
|
||||
@@ -57,6 +60,12 @@ export class GbufferFlow extends RenderFlow {
|
||||
const gbufferStage = new GbufferStage();
|
||||
gbufferStage.initialize(GbufferStage.initInfo);
|
||||
this._stages.push(gbufferStage);
|
||||
const lightingStage = new LightingStage();
|
||||
lightingStage.initialize(LightingStage.initInfo);
|
||||
this._stages.push(lightingStage);
|
||||
const postprocessStage = new PostprocessStage();
|
||||
postprocessStage.initialize(PostprocessStage.initInfo);
|
||||
this._stages.push(postprocessStage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -33,11 +33,11 @@ import { SetIndex } from '../define';
|
||||
import { Color, Rect, Shader, PipelineState, ClearFlagBit } from '../../gfx';
|
||||
import { IRenderStageInfo, RenderStage } from '../render-stage';
|
||||
import { DeferredStagePriority } from './enum';
|
||||
import { LightingFlow } from './lighting-flow';
|
||||
import { DeferredPipeline } from './deferred-pipeline';
|
||||
import { Material } from '../../assets/material';
|
||||
import { PipelineStateManager } from '../pipeline-state-manager';
|
||||
import { UIPhase } from '../forward/ui-phase';
|
||||
import { MainFlow } from './main-flow';
|
||||
import { opaqueCompareFn, RenderQueue, transparentCompareFn } from '../render-queue';
|
||||
import { RenderQueueDesc, RenderQueueSortMode } from '../pipeline-serialization';
|
||||
import { getPhaseID } from '../pass-phase';
|
||||
@@ -80,7 +80,7 @@ export class PostprocessStage extends RenderStage {
|
||||
return true;
|
||||
}
|
||||
|
||||
public activate (pipeline: DeferredPipeline, flow: LightingFlow) {
|
||||
public activate (pipeline: DeferredPipeline, flow: MainFlow) {
|
||||
super.activate(pipeline, flow);
|
||||
this._uiPhase.activate(pipeline);
|
||||
if (this._postProcessMaterial) { (pipeline.pipelineSceneData as DeferredPipelineSceneData).deferredPostMaterial = this._postProcessMaterial; }
|
||||
|
||||
@@ -36,8 +36,7 @@ import { legacyCC } from '../global-exports';
|
||||
import { BindingMappingInfo, DescriptorType, Type, ShaderStageFlagBit,
|
||||
DescriptorSetLayoutBinding, Uniform, UniformBlock, UniformSamplerTexture, UniformStorageImage, Device, Feature, API } from '../gfx';
|
||||
|
||||
export const PIPELINE_FLOW_GBUFFER = 'GbufferFlow';
|
||||
export const PIPELINE_FLOW_LIGHTING = 'LightingFlow';
|
||||
export const PIPELINE_FLOW_MAIN = 'MainFlow';
|
||||
export const PIPELINE_FLOW_FORWARD = 'ForwardFlow';
|
||||
export const PIPELINE_FLOW_SHADOW = 'ShadowFlow';
|
||||
export const PIPELINE_FLOW_SMAA = 'SMAAFlow';
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ForwardPipeline extends nr.ForwardPipeline {
|
||||
this.renderTextures = [];
|
||||
this.materials = [];
|
||||
}
|
||||
|
||||
|
||||
public init () {
|
||||
this.setPipelineSharedSceneData(this.pipelineSceneData.native);
|
||||
for (let i = 0; i < this._flows.length; i++) {
|
||||
@@ -237,7 +237,7 @@ DeferredPipeline.prototype.onLoaded = function () {
|
||||
this.init();
|
||||
}
|
||||
|
||||
export class GbufferFlow extends nr.GbufferFlow {
|
||||
export class MainFlow extends nr.MainFlow {
|
||||
constructor() {
|
||||
super();
|
||||
this._name = 0;
|
||||
@@ -276,24 +276,6 @@ export class GbufferStage extends nr.GbufferStage {
|
||||
}
|
||||
}
|
||||
|
||||
class LightingFlow extends nr.LightingFlow {
|
||||
constructor() {
|
||||
super();
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
this._tag = 0;
|
||||
this._stages = [];
|
||||
}
|
||||
init(pipeline) {
|
||||
for (let i = 0; i < this._stages.length; i++) {
|
||||
this._stages[i].init(pipeline);
|
||||
}
|
||||
let info = new nr.RenderFlowInfo(
|
||||
this._name, this._priority, this._tag, this._stages);
|
||||
this.initialize(info);
|
||||
}
|
||||
}
|
||||
|
||||
export class LightingStage extends nr.LightingStage {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -337,9 +319,8 @@ export class PostprocessStage extends nr.PostprocessStage {
|
||||
}
|
||||
|
||||
setClassName('DeferredPipeline', DeferredPipeline);
|
||||
setClassName('GbufferFlow', GbufferFlow);
|
||||
setClassName('MainFlow', MainFlow);
|
||||
setClassName('GbufferStage', GbufferStage);
|
||||
setClassName('LightingFlow', LightingFlow);
|
||||
setClassName('LightingStage', LightingStage);
|
||||
setClassName('PostprocessStage',PostprocessStage);
|
||||
setClassName('ForwardPipeline', ForwardPipeline);
|
||||
|
||||
@@ -43,9 +43,8 @@ export { ForwardPipeline } from './forward/forward-pipeline';
|
||||
export { ForwardFlow } from './forward/forward-flow';
|
||||
export { ForwardStage } from './forward/forward-stage';
|
||||
export { DeferredPipeline } from './deferred/deferred-pipeline';
|
||||
export { GbufferFlow } from './deferred/gbuffer-flow';
|
||||
export { MainFlow } from './deferred/main-flow';
|
||||
export { GbufferStage } from './deferred/gbuffer-stage';
|
||||
export { LightingFlow } from './deferred/lighting-flow';
|
||||
export { LightingStage } from './deferred/lighting-stage';
|
||||
export { PostprocessStage } from './deferred/postprocess-stage';
|
||||
export { ShadowFlow } from './shadow/shadow-flow';
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
},
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"renderTextures": []
|
||||
@@ -36,13 +33,19 @@
|
||||
"_tag": 0
|
||||
},
|
||||
{
|
||||
"__type__": "GbufferFlow",
|
||||
"_name": "GbufferFlow",
|
||||
"__type__": "MainFlow",
|
||||
"_name": "MainFlow",
|
||||
"_priority": 1,
|
||||
"_tag": 0,
|
||||
"_stages": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -65,20 +68,6 @@
|
||||
"deferred"
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "LightingFlow",
|
||||
"_name": "LightingFlow",
|
||||
"_priority": 1,
|
||||
"_tag": 0,
|
||||
"_stages": [
|
||||
{
|
||||
"__id__": 7
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "LightingStage",
|
||||
"_name": "LightingStage",
|
||||
@@ -86,7 +75,7 @@
|
||||
"_tag": 0,
|
||||
"renderQueues": [
|
||||
{
|
||||
"__id__": 8
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_deferredMaterial": null
|
||||
|
||||
Reference in New Issue
Block a user