ios opengles 2.0 lowp cause problem, right? and why?

Started by
3 comments, last by wantnon_cn 11 years, 4 months ago
i am working on a iOS 3d game, because i don't have a real device in hand, so i have being test it in iOS simulator, and it always run well.
today i got a itouch4 with 5.0.1 system and test my game on it.
i found a strange problem:
in shader, i set the texCoord to lowp, and the texture become mess on device (but nothing wrong in simulator), and when i modified it to mediump it fixed.
there are some other wrong effect, and they are also finally solved by change lowp to mediump or highp.
that is a little strange because even though we known a little precision loss many cause some flaws, but i never expected the flaw may so serious as to get totally wrong effect.
and this is not the most strange thing, i also found that after i changed some of the lowp to mediump or highp, the game runs much more fluent on the device than before.
so i start to suspect that may be lowp have some support issue on real device. does the system (here is iOS 5.0.1) not support lowp well?
anyone else have the similar annoying experience with lowp?
i also want to known if i should change all the lowp to mediump or highp (or may be better all change to highp)?
Advertisement
My rule of thumb is:

lowp for colours.
mediump for normals and UVs.
highp for positions.

You can lookup the ranges and precisions in the spec, you shouldn't be surprised that lowp is no good for UVs since the range is only -2 to 2, and the precision is too low to represent a large (256+) sized texture to texel accuracy (IIRC).

It's difficult to test your chosen precision produces correct results, because the compiler is always free to give you a higher precision than the one you request, so you just have to test on the various different types of hardware.

In general, I wouldn't expect that increasing precision would improve performance, but there's always edge cases. For instance, lowp UVs have to be converted upwards when you pass them into sampler functions and conversions carry a small penalty - this may explain it since iOS is very sensitive to pixel shader performance. Also, I seem to remember an issue of severe performance problems if your vertex shader output precisions mismatch with their corresponding pixel shader input precisions.

I seem to remember an issue of severe performance problems if your vertex shader output precisions mismatch with their corresponding pixel shader input precisions.

so, if in vertex shader i do not specify a precision for a vertex shader output varying variable, and in the fragment shader i specify it with lowp or highp, will this cause a mismatch problem (have a risk of low performance) ?

[quote name='C0lumbo' timestamp='1355346323' post='5009965']
I seem to remember an issue of severe performance problems if your vertex shader output precisions mismatch with their corresponding pixel shader input precisions.

so, if in vertex shader i do not specify a precision for a vertex shader output varying variable, and in the fragment shader i specify it with lowp or highp, will this cause a mismatch problem (have a risk of low performance) ?
[/quote]

Possibly - I'd recommend you be as explicit as possible with precision rather than using the default precision. That said, I'm afraid I don't know the full details - it was an issue that suddenly hit a project after an OS revision a couple of years ago, and we modified our shaders accordingly, but there's a good chance that the problem has been fixed by Apple. Still, it seems like a good idea to avoid a precision change between vertex shader output and fragment shader input anyway.

Possibly - I'd recommend you be as explicit as possible with precision rather than using the default precision.

ok, i will take your advice and specify the precision explicitly to insure the matching.

This topic is closed to new replies.

Advertisement