Fix calculation of scalar struct size (it's not aligned up to alignment)

This commit is contained in:
baldurk committed 2022-10-10 14:28:26 +01:00
1 parent f3a2d59212
commit 5c2c434885
1 file changed
+5 -1
@@ -397,7 +397,11 @@ StructSizes CalculateStructProps(uint32_t emptyStructSize, const ShaderConstant
if(i + 1 == c.type.members.size())
{
ret.scalarSize = AlignUp(m.byteOffset + member.scalarSize, ret.scalarAlign);
// scalar struct sizes are NOT padded up to the multiple of their alignment. It is allowed
// in scalar packing for an outside variable to 'sit in' the padding at the end of a struct
// due to alignment. This rule is more tight than even C packing, which normally has
// sizeof(struct) be a multiple of its alignment
ret.scalarSize = m.byteOffset + member.scalarSize;
ret.baseSize = AlignUp(m.byteOffset + member.baseSize, ret.baseAlign);
ret.extendedSize = AlignUp16(m.byteOffset + member.extendedSize);
}