Sign in to follow this  

Uniform Buffer & shared layout -> Index still -1

This topic is 1574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

<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();

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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). Edited by BitMaster

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites
Sign in to follow this