@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
108 lines (88 loc) • 1.98 kB
JavaScript
import { assert } from "../../../../core/assert.js";
import { noop } from "../../../../core/function/noop.js";
import { GraphNode } from "./GraphNode.js";
export class RenderPassNode extends GraphNode {
/**
*
* @type {Function}
*/
execute = noop
/**
*
* @type {boolean}
*/
has_side_effects = false;
/**
*
* @type {Object}
*/
data = {};
/**
* IDs of created resources
* @type {number[]}
*/
resource_creates = [];
/**
* IDs of read resources
* @type {number[]}
*/
resource_reads = [];
/**
* IDs of written resources
* @type {number[]}
*/
resource_writes = [];
/**
*
* @param {number} id
* @return {boolean}
*/
creates(id) {
assert.isNonNegativeInteger(id, 'id');
return this.resource_creates.includes(id);
}
/**
*
* @param {number} id
* @return {boolean}
*/
reads(id) {
assert.isNonNegativeInteger(id, 'id');
return this.resource_reads.includes(id);
}
/**
*
* @param {number} id
* @return {boolean}
*/
writes(id) {
assert.isNonNegativeInteger(id, 'id');
return this.resource_writes.includes(id);
}
write(resource) {
if (this.writes(resource)) {
return resource;
}
this.resource_writes.push(resource);
return resource;
}
/**
*
* @param {number} resource
* @returns {number} same as the input
*/
read(resource) {
if (this.reads(resource)) {
return resource;
}
this.resource_reads.push(resource);
return resource;
}
/**
*
* @return {boolean}
*/
can_execute() {
return this.ref_count > 0 || this.has_side_effects;
}
}