import '../../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * Performs a full radix-sort of an array in workgroup memory (which can be of length workgroupSize * grainSize),
 * using a more complicated/computational but lower-memory approach by packing the accumulated bits (that we scan over)
 * into a more compact form (packed into either a u32/vec2u/vec3u/vec4u, depending on the bitVectorSize parameter).
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, commentWGSL, nBitCompactSingleSortWGSL, u32S, wgsl } from '../../../imports.js';
import optionize from '../../../../../phet-core/js/optionize.js';
const compactSingleRadixSortWGSL = (providedOptions) => {
    const options = optionize()({
        getBits: value => providedOptions.getBitsAtIndex(value, wgsl `wrs_i`)
    }, providedOptions);
    return wgsl `
    ${commentWGSL('begin compact_single_radix_sort')}
  
    for ( var wrs_i = 0u; wrs_i < ${u32S(options.totalBits)}; wrs_i += ${u32S(options.bitsPerInnerPass)} ) {
      ${nBitCompactSingleSortWGSL(options)}
  
      // NOTE: no workgroupBarrier here, we already have it in the function
    }
  
    ${commentWGSL('end compact_single_radix_sort')}
  `;
};
export default compactSingleRadixSortWGSL;
alpenglow.register('compactSingleRadixSortWGSL', compactSingleRadixSortWGSL);
//# sourceMappingURL=compactSingleRadixSortWGSL.js.map