I have the following array of structs in glsl SSBO:
struct node {
vec3 min, max;
int hitNext;
int missNext;
int firstTri, numTris;
};
layout(std430, binding = 3) readonly buffer Nodes {
node[] nodes;
};
I am passing them a bytebuffer where I have stored the data in the following format:
4 bytes min.x, 4 bytes min.y, 4 bytes min.z, 4 bytes 1.0f,
4 bytes max.x, 4 bytes max.y, 4 bytes max.z, 4 bytes 1.0f,
4 bytes hitNext, 4 bytes missNext, 4 bytes firstTrue, 4 bytes numTris
But glsl is not reading the data properly. If I change the vec3
in the struct definition to vec4
it works perfectly. But why is that the case? According to the OpenGL specs won't this be the alignment?:
struct node { //Base alignment Aligned Offset
vec3 min; // 16 0
vec3 max; // 16 16
int hitNext; // 4 32
int missNext; // 4 36
int firstTri, numTris; // 4 40
// 4 44
};
layout(std430, binding = 3) readonly buffer Nodes {
node[] nodes; // 16 48
};
But this alignment matches up with the data I'm passing in. Why does this not work but vec4
works?