UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

66 lines (56 loc) 1.54 kB
// import { assert } from "../../../../core/assert.js"; /** * Built by FrameGraphBuilder, maps abstract resource handles to concrete, allocated GPU resources */ export class RenderPassResources { /** * * @type {RenderGraph|null} * @private */ __graph = null; /** * * @type {RenderPassNode|null} * @private */ __pass = null; /** * * @param {RenderGraph} graph * @param {RenderPassNode} node */ init(graph, node) { this.__graph = graph; this.__pass = node; } /** * @template T * @param {number} id resource id * @returns {T} */ get(id) { assert.ok( this.__pass.reads(id) || this.__pass.writes(id) || this.__pass.creates(id) , "Pass must declare a reference to the resource in some way (READ/WRITE/CREATE) during setup"); const entry = this.__graph.getResourceEntry(id); return entry.resource; } /** * @template T * @param {number} id resource id * @returns {T} */ getDescriptor(id) { assert.ok( this.__pass.reads(id) || this.__pass.writes(id) || this.__pass.creates(id) , "Pass must declare a reference to the resource in some way (READ/WRITE/CREATE) during setup"); const entry = this.__graph.getResourceEntry(id); return entry.resource_descriptor; } }