Hi!
I created a texture atlas using zwoptex. It is 1024x1024 and contains many smaller images of varying sizes. When I want to estimate texture memory usage, should I consider the size of the texture atlas and the size of each sprite I load and display from it, or should I just consider the size of the texture atlas?
To clarify: Let's say I have 4 256x256 byte images inside the atlas. I load them into the CCSpriteFrameCache object. When I display these sprites, I assume that 0.5M of texture memory is used (256x256x4x2). If I also count the atlas itself, then an additional 2M of texure memory is used. How mem is used then: 0.5 MB or 2.5 MB ?
I am using the RGBA4444 pixel format with PNG images.
Thank you!
Texture Memory and Texture Atlas
(3 posts) (2 voices)-
Posted 1 year ago #
-
you're loading the whole texture from texture atlas to memory, and only this texture. it does not matter in any way how many textures do you store in it - it is still treated as a single texture
so for a RGBA4444 - 1024x1024 pixels takes 1024x1024x16 bits which is 2 MB. for the same size RGBA8888 takes 4 MB
you can also use a smaller texture atlas - 4 256x256 textures can squeeze into one 512x512 texture that takes 512 KB (RGBA4444) or 1 MB (RGBA8888)
just for a clarification - texture atlases not only allow you to render things faster, but can save space as well. on iDevice when you load a texture it is automatically "padded" to the nearest power of 2. for example - if you load an image that is 300x300 pixels, it will be stored as a 512x512 texture. so for the same amount of memory 2 MB using RGBA4444 you can load 4 300x300 textures or squeeze 9 such images into one 1024x1024 texture atlas (and still have some extra space)
Posted 1 year ago #
Reply
You must log in to post.