   fast sqrt?
  I'm currently working on dynamic(mostly per-vertex)lighting for a 2d opengl based isometric game. The function I call to get the distance between any light and a vertex (or quad) uses sqrt and needless to say it's getting quite expensive. After searching a bit on google and this board I came across a number of optimized inverse sqrt routines such as this one:float InvSqrt (float x){    float xhalf = 0.5f*x;    int i = *(int*)&x    i = 0x5f3759df - (i >> 1);    x = *(float*)&i    x = x*(1.5f - xhalf*x*x);    return x;} When I tried running it I found that I was getting nearly exactly the same fps as with the normal sqrt routine. Is this related to my specific hardware(2.33 core 2 duo w/ radeonx1600) or something else?   
  Make sure you are performance testing in an optimized build environment such as Release mode and NOT Debug (benchmarking in debug is generally useless as nothing is optimized and it's clunky). Also, video card in this particular case doesn't matter because it's pure CPU-based calculations. What is your test case scenario?   ;  How many times a second do you use that function?You should use a profiler to find the time actually spent in the sqrt function, as it will require a very large number of calls per second to make sqrt slow anything down.Modern processors have an instruction to calculate the inverse sqrt too, which will probably always be the fastest.. so perhaps, depending on your compiler settings, this might be used automatically..My guess is that sqrt is not the bottle-neck for you performance though, unless you have confirmed so by timing it.   ;  My guess the sqrt function is not the bottleneck.To be sure replace it by an empty function. You'll get graphical glitches but it still should run:inline float InvSqrt (float x){return 1/x;}Also, use the inline keyword.Measure the speed improvement after using an empty InvSqrt. If there's none or insignificant, it's not worth spending more time on itCheersDark Sylinc   