Hello there,
I got some misunderstanding on uniform buffer with layout std140,
I got my glsl (330) struct but depending on which computer is use it, the memory doesn’t seem to be handled the same way (windows/nvidia vs osx/integrated intel)
for each struct i will show i have a unique array like so in a uniform:
layout (std140) uniform Organs
{
Organ organs[2048];
};
and the proper matching C structs (rust but i think it does not matter)
Here is the first struct:
struct Organ {
vec2 p; // 2N Ok
float range; // 1N Not ok
int kind // 1N Not ok
}; // 4N Ok
Problem is this code works on windows/nvidia but not osx (i have range and kind with aberrant behaviour but p is fine), is this some kind of luck from implementation details ?
Second behaviour i don’t get
on osx, this does not work
struct Organ {
vec2 p; // 2N Ok
vec2 d; // 2N Ok
}; // total 4N Ok
but this works
struct Organ {
vec4 p; // 4N Ok
}; // total 4N Ok
But still from what i understand of the specs, both should be fine ?
I could have working this struct
struct Organ {
vec2 p; // 2N ok
float range; // 1N
float pad1; // 1N => total 2N Ok
int kind; // 1N
int pad2; // 1N => total 2N Ok
float roundtovec4; // 1N
float roundtovec41; // 1N => total 2N
}; // total 8N => 2 vec4 => 32 bits Ok
So is this a valid way of using std140 on any platform ?
Could you point me out some errors i could have done in understanding std140 and structs ?
Thanks