mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 18:42:40 +08:00
02407dbc70
* decouple GlobalDescriptorSetManager from RenderPipeline * formatting * move interface onGlobalPipelineStateChanged from PipelineSceneData to Pipeline * add layouts * fix eslint error * rendergraph creates device resources * restore resourceGraph * resource graph updated * add scene interface * layout graph updated * stop use IntrusivePtr<gfx::Swapchain> * add setViewport setScissor * scene transversal modified * accidentally omitted * remove pipeline event from pipeline, decouple terrain from render pipeline * shadingScale moved from PipelineSceneData to Pipeline * Pipeline removed from PipelineSceneData * pipelineEvent refactored * fix typo * rendergraph executes * interface changed * fix submit * Update the draw function * pipeline runtime added to pipeline * automatically barrier * typo * comment * forgot sth important * add classic/custom pipeline switch * web pipeline can be enabled * relax pipeline interface * pipeline use gfx::Color * decouple native RenderPipeline * fix clang tidy * add get pipelineSceneData * present refactored * added executor example * half way done * find slot * merge & sort layout * layout graph updated * enable native usesCustomPipeline * change mergedbs * fix comment * fix eslint error * fix * draft * update the rendergraph compiler * update the compiler * update executor * update to latest * revert mtlcmdbuffer manually * valid added * external node * add framebuffer * fix linter * fix linter * fix implicit narrow cast * fix linter * use native root.pipeline * use Root to get pipeline instance * fix ccstd::string * turn off validation * cleanup * ccstd::pmr::string changed * update the pipeline ubo * use ccstd::pmr::string * uses ccstd::pmr::vector * uses ccstd::pmr::map * reconstruction * external res * compile issue * clang tidy * fix ccstd::pmr::string hash * fix potential issue * Fixed some rendering errors of webpipeline in the editor * Optimize attachment load/storeOp logic * update executor * WebPipeline bug fixed in editor * Fix the problem of resource cache error when camera is deleted or added * webpipeline performs logic adjustments and bug fixes * render graph updated * descriptor updated * descriptor updated * fix member traits * libstdc++ does not support hashing std::pmr::string on linux * refactor descriptor * jsb allocator walkaround * rename * descriptor type refactored * fix default * adding layout graph builder * transfer env * switch env * switch env * adding native layout builder * adding native builder * adding layout graph * adding descriptor * adding descriptor layout * create layout graph builder added * fix root * format * add web layout graph builder * refactor web layout graph * fix intrusive ptr * descriptor set data updated * before applying another idea * debug string added * adding render graph * adding resource graph * adding native pipeline * graph remove edge temporary fix * remove_edge simplified * remove edge simplified * outIter renamed * remove edges simplified * fix reference graph impl * run test case * adding native impl * remove unused native * queue added * pass reorder v1.0 * adding native pipeline * adding native pipeline * fix bug * render graph setup added * render graph updated * fix ccstd::string * getFirstChildLayout, num of children must be 1 * remove examples * structure refactor * pass reorder & framegraphDispatcher interface * remove test code * remove debug code * ts added object detection * ts get name added * RenderGraph setup moved * add ts layout graph implement * fix lint * fix ci: implicit type conversion * ci * adding warmup * turn off custom * pipeline updated * format * try disable clang 64 to 32 narrow warning Co-authored-by: zxx43 <zxx43@hotmail.com> Co-authored-by: GengineJS <476393671@qq.com> Co-authored-by: Zeqiang Li <zeqiang-li@outlook.com>
178 lines
4.7 KiB
TypeScript
178 lines
4.7 KiB
TypeScript
import { Pool } from './memop';
|
|
import { warnID } from './platform';
|
|
import { Batcher2D } from '../2d/renderer/batcher-2d';
|
|
import legacyCC from '../../predefine';
|
|
import { DataPoolManager } from '../3d/skeletal-animation/data-pool-manager';
|
|
import { Device } from './gfx';
|
|
|
|
declare const nr: any;
|
|
declare const jsb: any;
|
|
|
|
export const Root = jsb.Root;
|
|
|
|
enum LightType {
|
|
DIRECTIONAL,
|
|
SPHERE,
|
|
SPOT,
|
|
UNKNOWN,
|
|
}
|
|
|
|
/**
|
|
* @zh
|
|
* Root描述信息
|
|
*/
|
|
export interface IRootInfo {
|
|
enableHDR?: boolean;
|
|
}
|
|
|
|
const rootProto: any = Root.prototype;
|
|
|
|
Object.defineProperty(rootProto, 'batcher2D', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get(): Batcher2D {
|
|
return this._batcher;
|
|
},
|
|
});
|
|
|
|
Object.defineProperty(rootProto, 'dataPoolManager', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get(): DataPoolManager {
|
|
return this._dataPoolMgr;
|
|
},
|
|
});
|
|
|
|
Object.defineProperty(rootProto, 'pipelineEvent', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get () {
|
|
return this._pipelineEvent;
|
|
}
|
|
});
|
|
|
|
class DummyPipelineEvent {
|
|
on (type: any, callback: any, target?: any, once?: boolean) {}
|
|
once (type: any, callback: any, target?: any) {}
|
|
off (type: any, callback?: any, target?: any) {}
|
|
emit (type: any, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any) {}
|
|
targetOff (typeOrTarget: any) {}
|
|
removeAll (typeOrTarget: any) {}
|
|
hasEventListener (type: any, callback?: any, target?: any): boolean { return false; }
|
|
}
|
|
|
|
rootProto._ctor = function (device: Device) {
|
|
this._device = device;
|
|
this._dataPoolMgr = legacyCC.internal.DataPoolManager && new legacyCC.internal.DataPoolManager(device) as DataPoolManager;
|
|
this._modelPools = new Map();
|
|
this._lightPools = new Map();
|
|
this._batcher = null;
|
|
this._pipelineEvent = new DummyPipelineEvent();
|
|
this._registerListeners();
|
|
};
|
|
|
|
rootProto.initialize = function (info: IRootInfo) {
|
|
// TODO:
|
|
this._initialize(legacyCC.game._swapchain);
|
|
};
|
|
|
|
rootProto.createModel = function (ModelCtor) {
|
|
let p = this._modelPools.get(ModelCtor);
|
|
if (!p) {
|
|
this._modelPools.set(ModelCtor, new Pool(() => new ModelCtor(), 10, (obj) => obj.destroy()));
|
|
p = this._modelPools.get(ModelCtor)!;
|
|
}
|
|
const model = p.alloc();
|
|
model.initialize();
|
|
return model;
|
|
};
|
|
|
|
rootProto.removeModel = function (m) {
|
|
const p = this._modelPools.get(m.constructor);
|
|
if (p) {
|
|
p.free(m);
|
|
m.destroy();
|
|
if (m.scene) {
|
|
m.scene.removeModel(m);
|
|
}
|
|
} else {
|
|
warnID(1300, m.constructor.name);
|
|
}
|
|
};
|
|
|
|
rootProto.createLight = function (LightCtor) {
|
|
let l = this._lightPools.get(LightCtor);
|
|
if (!l) {
|
|
this._lightPools.set(LightCtor, new Pool(() => new LightCtor(), 4, (obj) => obj.destroy()));
|
|
l = this._lightPools.get(LightCtor)!;
|
|
}
|
|
const light = l.alloc();
|
|
light.initialize();
|
|
return light;
|
|
};
|
|
|
|
rootProto.destroyLight = function (l) {
|
|
const p = this._lightPools.get(l.constructor);
|
|
l.destroy();
|
|
if (p) {
|
|
p.free(l);
|
|
if (l.scene) {
|
|
switch (l.type) {
|
|
case LightType.SPHERE:
|
|
l.scene.removeSphereLight(l);
|
|
break;
|
|
case LightType.SPOT:
|
|
l.scene.removeSpotLight(l);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
rootProto._onBatch2DInit = function () {
|
|
if (!this._batcher && legacyCC.internal.Batcher2D) {
|
|
this._batcher = new legacyCC.internal.Batcher2D(this);
|
|
if (!this._batcher!.initialize()) {
|
|
this.destroy();
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
rootProto._onBatch2DUpdate = function () {
|
|
if (this._batcher) this._batcher.update();
|
|
};
|
|
|
|
rootProto._onBatch2DUploadBuffers = function () {
|
|
if (this._batcher) this._batcher.uploadBuffers();
|
|
};
|
|
|
|
rootProto._onBatch2DReset = function () {
|
|
if (this._batcher) this._batcher.reset();
|
|
};
|
|
|
|
rootProto._onDirectorBeforeCommit = function () {
|
|
legacyCC.director.emit(legacyCC.Director.EVENT_BEFORE_COMMIT);
|
|
};
|
|
|
|
const oldFrameMove = rootProto.frameMove;
|
|
rootProto.frameMove = function (deltaTime: number) {
|
|
oldFrameMove.call(this, deltaTime, legacyCC.director.getTotalFrames());
|
|
};
|
|
|
|
const oldSetPipeline = rootProto.setRenderPipeline;
|
|
rootProto.setRenderPipeline = function (pipeline) {
|
|
if (this.usesCustomPipeline) {
|
|
return oldSetPipeline.call(this, null);
|
|
} else {
|
|
if (!pipeline) {
|
|
// pipeline should not be created in C++, ._ctor need to be triggered
|
|
pipeline = new nr.ForwardPipeline();
|
|
pipeline.init();
|
|
}
|
|
return oldSetPipeline.call(this, pipeline);
|
|
}
|
|
}
|