iPhone OpenGL Texturing / Memory

Hi, I'm having an issue with textures. What is the opengl es available texture memory in iPhone?

What happens is that I'm trying to load about 60-70 varied size textures. And there is only two large textures that are 256x256. The most of them will be 32x32 or 64x64 and some 128x128. If I bind then on load time, I keep getting blank textures or textures being replaced by others (I think its memory issue?).

So I tried to bind and delete them just in their rendering time (bad, very bad, I know, its a test) and almost everything works, but then periodically I get a black texture somewhere.

How can I manage a high texture count on iPhone? I thought to implement texture atlas 1024x1024 so I can save some "blank" space from my tiny textures.

But first I'm looking for possible causes of my problem and another possible solutions.

White textures could be the result of many different things. Just a few things to keep in mind: You need to have glEnable(GL_TEXTURE_2D), and you need to have the correct texture coordinates in your glTexCoordPointer(), and you need to have glEnableClientState(GL_TEXTURE_COORD_ARRAY). You of course, also need to have uploaded your textures to the GL with glTexImage2D, and you need to have at least set the minification filter for each texture with something like glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

For memory, in practice, your app can use up maybe 10 to 15 or 20 MB before getting memory warnings on iPhone, according to some reports (more on iPod Touch I think). How much of that is for the GL is up to you. The guide says you should use no more than 24 MB for textures and surfaces.

What I do is use a texture atlas where possible, and PVRTC textures where possible. PVRTC saves an enormous amount of memory at the cost of some compression artifacts. For animated 2D images I've found the PVRTC is perfectly fine since you can't see the compression artifacts in the frames of animation as they whizz by.

I double checked my gl and tex initializations and yes, everything is fine. As I said, my problem is that I get theses glitches randomly. Sometime texture X appears on place of texture Y. Then when I restart, I can get texture H in place of texture C. Or else, just some of my textures will not shown (be blank if they aren't replaced by another one). So this really look as memory problem.

I will check about PVRTC, but most of my textures I need check pixel collision, so I dont know I will be able to use compressed textures.

ps.: Just as measurement, I got about 27mb of memory in use during my application. 25mb are from textures. I will try to keep it under 20mb to see if will solve.

It isn't expected that there will be any texture corruption issues. You should submit a bug report, with example code, at http://bugreport.apple.com.

However, if you go beyond 24MB of texture usage at the same time (dormant textures will be paged off), you will experience a very large drop in performance. Your framebuffers, including depth buffer, also count against this limit.

Use Instruments (GART Resident Object Size) to determine how much texture memory usage is currently being used.

Thanks, never heard about GART, just looks what I need
I will check it and post the results here. Btw, I got it working by deleting and rebinding textures "EVERY" frame. But pre-allocating them still doesn't work. And I haven't dormant textures. All them need shown off in the same screen at same time.