Uniform vs Vertex Attrib

Is there any difference (apart from the obvious setup differences) between using a Uniform to pass a vec4 to a shader, and using a Vertex Attrib?

i.e. If I have something changing every primitive and want to pass it in is either way better?

Eventually I’ll put sets into buffer / array objects, but for prototyping / not very often used instances, is one better than the other?

If it changing per primitive, then you are supposed to use uniform variable… they change per primitive too.

However if you are thinking about glVertexAttrib, a nVidia paper about speudo instancing give the advice to use this glVertexAttrib instead of glUniform. A reason could be because internally the drivers could relink the program when you change an uniform variable…

I have test actually so the best would be to have a look on the efficiency. This could have change with GeForce 8 anyway…

The issue is that the number of varying variable is quite limited comparying (64 float on GF8?) to uniform variable. (4096 float on GF8?)

WRT efficiency 1 for 1, changing uniforms are a lot slower than changing vertex attrib’s

And changing uniform buffers is slower still…

Thanks for the input people.

One further clarification if you don’t mind…

In my travels looking at some examples for clarification of ideas I have seen a lot of people sending identical Attrib data per vertex in immediate mode…

Obviously this becomes moot if you are using buffers but when I do it I seem to get away with just leaving the last data there for as long as it’s state does not change.
This is within a primitive, or groups of primitives…

But in any case my understanding is that as long as that attribute binding is in place the data should remain fixed.

Am I understanding this correctly, or getting away with something that is not guaranteed.

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