Memory usage

Is it possible to get the free/used memory status of the GPU with OpenGL?

No

Ok, thx. Any hints on how to do it otherwise? Just need to be pointed into the right direction.

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.

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

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?

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?

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).

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.

Extensions like
ATI_meminfo
might help to overcome “guesswork” in future.

@smileyj: I was talkig about this , for example.