Reputation: 731
I want to retrieve some properties of a shader storage buffer:
struct A{
float x;
float y;
vec4 v;
};
struct B{
vec3 u;
};
layout(std430) buffer foo{
B b;
A a[];
};
Let's suppose the buffer is active. Retrieving the size of the buffer via glGetProgramResourceiv() works and yields 48 machine units. But retrieving the offset of the buffer variables and the array stride of "a" doesn't work.
const GLenum props[] = {GL_OFFSET};
GLint* offset = new GLint;
GLuint varIndex = glGetProgramResourceIndex(_progID, GL_BUFFER_VARIABLE, "b");
glGetProgramResourceiv(_progID, GL_BUFFER_VARIABLE, varIndex, 1, props, 1, NULL, offset);
The varIndex is always "GL_INVALID_INDEX". How do I get the offsets for all the buffer variables?
Upvotes: 3
Views: 1275
Reputation: 473322
It's an invalid index because there is no variable b
. There is b.u
, but there's no b
. The only variables that exist, as far as the introspection API is concerned, are variables that are of non-user-defined types.
Structures are just aggregates; the members are the actual values in those aggregates.
Upvotes: 4