Costly Operations - how do you determine the expense?

Started by
0 comments, last by GameDev.net 24 years, 6 months ago
How do you know how costly an operation is? In response to my last question on unit vectors, the response was that we use unit vectors to avoid costly divides, but to me it seems as though it would be equally costly if not more so to convert vectors to unit vectors using square roots. Any general help would be greatly appreciated.

thanks

Advertisement
For that example, we don't convert to unit vectors before every single calculation, we do it once at startup, and then reuse the unit vectors. A couple squareroots once is trivial.

Generally, mathematical operations are ordered as follows, from most costly to least

FP SquareRoot
FP Divide
Integer Multiply
FP Multiply
FP Add
Integer Add, Subtract, logical operations (AND, OR, NOT, etc.)

But the PPro and above (and Pentium?) can execute integer code while it's doing the costly, long latency floating point multiplies and adds, giving these operations an effective execution time of a single cycle.

This topic is closed to new replies.

Advertisement