o3de / o3de-azslc

Amazon Shader Language (AZSL) Compiler
Other
23 stars 14 forks source link

Atom/galibzon/pad to n #18

Closed galibzon closed 3 years ago

galibzon commented 3 years ago

Add [[pad_to(N)]] language feature

This is version 1.7.34

"struct" definitions now support the [[pad_to(N)]] attribute. This attribute, when used, must be declared after a member variable. Each member variable can have one of these attributes after it.

The attribute is useful to pad the data with dummy variables until guaranteeing that the offset of the next variable starts with the desired alignment. The 'N' argument is a single integral literal that must be a multiple of 4.

A companion class to the IntermediateRepresentation has been added: StructPadToMutator. It contains all the logic and algorithms to collect, during parsing, the variables that require padding and apply the appropriate mutations (variable insertions) during the IntermediateRepresentation::MiddleEnd().