I have the following situation. UBO structure that holds 4 uint64_t in an array.
struct MaterialData{
uint64_t comps[4];
};
layout (std140, binding = 0) uniform MaterialBlock {
MaterialData data[50];
}material;
The problem is,only index = 0 gives me correct data.But if I change to GLSL built-in type vector of uint64_t, it all works ok:
struct MaterialData{
u64vec4 textures;
};
It surely has something to do with padding rules for std140.And here is what OpenGL 4.5 specs says:
If the member is an array of scalars or vectors, the base alignment and array stride are set to match the base alignment of a single array element, according to rules (1), (2), and (3), and rounded up to the base alignment of a vec4. The array may have padding at the end; the base offset of the member following the array is rounded up to the next multiple of the base alignment.
So I understand from this part
the base alignment and array stride are set to match the base alignment of a single array element
that each array's member alignment is the size of the member,which is 8 bytes.Though this is not exactly clear.And in reality it doesn't work.I can get along with u64vec4 but I want to know how to pad an array of uint64_t?