PDA

View Full Version : Memory usage



Thomas F.
02-24-2008, 07:03 AM
Is it possible to get the free/used memory status of the GPU with OpenGL?

Zengar
02-24-2008, 08:49 AM
No

Thomas F.
02-24-2008, 02:31 PM
Ok, thx. Any hints on how to do it otherwise? Just need to be pointed into the right direction.

Brolingstanz
02-24-2008, 02:51 PM
i think the right direction is the direction that takes you away from such concerns. Volatile resources are just that, volatile...... what's here one second is likely gone the next, depending on you particular context of course.

V-man
02-24-2008, 09:23 PM
GL doesn't offer such a feature since it is expected that the actual "type of computer" could inform you of its characteristics.
In other words, if you are using a PC with Windows, then the OS should have functions to inform you of VRAM, AGP, RAM. If you run PalmOS on a PDA, same deal.

For Windows, I know that DirectDraw offers some functions
http://www.gamedev.net/community/forums/topic.asp?topic_id=263782

Thomas F.
02-26-2008, 11:26 PM
i think the right direction is the direction that takes you away from such concerns. Volatile resources are just that, volatile...... what's here one second is likely gone the next, depending on you particular context of course.

I'm working on an image viewer (lots and lots of images) - and I wanna know when I should start deleting my textures before it's too late. And I don't want to do it earlier because it could mean unecessary loading times.

Direct3D hmm, thx. Not sure if I wanna use it since my application should stay platform independent (currently OpenGL + QT). Or do you know a way for doing this on Linux + MacOSX too?

MeneerDePeer
02-27-2008, 12:38 AM
Just don't load those lots and lots of images all into memory at the same time and you should be quite safe.

If you want to cache images because you think loading them from the HDD is slow, put them into main memory, and only load those that are likely to be shown next.

If you're going to show thumbnails, build thumbnails and don't load the full images into memory.

As far as I can see there's not really a requirement to "start deleting textures before it's too late" that way?

smileyj
02-27-2008, 11:17 PM
As long as it's only texture memory utilisation you're worried about, you can use the texture proxy.

Here's the example code from the Red Book for checking whether there's enough space left to load a borderless 64x64 RGBA8 texture:

GLint width;
glTexImage2d(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);

'width' will be zero after the 'get' if there's not enough texture memory left to accommodate a new texture with the specified characteristics.

Details are on page 380 of the 5th edition of the book (or look up "proxy textures" in the index for other editions).

Zengar
02-28-2008, 12:19 AM
I wouldn't rely on proxies... We had some reports suggesting that IHV don't take them too seriously.

smileyj
02-28-2008, 05:10 AM
I wouldn't rely on proxies... We had some reports suggesting that IHV don't take them too seriously.
I got so fired up about vendors undermining the spec like this I just posted a couple of suggestions (OK, it's a rant) in the nextgen OpenGL forum: 1. the OpenGL conformance test results be made public and 2. developers donate code to their own public conformance/performance suite.

Zengar: I quoted your reply above there with indirect attribution in case you didn't want to get dragged into it. Happy to edit your name in if you want.

skynet
02-28-2008, 06:32 AM
Extensions like
ATI_meminfo
might help to overcome "guesswork" in future.

Zengar
02-28-2008, 06:41 AM
@smileyj: I was talkig about this (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Board=2&Number=234141&Searchpage=1&Main=46449&Words=proxy&topic=0&Search=true#Post234141) , for example.