Transfer from http://www.cnblogs.com/lancidie/archive/2011/05/20/2052094.html
Learning D3D, should be on these three memory understanding, online collection of relevant information, collection down.
Three kinds of Memory AGP memory (non-local memory), memory (local RAM), system memory, which we all know the system memory is our memory bar, then this AGP memory is a what thing ah? In fact, because in the previous video card memory is very small, then still in the video memory is 16m,32m for the mainstream, if you run a need a lot of texture 3D program, then the memory will not be enough, then what? Had to ask the system memory borrow point use! This is the origin of AGP memory, in our computer BIOS has an option to set the AGP aperture, this is to set the video card can use the maximum allowable value of system memory, usually set to 64M. Note that this is only the maximum allowable value, not a boot he took the 64M to take away, your 256 memory becomes 192! Instead, your memory is still 256M, just limit the video card to use up to 64M of system memory.
Say that the speed of the three memory is different!
System memory is, of course, someone else's CPU read and write operations the fastest! And the video card will be compared to the use of their own memory slow a lot!
AGP memory is the speed of the graphics card read and write, of course, there is no graphics card using the memory speed is fast! CPU is relatively complex point, the CPU reads AGP memory is slow, but the speed of writing is not slow, but the speed is generally slower than the use of system memory a little bit, that is, suitable for the CPU to write but not suitable for reading. Some people will ask, the same system memory is only the name is not the same, how the speed of the difference? Well, I'm not too sure, the foreigner didn't say too detailed, everyone just remember it!
Finally said is the memory, this is very simple, of course, the graphics card read and write the fastest, and the CPU reading and writing speed must be much slower!
Say three memory differences, now say what they are useful for it! This involves a D3dusage enumeration:
D3dusage_dynamic, this variable is used when you create a resource, which instructs D3D to specify the resource as dynamic, while the dynamic means that it needs to be modified frequently, and the modification is usually CPU-modified, so the dynamic resource should be in AGP memory. This can minimize the effect on speed.
The D3DUSAGE_WRITEONLY flag allows only write operations for the resources you create. Using this flag allows the device to place this resource in memory where it is most suitable for write processing and rendering. If you do not use the D3DUSAGE_WRITEONLY flag, then the device will assume that the resources you create are both read and write, then the device will most likely choose a memory area where both the read and write operations are moderate. This will sacrifice part of the processing and rendering speed.
Also has an impact on D3dlock flags and resource creation types
But three kinds of memory is another way to optimize access, because, for example, the particle system needs to use AGP memory, because he needs to change the CPU frequently, but also need to read the graphics processing card frequently, if placed in memory so the efficiency of CPU modification is too low! If you put in memory, then the graphics processing card access is too slow! So these three kinds of memory still need to be clear separately!
Understanding of AGP memory, system memory, video memory in D3D