Jump to content
  • Advertisement
Sign in to follow this  
np39223

detecting graphic card memory size

This topic is 4234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello... How to get physical memory size of graphic card. I was thinking glGet, and GlobalMemory status, but it's no good. Do I need win32 API function to do this, or openGL API function, which one? Is there any tutorial on on web how to get this kind of hardware specific info using win32 api. There is directX function GetAvailableVidMem but I'm writtin GL app. so It's stupid to init directX just to get this info.. I posted this on openGL furum, no one replied.. I googled a lot and found nothing usefull.. Thanks for reading this...

Share this post


Link to post
Share on other sites
Advertisement
There's no way you can detect memory size of the graphic adapter in the OpenGL. And why do you even need it? You don't need to do any memory management since that is handled automatically by the driver.
I remember that people tried to use glAreTexturesResident to determine size of the video memory but that is useless since you driver may always return true event if the texture is not directly in the video ram.
If you really want to determine size of the memory, you can use WMI and query for Win32_VideoController class. Size of video ram is then stored in AdapterRAM property.
Note that with newer systems video ram size may become irrelevant (for example on Vista) since system may page out unused portions of the video memory to the computer's RAM (or even to the disk if RAM is full). It is all transparent to the application.

Share this post


Link to post
Share on other sites
> And why do you even need it?
May be useful for initial autodetection of graphics settings the current system can handle.

> There is directX function GetAvailableVidMem but I'm writtin GL app. so It's stupid to init directX just to get this info..
True in principle, but it probably is the easiest way. This info is also given by ddraw caps; just query those and be done.

	IDirectDraw* dd = 0;
HRESULT hr = DirectDrawCreate(0, &dd, 0);
if(SUCCEEDED(hr) && dd != 0)
{
DDCAPS caps;
memset(&caps, 0, sizeof(caps));
caps.dwSize = sizeof(caps);
hr = dd->GetCaps(&caps, 0);
if(SUCCEEDED(hr))
video_info.video_mem = caps.dwVidMemTotal;
dd->Release();
}


WMI = COM ugliness. heh, just looking at the linked page:
Quote:
Starting with Windows Vista, hardware that is not compatible with Longhorn Display Driver Model (LDDM) returns inaccurate property values for instances of this class.

Yikes!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You don't need the size of the memory on card. It can pull from system memory too when it wishes. It can also have other applications already using some of it, so you get different sizes each time you poll. I, also, at one time thought I needed this information, but at the end of the day it's useless and unreliable, hence why it's not available on Vista on. OpenGL from my understanding doesn't even give you a glimpse at it in the 3.0 specifications either.

Really think about why you want this info.

Share this post


Link to post
Share on other sites
Thank you people for Your effort.
I wrote why I need video memory size in my openGL forum post.

I'm working on hardware accelerated volume rendering. This is visualizing large 3d data like 3D - CT scan, or 3D MRI scan or similar. You visualize this as semi transpirent 3d structure so unlike with surface graphics(used in games) inside of an object is rendered too. So you use series of 2D slices and alpha blend them or use 3D textures instead. This datasets are very large eg. 128 MB so if entire volume datasets fits into video memory you achieve real time rendering. If you have to load part of volume on fly - by by realtime :( You can use system memory
but loading takes time

So I need vidmem size eg. 128MB or 256MB for simple decision making - to resample volume if needed, use 2D or 3D textures etc.
I don't need to do some memory management, but only info on physical size..

I posted this to find out is there any simple solution, but I guess there isn't.
I'll probably use directX than..

Again, thanks a lot !!

Share this post


Link to post
Share on other sites
Thanks Jan Wassenberg, i copy pasted your code and it's working.
You saved me quite a time, since I'd have to read directX
documentation but I'm quite bussy.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You realize that the size is not always accurate, each card can return something different right? You also realize you will not get a return of the current memory available but the max you can have ON card. The card can choose at anytime to swap to system momory if it needs more. Again, something else could be using video memory and you'll never know. Just write your application, figure out the requirements and tell your customers. Video cards are CHEAP unless you need something over 512MB and in that case it doesn't matter anyways.

Oh and note, some video cards, like on laptops or integrated video cards will return whatever they want. My friends PC returns 256MB but its all system memory and SLOW.

I also thought it would be cool to know so I could make some decisions then I started testing random cards and getting random return results. I had a 64MB card return 256! You're playing with a gernade by relying on these results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!