On Adreno 320 (Sony Xperia ZL, driver [email protected]), there's a bug with arrays of structures.
If you access a structure from an array with a variable index, all fields of the structure point to the first field.
Here's example code:
glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color1"), 0.2f, 0.0f, 0.0f);
glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color2"), 0.0f, 1.0f, 0.0f);
glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color3"), 0.0f, 0.0f, 1.0f);
struct Colors { vec3 Color1, Color2, Color3; };
uniform Colors u_Colors[1];
void main() {
vec3 color = vec3(0.0);
for (int i = 0; i < 1; ++i)
color += u_Colors[i].Color1 + u_Colors[i].Color2 + u_Colors[i].Color3;
gl_FragColor = vec4(color, 1.0);
}
This should produce light-cyan-colored pixels (0.2, 1.0, 1.0). However, it gives (0.6, 0.0, 0.0), because Color1, Color2 and Color3 point to Color1.
It works correctly if you index the array with a constant number, however.
Hi..
This sounds similar to other array indexing issues that have been reported. We believe they've been fixed in drivers for later Adreno hardware, but not sure about the Sony Xperia Z. Is the build you have installed the latest one available for Sony Xperia Z?
If you have a sample apk we can try running on a few devices to confirm the specific problem has been fixed.