iDevGames Forums
iPhone Game Framerates? Chipmunk & OpenGL - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: iPhone Game Framerates? Chipmunk & OpenGL (/thread-2422.html)

Pages: 1 2 3 4


iPhone Game Framerates? Chipmunk & OpenGL - kelvin - Sep 4, 2008 12:38 AM

So, I've put together a few test projects with the iPhone; basically just EAGLView + Chipmunk. I'm struggling to get 60fps with 10 objects and 4 walls, 2 updates per tick.

I'm curious to know what other people are seeing in terms of framerates for OpenGL games with 2D physics. I could just run at 30fps, but if there's a way to get to 60fps consistently, I'd like to at least try.

[Edit:] Just to clarify, I'm looking for framerates you've seen on any iPhone apps, not specifically anything you yourself have built or published. That being said, I care more about the feel of it, not exact numbers.


iPhone Game Framerates? Chipmunk & OpenGL - Jake - Sep 4, 2008 05:13 AM

I'm normally running at my max of 30 FPS (drops to 15-20 sometimes). I loop my physics twice per frame, which only adds maybe 5% overhead.


iPhone Game Framerates? Chipmunk & OpenGL - AnotherJake - Sep 4, 2008 05:39 AM

60 FPS all the time is pretty hard to achieve from what I've seen. My stuff likes to hang around anywhere from maybe 15 to 40, depending on complexity.


iPhone Game Framerates? Chipmunk & OpenGL - Najdorf - Sep 4, 2008 06:13 AM

isn't 30 the maximum refresh rate on the iphone?


iPhone Game Framerates? Chipmunk & OpenGL - ThemsAllTook - Sep 4, 2008 06:54 AM

Najdorf Wrote:isn't 30 the maximum refresh rate on the iphone?

No, it's 60. Where'd you get 30 from?


iPhone Game Framerates? Chipmunk & OpenGL - Najdorf - Sep 4, 2008 06:57 AM

ThemsAllTook Wrote:No, it's 60. Where'd you get 30 from?

http://www.apple.com/iphone/specs.html though apparently it's only referring to video.


iPhone Game Framerates? Chipmunk & OpenGL - Skorche - Sep 4, 2008 07:13 AM

For ScribBall (also using Chipmunk) I had to fiddle a lot in order achieve 30fps. Not sure how much this will be useful to you as ScribBall has a lot of objects on the screen.

For Chipmunk, follow what the docs say about optimization. (keep polys simple or avoid them altogether, don't use variable time steps, decrease stacking depth so you can lower iterations, set appropriate values for the spacial hash, etc) You can also pick the float/double precision of Chipmunk, make sure it's set to floats in chipmunk.h. Chipmunk also likes to be compiled as -03 with --ffast-math.

Beyond that, I found that I had to cut back to a 30Hz physics refresh rate and couldn't run more than 4 iterations of the impulse solver. Chipmunk uses interframe coherency to speed up the solver. With so few iterations, I had to increase the collision slop considerably in order to prevent contacts from flickering (which causes them to lose the cached values).

Make sure you profile! You don't get the gloriousness of Shark, but at least you can sample the stack. That's somwhat helpful, but what I found worked even better was just to add some printf to spit out the duration of certain chunks of code. Ultimately, we found that the drawing was about half as expensive as the physics (with little room for optimization), and that the graph algorithms about a third as expensive (ouch).

Due to the relatively small and sparse graphs generated by the game, we replaced the "smart" algorithms using adjacency lists and node sets with a naive implementation that just did a lot of linear searching... 8x speedup and 1/3 of the code. I never figured it out exactly, but the new algorithm was at least one order of magnitude worse. The bonus being that it exclusively used stack allocations (cache friendly) and linear searching on lists that were generally in the single digits for length. Dumb dumb dumb. Sad

After all that we were able to hit a pretty steady and respectable 30fps. I'm still a bit worried that the high CPU usage of ScribBall is going to be a battery killer, but I haven't noticed that to be the case.

EDIT: Time to eat my words I guess. OSC IMed me to tell me that you're supposed to be able to use Shark, but the option is greyed out for me in XCode for both sim and device. Dunno what's up with that. Trying to connect with just Shark alone fails. Apparently other people have been able to use it though.


iPhone Game Framerates? Chipmunk & OpenGL - reubert - Sep 4, 2008 02:54 PM

You can use Shark on the device. Open up the Shark app and go to Sampling -> Network/iPhone profiling.

And er... be patient, you might have to wait half an hour.


iPhone Game Framerates? Chipmunk & OpenGL - Skorche - Sep 4, 2008 04:25 PM

Yeah... no kidding. I just reinstalled the SDK (isn't reinstalling more of a Windows thing?) and was able to get Shark to connect (along with making other errors go away). A only sampled for a few seconds, then proceeded to wait five minutes for it to generate the profile. Eeek.

I didn't think that there could be anything more painful than "generating application map". I was wrong. Sad


iPhone Game Framerates? Chipmunk & OpenGL - Jake - Sep 4, 2008 04:29 PM

Skorche Wrote:I didn't think that there could be anything more painful than "generating application map". I was wrong. Sad

Trust me when I say the apple review wait is the absolute worst.


iPhone Game Framerates? Chipmunk & OpenGL - kelvin - Sep 4, 2008 05:36 PM

Has anyone seen any dramatic differences between 32-bit (ARM) and 16-bit (Thumb) executables where there's a lot of floating point ops?


iPhone Game Framerates? Chipmunk & OpenGL - kelvin - Sep 4, 2008 06:21 PM

Wow... I spent a couple minutes tweaking the GCC settings for my build target and I've more than doubled my floating point performance! I now have a solid 60fps at all times for 10 bodies. ~55ish fps for 20 bodies.

I haven't even optimized my graphics pipeline yet.

Seriously, wow, I don't know why I'm so surprised.


iPhone Game Framerates? Chipmunk & OpenGL - reubert - Sep 4, 2008 07:16 PM

Jake Wrote:Trust me when I say the apple review wait is the absolute worst.

I beg to differ. That 3 week wait with absolutely no sales figures at the start was excruciating. At least none of you will have to go through that Wink


iPhone Game Framerates? Chipmunk & OpenGL - reubert - Sep 4, 2008 07:17 PM

kelvin Wrote:Wow... I spent a couple minutes tweaking the GCC settings for my build target and I've more than doubled my floating point performance! I now have a solid 60fps at all times for 10 bodies. ~55ish fps for 20 bodies.

Care to elaborate? What did you change?


iPhone Game Framerates? Chipmunk & OpenGL - kelvin - Sep 4, 2008 07:44 PM

reubert Wrote:Care to elaborate? What did you change?

Thumb (16-bit) -> ARM (32-bit)
-O0 -> -O3
-> Auto Vectorize (this doesn't really help)
-> Unroll Loops (helps only in certain cases)
-> Strip debug (same as release, for size)

Compiling in 32-bit mode will probably be a big battery hog, so I might forego this option if I can't hit 60fps in the end anyways.