I have a Nexus 10 with Android 5.0 and I'm getting this "error" when compiling the attached shaders :
12-09 04:33:35.369: I/com.re3.benchmark(5159): L0001 The fragment shader uniform structure Light0 does not match the vertex shader uniform structure Light0.
12-09 04:33:35.369: I/com.re3.benchmark(5159): The precision does not match.
I'm basically declaring a structure in the VS that I'm not using, and I think the compiler optimizes the components out, compares with the one that's used in the FS and then realizes they don't match, but instead it says the precision doesn't match. As you can see my FS is highp and putting highp manually in the VS doesn't change the error returned. I've also encountered a second error with a shader that declares just a uniform in the VS but is only used in the FS.
This shouldn't be an error obviously, and an ETA on a fix would be nice.
> This shouldn't be an error obviously, and an ETA on a fix would be nice.
OpenGL ES requires that precision of variables in the two shaders matches - the specification strongly implies that this check is done early (i.e. before we know whether values are used or not) - so I don't think this is a bug in the Mali compiler. The relevant part of the ESSL specification is:
Uniforms in the vertex and fragment shaders share a single global name space. Hence, the types, precisions and any location specifiers of all declared uniform variables with the same name must match across shaders that are linked into a single program.
The specification defines "declaration" as the critical point, not "used", so the compiler is correct to raise a mismatch even if they are not used. I think the issue with your shaders is that you have an integer (LightType) in that structure, and don't set highp precision for integer types in the fragment shader (you only set it for float types).
Note that globally setting highp for everything in a fragment shader is generally bad for performance and power efficiency, and totally overkill for calculating color values, so rather than globally forcing this I'd suggest setting precision on the individual uniform values.
HTH, Pete
Thanks for the insight, so the int was it ? It would be nice for the error to say that the "int precision mismatched", most of the time I use floats so I intuitively thought it's about floats and thought it was an error. I force highp because I want to have a somewhat parity at the shader level between the mobile version of my app and the desktop version where everything is 32bit precision by default. My Terrain Shader though after multiplying 6 textures gets very pixelated under mediump.
It would be nice for the error to say that the "int precision mismatched"
Yep, I agree - I'll raise a request with our compiler team
Regards
Pete