Math on the iPhone
When writing a game for a device like an iPhone you'll notice how much math is required. There is quite a lot to be evaluated, from physics to collision detection, lighting and animation.
Here is a little tidbit from the iPhone development guide that you may have missed. It's a bit counter intuitive to those of us trained to optimize code for older platforms.
On older platforms it was always faster to use fixed point arithmetic. We contorted our code to account for this and squeeze that last drop of performance from our code. Now, writing code for the iPhone requires a bit of a mindset change. Not to mention, if you're porting code from an older system you should convert the mathematic algorithms from fixed point to floating point.
And finally, in the performance world size really doesn't matter. It's all about the speed. Don't forget to switch from thumb mode to ARM mode, as discussed in this earlier post.
Here is a little tidbit from the iPhone development guide that you may have missed. It's a bit counter intuitive to those of us trained to optimize code for older platforms.
Make sure you use floating point rather than fixed point arithmetic for iPhone games. The iPhone CPU implements a floating point instruction set natively. The ARM processor in iPhones and iPod Touches includes a Vector Floating Point (VFP) unit. Fixed point arithmetic [uses software libraries instead and] leaves the VPF unit unused.
On older platforms it was always faster to use fixed point arithmetic. We contorted our code to account for this and squeeze that last drop of performance from our code. Now, writing code for the iPhone requires a bit of a mindset change. Not to mention, if you're porting code from an older system you should convert the mathematic algorithms from fixed point to floating point.
And finally, in the performance world size really doesn't matter. It's all about the speed. Don't forget to switch from thumb mode to ARM mode, as discussed in this earlier post.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home