Skip to content

align

align<TAlign, TData>(alignment, data): Decorate<TData, Align<TAlign>>

Defined in: packages/typegpu/src/data/attributes.ts:167

Gives the wrapped data-type a custom byte alignment. Useful in order to fulfill uniform alignment requirements.

TAlign extends number

TData extends AnyData

TAlign

The multiple of bytes this data should align itself to.

TData

The data-type to align.

Decorate<TData, Align<TAlign>>

const Data = d.struct({
a: u32, // takes up 4 bytes
// 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
b: d.align(16, u32),
});