In GLSL shared memory follow std430 alignment rules, meaning padding after vec3 can be utilized by 4-byte variable.
For example:
struct S {
vec3 pos;
uint uv;
};
// sizeof(S) == 16
However, when translated to MSL, it becomes:
struct S
{
float3 pos; // size = 16'bytes, alignment = 16'bytes
uint uv;
};
// sizeof(S) == 32
This mismatch can cause significant memory overuse. In my particular case, resulting in shader fail to run, due to use of more than 32kb of memory.
Suggested fix: use packed_float3 with alignas:
struct S
{
alignas(16) packed_float3 pos;
uint uv;
};