Direct3D 11中的GetAvailableTextureMem等价物

时间:2012-03-11 14:30:40

标签: memory-management textures direct3d direct3d11

我正在寻找估计Direct3D中的自由纹理内存的可能性,就像使用IDirect3DDevice9::GetAvailableTextureMem一样,但到目前为止还没有找到任何东西。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您可以使用此代码段:

int getAviableVideoMemoryInBytes(ID3D11Device* pd3dDevice)
{
    assert(pd3dDevice);

    IDXGIDevice * pDXGIDevice = nullptr;
    HRESULT hr = pd3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice);

    if( FAILED(hr) )
    {
        std::cout << "Failed to query interface IDXGIDevice" << std::endl;
    }

    IDXGIAdapter * pDXGIAdapter = nullptr;
    pDXGIDevice->GetAdapter(&pDXGIAdapter);

    DXGI_ADAPTER_DESC adapterDesc;
    pDXGIAdapter->GetDesc(&adapterDesc);

    pDXGIDevice->Release();

    return adapterDesc.DedicatedVideoMemory;
}