Is It OK To Use Highp In Fragment Shaders For IOS/Android?
Solution 1:
There's a database, where you can lookup GL_OES_fragment_precision_high which suggests that just under 50% of Android devices support highp in the fragment shader. You can inspect which ones have and do not have this extension. link
However, that might be misleading because that GLES extension has been withdrawn, so maybe some devices don't report it anymore even though they do support highp, so you can consider that 50% a minimum - it could be a lot higher. The extension is replaced by GetShaderPrecisionFormat, and I can't find a good database for that.
With a much smaller dataset, I have tested my game on 28 devices, 8 of which do not support highp in fragment shader, including a Nexus 7 and a Samsung Galaxy Note II running Android 4.4 and a Samsung Galaxy S3 running 4.3 (the other devices I had which didn't support highp in fragment shader were pretty obscure brands)
I'm pretty sure all your target iOS devices do support highp in fragment shader but can't find any evidence right now to back that up.
Finally, as you mention "precision mediump float;", IMO you should be picking a precision on a case-by-case basis and not picking a level for the entire shader. You'd be wasting a lot of performance on some GPUs if you used highp on everything (particularly colour based operations which can easily be lowp). Of course, you can set a default precision, then override wherever necessary, and perhaps that's what you're doing, but personally I prefer not to set a default precision in fragment shaders, then the compiler forces me to be explicit.
Edit: Also, it's allowed to use highp in a fragment shader even for devices that don't support it, you'll just get mediump. In a lot of cases that fallback behaviour is fine - high end devices get better precision lighting or whatever, lower end devices fallback to something less perfect but still acceptable.
Post a Comment for "Is It OK To Use Highp In Fragment Shaders For IOS/Android?"