How can I got the true video memory information

I use two fuctions to get video memory information.One is the getcaps in Directdraw. The other is getavailabletexturemem in directx9. But the two fuctions just return the video memory changes when I play a movie by realplayer. When I just show a picture in Mspaint, the video memory information doesn't change at all. To confirm my video memory information, I use the caps viewer which ship with directx9. But no different result was found out.

So is there any other function to get video memory information?

Why the video memory doesn't change at all when show a picture?

thanks.

[609 byte] By [mr3] at [2007-12-25]
# 1
The memory doesn't change when Paint displays a picture because it doesn't need to allocate any video memory to do so.
RossRidge at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 2
Thanks for reply.
But do you have any evidence of memory usage when display an BMP file? If you try show a bmp file which size larger than your video memory, the operation may failed.And there is api which named blit used to display bmp file. The API should be used to transfer data from system memory to video memory.
mr3 at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 3
As Ross said. Blitting doesn't allocate memory. When you load a BMP, the only memory you'd allocate is enough RAM to store the bits before blitting them. So this doesn't take any video memory.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 4

Thanks Bahnassi.

But I think the picture data should be put into the video memory when I want to show a picture on screen. The blit function should transfer the bits in system memory to video memory. What I mean is that the process of show a picture should consume the video memory, not just allocate memory to load bmp file.

mr3 at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 5

No it doesn't. It's not a memory "move". It's a copy of the bits from one place to another. Both memory areas are preallocated: your BMP in system ram, and your frame buffer in video memory. You just copy the values of the bitmap bits from the former to the latter.

The following figure might help:

Before blit:

Bitmap:
11000
01000
00100
00011

Video (a black screen):
00000
00000
00000
00000

After blit:

Bitmap:
11000
01000
00100
00011

Video:
11000
01000
00100
00011

Note that the number of fields didn't change after the blit...

WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 6
Bahnassi, thank you very much.
I know what 's you mean. Is that true the video memory usage should increased
after blitting? In the ddk document, the video memory can be direct accessed by GDI module and directx module. There is a video heap management service in directx module. Should the directx module be notifyed after GDI module allocate some video memory?
I make a test sample:
The test machine have 16M local video memory and 256M texture memory.
I create many surface in the video memory. The local video memory was reduced to almost 400k and the texture memory was reduced to 4MB. But I still can open a BMP file which size is 9MB.Why does this could happen? Is that mean some unactived data was removed out of the video memory by the heap management module of directx?
mr3 at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 7
I believe I already said that your BMP is allocated in system ram.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 8
But the data still need to be copy to video memory when display bmp file. So the video memory usage should be increased.
mr3 at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 9

Think about it this way: video memory has two sections.

First you have video buffer memory, that is used to display the actual monitor image. This is ALWAYS being used - data is simply being copied into it, overwriting whatever is already there. So the "amount" of memory in the video buffer section never increases or decreases.

Second you have texture memory. This IS consumed as textures are copied from system RAM to the video card. So at a certain point you can "fill it up" with textures, and can't copy any more until some are freed (removed).

Your .BMP image is being copied into the first section, the video buffer, for display. So there is no change in the amount of free memory. If your .BMP were used in a Direct3D texture object, then it would be copied into the texture memory section, and available free memory would decrease.

The main thing is you really shouldn't worry about this too much. You can't "use up" video buffer memory, and the system will manage texture memory for you by default - if you have too many textures it will remove the least-used ones to allow new ones to be copied. This is called "texture thrashing" and it can lead to slow performance when doing 3D graphics - in which case you need to look into managing your textures more carefully. You can find plenty of articles and tutorials on this by typing something like "texture management" into Google.

-tAE-

theAntiELVIS at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 10

theAntiELVIS, thank you very much. Your answer is very helpful. You are the best.

Thanks to the detailed explanation again.

mr3 at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...