2 ms·
The code [1] includes an implementation of the FastInvSqrt that date back at least to 1996. There's an assembly and a C version, referred as SLOW_SQRT_DIV :).
by rubycon 5y ago
The code [1] includes an implementation of the FastInvSqrt that date back at least to 1996. There's an assembly and a C version, referred as SLOW_SQRT_DIV :).
It uses float/int pruning through union (in C) and one or two rounds of Newton-Raphson refinements.
Interestingly corrections aren't done with a fixed value (part of the famous 0x5F3759DF) but through a LUT [2], which I guess, yield better results but was a bit slower on 90's arch.
[1] https://github.com/powervr-graphics/PowerVR-Series1/blob/main/Source/sgl_mat2.h#134 https://github.com/powervr-graphics/PowerVR-Series1/blob/mai...
[2] https://github.com/powervr-graphics/PowerVR-Series1/blob/main/Source/sgl_math.c#L933 https://github.com/powervr-graphics/PowerVR-Series1/blob/mai...