Why is my iPad game so slow?

Moderator
Posts: 335
Joined: 2002.04
Post: #16
Probably not a 15-60fps changer but it might be worth taking the D3D optimisation out of your workflow for a test. What's optimum for D3D is rarely optimum for anything else Wink

Can't see it being a huge impact unless it's really wild, but might be worth testing anyway.
Quote this message in a reply
Member
Posts: 353
Joined: 2002.04
Post: #17
I'm far far from the most knowledgeable about GL on these boards, but you mention reducing your textures down to a small size. How many times are you swapping textures in one pass? Using texture atlases and reducing the number of swaps vastly improved my performance.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #18
Thanks for the further suggestions.

There are only 11 binds per frame atm as the level mesh is already as optimal as its going to get. Sure enough the tanks and level decoration stuff would benefit from better atlasing (as would the pc version for that matter) and it's something we'll get around to when that's our biggest problem. It's moot atm though.

You're right about the d3d optimisation not being an iPad optimisation, but I'm assuming that its better than nothing given we don't have details about an iPad optimisation. (Meaning the D3D version is probably better than the other option - random).

Is there somewhere I can get proper hardware details about what is actually in the iPad? PT cache, texture cache, bus latency, etc?

Might give strips ago, but I thought they were no brainers for many a year now.

Paul Johnson
Great Little War Game
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #19
I wouldn't use actual triangle strips, if that's what you mean, because of the explosion in GL calls; just stick with glDrawElements, using single batches of verts as usual, but order the verts in strip fashion. The PVR docs illustrate why this might help (sorry I don't have a link handy). Like I mentioned earlier, there is a good stripification class in the oolong engine which can be used for this if you want to try it out.

That said, I think you need to find the big culprit first, and it seems we're all circling around that most likely being one of your shaders.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #20
Right, I see what you mean. I'll check out the oolong thing some time soon. I totally agree this won't be the killer and in all likelihood it's something to do with shading. Pretty sure its not the shader length itself or texture crapness, so what else might it be?

I seem to recall that "dependent texture read" is a pretty broad gotcha. So broad though that I don't really know what the gotchas are yet. It implies reading from a texture using UV generated by a previous read, but I know its worse than that as I saw it once somewhere. But still, outputting just white didn't go >40


Another quickie. Am I missing anything in relation to glHint ? We're not using it atm as ime it never does owt, but maybe some options are available here?

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #21
Those shaders, as requested. (Note that the VS looks a bit bloated due to the precompiler - this is raw output.

Code:
const int I0 = 0;
const int I1 = 1;
const int I2 = 2;
const int I4095 = 4095;
const int I127 = 127;
const int I255 = 255;
#define F0 (float(I0))
#define F1 (float(I1))
#define F2 (float(I2))
#define F4095 (float(I4095))
#define F127 (float(I127))
#define F255 (float(I255))
uniform highp mat4 u_proj;
uniform highp mat4 u_modeltoworld;
uniform highp vec4 u_camposworld;
uniform mediump vec4 u_uvoffset;
attribute highp vec4 a_position0;
attribute highp vec4 a_normal0;
attribute highp vec4 a_normal1;
attribute lowp vec4 a_colour0;
attribute highp vec2 a_texcoord0;
attribute highp vec2 a_texcoord1;
varying mediump vec4 v_colour0;
varying mediump vec2 v_texcoord0;
varying mediump vec2 v_texcoord1;
varying highp vec3 PosW;
void main (void)
{
highp vec4 Normal = (a_normal0 / F127) - F1;
highp vec4 InPos = vec4(a_position0.xyz,F1);
highp mat3 modeltoworld33 = mat3(u_modeltoworld[I0].xyz,u_modeltoworld[I1].xyz,u_modeltoworld[I2].xyz);
PosW = (InPos * u_modeltoworld).xyz;
gl_Position = vec4(PosW,1.0) * u_proj;
v_colour0 = a_colour0 / 255.0;
v_texcoord0 = (a_texcoord0 / F4095)*u_uvoffset.xy+u_uvoffset.zw ;
v_texcoord1 = (a_texcoord1 / F4095)*u_uvoffset.xy+u_uvoffset.zw ;
}

Code:
uniform lowp sampler2D u_sampler0;
uniform lowp sampler2D u_sampler1;
uniform lowp sampler2D u_sampler3;
uniform lowp vec4 u_colour0;
varying lowp vec4 v_colour0;
varying mediump vec2 v_texcoord0;
varying mediump vec2 v_texcoord1;


void main (void)
{
lowp vec3 Pix1 = texture2D(u_sampler0, v_texcoord0).rgb;
lowp float PixA = texture2D(u_sampler0, v_texcoord1).a;
lowp vec3 Pix2 = texture2D(u_sampler1, v_texcoord0).rgb;
lowp vec3 Pix4 = texture2D(u_sampler3, v_texcoord1).rgb;
lowp vec4 MainPix = vec4(mix(Pix2,Pix1,PixA)*Pix4*u_colour0.rgb,1.0) ;
gl_FragColor = vec4(MainPix.rgb*v_colour0.rgb,MainPix.a);
}

Anything?

Paul Johnson
Great Little War Game
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #22
Anything wrong with it ? Ta

Paul Johnson
Great Little War Game
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #23
(Nov 16, 2010 08:44 AM)Applewood Wrote:  Anything wrong with it ? Ta

Looks like it should be easily digestible on a glance, so I don't see anything obvious sticking out.

How hard would it be to do an ES1 test of your geometry, outside of your engine?
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #24
Funnily enough, we're doing that right now. Coming to the conclusion that shaders don't give us what we were looking for, we're going to switch to FFP and at least encompass all devices. (Plus get code working for stuff like android into the bargain, if that's not a swear word around here).

Outside of our engine completely would be hard but not beyond the realms of possibility. I don't think the problem lies in other code areas in our engine though as it works on a few supposedly lowlier platforms at a fair clip. (We have a 90% implemented ES1 engine already, just not targetted at iPad yet)

Paul Johnson
Great Little War Game
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2010.01
Post: #25
Are you rendering at the native iPad resolution, or 320x480? In the back of my mind is the thought that what we think of as being possible on the device -- and Epic Citadel is the benchmark I guess -- might be only be possible at 320x480.

Longshot: Have you tested your game on another iPad?

Rowan.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #26
Yes, 1024x768. Is Epic Citadel 320x480 ?!?

Sadly don't have another one yet, but the thought has crossed my mind. Not played anything yet that felt genuinely fluid.

Paul Johnson
Great Little War Game
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2010.01
Post: #27
I just downloaded Citadel for my iPhone 4 and... it's running at the Retina resolution. I assume the iPad version probably does as well. :|

I don't understand how this Citadel demo does what it does. I double-checked the install size, just to convince myself that they hadn't simply pre-rendered every conceivable frame and let you play it like an interactive video. Sadly, it appears to be real.

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.

Maybe they're using low bits-per-pixel or something. I guess I need to go back and have another look at it. :|

Rowan.
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #28
Please do share your findings. We're at the same point you are - utter despair. There has to be something those guys know that we don't, but I'd swear blind we've run out of options to test. Sad

Paul Johnson
Great Little War Game
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #29
I was just thinking of doing the ES1 route as a sanity check, since it sounds like you guys could use a little of that at this point, but if you can incorporate it into your engine then all the better, since like you said, then you can reach back to older devices anyway. Unfortunately, the shader route should always be faster than FFP on iOS devices, but at this point it doesn't sound like you have anything to lose. Personally, if it were me, I'd start a test project completely on its own with test geometry and shader route to try to nail down the fast path, then re-incorporate that back into the engine once I had found it.

BTW, no, Android is not a swear word here. We focus on Apple technology discussions in these forums, but we're not zealots. Indeed, I myself am making great effort to develop cross-platform these days (including Win/Linux/etc). I even have the Android SDK installed on my dev machine. I poked around with it and did some research and decided there are just too many devices to bother supporting in a rather chaotic market where there appears to be only 1/10th the revenue of iPhone for developers, and shelved the idea for now. If somebody could convince me that it's worth it, I'd be happy to pull it out of storage. Wink
Quote this message in a reply
Member
Posts: 54
Joined: 2010.10
Post: #30
Good advice. We do have a really simple test app we can frig about with, so once we have the engine code working we can pull out the bits and test it in isolation there. Not that I'm expecting any great revelations at this point. Me=defeated, lol

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,484 Dec 9, 2013 07:34 AM
Last Post: s0ckman
  XML too slow, best way to go binary markhula 9 8,399 Jan 14, 2011 06:58 AM
Last Post: markhula
  emulator slow when rendering from a second thread captainfreedom 1 2,928 Jan 30, 2010 05:05 PM
Last Post: ChrisD
  Simple application slow down, FPS drops Newbrof 15 8,058 Sep 2, 2009 12:51 PM
Last Post: AnotherJake
  Chipmunk is too slow? jaguard 14 8,242 Jan 22, 2009 04:49 AM
Last Post: jaguard