import '../../../../../assert/js/assert.js';
import '../../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * Increments a count from within a bit-packed histogram. See bit_pack_radix_access for more documentation.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, u32S, wgsl } from '../../../imports.js';
const bitPackRadixIncrementWGSL = (options) => {
    const bitVector = options.bitVector;
    const bits = options.bits;
    const bitsPerInnerPass = options.bitsPerInnerPass;
    const bitVectorSize = options.bitVectorSize;
    const maxCount = options.maxCount;
    // TODO: code share with other components(!)
    const countBitQuantity = Math.ceil(Math.log2(maxCount));
    const countsPerComponent = Math.floor(32 / countBitQuantity);
    assert && assert(bitVectorSize * countsPerComponent >= (1 << bitsPerInnerPass), 'Not enough space for bit-packing');
    return wgsl `
    ${bitVector}${bitVectorSize > 1 ? wgsl `[ ${countsPerComponent === 1 ? bits : wgsl `( ${bits} ) / ${u32S(countsPerComponent)}`} ]` : wgsl ``} += 1u${countsPerComponent === 1 ? wgsl `` : wgsl ` << ( ( ( ${bits} ) % ${u32S(countsPerComponent)} ) * ${u32S(countBitQuantity)} )`};
  `;
};
export default bitPackRadixIncrementWGSL;
alpenglow.register('bitPackRadixIncrementWGSL', bitPackRadixIncrementWGSL);
//# sourceMappingURL=bitPackRadixIncrementWGSL.js.map