texture memory usage

I feel that I may have asked this before, but I can’t find anything about it in the forums. Does Panda provide a way to get the total current texture memory usage for the application? If pstats is the best way, I’m not familiar with how to use that.

I see that the Texture object has an estimateTextureMemory() method, which I presume gives a simple (width * height * bytes_per_pixel) and maybe multiplies by two for mipmaps. I could use that if there is a way to enumerate all currently allocated textures.

PStats is really the best way to view that data, since it can report a better estimate of texture memory actually used, as reported by your graphics card, rather than guessing based on the number of pixels.

You can read a quick summary of using PStats here, in the manual. It should be enough to get you started. You really only need to read about the first half of that document.

Currently, the texture memory shows up in PStats under the heading “graphics memory” (since this same memory is also used for vertex buffers). If you subdivide that category, it will show the breakdown into textures and vertex buffers; and if you pick texture memory, it will show you the portion of texture memory that’s currently active, e.g. onscreen, and the portion that’s inactive but still available in texture memory, and the portion that’s been completely paged out of texture memory.

Note that you can also enable runtime compressed textures with the config variable:

compressed-textures 1

This will significantly reduce your texture memory usage, at the cost of some visual quality of your textures. Presently, it only works in OpenGL mode.

David