Short question on shader variable indices

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?

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.

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).

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 :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.