Reputation: 764
I'm trying to get the total amount of VRAM my game is currently using. I want to display this in my debug information.
When I was using the Visual Studio Graphics Analyzer
I got an idea.
I figured that I could get the amount of VRAM used by adding the size of each of the graphic objects as seen in the Graphics Object Table
.
Unfortunately I have no idea how to get each of those objects. Is there a simple way to get these?
Upvotes: 3
Views: 2112
Reputation: 764
I actually found an easier way to do this:
#include <dxgi1_4.h>
...
IDXGIFactory4* pFactory;
CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&pFactory);
IDXGIAdapter3* adapter;
pFactory->EnumAdapters(0, reinterpret_cast<IDXGIAdapter**>(&adapter));
DXGI_QUERY_VIDEO_MEMORY_INFO videoMemoryInfo;
adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &videoMemoryInfo);
size_t usedVRAM = videoMemoryInfo.CurrentUsage / 1024 / 1024;
This gets the currently used VRAM from the default (ID 0) adapter and converts it to megabytes.
Note: This does require the use of the windows 10 SDK
Upvotes: 5