Why is my iPad game so slow?

Member
Posts: 166
Joined: 2009.04
Post: #31
(Nov 17, 2010 07:09 AM)Sumaleth Wrote:  I couldn't even get a simple ambient+diffuse+specular shader to run at 30fps at the Retina resolution, even with all the optimizations I could think of. So I set contentScaleFactor to 1.0f and moved on. But Citadel shows it can easily do that, plus more.

Their demo is mostly lightmapping which is as cheap as it gets.
Quote this message in a reply
Member
Posts: 87
Joined: 2006.08
Post: #32
In the very first post, you mentioned that the CPU was entirely busy, but there has not been mention of further data-driven optimizations since then, just lots of feeling around in the dark.

I suggest you go right back to Instruments, and gather this information:
a) using the OpenGL ES plugin, get the TA Utilization % and Renderer Utilization %
b) using Instruments or Shark, capture an All Thread States Time Profile, and post the results of that here. Shark provides some handy data mining tools that you can use to easily determine the proportion of CPU time spent inside of OpenGL vs. elsewhere. By looking in the 'advanced' panel, there is the ability to present the call tree by Library, instead of by Symbol.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #33
I said it WASN'T at all busy. This was the first thing we profiled and we quickly ruled it out.

This is a turn based game so there's almost no game logic happening whilst idling, so all that remains is the scene preparation stuff for the render. Which in our paired down world is almost nothing.

Good try though, thanks Smile

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 22
Joined: 2006.04
Post: #34
If you're getting a jump from 15fps to 40fps by eliminating the fragment shader then this indicates a pretty serious bottleneck caused by the original fragment shader. I'm guessing that it's the 4 texture reads rather than the processing (9 cycles isn't much - notes that the iPhone compiler might not be exactly the same as the PowerVR one though). Try reducing the number of reads and see if you still get the same improvement?

Since you've hit 40fps with a trivial fragment shader then you need to look for where the next bottleneck is if you want to hit 60fps. It's going to be something different and you'll need to investigate using all the techniques suggested again, but with the fragment shader left trivial.

Strikes me that if your CPU usage is so low then you could consider using the CPU to take some load off the GPU in this situation.

Have you read all of Apple's and PowerVR's performance guidelines?

Flash!
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #35
Yup, done all of the above sadly. There's another thread around here going on about a dodgy xib, so I don't know if that's the magic bullet.

As I intimated above though, all our textures are mipped and compressed and stuff, so if a shader of that complication level isn't acheivable then this is all moot tbh. ES1.1 has too many other positives for the bigger picture.

I've done from dumbfounded to just plain disappointed now tbh. Sad

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 204
Joined: 2002.09
Post: #36
If I were to take a wild stab, I would recommend making sure you have no dependent texture fetches ( when your coords to fetch from one texture are calculated off of the results of another texture fetch in the same shader ). Doing this on every pixel on the iPad screen will easily bring to 15 fps or less.

[edit] Reading fail, I see shaders in previous post [/edit]

[edit2] Are any of the textures feeding this shader generated dynamically? If so, a similar dependency can be created and causing things to stall. [/edit2]
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #37
Nothing like that, sadly. There is another thread about removing some dogdy xib that made a massive difference, but I'm not sure if that's relevant. (I'm not conversant with the build project, someone else put it together)

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 40
Joined: 2009.05
Post: #38
Are you using VBOs for your geometry? If does seem weird that you can't get 60fps when you've only got a trivial shader.

Quote:Since you've hit 40fps with a trivial fragment shader then you need to look for where the next bottleneck is if you want to hit 60fps. It's going to be something different and you'll need to investigate using all the techniques suggested again, but with the fragment shader left trivial.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #39
Again, yes. Lol, there's a pattern forming here. Coming from PC source it was easier to get that stuff going than it would be retrofitting from a drawarrays based system.

We even tried unpacking all the compressed vertex attribs, ie 3 floats for a normal instead of 4 bytes. Nada.

A lot of times people look for a silver bullet when there isn't one. As a general "engine guy" of 25 years, I know this more than most. However I really do feel there must be some big elephant in the room here because all of the minor tweaks we've done, including those suggested here, never made any real difference at all. And some of them really should've, so I really do think there's one single thing elsewhere that I'm doing wrong or not doing at all.

At some point soon someone here will suggest, or we'll find ourselves, "Have you turned on the widget for the procedural flanger?" and then we'll slap our heads and smile at the awesome speed difference.

So please guys, keep up the suggestions. Try not to blame me when I come back with "thanks but nada". Smile

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 87
Joined: 2006.08
Post: #40
Can you still take a look in the OpenGL ES Driver instrument, and gather the Tiler and Renderer utilization? You seem to be trying to optimize both vertex and fragment processing, indicating that you haven't used this tool to verify where the issue is.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #41
A colleague is actually doing this day to day now, so I'm not totally sure. I do remember seeing the renderer at 100%, but I'll take a look at this stuff again on Monday and report back, thanks.

Paul Johnson
Great Little War Game
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2010.08
Post: #42
(Nov 20, 2010 10:50 AM)iamflimflam1 Wrote:  Are you using VBOs for your geometry? If does seem weird that you can't get 60fps when you've only got a trivial shader.

VBO's make a big difference on the iPad. Without them our game dropped framerate significantly. Do you use VBO's for both indicies and vertices?
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #43
I think so, yes. I'll check that though, thanks.

Paul Johnson
Great Little War Game
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2010.11
Post: #44
Have you downloaded Apple's most recent OpenGL Programming Guide? It was just updated a few weeks ago and contains a lot of suggestions for optimizing stuff.

That said, 20000 vertices seems like a lot to me for an iOS device. My game
(on the ipad) maxes out around 18000, and much of that is culled by a clip plane. (Triangles, actually, not vertices, although the two should be very close since almost everything is triangle strips.) (On a side note, I read somewhere NOT to use triangle strips anymore, but instead just use... well, whatever the current term for "indexed face sets" is, I forget... is this true? Probably only on the latest nvidia hardware or something, not the ipad...) At 18000 triangles, I'm just barely squeezing by on what I'd consider to be an acceptable framerate (29~30 fps, with some hiccups down into the low 20s), and I have to downsample (I'm not running at the full screen resolution, but about halfway between full and half.)
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #45
Not checked for the latest doc, could be worth a go thanks.

Regarding vertices, I've always been a bit worried about the entire scene tbh, but my problems are more fundamental than that. If I can't get just the landscape only rendering >20 fps then that indicates a fault in my app tbh - nothing can be that unperformant these days, surely.

The odd thing is, we've almost got the FFP path working now and the entire game renders just above 20fps with all the units and a "full" 4 layer ffp setup for the ground (although the units and trees etc aren't lit yet). Taking all that stuff out the fps rises to about 25 with just the ground and its new "shader".

Already using indexed triangle lists. Triangle strips have been "the wrong way" for quite a few years due to post-transform cache. Maybe you can give that a go and see if it makes a big difference in your app?

Paul Johnson
Great Little War Game
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Scaling iOS Game: iPhone -> iPad s0ckman 2 1,349 Dec 9, 2013 07:34 AM
Last Post: s0ckman
  XML too slow, best way to go binary markhula 9 8,323 Jan 14, 2011 06:58 AM
Last Post: markhula
  emulator slow when rendering from a second thread captainfreedom 1 2,879 Jan 30, 2010 05:05 PM
Last Post: ChrisD
  Simple application slow down, FPS drops Newbrof 15 7,916 Sep 2, 2009 12:51 PM
Last Post: AnotherJake
  Chipmunk is too slow? jaguard 14 8,155 Jan 22, 2009 04:49 AM
Last Post: jaguard