Imagination PowerVR SDK Blog

Maximum number of varyings ?



Recently, I am using many varyings in my shader. 

How many varying variables can I use in a GLSL ES shader ? 

I searched this issue, and some people says only 8 varyings can be used on GLSL ES. 

Maybe there are limitations depending on hardware. 

I’m usually working on iPad 3rd gen and iphone 4s. 

Thanks in advance. 



You can query the maximum value with glGet(GL_MAX_VARYING_VECTORS). The OpenGL ES 2.0 manual pages have more information about this:

It’s worth noting that on some PowerVR platforms, the compiler will not pack for you - if 8 varying vectors are available, you need to ensure that you are only using a maximum of 8 vec4 varyings. This means that  you may not be able to, for example, have 7 vec4 varyings and 4 float varyings as the compiler may not be able to pack this into 8 vec4’s automatically.



Thanks, Joe. 

I just tested on a simulator because I don’t have a device now. 
On the iPhone simulator, glGet gave me 8. 

Actually, I need 12 varying variables for my shader. 
So I may be able to declare them as 3 vec4 vectors. 
Am I on a right way ? 


If you run the free app: OpenGL Extension Viewer (available on both iOS and Android), you can find many information about OpenGL ES capability.

Both of my iPod Touch 4G (SGX 535) and iPad 2 (SGX 543) have 8 varying vectors.



Yes - if you need 12 scalar varying values, it will be best to pack them into vec4’s. This should solve your problem :slight_smile: