@openhps/core
Version:
Open Hybrid Positioning System - Core component
86 lines (82 loc) • 2.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.workgroupBarrier = exports.textureBarrier = exports.storageBarrier = exports.default = void 0;
var _Node = _interopRequireDefault(require("../core/Node.js"));
var _TSLCore = require("../tsl/TSLCore.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Represents a GPU control barrier that synchronizes compute operations within a given scope.
*
* This node can only be used with a WebGPU backend.
*
* @augments Node
*/
class BarrierNode extends _Node.default {
/**
* Constructs a new barrier node.
*
* @param {string} scope - The scope defines the behavior of the node.
*/
constructor(scope) {
super();
this.scope = scope;
}
generate(builder) {
const {
scope
} = this;
const {
renderer
} = builder;
if (renderer.backend.isWebGLBackend === true) {
builder.addFlowCode(`\t// ${scope}Barrier \n`);
} else {
builder.addLineFlowCode(`${scope}Barrier()`, this);
}
}
}
var _default = exports.default = BarrierNode;
/**
* TSL function for creating a barrier node.
*
* @tsl
* @function
* @param {string} scope - The scope defines the behavior of the node..
* @returns {BarrierNode}
*/
const barrier = (0, _TSLCore.nodeProxy)(BarrierNode);
/**
* TSL function for creating a workgroup barrier. All compute shader
* invocations must wait for each invocation within a workgroup to
* complete before the barrier can be surpassed.
*
* @tsl
* @function
* @returns {BarrierNode}
*/
const workgroupBarrier = () => barrier('workgroup').append();
/**
* TSL function for creating a storage barrier. All invocations must
* wait for each access to variables within the 'storage' address space
* to complete before the barrier can be passed.
*
* @tsl
* @function
* @returns {BarrierNode}
*/
exports.workgroupBarrier = workgroupBarrier;
const storageBarrier = () => barrier('storage').append();
/**
* TSL function for creating a texture barrier. All invocations must
* wait for each access to variables within the 'texture' address space
* to complete before the barrier can be passed.
*
* @tsl
* @function
* @returns {BarrierNode}
*/
exports.storageBarrier = storageBarrier;
const textureBarrier = () => barrier('texture').append();
exports.textureBarrier = textureBarrier;