Uniform arrays in OpenGLES

In my fragment shader, I have a uniform array like this:

uniform mediump vec3 lightdirection[4];

On iPhone 4, iPad 2, and HTC Evo, I use the string “lightdirection[0]” to set the uniform value from the main program.

I got a Samsung Galaxy Tab today and it only works if I use “lightdirection” to identify the uniform. Which is it supposed to be?

According to this, it’s both, which makes sense:
http://www.opengl.org/wiki/GLSL_Uniform

I swear it wasn’t working on iOS. Can anyone comment on this?

I just tested, and I’m right. On iOS, only the uniform with the suffix ‘[0]’ is recognized. On the Galaxy Tab, only the uniform without the suffix is recognized. My solution is to never use uniform arrays.

Excuse me for using your thread, but please explain the idea behind declaring a uniform array with size 0.

I have a uniform array where I don’t know what size I need. That is, I would like the size to be dynamic, not static. Is that when you use 0 in the declaration? I am using OpenGL 3, not ES.

The link you provided above states that each entry in the array have a location of their own. But I currently update the whole array with one call to glUniform4fv, and it seems to work. According to the documentation, you can update an array of uniforms that way.

My solution is to never use uniform arrays.

It’s certainly one solution. You could also just upload each element individually.

It also shows how much the GL ES 2.0 conformance tests actually prevent these kinds of problems. IE: not at all.

Excuse me for using your thread, but please explain the idea behind declaring a uniform array with size 0.

He’s not declaring a uniform array with size 0. He’s talking about getting the uniform location for the array, so that he can upload multiple elements at once with glUniformfv

Ah, but you can’t. The Galaxy Nexus won’t recognize the uniform name with the indice appended ([0],[1],[2]). There is no reliable way to send any data to a uniform array on mobile devices.

Who produces the drivers for these? Both the iPad and Galaxy Tab use a PowerVR chip. Does Samsung actually write their own drivers for this, or do they get them from PowerVR, and just haven’t updated the software?