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.
Type Parameters
Section titled “Type Parameters”• TAlign extends number
• TData extends AnyData
Parameters
Section titled “Parameters”alignment
Section titled “alignment”TAlign
The multiple of bytes this data should align itself to.
TData
The data-type to align.
Returns
Section titled “Returns”Decorate
<TData
, Align
<TAlign
>>
Example
Section titled “Example”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),});