mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
remove Forward Deferred pipelines (#17448)
This commit is contained in:
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { Camera, CameraUsage } from '../../render-scene/scene';
|
||||
import { BasicPipeline, PipelineBuilder } from './pipeline';
|
||||
import { buildClusterPasses } from './define';
|
||||
import { isUICamera } from './utils';
|
||||
import {
|
||||
prepareResource,
|
||||
setupForwardPass,
|
||||
setupForwardRes,
|
||||
setupReflectionProbePass,
|
||||
setupReflectionProbeRes,
|
||||
updateForwardRes,
|
||||
updateReflectionProbeRes,
|
||||
CameraInfo,
|
||||
setupGBufferPass,
|
||||
updateGBufferRes,
|
||||
setupGBufferRes,
|
||||
setupLightingPass,
|
||||
setupLightingRes,
|
||||
updateLightingRes,
|
||||
setupPostprocessPass,
|
||||
setupPostprocessRes,
|
||||
updatePostprocessRes,
|
||||
setupUIPass,
|
||||
setupUIRes,
|
||||
updateUIRes,
|
||||
setupDeferredForward,
|
||||
setupScenePassTiled,
|
||||
} from './pipeline-define';
|
||||
import { Feature } from '../../gfx';
|
||||
|
||||
export class ForwardPipelineBuilder implements PipelineBuilder {
|
||||
public setup (cameras: Camera[], ppl: BasicPipeline): void {
|
||||
for (let i = 0; i < cameras.length; i++) {
|
||||
const camera = cameras[i];
|
||||
if (camera.scene === null) {
|
||||
continue;
|
||||
}
|
||||
ppl.update(camera);
|
||||
const info = prepareResource(ppl, camera, this.initResource, this.updateResource);
|
||||
setupForwardPass(ppl, info);
|
||||
if (EDITOR) {
|
||||
setupReflectionProbePass(ppl, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
private initResource (ppl: BasicPipeline, cameraInfo: CameraInfo): void {
|
||||
setupForwardRes(ppl, cameraInfo);
|
||||
if (EDITOR) setupReflectionProbeRes(ppl, cameraInfo);
|
||||
}
|
||||
private updateResource (ppl: BasicPipeline, cameraInfo: CameraInfo): void {
|
||||
updateForwardRes(ppl, cameraInfo);
|
||||
if (EDITOR) updateReflectionProbeRes(ppl, cameraInfo);
|
||||
}
|
||||
}
|
||||
|
||||
export class DeferredPipelineBuilder implements PipelineBuilder {
|
||||
public setup (cameras: Camera[], ppl: BasicPipeline): void {
|
||||
for (let i = 0; i < cameras.length; ++i) {
|
||||
const camera = cameras[i];
|
||||
if (!camera.scene) {
|
||||
continue;
|
||||
}
|
||||
ppl.update(camera);
|
||||
const forceDisableCluster = false;
|
||||
const useCluster = !forceDisableCluster && ppl.device.hasFeature(Feature.COMPUTE_SHADER);
|
||||
|
||||
const isGameView = camera.cameraUsage === CameraUsage.GAME
|
||||
|| camera.cameraUsage === CameraUsage.GAME_VIEW;
|
||||
const info = prepareResource(ppl, camera, this.initResource, this.updateResource);
|
||||
if (!isGameView) {
|
||||
setupForwardPass(ppl, info);
|
||||
continue;
|
||||
}
|
||||
if (!isUICamera(camera)) {
|
||||
if (useCluster) {
|
||||
buildClusterPasses(camera, ppl);
|
||||
}
|
||||
|
||||
// GBuffer Pass
|
||||
setupGBufferPass(ppl, info);
|
||||
// Lighting Pass
|
||||
const lightInfo = setupLightingPass(ppl, info, useCluster);
|
||||
// Deferred ForwardPass, for non-surface-shader material and transparent material
|
||||
setupDeferredForward(ppl, info, lightInfo.rtName, useCluster);
|
||||
// Postprocess
|
||||
setupPostprocessPass(ppl, info, lightInfo.rtName);
|
||||
|
||||
continue;
|
||||
}
|
||||
// render ui
|
||||
setupUIPass(ppl, info);
|
||||
}
|
||||
}
|
||||
private initResource (ppl: BasicPipeline, cameraInfo: CameraInfo): void {
|
||||
if (EDITOR) {
|
||||
setupForwardRes(ppl, cameraInfo);
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
if (!isUICamera(cameraInfo.camera)) {
|
||||
setupGBufferRes(ppl, cameraInfo);
|
||||
setupLightingRes(ppl, cameraInfo);
|
||||
setupPostprocessRes(ppl, cameraInfo);
|
||||
} else {
|
||||
setupUIRes(ppl, cameraInfo);
|
||||
}
|
||||
}
|
||||
private updateResource (ppl: BasicPipeline, cameraInfo: CameraInfo): void {
|
||||
if (EDITOR) {
|
||||
updateForwardRes(ppl, cameraInfo);
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
if (!isUICamera(cameraInfo.camera)) {
|
||||
updateGBufferRes(ppl, cameraInfo);
|
||||
updateLightingRes(ppl, cameraInfo);
|
||||
updatePostprocessRes(ppl, cameraInfo);
|
||||
} else {
|
||||
updateUIRes(ppl, cameraInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-len */
|
||||
import { Viewport } from '../../gfx';
|
||||
import { assert } from '../../core';
|
||||
import { DefaultVisitor, ReferenceGraphView, ED} from './graph';
|
||||
import { Blit, ClearView, ComputePass, ComputeSubpass, CopyPass, Dispatch, getRenderGraphValueName, MovePass, RasterPass, RasterSubpass, RaytracePass, RenderGraph, RenderGraphVisitor, RenderQueue, SceneData } from './render-graph';
|
||||
import { getQueueHintName } from './types';
|
||||
|
||||
export const enableDebug = true;
|
||||
|
||||
let oss = '';
|
||||
let space = '';
|
||||
|
||||
class PrePrintVisitor implements RenderGraphVisitor {
|
||||
constructor (g: RenderGraph) {
|
||||
this.g = g;
|
||||
}
|
||||
clear (value: ClearView[]): void {
|
||||
// do nothing
|
||||
}
|
||||
viewport (value: Viewport): void {
|
||||
// do nothing
|
||||
}
|
||||
rasterPass (value: RasterPass): void {
|
||||
oss += `${space}width = ${value.width}\n`;
|
||||
oss += `${space}height = ${value.height}\n`;
|
||||
for (const rasterView of value.rasterViews) {
|
||||
oss += `${space}"${rasterView[0]}": RasterView\n`;
|
||||
}
|
||||
for (const computeView of value.computeViews) {
|
||||
oss += `${space}"${computeView[0]}": ComputeView[]\n`;
|
||||
}
|
||||
}
|
||||
rasterSubpass(value: RasterSubpass): void {}
|
||||
computeSubpass(value: ComputeSubpass): void {}
|
||||
compute (value: ComputePass): void {
|
||||
for (const computeView of value.computeViews) {
|
||||
oss += `${space}"${computeView[0]}": ComputeView[]\n`;
|
||||
}
|
||||
}
|
||||
copy (value: CopyPass): void {
|
||||
if (value.copyPairs.length === 1) {
|
||||
const pair = value.copyPairs[0];
|
||||
oss += `${space}source = "${pair.source}"\n`;
|
||||
oss += `${space}target = "${pair.target}"\n`;
|
||||
} else {
|
||||
let i = 0;
|
||||
oss += `${space}sources = [`;
|
||||
for (const pair of value.copyPairs) {
|
||||
if (i++) {
|
||||
oss += ', ';
|
||||
}
|
||||
oss += `"${pair.source}"`;
|
||||
}
|
||||
oss += ']\n';
|
||||
|
||||
oss += `${space}targets = [`;
|
||||
for (const pair of value.copyPairs) {
|
||||
if (i++) {
|
||||
oss += ', ';
|
||||
}
|
||||
oss += `"${pair.target}"`;
|
||||
}
|
||||
oss += ']\n';
|
||||
}
|
||||
}
|
||||
move (value: MovePass): void {
|
||||
if (value.movePairs.length === 1) {
|
||||
const pair = value.movePairs[0];
|
||||
oss += `${space}source = "${pair.source}"\n`;
|
||||
oss += `${space}target = "${pair.target}"\n`;
|
||||
} else {
|
||||
let i = 0;
|
||||
oss += `${space}sources = [`;
|
||||
for (const pair of value.movePairs) {
|
||||
if (i++) {
|
||||
oss += ', ';
|
||||
}
|
||||
oss += `"${pair.source}"`;
|
||||
}
|
||||
oss += ']\n';
|
||||
|
||||
oss += `${space}targets = [`;
|
||||
for (const pair of value.movePairs) {
|
||||
if (i++) {
|
||||
oss += ', ';
|
||||
}
|
||||
oss += `"${pair.target}"`;
|
||||
}
|
||||
oss += ']\n';
|
||||
}
|
||||
}
|
||||
raytrace (value: RaytracePass): void {
|
||||
for (const computeView of value.computeViews) {
|
||||
oss += `${space}"${computeView[0]}": ComputeView[]\n`;
|
||||
}
|
||||
}
|
||||
queue (value: RenderQueue): void {
|
||||
oss += `${space}hint = ${getQueueHintName(value.hint)}\n`;
|
||||
}
|
||||
scene (value: SceneData): void {
|
||||
oss += `${space}scenes = [`;
|
||||
let i = 0;
|
||||
for (const scene of value.scenes) {
|
||||
if (i++) {
|
||||
oss += ', ';
|
||||
}
|
||||
oss += `"${scene}"`;
|
||||
}
|
||||
oss += ']\n';
|
||||
}
|
||||
blit (value: Blit): void {}
|
||||
dispatch (value: Dispatch): void {
|
||||
oss += `${space}material = "${value.material?.name}"\n`;
|
||||
oss += `${space}passID = "${value.passID}"\n`;
|
||||
oss += `${space}groupX = ${value.threadGroupCountX}\n`;
|
||||
oss += `${space}groupY = ${value.threadGroupCountY}\n`;
|
||||
oss += `${space}groupZ = ${value.threadGroupCountZ}\n`;
|
||||
}
|
||||
g: RenderGraph;
|
||||
}
|
||||
|
||||
class PostPrintVisitor implements RenderGraphVisitor {
|
||||
constructor (g: RenderGraph) {
|
||||
this.g = g;
|
||||
}
|
||||
clear (value: ClearView[]): void {
|
||||
// do nothing
|
||||
}
|
||||
viewport (value: Viewport): void {
|
||||
// do nothing
|
||||
}
|
||||
rasterPass (value: RasterPass): void {
|
||||
// post raster pass
|
||||
}
|
||||
rasterSubpass(value: RasterSubpass): void {}
|
||||
computeSubpass(value: ComputeSubpass): void {}
|
||||
compute (value: ComputePass): void {}
|
||||
copy (value: CopyPass): void {}
|
||||
move (value: MovePass): void {}
|
||||
raytrace (value: RaytracePass): void {}
|
||||
queue (value: RenderQueue): void {
|
||||
// collect scene results
|
||||
}
|
||||
scene (value: SceneData): void {
|
||||
// scene command list finished
|
||||
}
|
||||
blit (value: Blit): void {}
|
||||
dispatch (value: Dispatch): void {}
|
||||
g: RenderGraph;
|
||||
}
|
||||
|
||||
export class RenderGraphPrintVisitor extends DefaultVisitor {
|
||||
constructor (g: RenderGraph) {
|
||||
super();
|
||||
this.preVertexVisitor = new PrePrintVisitor(g);
|
||||
this.postVertexVisitor = new PostPrintVisitor(g);
|
||||
}
|
||||
initializeVertex (v: number, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
// initialization
|
||||
}
|
||||
startVertex (v: number, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
const g = gv.g;
|
||||
// passes begin
|
||||
// assert(g.holds(RenderGraphValue.RasterPass, v)
|
||||
// || g.holds(RenderGraphValue.Compute, v)
|
||||
// || g.holds(RenderGraphValue.Copy, v)
|
||||
// || g.holds(RenderGraphValue.Move, v)
|
||||
// || g.holds(RenderGraphValue.Raytrace, v));
|
||||
}
|
||||
discoverVertex (v: number, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
const g = gv.g;
|
||||
oss += `${space}"${g.getName(v)}": ${getRenderGraphValueName(g.id(v))} {\n`;
|
||||
space += ' ';
|
||||
|
||||
g.visitVertex(this.preVertexVisitor, v);
|
||||
}
|
||||
backEdge (e: ED, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
assert(false);
|
||||
}
|
||||
forwardOrCrossEdge (e: ED, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
assert(false);
|
||||
}
|
||||
finishEdge (e: ED, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
const g = gv.g;
|
||||
}
|
||||
finishVertex (v: number, gv: ReferenceGraphView<RenderGraph>): void {
|
||||
const g = gv.g;
|
||||
g.visitVertex(this.postVertexVisitor, v);
|
||||
|
||||
space = space.substring(0, space.length - 4);
|
||||
oss += `${space}}\n`;
|
||||
}
|
||||
print (): string {
|
||||
return oss;
|
||||
}
|
||||
readonly preVertexVisitor;
|
||||
readonly postVertexVisitor;
|
||||
}
|
||||
@@ -25,7 +25,6 @@
|
||||
declare const render: any;
|
||||
|
||||
import { Pipeline, PipelineBuilder, RenderingModule } from './pipeline';
|
||||
import { DeferredPipelineBuilder } from './builtin-pipelines';
|
||||
import { Device } from '../../gfx';
|
||||
import { PostProcessBuilder } from '../post-process/post-process-builder';
|
||||
import { forceResizeAllWindows } from './framework';
|
||||
@@ -64,7 +63,6 @@ export function getCustomPipeline (name: string): PipelineBuilder {
|
||||
|
||||
function addCustomBuiltinPipelines (map: Map<string, PipelineBuilder>) {
|
||||
map.set('Forward', new PostProcessBuilder());
|
||||
map.set('Deferred', new DeferredPipelineBuilder());
|
||||
map.set('Custom', new PostProcessBuilder());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
import { BasicPipeline, PipelineBuilder } from './pipeline';
|
||||
import { WebPipeline } from './web-pipeline';
|
||||
import { macro } from '../../core/platform/macro';
|
||||
import { DeferredPipelineBuilder } from './builtin-pipelines';
|
||||
import { LayoutGraphData, loadLayoutGraphData } from './layout-graph';
|
||||
import { BinaryInputArchive } from './binary-archive';
|
||||
import { WebProgramLibrary } from './web-program-library';
|
||||
@@ -76,7 +75,6 @@ export function getCustomPipeline (name: string): PipelineBuilder {
|
||||
|
||||
function addCustomBuiltinPipelines (map: Map<string, PipelineBuilder>): void {
|
||||
map.set('Forward', new PostProcessBuilder());
|
||||
map.set('Deferred', new DeferredPipelineBuilder());
|
||||
map.set('Custom', new PostProcessBuilder());
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ import { PipelineUBO } from '../pipeline-ubo';
|
||||
import { builtinResMgr } from '../../asset/asset-manager';
|
||||
import { GeometryRenderer } from '../geometry-renderer';
|
||||
import { Material, TextureCube } from '../../asset/assets';
|
||||
import { DeferredPipelineBuilder, ForwardPipelineBuilder } from './builtin-pipelines';
|
||||
import { decideProfilerCamera } from '../pipeline-funcs';
|
||||
import { DebugViewCompositeType } from '../debug-view';
|
||||
import { buildReflectionProbePass } from './define';
|
||||
@@ -1265,8 +1264,6 @@ export class WebPipeline implements BasicPipeline {
|
||||
if (this.usesDeferredPipeline) {
|
||||
this.setMacroInt('CC_PIPELINE_TYPE', 1);
|
||||
}
|
||||
this._forward = new ForwardPipelineBuilder();
|
||||
this._deferred = new DeferredPipelineBuilder();
|
||||
return true;
|
||||
}
|
||||
public destroy (): boolean {
|
||||
@@ -1763,8 +1760,6 @@ export class WebPipeline implements BasicPipeline {
|
||||
private _compiler: Compiler | null = null;
|
||||
private _executor: Executor | null = null;
|
||||
private _customPipelineName = '';
|
||||
private _forward!: ForwardPipelineBuilder;
|
||||
private _deferred!: DeferredPipelineBuilder;
|
||||
private _globalDescSetData!: DescriptorSetData;
|
||||
private _combineSignY = 0;
|
||||
// csm uniform used vectors count
|
||||
|
||||
@@ -37,7 +37,6 @@ import * as gfx from '../cocos/gfx';
|
||||
export * from '../cocos/core';
|
||||
|
||||
export * from '../cocos/rendering';
|
||||
export * from '../cocos/rendering/custom/builtin-pipelines';
|
||||
export * from '../cocos/scene-graph';
|
||||
export * from '../cocos/misc';
|
||||
export * from '../cocos/game';
|
||||
|
||||
Reference in New Issue
Block a user