VOGONS


First post, by keenmaster486

User metadata
Rank l33t
Rank
l33t

I'm trying to optimize this 2D game engine I'm writing to be as fast as possible. Ultimately I want it to run on a 486 with no problems, right now it just barely runs smoothly on a 486 but has no problems on Pentium-based machines.

The question is this: how much faster is integer math than floating point on a 486, and likewise with a Pentium? And how much speed can I gain on each processor by converting as many key variables as I can to long integers instead of single or double precision jobs?

I do know that floating point math is faster on a Pentium than on a 486, so maybe the speed gain, if there was any, would be more noticeable on the 486. Can someone impart knowledge here? 😁

World's foremost 486 enjoyer.

Reply 1 of 3, by PhilsComputerLab

User metadata
Rank l33t++
Rank
l33t++

Pixelmusement talked about this in the Quake video. The Pentium floating point is much, much faster compared to the 486 😀

That's all I remember though 😊

YouTube, Facebook, Website

Reply 2 of 3, by mrau

User metadata
Rank Oldbie
Rank
Oldbie
keenmaster486 wrote:

I do know that floating point math is faster on a Pentium than on a 486, so maybe the speed gain, if there was any, would be more noticeable on the 486. Can someone impart knowledge here? 😁

in an assembler basics book i read it said, that all examples were made with fixed point math, since the author was using mainly a 486;
floating point is a real thing starting with pentium, and only if it is single precision;
they did everything on precalced stuff;

also, can You elaborate on "2d engine"?

Reply 3 of 3, by Scali

User metadata
Rank l33t
Rank
l33t
keenmaster486 wrote:

The question is this: how much faster is integer math than floating point on a 486, and likewise with a Pentium? And how much speed can I gain on each processor by converting as many key variables as I can to long integers instead of single or double precision jobs?

Integer math can easily be 3 to 4 times as fast as floating point on 486. About the same on Pentium I guess (Pentium may have a faster FPU, but it also has two integer pipelines instead of the one on 486, so best-case your integer code on Pentium is about twice as fast as on 486).

Thing is, in the end, you always need integer coordinates for the pixels on your screen. If nothing else, you can shave a lot of time off the conversion from float to int alone, which is one of the more expensive operations.
Addition and subtraction is also more expensive on FPU. Mul and div are generally about as fast, if not faster, but you don't use them that much.
You can build entire 3d engines with integers only (I believe Descent does that, these 3d renderers I made are also integer-only: https://youtu.be/4ClrU-ne2Us https://youtu.be/xE9iifKXvY4), so there's really no reason to use floats at all... except perhaps if you want to precalc some sine/cosine tables etc (fsin and fcos are quite expensive operations as well, as is fsqrt for example, so if you can avoid these by precalcing things in tables, you can gain quite a lot, even on FPU).

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/