How is video-ram mapped into virtual memory space ?

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
Suppose a 64-bit OS.
Suppose a 32-bit application.
Suppose a videocard with 2GB of vram.
Suppose Windows 7.

The application is 32-bit. So the process has a range of virtual memory of maximum 4 GB.

I've read that the vram is mapped into the process's general virtual memory space. As far as I can understand this means that this will reduce the amount of address space available for the process. Basically the virtual memory available for the process will be: 4GB - amount of mapped vram - some more space reserved by the OS for other mappings.

Am I correct so far ?

The question is, how much vram will be mapped into virtual memory ? All 2GB ? Or only part of the 2GB ? Does this depend on the situation ? If so, how ?

I can't believe all vram will be mapped into virtual memory space. Almost all games these days are still 32-bit applications. That means that if you have a 2GB videocard, then you lose half your virtual address space ! Also, if communication between CPU and GPU is really only via memory mapping, then when you use SLI/CF, you lose double (or triple, quadrupple) that amount of virtual memory space. If vram is always fully mapped into virtual memory, then running 2x gtx680 (2x2GB) or 4x gtx560ti (4x1GB) would allow zero virtual memory for the application ?!?

Please enlighten me. TIA.
 
Last edited:

Concillian

Diamond Member
May 26, 2004
3,751
8
81
It's not all mapped into the game's addressable space, as there are a lot of functions the video card will do that the game doesn't even have to know about.

The game needs to know about textures. It says "I need this texture to be put in that location." It needs to know what and where that texture is to be able to do that.

The game does not need to know about the memory used for AA calculations. This happens in memory space that is not a part of the games 32 bit address space. How can we be certain of this? Well, you can force AA at the driver level, and the game will never know it's running AA. This is handled by a different application, and while I suspect this memory space would be subject to the address space limit of a 32 bit OS, it should not be an issue for a 32 bit app in a 64 bit OS.

Texture and AA are the obvious examples of memory that does and does not need to be a part of the game's addressable memory space. Other buffers and filtering are less obvious one way or another, but I think it's safe to say a good portion of VRAM doesn't need to be part of the game's addressable space.

The answer to your question of how much VRAM is mapped is not a straightforward one. It's dependent on the game, and is most dependent on the textures. You only hear about people running out of VRAM in one of two cases:
1) using mods with textures, because this is something that affects VRAM space that the user has control over.
2) using high resolutions (multi-monitor setups). Check the recent [H] review of Tri-fire / Tri-SLI and actually read all of what they wrote. They discuss how memory limitations at these extreme resolutions affect which settings are smooth and which are not.

Other than these two cases, developers design for an amount of VRAM usage that is in line with what popular cards actually have on them. You can bet if budget cards had 4GB, that games would store larger textures, as these can increase visual quality with very low impact on FPS.
 
Last edited:

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
Also from a security point of view, and a robustness point of view, it would not be advisable to allow any user process to mess directly with vram.

Too bad I can't find any specific info on the subject anywhere on the web. All google results are very vague. :( I had hoped someone here knows more about it.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
Did u check the wiki link i posted?It may have some information for u.
 

Schmide

Diamond Member
Mar 7, 2002
5,712
976
126
In a 32bit space, regardless of what video memory is mapped into it, programs are usually limited to 2gb of memory allocation unless they compile with the /LARGEADDRESSAWARE flag and even then they are limited to 3gb of space. The upper 1-2gb of space is reserved for the mapping of OS related memory, buffers (video memory), device interfaces, and so on. You'll never get 4gb of space with a 32bit environment.

Here is a good post at [H] about it.

http://hardforum.com/showthread.php?t=1035670

Even in a 64bit OS there still exists many of these windows into memory as most programs still run in the standard 32bit environment. Some of the standard OS related activities just have a smaller footprint.

It's usually not that much mapped on a dedicated card, most likely less that 512mb. (Edit: not so sure about this, haven't had a 32bit OS in years)

Of course a true 64 bit program can see as much memory as it needs.
 
Last edited:

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
In a 32bit space, regardless of what video memory is mapped into it, programs are usually limited to 2gb of memory allocation unless they compile with the /LARGEADDRESSAWARE flag and even then they are limited to 3gb of space. The upper 1-2gb of space is reserved for the mapping of OS related memory, buffers (video memory), device interfaces, and so on. You'll never get 4gb of space with a 32bit environment.

I had read that on 32-bit windows, with the LAA-flag, a process could get 3GB of allocatable virtual memory. That other 1GB in the address space is reserved for memory-mapped IO and other registers and buffers and stuff. Good to hear you acknowledge my understanding of this.

I had also read that on 64-bit windows, with the LAA-flag, a process could get 4GB of allocatable virtual memory. That is obviously bogus. I see that now. When an application is compiled with 32-bit code, then it just can't see more than 4GB. The application still needs to reserve address space for OS related functions. So it can never see the full 4GB of address space. That seems obvious.


Thanks !
That was very enlightening.
I checked out the allocations on my own PC (Win7 64-bit). But the names are a bit confusing, and it is not easy to see what is what. But from the article itself, it seems there was 256MB of address space allocated to the videocard. That makes sense. I guess there is no real need to map more memory, even if the card has more vram. So I guess it is safe to assume that on my system (4GB ram, videocard with 2GB of vram) also only 256MB of vram is memory-mapped into my virtual address space.

It's usually not that much mapped on a dedicated card, most likely less that 512k. (Edit: not so sure about this, haven't had a 32bit OS in years)

I would assume that the amount of memory mapped depends on how the application is compiled, and less on how the OS is compiled ? (32 bit vs 64 bit). Anyway, for the article you linked, it seems the videocard in their example allocates 256MB out of the address space. (This was after they increased the AGP aperture size from 64MB to 256MB).

Thanks for the link.
It was very helpful.