[vtk-developers] Speeding up raycasting on x86
David Gobbi
dgobbi at imaging.robarts.ca
Thu Jul 11 14:15:53 EDT 2002
Hi Lisa,
I tried a little experiment with vtkVolumeRayCastCompositeFunction
and managed a speed-up of 35% in VTK's trilinear ray casting.
I replaced all instances of
<something> = (int)(floatval)
with
<something> = vtkQuickFloor(floatval)
according to the following definition of vtkQuickFloor:
inline int vtkQuickFloor(double x)
{
#if defined i386 || defined _M_IX86
unsigned int hilo[2];
*((double *)hilo) = x + 103079215104.0; // (2**(52-16))*1.5
return (int)((hilo[1]<<16)|(hilo[0]>>16));
#else
return (int)(x);
#endif
}
That big mess with the bitshifts and whatnot is a trick that I found
on a web page a couple years ago (I could dig up the URL) that works
many times faster than what most iX86 compilers generate for (int)
casts. I've been using it in vtkImageReslice for a while now.
Is this the sort of optimization that Kitware is interested in?
It is messy and CPU-specific, but it is confined to one single
inline function.
- David
More information about the vtk-developers
mailing list