I cannot get the following structure to work when using it in Shader Storage Object:
Definitions in shader:
struct Object
{
vec4 color;
mat3 transform;
float depth;
float pObjIndex;
//float align1;
//float align2;
};
layout (std430, binding = 0) buffer Objects
{
Object objects[];
};
It's my understanding that the Object structure is aligned in GLSL by its largest member which is vec4, i.e. by 16-byte boundary. (mat3 is treated as 3-element array of vec3's and is aligned by 12-bytes boundary). The vec4, mat3 and 2 floats give 72 bytes. When I pad the structure to the nearest 16-byte multiple - 80 - with two floats, it's not working properly just as without padding.
Are both variants of this structure's layout - with padding with 2 floats and without any padding - incorrect?
the mat3
is actually 3 vec4
s as each vec3 is 3 floats aligned to 16 bytes (or at least it may not straddle a 16 byte boundary)
struct Object
{
float[4] color;
float[4][3] transform;
float depth;
float pObjIndex;
//float align1;
//float align2;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With