Jump to content

  • Log In with Google      Sign In   
  • Create Account


Uniform Buffer & shared layout -> Index still -1


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 stefthedrummer   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 September 2013 - 07:27 AM

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


Sponsor:

#2 3TATUK2   Members   -  Reputation: 638

Like
1Likes
Like

Posted 26 September 2013 - 07:36 AM

they're optimized out because they're unused?



#3 Kraecker   Members   -  Reputation: 400

Like
0Likes
Like

Posted 26 September 2013 - 07:54 AM

they're optimized out because they're unused?

 

indeed :)



#4 stefthedrummer   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 September 2013 - 08:19 AM

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?



#5 stefthedrummer   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 September 2013 - 08:20 AM

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.



#6 BitMaster   Crossbones+   -  Reputation: 3001

Like
0Likes
Like

Posted 26 September 2013 - 08:33 AM

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, 26 September 2013 - 08:34 AM.


#7 stefthedrummer   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 September 2013 - 09:02 AM

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 ?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS