[PROGRAMMING TIPS] How to Know the Graphics Memory Size and Usage In OpenGL



ATI Radeon

You’re an OpenGL developer and you need a simple way to know graphics memory information such as the memory size or memory usage? If so, this is the right place!

Few years ago, this kind of information wasn’t available to OpenGL developers but today, the two majors in OpenGL (I mean NVIDIA and AMD/ATI) have added some useful extensions to fetch graphics card memory size and other related data.

OpenGL Memory Size with NVIDIA

NVIDIA has recently published the specs of a new extension called GL_NVX_gpu_memory_info.

Thanks to GL_NVX_gpu_memory_info you can retrieve the size of the total available GPU memory and the size of the current available GPU memory.

Here is a code snippet that shows how to use it. GL_NVX_gpu_memory_info returns sizes in KB.


GLint total_mem_kb = 0:

GLint cur_avail_mem_kb = 0:

This extension is used in GPU Shark to get the memory usage for NVIDIA graphics cards as you can see in the following picture:

Memory usage - OpenGL - GeForce  GTX 260

According to Geeks3D OpenGL extensions DB, GL_NVX_gpu_memory_info is available in NVIDIA display drivers since R196.xx (see R196.21).

OpenGL Memory Size with AMD/ATI

AMD has released two extensions to deal with the size of video memory:

WGL_AMD_gpu_association is an extension developed for parallel rendering: you can create a different OpenGL context on each available GPU. This extension comes with hardware query functionalities. With WGL_AMD_gpu_association you can get the amount of graphics memory available for the GPU.

Here is how to use it to get the size of GPU memory in MB:

UINT n = wglGetGPUIDsAMD(0, 0);
UINT *ids = new UINT[n];
size_t total_mem_mb = 0;
wglGetGPUIDsAMD(n, ids);

I tested this extension in this pico tool called Radeon-Z ;)

Memory usage - OpenGL - Radeon HD 5870

GL_ATI_meminfo is used when you need more detailed information about the available memory for VBO (vertex buffer object) or for your textures.

Want other articles and tutorials ? Just jump here:
[ Geeks3D ARTICLES and TUTORIALS Main Index ]

[ Subscribe to Geeks3D latest news by email ]


↑ Grab this Headline Animator