How do you query the amount of VRAM available when using DirectX?
According to Game Coding Complete 3, there are a few ways:
- DX7's GetAvailableVidMem() - usually pretty good. Doesn't work too well on cards with shared memory.
- WMI (Windows Management Interface) has a similar result to the above.
- DxDiag uses both to give a better result.
- D3D9 has a GetAvailableTextureMemory() function, but can only be used on Windows Vista/7.
Look for a DX sample in March 08 or later SDK called 'VideoMemory'.
For DX9EX on Vista and later:
IDXGIDevice * pDXGIDevice; hr = g_pd3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice); IDXGIAdapter * pDXGIAdapter; pDXGIDevice->GetAdapter(&pDXGIAdapter); DXGI_ADAPTER_DESC adapterDesc; pDXGIAdapter->GetDesc(&adapterDesc); return adapterDesc.DedicatedVideoMemory;