@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
87 lines (73 loc) • 1.95 kB
JavaScript
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;
/**
*
* @return {string}
*/
get pass_name() {
return this.__pass.name;
}
/**
*
* @return {number}
*/
get pass_id() {
return this.__pass.id;
}
/**
*
* @param {RenderGraph} graph
* @param {RenderPassNode} node
*/
init(graph, node) {
assert.defined(graph, 'graph');
assert.defined(node, 'node');
this.__graph = graph;
this.__pass = node;
}
/**
* @template T
* @param {number} id resource id
* @returns {T}
*/
get(id) {
assert.isNonNegativeInteger(id, '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.isNonNegativeInteger(id, '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;
}
}