UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

173 lines 4.69 kB
/** * Based on the Frostbite's GDC paper "FrameGraph: Extensible Rendering Architecture in Frostbite" by Yuriy O'Donnell * @example * const graph = new RenderGraph("My Graph"); * * const pass_data = {}; * const pass = graph.add("GBuffer Pass", pass_data, (data, resources, context) => { * * context.beginRenderPass({ * depth_attachment: resources.get(data.depth), * color_attachments:[ * resources.get(data.normal), * resources.get(data.albedo), * ] * }); * * for (const renderable in renderables){ * drawMesh(context, renderable.mesh, renderable.material); * } * * context.endRenderPass(); * * }); * * pass_data.depth = pass.create("depth", {...}); * pass_data.albedo = pass.create("albedo", {...}); * pass_data.normal = pass.create("normal", {...}); * * graph.compile(); * graph.execute(context); * */ export class RenderGraph { /** * * @param {string} name */ constructor(name?: string); /** * Human-readable name, used for debugging and UI primarily. * There is no uniqueness guarantee * @type {string} */ name: string; /** * * @type {RenderPassNode[]} * @private */ private __pass_nodes; /** * * @type {ResourceNode[]} * @private */ private __resource_nodes; /** * * @type {ResourceEntry[]} * @private */ private __resource_registry; /** * * @param {number} id Resource Node ID * @returns {ResourceEntry} */ getResourceEntry(id: number): ResourceEntry<any>; /** * * @param {number} id * @returns {ResourceNode} */ getResourceNode(id: number): ResourceNode<any>; /** * @template T * @param {number} id resource ID * @returns {T} */ getDescriptor<T>(id: number): T; /** * @template T * @param {string} name * @param {T} descriptor * @returns {number} */ create_resource<T_1>(name: string, descriptor: T_1): number; /** * @template T * @param {T} descriptor * @return {ResourceEntry} * @private */ private _createResourceEntry; /** * * @param {string} name * @param {number} resource_id * @return {ResourceNode} * @private */ private _createResourceNode; /** * * @param {number} node_id * @returns {number} ID of the cloned resource node */ clone_resource(node_id: number): number; /** * @template T * @param {string} name * @param {ResourceDescriptor<T>} description * @param {T} resource * @returns {number} */ import_resource<T_2>(name: string, description: ResourceDescriptor<T_2>, resource: T_2): number; /** * @returns {boolean} * @param id */ is_valid_resource(id: any): boolean; /** * Add a new pass to the graph. * @template T * @param {string} name * @param {T} data * @param {function(data:T, resources: RenderPassResources, context:IRenderContext):void} execute * @returns {RenderPassBuilder} */ add<T_3>(name: string, data: T_3, execute: any): RenderPassBuilder; /** * Perform validation, useful for debugging * Typically done before compilation * @param {function(problem:string):*} problem_consumer * @param {*} [problem_consumer_context] thisArg for `problem_consumer` * @returns {boolean} */ validate(problem_consumer: any, problem_consumer_context?: any): boolean; compile(): void; /** * * @param {IRenderContext} context */ execute(context: IRenderContext): void; /** * Should only call after {@link compile} * * Can be visualized with this tool: https://skaarj1989.github.io/FrameGraph/ * * @see https://github.com/skaarj1989/FrameGraph/blob/viewer/JsonWriter.hpp * @return {{passes: [], resources: []}} */ exportToJson(): { passes: []; resources: []; }; /** * Export the graph diagram in GraphViz DOT format. * Useful for debugging. * @see https://en.wikipedia.org/wiki/DOT_(graph_description_language) * @return {string} */ exportToDot(): string; /** * @readonly * @type {boolean} */ readonly isRenderGraph: boolean; } import { ResourceEntry } from "./ResourceEntry.js"; import { ResourceNode } from "./ResourceNode.js"; import { RenderPassBuilder } from "./RenderPassBuilder.js"; //# sourceMappingURL=RenderGraph.d.ts.map