A little function to speed things up a bit
Posted: Fri Nov 03, 2006 11:43 am
After running VTune against Jet3D, I noticed that Jet3D was spending a lot of time converting floats to DWORDs. As we all know, that is an evil operation and should have holy water sprayed all over it. Fear not, as I have exercised that demon. I wrote a small inline assembly function that converts a float to a DWORD without resetting the FPU each time. This little function gained us about 5 FPS. I noticed that Genesis has the same issue also which is why I am posting it here.
Just replace the FtoDW() function in the drivers with this and for any float to DWORD (or integer) conversions, use it.
Code: Select all
inline DWORD FtoDW(float f)
{
DWORD d;
_asm
{
fld f
lea eax, [d]
fistp dword ptr[eax]
}
return d;
}