PDA

View Full Version : Short question on shader variable indices



Lefteris
11-25-2010, 08:08 AM
Hey all,

I noticed something using the functions glGetActiveAttrib and glGetActiveUniform. If I try to run through all the uniform variables of the active shader I noticed that they are returned to me alphabetically. Same applies for attribute variables.

So for example variable "aaa" is at i = 0, "aab" at i=1, e.t.c.
Because in my application I need to be able to acquire all active variables and assign values to them this fact is quite useful to me.

But I have one question. I did not see this written anywhere. Could this be implementation specific depending on the user's graphics card? Or is this standard practice and I can rely on it always happening?

YarUnderoaker
11-25-2010, 09:40 AM
I noted that only NVidia GLSL compiler sort variables alphabetically. AMD compiler assign indices in order as variable meets in shader code. So vendor behavior is different.

Aleksandar
11-25-2010, 01:17 PM
Don't rely on that!
It is more likely that the indices are assigned in order they appear in the shader, but it is implementation dependent (even various drivers from the same vendor can have various indexing).

Lefteris
11-25-2010, 08:31 PM
I see guys. Thanks for your answers. Damn would be nice if they all followed the alphabetic order standard. Anyhow I will have to figure somehting else out. Thanks for warning me for that. You saed me from lots of debugging in the future :)