Directx 11 memory management

I have been studying DirectX 11 for a while, but I'm still confused about how DirectX 11 manages memory. For example, if I create a vertex buffer using ID3D11Device :: CreateBuffer, where is the new buffer stored? I know that it returns a pointer to a buffer, so does this mean that it should be stored directly on the processor RAM? However, I thought this would make ID3D11DeviceContext :: IASetVertexBuffers a very slow process because it would have to copy the buffer from the processor RAM to the GPU RAM. But if all the buffers created using ID3D11Device: CreateBuffer were saved in the GPU RAM, will the RAM GPU really work fast? Basically, I would like to know: when I create a buffer, where is this data stored? In processor RAM or GPU RAM? Also, what does ID3D11DeviceContext :: IASetVertexBuffers do with the buffer (copy / configure?).

+5
source share
1 answer

The general answer is that "this is wherever the driver wants it to be." For "DYNAMIC" resources, they are usually placed in memory available for both the processor and the GPU (on modern PCs, this is allocated via the PCIe bus). For "STATIC" resources, they can be in video memory available only to the GPU, which is copied through a "common" memory window or if limited space is placed in a "common" memory window. Render Targets are usually placed in video memory.

For a deeper insight into Direct3D video memory management, see the section "Why won't your Windows game work in 2,147,352,576?" which is no longer on the MSDN download, but can be found on my blog .

If you want detailed hardware details, read the documentation.

You can also find a sample of Video Memory in the MSDN Code Gallery educational gallery.

+7
source

Source: https://habr.com/ru/post/1204885/


All Articles