Optimization tips?

Monkey Targets Forums/Android/Optimization tips?

Supertino(Posted 2013) [#1]
Any one have any tips other than what I am doing at the moment?

Things I do at the moment in the belief they're best.

1. Use texture atlas' and draw using grabimage - I currently use 3 1024x1024 textures (I use 1024 for compatibility with older devices)
2. Reduce texture swapping - I render my images in such a way to not draw an image from texture#1 followed by an image from texture#2 followed by an image from texture#1 etc.
2. Culling - where possible I don't render an image if it's off the screen
3. I don't use mojo's DrawRect,DrawOval and such though I am not sure if they are slow or not best use?

Things I do do which I am not sure is not optimal.

1. Use SetColor a few times each render loop to render different coloured text and a few other bits.
2. Break large images such as a 576x576 into four 288x288 images and end up drawing four smaller images rather then one larger image.
3. I have one or two setsissors, pop/push matrix, translate calls per render loop.
4. I tend to use SetAlpha rather then baking the Alpha into the image(s).

I have a Nexus 7 and an S3Mini - S3 doesn't miss a beat and maintains 60fps, the Nexus 7 hang's around the 55fps.

I render up or down (autofit) from a base size of 1024x576.

I under stand both my devices are reasonably powerful and that older devices probably wont get near 60FPS but without such a device It's hard to know what's best.


NoOdle(Posted 2013) [#2]
I would try and avoid 1) & 4) from your bottom list if you can....


muddy_shoes(Posted 2013) [#3]
Avoiding texture loads is always going to pay off (following the general rule that not doing something is faster than doing it), after that it starts to get trickier. For example it's very possible for culling in your code to be more expensive than simply letting the hardware deal with it.

You really need to profile your application to see what's going on.


Supertino(Posted 2013) [#4]
Thanks guys, I'll bake the alpha in to the images rather then using set alpha as much, think ill go get a cheap 2010 android phone off ebay to test with, in the mean time I'll put up a demo in the next day or so I can get some feedback on performance.


therevills(Posted 2013) [#5]
Don't you list, do use object pooling. Try not to create objects when the gameplay is happening.


Supertino(Posted 2013) [#6]
Ah yes I learned to not create objects on the fly with Android a while back.

there's a demo of the game here http://www.monkeycoder.co.nz/Community/posts.php?topic=5298#58751 if any one is interested in testing it - really looking to see how it performs on 2.3.3 devices.