Fixed-Point math
Has anyone ever used fixed-point math in any projects they do? What I would like to know is with todays fast CPUs with multiplely pipelinged floating point units, etc.. is there a noticable gain in speed (above 20% gain) when using strictly integer based mathematics?
Jason A.
---
I write code.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
If you are writing your own personal software renderer there can still be noticable gains in speed. (If you do it right.) However, if you try to use any 3d APIs (OpenGL, Direct3D) you need to convert the fixed point values to floating point values and that conversion takes long enough that everything you gained will be lost.
Well... Floting point math and integer based math (used for fixed point) are about the same these days, so whichever you choose will be about the same (unless you use OpenGL or something, then use floats, as SiCrane mentioned)
Morgan
Morgan
May 26, 2000 11:18 AM
Floats are actually faster nowadays.
Theres a small table of comparisons at http://www.d6.com/users/checker/pdfs/gdmfp.pdf
The reason that a software renderer can be slightly faster with ints rather than floats is that at some point in the drawing pipeline the output must be converted to ints...this is a quite slow step and hogs the processor.
With OpenGL and D3D which use floating point maths internally, I would have thought that using int would slow it down slightly as they would have to be converted before being used.
dan
Theres a small table of comparisons at http://www.d6.com/users/checker/pdfs/gdmfp.pdf
The reason that a software renderer can be slightly faster with ints rather than floats is that at some point in the drawing pipeline the output must be converted to ints...this is a quite slow step and hogs the processor.
With OpenGL and D3D which use floating point maths internally, I would have thought that using int would slow it down slightly as they would have to be converted before being used.
dan
Float and doubles are very good for math. If you''re doing some vector/matrix calculation - best to use FPU.
(Div Mul Sqrt Sin Cos)
On the other hand, if you''re doing some blitting or writting a fast inner loop with simple math (add,sub) - best to use fixed point.
(Add Sub Shift)
Maybe if compilers will make optimal use of MMX, this will change the situation! Add, Sub, Shift and Mul are much much faster with MMX.
(Add Sub Shift Mul)
(Div Mul Sqrt Sin Cos)
On the other hand, if you''re doing some blitting or writting a fast inner loop with simple math (add,sub) - best to use fixed point.
(Add Sub Shift)
Maybe if compilers will make optimal use of MMX, this will change the situation! Add, Sub, Shift and Mul are much much faster with MMX.
(Add Sub Shift Mul)
![](http://www.baskuenen.myweb.nl/images/title.jpg)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement