Re: d3dx9 [patch 1/3]: Avoid two useless computations
On 05.04.2013 09:13, Nozomi Kodama wrote:
s = 0.75f; - if ( order > 2 ) - s += 5.0f / 16.0f; - if ( order > 4 ) - s -= 3.0f / 32.0f; + if (order > 2) + s = 1.0625f; + if (order > 4) + s = 0.96875f; s /= D3DX_PI;
Doesn't the compiler do that already? If not something like this would probably better: s = 0.23873...f; /* 0.75f / D3DX_PI */ if (order > 2) s = 1.0625f / D3DX_PI; if (order > 4) s = 0.96875f / D3DX_PI; Cheers Rico
On Fri, Apr 5, 2013 at 9:41 AM, Rico Schüller <kgbricola(a)web.de> wrote:
On 05.04.2013 09:13, Nozomi Kodama wrote:
s = 0.75f; - if ( order > 2 ) - s += 5.0f / 16.0f; - if ( order > 4 ) - s -= 3.0f / 32.0f; + if (order > 2) + s = 1.0625f; + if (order > 4) + s = 0.96875f; s /= D3DX_PI;
Doesn't the compiler do that already?
Most likely,since those are literal constants. Besides, 5.0f / 16.0f is more readable than a pre-computed result. So I don't think this patch is really useful. Frédéric
participants (2)
-
Frédéric Delanoy -
Rico Schüller