After reading that converting between ints and floats is a mortal sin,
I decided to rewrite my simple software rasterizer to use floats only.
No more 255, just plain 1.
No more i * a / 255, just plain f * a.
No more overflow checks, just treat 1.25 as white.
The result? It runs SLOWER now than before.
Maybe memory bandwidth is more of an issue.
Ints and floats
Conversion isn't a mortal sin for performance reasons (though it doesn't help); it's due to accuracy reasons.
The result? It runs SLOWER now than before.
Maybe memory bandwidth is more of an issue.
Are you asking why, or are you just complaining about it?
A CPU calculate integer faster.
A GPU calculate floats faster.
You use a SOFTWARE rasterizer, hence done on the CPU. Of course floats will be slower. Unless you use some GPGPU calculations...
A GPU calculate floats faster.
You use a SOFTWARE rasterizer, hence done on the CPU. Of course floats will be slower. Unless you use some GPGPU calculations...
A CPU calculate integer faster.
Once upon a time, yes - these days it's not quite so cut-and-dried. The FPU may actually be faster than the ALU at many tasks, especially if you can make use of SIMD (SSE/altivec) instructions.
As a rule of thumb, every time you see a statement to the effect that "X is a mortal sin", or "you should never do Y", or "if you're not doing Z you're doing it wrong", you should always look for the part of it beginning with the words "but..." or "except..."
If that's missing take it with an appropriately sized grain of salt.
If that's missing take it with an appropriately sized grain of salt.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement