Fix calculation of array size when calculating struct sizes

* Non-tightly packed arrays can be larger based on the stride than base size
  multiplied by element count, e.g. with a 4-byte uint with a 16-byte array
  stride.
This commit is contained in:
baldurk
2026-08-03 21:15:19 +01:00
parent 430286642d
commit fda6fc2322
@@ -484,9 +484,13 @@ StructSizes CalculateStructProps(uint32_t emptyStructSize, const ShaderConstant
}
}
ret.scalarSize *= RDCMAX(c.type.elements, 1U);
ret.baseSize *= RDCMAX(c.type.elements, 1U);
ret.extendedSize *= RDCMAX(c.type.elements, 1U);
if(c.type.elements > 1)
{
const uint32_t nonFinalArraySize = (c.type.elements - 1) * c.type.arrayByteStride;
ret.scalarSize += nonFinalArraySize;
ret.baseSize += nonFinalArraySize;
ret.extendedSize += nonFinalArraySize;
}
return ret;
}