import '../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * Contains all the data/methods needed by a kernel to run in parallel. Passed to the kernel execution function, so that
 * it can make equivalent calls similar to the WGPU calls.
 *
 * See ParallelExecutor for more high-level documentation.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow } from '../imports.js';
import Vector3 from '../../../dot/js/Vector3.js';
export default class ParallelContext {
    constructor(kernel, localId, workgroup, executor) {
        this.kernel = kernel;
        this.localId = localId;
        this.workgroup = workgroup;
        this.executor = executor;
        this.workgroupId = workgroup.id;
        this.globalId = new Vector3(localId.x + this.workgroupId.x * kernel.workgroupX, localId.y + this.workgroupId.y * kernel.workgroupY, localId.z + this.workgroupId.z * kernel.workgroupZ);
        this.localIndex = localId.x + localId.y * kernel.workgroupX + localId.z * kernel.workgroupX * kernel.workgroupY;
        this.workgroupValues = workgroup.values;
    }
    // To be called from within the kernel execution function
    async start() {
        return this.executor.start();
    }
    // To be called from within the kernel execution function
    async workgroupBarrier() {
        return this.executor.workgroupBarrier(this.workgroup);
    }
    // To be called from within the kernel execution function
    async storageBarrier() {
        return this.executor.storageBarrier(this.workgroup);
    }
    // TODO: workgroupUniformLoad
    // To be called from within the kernel execution function
    async afterSet() {
        return this.executor.afterSet();
    }
    // To be called from within the kernel execution function
    async afterGet() {
        return this.executor.afterGet();
    }
}
alpenglow.register('ParallelContext', ParallelContext);
//# sourceMappingURL=ParallelContext.js.map