-
Notifications
You must be signed in to change notification settings - Fork 648
Open
Description
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) == 16However, when translated to MSL, it becomes:
struct S
{
float3 pos; // size = 16'bytes, alignment = 16'bytes
uint uv;
};
// sizeof(S) == 32This 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;
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels