Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Ints and floats

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 meanwhile   Members   

98
Like
-2Likes
Like

Posted 31 January 2012 - 01:30 PM

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.

#2 Telastyn   Members   

3777
Like
0Likes
Like

Posted 31 January 2012 - 03:20 PM

Conversion isn't a mortal sin for performance reasons (though it doesn't help); it's due to accuracy reasons.

#3 Cornstalks   Members   

7030
Like
0Likes
Like

Posted 31 January 2012 - 03:24 PM

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?
[ 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 ]

#4 Dunge   Members   

405
Like
0Likes
Like

Posted 31 January 2012 - 03:29 PM

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...

#5 swiftcoder   Senior Moderators   

18214
Like
1Likes
Like

Posted 31 January 2012 - 03:51 PM

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 - Software Engineer @ Amazon - [swiftcoding] [GitHub]


#6 mhagain   Members   

13154
Like
3Likes
Like

Posted 31 January 2012 - 04:01 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.