Uniform Buffer & shared layout -> Index still -1

Started by
5 comments, last by Stephan Picker 10 years, 7 months ago
<h1>Problem</h1>
Hello. I'm trying to share a Uniform Buffer among different programs. The problem is, that I have to query the layout - which is shared - at one point. I tried all possibilities, but it always return -1.
The specification tells me, that with the shared layout, the driver is not allowed to optimize and has toactivate the variables.
What did I miss?
<h1>Code</h1>

#version 420 core
 
layout(shared) uniform Camera {
mat4 camViewProj;
mat4 sunViewProj;
mat4 sunViewCoordProj;
};
 
out mat4 outVar;
 
void main()
{
//outVar = camViewProj;
}
I only get a valid index for "camViewProj" when I uncomment the section above.
To Query the indices, I used:

glGetProgramResourceIndex();
glGetUniformIndices();
Advertisement

they're optimized out because they're unused?

they're optimized out because they're unused?

indeed :)

no ?!? But it's "shared": So it must not be optimized out.

If I'm not understanding right - whats the right approach to get the layout even for variables which are not used?

no ?!? But it's "shared": So it must not be optimized out.

If I'm not understanding right - whats the right approach to get the layout even for variables which are not used?

... I just want to get a valid index/location for all of them - even if they're not used. Because they're shared and not every shader needs all of them.

I think there was a very similar topic a while ago. While the driver cannot just drop the uniform from the uniform block it is under no obligation to supply you with a valid index while the uniform is not used in that particular shader (even though space is reserved for the uniform).

I think there was a very similar topic a while ago. While the driver cannot just drop the uniform from the uniform block it is under no obligation to supply you with a valid index while the uniform is not used in that particular shader (even though space is reserved for the uniform).

ok! Doesn't sound unreasonable.

But Is there still a mechanic/technique, that allows me to query layout information even though I don't use any variable at all ?

This topic is closed to new replies.

Advertisement