Imagination PowerVR SDK Blog

Uniform vs Constant Attribute?


#1

I'm a bit confused on the circumstances in which a constant Attribute should be used. Presumably changing a uniform may end up with the shader being recompiled, whereas attributes will not attempt optimisation.Â

Using PVR OGLES2.0 emulation i found that passing regularly changing values as constant attributes gave a significant performance advantage. Is this true on actual devices? Or is it entirely driver dependant?


#2
Adventus wrote:
I'm a bit confused on the circumstances in which a constant Attribute should be used. Presumably changing a uniform may end up with the shader being recompiled, whereas attributes will not attempt optimisation.

Constant attributes are merely a convenience feature so you don't have to modify a shader for just a few meshes which happen to have a constant value for an attribute. Plus you can fit a few more constants if you run out of uniform space.



Apart from that, you should use them for what they were intended: attributes for values that may change per vertex, uniforms for values that may change per draw call.



Quote:
Using PVR OGLES2.0 emulation i found that passing regularly changing values as constant attributes gave a significant performance advantage. Is this true on actual devices? Or is it entirely driver dependant?

PC Emulation performance is very much dependent on the underlying desktop OpenGL driver.

#3

Thanks, I suspected that might be the answer. I'll see if my 8600GT driver is the cause of my woes.

Edit: Yep it was my drivers, changing from 169.X to 180.X drivers caused it to go from ~25 fps to ~300 fps. Something was messed up.


Adventus2009-01-07 02:51:43