Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2011, 06:48 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default 3D Performance Considerations: iPad 1, especially

[SOLVED] - good discussion though worth keeping around for future

I am within 6 weeks of launching my first iPhone/iPad Universal game. I've worked on it for 3 months full-time, and it is really looking great! The game runs fantastically well on an iPhone 3GS and an iPad2, but horrendously on an iPhone 4 and iPad 1. I am still relatively unfamiliar with Apple's instrument tools, but I understand that at least one or two of them could provide me with a lot more information as to what the bottleneck (particularly on that hardware) is. If I disable retina on the iPhone 4, its performance is as good as the 3GS. With the iPad 1, of course, I have no such option.

So here's my first question: what tool(s) should I run for profiling in instruments, and what should I look for to know where to optimize? I have a strong feeling there has to be some dead give-away here I'm missing that would tell me "ah, you're maxing out the GPU's fill rate", or something.

Below are some additional specifics that may help provide an idea of what I'm doing. Any help or suggestions would be truly appreciated. I will keep trying, but any pointers from folks who've been there would be tremendous. Thank you for your time and consideration! If I can leave any more details or info, just ask. Happy to provide more.
--------------


I've done a number of tweaks already, but they have either not helped or made it worse. Here's some basic info about the engine:

1) I'm using OpenGLES 2.0 (also have built the engine up to support 1.1 as a fallback)
2) It's a fully 3D game with a sprite mapping text class and standard 2D sprite support for UI
3) I'm using the PVR format for textures and sprites - all textures are 1024x1024 on iPad, and 512x512 for iPhone/iPod touch. Reducing textures to 512x512 did not help the iPad 1.
4) I'm using the POD format for 3D models - single mesh
5) I am utilizing a View Frustum Culling algorithm to prevent drawing objects not in view
6) I'm utilizing backface culling
7) My shader is not too complex and is primarily based on two direction lights
8) I was originally using GL_FLOAT for drawing primitives, but I have switched to GL_SHORT. I read somewhere on Stack Overflow that this resulted in a 30% frame rate boost for several iPhone 3D games, but mine saw no such boost. In fact, I'm considering that it may have reduced the overall performance (hah). If nothing else, it is certainly more annoying working with shorts with some of the more complex meshes. Plus the loss in the shader of having to convert texture coordinates from shorts to normalized floats at render time may be losing any benefit I get out of sending half the data. I did check to ensure that the data is 4-byte aligned too (it's 16 bytes total, an x, y, z, w component, normal component (x2), and texture coord component (x2).
9) Most meshes are very simple - 12 triangles make up the 3D tiles that are predominant in the game. The player's mesh is significantly more complex, but just about everything else is a fraction of that.

I am using CADisplayLink to control the update timing, and I am using an animation interval of 2, to cap the FPS at 30. Like I said, I get a smooth 30 on the 3GS and iPad 2, but a jumpy 20-24 on iPhone 4/iPad 1.

Last edited by dbh1313; 08-17-2011 at 04:56 PM. Reason: SOLVED
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 01:32 PM   #2 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

As an update, I'm looking at 11-14 FPS on an iPad 1, with a constant 30 FPS on all other devices (iPhone 3GS+, iPod+, iPad 2). I need to find a way to double the performance on an iPad 1. I'm really considering adding conditionals to the code like:

"if device == iPad 1, use lower res textures"

but I have a feeling Apple frowns on device-specific coding practices in app submission? Do they downright reject apps that do this? I know it's a bad practice in the first place, but when you're trying to make greased lightning run on what feels like a Nintendo 64, you sure don't want to have to compromise quality for the devices that are capable.

Any thoughts? Advice? Suggestions?
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 01:53 PM   #3 (permalink)
Registered Member
 
headkaze's Avatar
 
Join Date: Feb 2010
Posts: 359
headkaze is on a distinguished road
Default

I had the same problem with my game on the iPad 1. I was getting about 20 FPS on it and 30 FPS on everything else. I ended up using VBO's for my vertex data and it boosted performance to a solid 30 FPS.
__________________
Headsoft | Jungool
headkaze is offline   Reply With Quote
Old 08-17-2011, 01:58 PM   #4 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

Quote:
Originally Posted by headkaze View Post
I had the same problem with my game on the iPad 1. I was getting about 20 FPS on it and 30 FPS on everything else. I ended up using VBO's for my vertex data and it boosted performance to a solid 30 FPS.
Ah yep, using VBO's for data. I think I'm even using iVBO's for any 2D sprites (I'll have to check).

By the way, HeadKaze, I owe you a big thank you. Your advice on this forum awhile back to go with POD and PVR file formats was a huge win. Building my own engine, I was debating several file formats, and that has since proven to be by far the right choice! I can't imagine where I'd be with this engine today without PVR's utilities and their fast formats. Even using their vector library!

I'm looking at fill rate limitations right now... I read that a lot of iPad 1 performance problems stem from hitting the ceiling on that. Is there a way with the profilers to tell if that's the bottleneck?
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 02:05 PM   #5 (permalink)
Registered Member
 
headkaze's Avatar
 
Join Date: Feb 2010
Posts: 359
headkaze is on a distinguished road
Default

You can use instruments to monitor OpenGL ES calls to locate bottlenecks. There is a post on here about OpenGL optimization that you might want to try a search for.

Two resources I recommend reading

Loading…

http://www.imgtec.com/factsheets/SDK...a.External.pdf

PS I'm happy to hear my advice helped you pick a model format
__________________
Headsoft | Jungool
headkaze is offline   Reply With Quote
Old 08-17-2011, 02:08 PM   #6 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

Pulled them both up, and I'll look through - thank you! I'll post back any updates of success/failures with the optimization today and tomorrow.
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 03:48 PM   #7 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

Great boost in performance from disabling GL_BLEND on draw calls to game objects that are not transparent (textures or object itself). Now up to ~15-17 FPS from 10-12 FPS on iPad 1.

Other minor tweaks here and there from the PVR guide have not made any improvements.

I am really stumped by one thing though... I was considering batching my world object draw calls down to one call (would be challenging, but I think it can be done). I'd break down there 3-4 textures into one texture map, then combine their VBO's into one giant VBO and tell the GPU to go wild (is this a good idea?).

Before I implemented this though, I converted a map file from ~200 world objects down to just one world object. I removed all enemies, all pickups, everything - just that one tile. The game is STILL only at 15-17 FPS! That's without any game logic (no objects alive to run updates on), and virtually no render calls except for my skybox and some 2D UI sprites.

..........

Is that crazy or what? I mean, I guess the silver lining is, "yay", my 3d object rendering code, and my AI/update logic is definitely on the right side of the performance curve... but what does that mean I should point my finger at as the culprit? There isn't much left...
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 03:49 PM   #8 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

Quote:
Originally Posted by dbh1313 View Post
Great boost in performance from disabling GL_BLEND on draw calls to game objects that are not transparent (textures or object itself). Now up to ~15-17 FPS from 10-12 FPS on iPad 1.

Other minor tweaks here and there from the PVR guide have not made any improvements.

I am really stumped by one thing though... I was considering batching my world object draw calls down to one call (would be challenging, but I think it can be done). I'd break down there 3-4 textures into one texture map, then combine their VBO's into one giant VBO and tell the GPU to go wild (is this a good idea?).

Before I implemented this though, I converted a map file from ~200 world objects down to just one world object. I removed all enemies, all pickups, everything - just that one tile. The game is STILL only at 15-17 FPS! That's without any game logic (no objects alive to run updates on), and virtually no render calls except for my skybox and some 2D UI sprites.

..........

Is that crazy or what? I mean, I guess the silver lining is, "yay", my 3d object rendering code, and my AI/update logic is definitely on the right side of the performance curve... but what does that mean I should point my finger at as the culprit? There isn't much left...
By the by, disabling the Skybox altogether results in 3-4 more FPS boost (I'll need to look at it and retool). I'm still not at 30 FPS though with it disabled. Keep in mind, before ANY of these optimizations today, the game was running at a solid 30 FPS on all other devices. I must be maxing something out on the iPad 1, I just can't seem to figure out what.
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 03:59 PM   #9 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

Sorry for the spam, but I think I may have answered my own question. Disabling the sprites from rendering (text and 2D UI elements) results in a solid 30 FPS with everything else back enabled. I'd have to do more extensive benchmarking to get more descriptive stats, but that's a big boost.

I imagine it COULD be the fill rate... having to render the entire 3D scene, then draw the sprites on top of it... could be a problem. Any tips on how I could improve this? I'll take a look at the sprite render code to see what could be slowing down, but maybe I should look into a smaller 3D render area and draw UI there.
dbh1313 is offline   Reply With Quote
Old 08-17-2011, 04:55 PM   #10 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
dbh1313 is on a distinguished road
Default

SOLVED! Hah, this makes me sad, but it was an easy problem. I have a list of a dozen things I could try to do (almost all of which are difficult to implement), a few of which I've done (which did result in a performance boost!). Turns out, this was the glaring omission on my part:

All game objects (2D or 3D) derive from an ABC that has a boolean "active" flag. If inactive, they don't get drawn.

This flag was not being set for one KEY sprite: the fade to black sprite that gets stretched the size of the viewport! So after a dramatic fade-in to the game, this sprite was hanging around *and being rendered* every draw call. That's 1024x768 pixels of wasted draw. Ouch!

Needless to say, adding a safety catch (if (!active || alpha == 0.0f) solved the problem quite nicely (and of course, fixing the active bug itself).

I'm now at 29-30 FPS on an iPad, and the other devices are even smoother. I'll still spend most of tomorrow adding the remaining optimizations I was considering (just good sense, plus allows me to do more).

Thank you so much HeadKaze for the great links - got me down the right path! Hope some of this discussion is helpful down the road for others scratching their heads like me!
dbh1313 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 411
11 members and 400 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,923
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:21 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0