tags:

views:

13

answers:

1

Here are signatures.

glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
glUniform4fv(GLint location, GLsizei count, const GLfloat *v);

In my humble opinion, former should be faster because values can be passed directly from registers without fetching from memory. However, I want to hear many opinions.

A: 

They aren't comparable. The former sets a uniform variable which is a scalar (by which i mean a single 4-vector), the latter sets one which is an array (of 4-vectors).

It might be possible to treat an array of length 1 as a scalar, and vice versa, but it would be perverse. Thus, you are never in a situation where you have a choice between the two.

If you're really talking about the decision between using a single array variable and several scalars, then as long as you access all of them homogenously (ie do the same kinds of computations with them), i would imagine an array would be faster, because if you use multiple scalars, you have to do all the array arithmetic yourself, and it's likely the hardware will be better at that than you are.

Tom Anderson
@Tom Wow. I couldn't think about role of 'count' parameter. It's for bulk loading avoiding calling overhead! I was stupid! Thanks a lot!
Eonil