UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

17 lines (16 loc) 456 B
/** * @param io the IO to align * @param baseAlignment must be power of 2 */ function alignIO(io, baseAlignment) { const currentPos = 'size' in io ? io.size : io.currentByteOffset; const bitMask = baseAlignment - 1; const offset = currentPos & bitMask; if ('skipBytes' in io) { io.skipBytes((baseAlignment - offset) & bitMask); } else { io.add((baseAlignment - offset) & bitMask); } } export default alignIO;