iPhone Game Framerates? Chipmunk & OpenGL

Member
Posts: 469
Joined: 2002.10
Post: #1
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.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #2
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.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #3
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.
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #4
isn't 30 the maximum refresh rate on the iphone?

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
Najdorf Wrote:isn't 30 the maximum refresh rate on the iphone?

No, it's 60. Where'd you get 30 from?
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #6
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.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #7
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #8
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.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #9
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

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #10
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.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #11
Has anyone seen any dramatic differences between 32-bit (ARM) and 16-bit (Thumb) executables where there's a lot of floating point ops?

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #12
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.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #13
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

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #14
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?

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #15
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.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Differences between iPhone Sim and Real iPhone SparkyNZ 5 6,660 Apr 13, 2011 11:40 AM
Last Post: SparkyNZ