Ints and floats

Started by
4 comments, last by 21st Century Moose 12 years, 2 months ago
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.
Advertisement
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?
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
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 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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement