import '../../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * Converts an index from a normal (blocked) order to a striped order (for improved memory coherence).
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, u32S, wgsl, wgslOneLine } from '../../../imports.js';
const toStripedIndexWGSL = (options) => {
    const i = options.i;
    const workgroupSize = options.workgroupSize;
    const grainSize = options.grainSize;
    return wgslOneLine(wgsl `
    // TODO: optimizations if workgroupSize or grainSize is 1
    (
      ( ( ${i} ) / ${u32S(workgroupSize * grainSize)} ) * ${u32S(workgroupSize * grainSize)} +
      ( ( ${i} ) % ${u32S(grainSize)} ) * ${u32S(workgroupSize)} +
      ( ( ( ${i} ) % ${u32S(workgroupSize * grainSize)} ) / ${u32S(grainSize)} )
    )
  `);
};
export default toStripedIndexWGSL;
alpenglow.register('toStripedIndexWGSL', toStripedIndexWGSL);
//# sourceMappingURL=toStripedIndexWGSL.js.map