5

I am creating an android game using opengl and a cocos2d port (http://code.google.com/p/cocos2d-android-1). I am targeting a wide range of devices and want to ensure that it performs well. I only test on a nexus one and am hoping to get some input from people with experience on slower devices.

Currently the game uses two 1024x1024 textures as well as two 256x256 textures. Is this within the limits of most devices? Anyone have any rule of thumb or experience with graphics memory limits in these cases? If gfx memory is exceeded does it page to normal memory?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
ghempton
  • 7,777
  • 7
  • 48
  • 53
  • What's the purpose of the 1024x1024 texture on a device with a resolution smaller than that? I'm working on Xbox 360/PS3 titles, and we rarely ever use textures of that size. – EboMike Dec 21 '10 at 01:41
  • The reason for the 1024x1024 is to store an "atlas" of miscellaneous sprites which are subrects of the texture. It's much more efficient and hard to afford otherwise. – ghempton Dec 21 '10 at 03:36
  • Your texture cache won't be happy about that (although I admit that I don't know how the texture cache works internally on the most common Android GPUs). In any case, is that the entire extent of your game? 2*1024x1024 and 2*256x256? That should fit on most phones. – EboMike Dec 21 '10 at 10:29
  • Well each sprite is going to be from different data (regardless of whether its in the same texture or not). How would the texture cache be LESS happy if its only caching a single texture vs 10 textures? The main reason for having them all in a single texture is so that in a single glDrawQuads call with a single texture loaded you can draw multiple sprites. Yeah that is the extent of the texture data for my game, good to know it should fit, thanks! – ghempton Dec 21 '10 at 19:53
  • 2
    A texture cache doesn't cache individual textures. It caches pages. If you have a small texture, it will be able to fit the entire texture in the cache. If it's big, then not so much. But there are other things to consider - render state switches are expensive too, so you don't want to re-bind your texture for every draw call. It's always a balance act. See how your game performs, and if things are lousy, you can experiment with different things, like texture sizes. – EboMike Dec 22 '10 at 06:52
  • @EboMike Just discovered the re-binding caveat for myself. On my newer 2.2 phone, I can re-bind textures quite frequently (game remains at 50 fps), but on my older 2.1 phone re-binding just once causes the fps to drop from 20 fps to 5 fps. Yikes! – Nick Bolton Apr 17 '11 at 13:59
  • @EboMike Also, about paging. It seems I was also misusing the texture cache; I noticed that when I load anything >512^2, the performance on my old 2.1 phone plummets (but remains the same on my newer 2.2 phone). At first, I figured the same as Gordon; "bigger texture = better memory usage" -- not true! It works the other way round. To follow on from my last comment; it seems that re-binding large textures is bad, but re-binding small textures is not so bad. – Nick Bolton Apr 17 '11 at 19:08

3 Answers3

11

Java Apps are 16Mo (mdpi) or 24Mo (hdpi). But Native aren't and OpenGL Java API is only a JNI wrapper. So you can load on GPU more than 24Mo of texture. My experience was to limit Atlas at 512*512 at first (because G1 was slow on big textures) but today i use bigger atlas texture.

Our current games use 20-50 Mo of ram and use 2048*2048 textures.

Ellis
  • 1,521
  • 1
  • 14
  • 16
1

Old post I know but nowadays your talking at least 128mb in the VM for available loading space on Bitmaps in memory using android java.

With textures you are loading outside the app space (c). So the loading limit is the same as the phones memory. (You'll notice on memory intensive games that the icons draw when going back to the home screen)

Oliver Dixon
  • 7,012
  • 5
  • 61
  • 95
0

Afaik the Memory Limits for textures are the same as the memory limits of your app, which is 16 megs in most situations I believe, although it might be all available phone memory that's accessible.

I've loaded MUCH more than this into my apps before I ran into problems, at least one 2048x2048 texture and several 512x512 textures, all 8888 in memory.

I've never had a oom error on texture binding, only on loading bitmaps, so I hope that helps.

HaMMeReD
  • 2,440
  • 22
  • 29
  • Just to re-iterate EboMike's point. I think the 512^2 limit still applies, as there are still some older phones still in use (e.g. HTC Hero) that don't work well with larger textures. – Nick Bolton Apr 17 '11 at 19:24