import '../../../../../globals.js';
// Copyright 2024, University of Colorado Boulder
/**
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, BufferBindingType, decimalS, mergeSimpleWGSL, wgsl, WGSLMainModule, WGSLSlot } from '../../../imports.js';
export const MAIN_MERGE_SIMPLE_DEFAULTS = {
// TODO: will need something once we have lengthExpression optional
};
const mainMergeSimpleWGSL = (options) => {
    const workgroupSize = options.workgroupSize;
    const grainSize = options.grainSize;
    const order = options.order;
    const lengthExpressionA = options.lengthExpressionA;
    const lengthExpressionB = options.lengthExpressionB;
    return new WGSLMainModule([
        new WGSLSlot('a', options.inputA, BufferBindingType.READ_ONLY_STORAGE),
        new WGSLSlot('b', options.inputB, BufferBindingType.READ_ONLY_STORAGE),
        new WGSLSlot('c', options.output, BufferBindingType.STORAGE)
    ], wgsl `
    @compute @workgroup_size(${decimalS(workgroupSize)})
    fn main(
      @builtin(global_invocation_id) global_id: vec3u,
      @builtin(local_invocation_id) local_id: vec3u,
      @builtin(workgroup_id) workgroup_id: vec3u
    ) {
      ${mergeSimpleWGSL({
        lengthA: lengthExpressionA,
        lengthB: lengthExpressionB,
        setFromA: (indexOutput, indexA) => wgsl `c[ ${indexOutput} ] = a[ ${indexA} ];`,
        setFromB: (indexOutput, indexB) => wgsl `c[ ${indexOutput} ] = b[ ${indexB} ];`,
        grainSize: grainSize,
        compare: (indexA, indexB) => order.compareWGSL(wgsl `a[ ${indexA} ]`, wgsl `b[ ${indexB} ]`),
        greaterThan: (indexA, indexB) => order.greaterThanWGSL(wgsl `a[ ${indexA} ]`, wgsl `b[ ${indexB} ]`),
        lessThanOrEqual: (indexA, indexB) => order.lessThanOrEqualWGSL(wgsl `a[ ${indexA} ]`, wgsl `b[ ${indexB} ]`)
    })}
    }
  `);
};
export default mainMergeSimpleWGSL;
alpenglow.register('mainMergeSimpleWGSL', mainMergeSimpleWGSL);
//# sourceMappingURL=mainMergeSimpleWGSL.js.map