- Home /
fixed half float performance on iOS?
It's advised to use as small as feasible variable formats in shaders - however, during my few months developping with unity on iOS I noted quite consistently that framerate becomes better (up to 20%) when switching fixed and halfs for floats. Now I use only float in my shaders.
I'm curious if someone experienced similar behaviour and has an explanation for it?
Answer by guppyd · Apr 01, 2014 at 07:10 AM
On mobile platforms, the key is to ensure as much as possible stays in low precision in the fragment shader. On most mobile GPUs, applying swizzles to low precision (fixed/lowp) types is costly; converting between fixed/lowp and higher precision types is quite costly as well.
fixed4 uniform;
...half4 result = pow (l, 2.2) + uniform; // BAD: fixed -> half conversion
struct Input {
float4 color : TEXCOORD0;
};
fixed4 frag (Input IN) : COLOR
{
return IN.color; // BAD: float -> fixed conversion
}
half4 tex = tex2d (textureRGBA8bit, uv); // OK: conversion for free
http://docs.unity3d.com/Documentation/Components/SL-ShaderPerformance.html
http://www.realtimerendering.com/downloads/MobileCrossPlatformChallenges_siggraph.pdf (page.25)
Your answer
Follow this Question
Related Questions
See through issue in iOs 0 Answers
Problem with transparent shader on iOS 0 Answers
how to build impressive shaders for iOS? 1 Answer
Standard shader strange reflection artefacts 0 Answers
Different Shader Display on 3gs vs. 4s 2 Answers