Any way to query the video card for free memory?

Is there any way to find out how much video RAM is being used? Other than by keeping track of the textures and vertex data you’re sending to it?

Short answer: no.

Long answer: even keeping track of it yourself won’t necessarily tell you how much video RAM is used. The drivers may shift textures around whenever they see fit, so the data may be in AGP memory or system memory, and hence you can’t know how much video memory is free.

The standard answer to this question is: you should not need to know.

– Tom

Well, it’s nice to have some kind of budgets to work for.

For example, you can assume that the user’s frame buffer(s) are 8MB, and that you then have 24 MB of (possibly compressed) data to allocate to a scene if you want the scene to run well.

To then figure out whether you’re on budget or not, you have to define what a “scene” is (which is special to your project) and then sum up the potential texture usage in that scene. This is almost all knowledge the application has much more of than OpenGL, though, so it’s reasonable that OpenGL doesn’t tell you.

We have hooks in the renderer so that artists can press a key, and out comes an excel file which shows how many vertices, mateirals, texture space, etc are used in whatever frame they’re looking at. Very useful.

Something that I’ve noticed (at least with my 9700 anyway) is that if you launch a another thread or process and use DirectDraw to query the free/total video memory it will be affected by any program using the card’s memory (OpenGL frame buffer, textures, VAO data <- not sure about that one), something odd though is that the windows desktop doesn’t seem to change the free memory.

But I’m not sure if it’s really a good idea to do that though.

Thanks for the replies, guys. I asked the question as part of my ongoing problem with uploading enough vertex data to the video card. I’m still having that issue, but it’s no longer a problem since I’ve found a workaround.

Just to reiterate my project: I have a terrain engine that uses Perlin Noise to randomly generate segments of terrain. Each segment is 256x256 and at least 9 need to be rendered each frame. This fits in memory easily, but at a maximum I need 16 segments generated.

Most of the time it takes to generate a single terrain segment is in creating the heightmap via Perlin Noise and the Octree. For this reason, it isn’t enough to limit the maximum number of active segments to 9. If one crosses into another segment I would have to create the new segments, plus delete the ones outside of the 3x3 grid in order to save memory. What if one immediately decides to turn around, though? The old segments would have to be generated again – which takes quite a while. However, I’ve found that generating vertices from the height map and tossing them into a vertex array doesn’t take much time at all. Thus, when a segment goes out of the 3x3 grid, it is “deactivated”. The vertex array attributed to it is freed, but the heightmap remains. If one turns around immediately to go back, the segments do not have to be totally recreated. All I have to do is regenerate the vertices and upload them to a vertex array, which takes only a couple seconds.

Of course, I’m still worried about running out of memory, given that there will be geometry for other objects that have to be uploaded into memory. . .

look into ‘texture caching’ as in implementing your own sceme. look for info relavent in the days when u done your own 3d software engine.
i do have a couple of links if u wish ill dig them up.
also check out www.vterrain.org

btw >>Most of the time it takes to generate a single terrain segment is in creating the heightmap via Perlin Noise and the Octree<<

it sounds like youre doing something very similar to what im doing in my sparetime.
though octree? i find all the time is taken up with generating the heights + coloring the terrain (bumps + decal)

[This message has been edited by zed (edited 02-13-2003).]

btw again, i also do it this way.
i create X number of textures (a constant value) and each time upload new data into one of the textures, ie im not creating new textures all the time. (+ my scene consists of trillions of polygons).
texture creation on the fly (…insert rant about it being the future)

[This message has been edited by zed (edited 02-13-2003).]