开发者

Track opengl texture memory in Android

开发者 https://www.devze.com 2023-01-03 21:20 出处:网络
How do I track the memory used by OpenGL textu开发者_如何学Gores in Android? I understand the texture memory is on the Video RAM, but do they get swapped in with the RAM? If I call glGenTextures and

How do I track the memory used by OpenGL textu开发者_如何学Gores in Android? I understand the texture memory is on the Video RAM, but do they get swapped in with the RAM? If I call glGenTextures and do not call glDeleteTextures, how does it impact the memory usage of my current process?


This might depend on the device. But in some implementations of OpenGL, when the VRAM runs out, it will try to transfer some of the older textures on to the system memory if there is room. If there is no room, it will get deallocated. However, OpenGL memory will never enter your application memory as usually there is only a single OpenGL context at a time on a device. This means that it is handled by the system and its not your applications problem.

So in other words, through pure OpenGL, you can't tell how much memory you have used. However you can keep track of this your self with each texture you upload to VRAM (since you have the bytes you upload).

As for not calling glDeleteTextures, you don't really need to if you don't use that much memory. It doesn't use more battery or CPU or GPU power, the bits of VRAM are just simply set to 1 instead of 0. If other applications need that memory after your applications pauses or dies, they will just automatically delete your textures and overwrite them with theirs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号