在 DirectX 中,当您想要创建 VertexBuffer、IndexBuffer 或 ConstantBuffer 时,您需要依赖 ID3D11Buffer interface 和 ID3D11Device::CreateBuffer。
我想知道这个缓冲区是在哪里创建的?
是在系统内存还是显存
以及当您使用 ID3D11DeviceContext::IASetVertexBuffers 设置顶点缓冲区以及 IndexBuffer 和 ConstantBuffer 的相应方法时究竟发生了什么。
最佳答案
In Direct3D 10/11, an application no longer specifies what type of memory (the pool) to create a resource in. Instead, you specify the intended usage of the resource, and let the runtime (in concert with the driver and a memory manager) choose the type of memory that will achieve the best performance.
无法保证缓冲区等资源的存储位置。
您可以“控制”在何处创建资源的唯一方法是为它们选择正确的 D3D11_USAGE
。
D3D11_USAGE_DEFAULT
和 D3D11_USAGE_IMMUTABLE
资源可能最终会出现在 VRAM 中,D3D11_USAGE_DYNAMIC
和 D3D11_USAGE_STAGING
会出现在一些内存区域中,这两个区域都可以访问到 CPU 和 GPU。
只需确保根据资源需求选择最快的资源使用方式
D3D11_USAGE_IMMUTABLE
> D3D11_USAGE_DEFAULT
> D3D11_USAGE_DYNAMIC
> D3D11_USAGE_STAGING
关于c++ - DirectX 11 缓冲区位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20563391/