View Full Version : OpenGL stunts: Watching GPU memory occupancy
Petr Schreiber
10-08-2011, 23:53
I found out there is a way to retrieve total/available memory on GPU. There is GL_NVX_gpu_memory_info on NVIDIA hardware and GL_ATI_meminfo on AMD cards.
The code I provide below works only for NVIDIA cards, once my friend gets ATi I will test the GL_ATI_meminfo and provide solution working on Radeons as well.
It is interesting to watch how much GPU memory uses for example Firefox, try to launch the program and then just open new tabs in FireFox 5.
The proggie is very elemental, it allocates 512x512 textures as user commands via PageUp/PageDown. The textures are created on the fly.
Petr
Charles Pegge
11-08-2011, 06:41
Thanks Petr,
Interesting to see how many megabytes of memory is consumed by even the simplest of graphics programs. One of my Opengl benchmark programs takes up 15 meg of main memory then a further 9 Meg of GPU memory, which expands towards 100 Meg as the window is enlarged.
And here was I thinking that my basic runtime space of 3 megs was seriously bloated :)
Charles
Petr Schreiber
11-08-2011, 08:21
Hi Charles,
I must admit I was surprised too. But this proggie is extreme case - it uses anisotropic filtering in conjunction with mip maps. And it creates multiple textures (up to 1024).
Each texture is 512x512, in RGBA8 format + mipmaps. That means just for all the levels:
512x512x4 + 256x256x4 + 128x128x4 + 64x64x4 + 32x32x4 + 16x16x4 + 8x8x4 + 4x4x4 + 2x2x4 + 1x1x4 = 1 398 100 bytes!
Each bubble on the image has its own unique copy of the texture, which is horror scenario specifically designed for quick gluttonizing of memory :)
How did it behaved on your GPU, did you managed to fill whole memory? On my PC I did not managed to get it full :D
Petr
P.S. It is good to mention that after launching the program I see 160MB occupied - that does not mean the program ate 160MB after start. It displays global state affected by other programs as well.
Another cool proggie Petr. Here is a screenshot with it maxed out as I could get it on my old dual core. I can't believe this computer is 6 years old already, but I did upgrade the video card twice.
I like the little bug wobble too of your objects!
Charles Pegge
11-08-2011, 14:14
How did it behaved on your GPU, did you managed to fill whole memory?
I have not tested to the limit, Petr. The nVidia GT120 has 1 Gig of memory available, which is plenty for most apps. I will try next time I boot into Vista.
Charles
your graphics card is very slow. Nvidia Geforce 120 GT is only G96 typ: meant is a 9500 GT or 9600 GT.
you get this by Media Markt. Nvidia cheats here with the names.
Charles Pegge
11-08-2011, 20:52
It maintains 60FPS up to around 700 Meg of Texture space, then drops rapidly to 30FPS
At 1 Gig there are 729 textures and 1.25 million polygons. (30FPS)
No overflow problems.
Charles
Petr Schreiber
11-08-2011, 22:34
Thank you Charles :) 60FPS and then drop to 30FPS - that seems like forced VSync kicked in. Very nice speed anyway!
The code I posted stops adding textures once it detects submitting the data does not change the memory.
At home I used modded version with this limitation gone, as my card is split personality - it has 512MB own memory but can texture from RAM as well.
The results I saw in the modified version showed that this is not very big win as the performance gets unpredictable - few hundred MB from RAM was still very smooth, but then it suddenly dropped and whole system stopped being responsive (that's why I didn't published the unlocked version, it is not very pleasant to experience PC "stalled").
Petr
Petr Schreiber
11-08-2011, 22:48
I updated the first post with version, where it is more evident, that each texture is different.
To make the resolution obvious, the texture is composed of stripes. So dense, it makes very interesting artifacts (moire).
Petr