remove pipeline event from pipeline, decouple terrain from render pipeline (#10283)

This commit is contained in:
hyde zhou
2022-03-09 17:31:46 +08:00
committed by GitHub
parent ae245aaec0
commit d6f93d364b
7 changed files with 94 additions and 8 deletions
+4 -5
View File
@@ -31,7 +31,7 @@
/* eslint-disable max-len */
import { EffectAsset } from '../../assets';
import { Camera } from '../../renderer/scene/camera';
import { Buffer, DescriptorSet, DescriptorSetLayout, DrawInfo, Format, InputAssembler, PipelineState, Rect, Sampler, Texture, Viewport } from '../../gfx';
import { Buffer, DescriptorSet, DescriptorSetLayout, DrawInfo, Format, InputAssembler, PipelineState, Rect, Sampler, Swapchain, Texture, Viewport } from '../../gfx';
import { GlobalDSManager } from '../global-descriptor-set-manager';
import { Color, Mat4, Quat, Vec2, Vec4 } from '../../math';
import { MacroRecord } from '../../renderer/core/pass-utils';
@@ -41,9 +41,11 @@ import { ComputeView, CopyPair, MovePair, RasterView } from './render-graph';
import { RenderScene } from '../../renderer/scene/render-scene';
import { RenderWindow } from '../../renderer/core/render-window';
import { Model } from '../../renderer/scene';
import { PipelineEventType } from '../pipeline-event';
export abstract class PipelineRuntime {
public abstract activate(swapchain: Swapchain): boolean;
public abstract destroy(): boolean;
public abstract render(cameras: Camera[]): void;
public abstract get macros(): MacroRecord;
public abstract get globalDSManager(): GlobalDSManager;
public abstract get descriptorSetLayout(): DescriptorSetLayout;
@@ -52,9 +54,6 @@ export abstract class PipelineRuntime {
public abstract get profiler(): Model | null;
public abstract set profiler(profiler: Model | null);
public abstract onGlobalPipelineStateChanged(): void;
public abstract on (type: PipelineEventType, callback: any, target?: any, once?: boolean): typeof callback;
public abstract off (type: PipelineEventType, callback?: any, target?: any): void;
}
export abstract class DescriptorHierarchy {
+8
View File
@@ -52,6 +52,14 @@ Object.defineProperty(rootProto, 'pipeline', {
}
});
Object.defineProperty(rootProto, 'pipelineEvent', {
configurable: true,
enumerable: true,
get () {
return this._pipeline;
}
});
rootProto._ctor = function (device: Device) {
this._device = device;
this._dataPoolMgr = legacyCC.internal.DataPoolManager && new legacyCC.internal.DataPoolManager(device) as DataPoolManager;
+9
View File
@@ -44,6 +44,7 @@ import { warnID } from './platform/debug';
import { Pipeline, PipelineRuntime } from './pipeline/custom/pipeline';
import { createCustomPipeline } from './pipeline/custom';
import { Batcher2D } from '../2d/renderer/batcher-2d';
import { IPipelineEvent } from './pipeline/pipeline-event';
/**
* @zh
@@ -122,6 +123,14 @@ export class Root {
return this._pipeline!;
}
/**
* @zh
* 渲染管线事件
*/
public get pipelineEvent (): IPipelineEvent {
return this._pipeline!;
}
/**
* @zh
* UI实例
+3 -3
View File
@@ -50,7 +50,7 @@ import { TerrainLod, TerrainLodKey, TERRAIN_LOD_LEVELS, TERRAIN_LOD_MAX_DISTANCE
import { TerrainAsset, TerrainLayerInfo, TERRAIN_HEIGHT_BASE, TERRAIN_HEIGHT_FACTORY,
TERRAIN_BLOCK_TILE_COMPLEXITY, TERRAIN_BLOCK_VERTEX_SIZE, TERRAIN_BLOCK_VERTEX_COMPLEXITY,
TERRAIN_MAX_LAYER_COUNT, TERRAIN_HEIGHT_FMIN, TERRAIN_HEIGHT_FMAX, TERRAIN_MAX_BLEND_LAYERS, TERRAIN_DATA_VERSION5 } from './terrain-asset';
import { CCBoolean, CCFloat, CCInteger, Node, PipelineEventType, RenderPipeline } from '../core';
import { CCBoolean, CCFloat, CCInteger, Node, PipelineEventType } from '../core';
/**
* @en Terrain info
@@ -1584,11 +1584,11 @@ export class Terrain extends Component {
this._blocks[i].visible = true;
}
(legacyCC.director.root as Root).pipeline.on(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this);
(legacyCC.director.root as Root).pipelineEvent.on(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this);
}
public onDisable () {
(legacyCC.director.root as Root).pipeline.off(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this);
(legacyCC.director.root as Root).pipelineEvent.off(PipelineEventType.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this);
for (let i = 0; i < this._blocks.length; ++i) {
this._blocks[i].visible = false;
@@ -19,6 +19,47 @@
se::Object* __jsb_cc_render_PipelineRuntime_proto = nullptr; // NOLINT
se::Class* __jsb_cc_render_PipelineRuntime_class = nullptr; // NOLINT
static bool js_render_PipelineRuntime_activate(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::render::PipelineRuntime>(s);
SE_PRECONDITION2(cobj, false, "js_render_PipelineRuntime_activate : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 1) {
HolderType<cc::gfx::Swapchain*, false> arg0 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
SE_PRECONDITION2(ok, false, "js_render_PipelineRuntime_activate : Error processing arguments");
bool result = cobj->activate(arg0.value());
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_render_PipelineRuntime_activate : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(js_render_PipelineRuntime_activate)
static bool js_render_PipelineRuntime_destroy(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::render::PipelineRuntime>(s);
SE_PRECONDITION2(cobj, false, "js_render_PipelineRuntime_destroy : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 0) {
bool result = cobj->destroy();
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_render_PipelineRuntime_destroy : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_render_PipelineRuntime_destroy)
static bool js_render_PipelineRuntime_getConstantMacros(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::render::PipelineRuntime>(s);
@@ -148,6 +189,25 @@ static bool js_render_PipelineRuntime_onGlobalPipelineStateChanged(se::State& s)
}
SE_BIND_FUNC(js_render_PipelineRuntime_onGlobalPipelineStateChanged)
static bool js_render_PipelineRuntime_render(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::render::PipelineRuntime>(s);
SE_PRECONDITION2(cobj, false, "js_render_PipelineRuntime_render : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 1) {
HolderType<std::vector<const cc::scene::Camera *>, true> arg0 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
SE_PRECONDITION2(ok, false, "js_render_PipelineRuntime_render : Error processing arguments");
cobj->render(arg0.value());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(js_render_PipelineRuntime_render)
static bool js_render_PipelineRuntime_setProfiler(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::render::PipelineRuntime>(s);
@@ -177,7 +237,10 @@ bool js_register_render_PipelineRuntime(se::Object* obj) // NOLINT(readability-i
cls->defineProperty("pipelineSceneData", _SE(js_render_PipelineRuntime_getPipelineSceneData_asGetter), nullptr);
cls->defineProperty("constantMacros", _SE(js_render_PipelineRuntime_getConstantMacros_asGetter), nullptr);
cls->defineProperty("profiler", _SE(js_render_PipelineRuntime_getProfiler_asGetter), _SE(js_render_PipelineRuntime_setProfiler_asSetter));
cls->defineFunction("activate", _SE(js_render_PipelineRuntime_activate));
cls->defineFunction("destroy", _SE(js_render_PipelineRuntime_destroy));
cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_render_PipelineRuntime_onGlobalPipelineStateChanged));
cls->defineFunction("render", _SE(js_render_PipelineRuntime_render));
cls->install();
JSBClassType::registerClass<cc::render::PipelineRuntime>(cls);
@@ -29,7 +29,10 @@ extern se::Class * __jsb_cc_render_PipelineRuntime_class; // NOLINT
bool js_register_cc_render_PipelineRuntime(se::Object *obj); // NOLINT
SE_DECLARE_FUNC(js_render_PipelineRuntime_activate);
SE_DECLARE_FUNC(js_render_PipelineRuntime_destroy);
SE_DECLARE_FUNC(js_render_PipelineRuntime_onGlobalPipelineStateChanged);
SE_DECLARE_FUNC(js_render_PipelineRuntime_render);
extern se::Object *__jsb_cc_render_DescriptorHierarchy_proto; // NOLINT
extern se::Class * __jsb_cc_render_DescriptorHierarchy_class; // NOLINT
@@ -78,6 +78,10 @@ public:
virtual ~PipelineRuntime() noexcept = 0;
virtual bool activate(gfx::Swapchain * swapchain) = 0;
virtual bool destroy() noexcept = 0;
virtual void render(const std::vector<const scene::Camera*>& cameras) = 0;
virtual const MacroRecord &getMacros() const = 0;
virtual pipeline::GlobalDSManager &getGlobalDSManager() const = 0;
virtual gfx::DescriptorSetLayout &getDescriptorSetLayout() const = 0;