Get GPU usage
https://stackoverflow.com/questions/77643749/getting-gpu-usage-statistics-with-pdh https://stackoverflow.com/questions/56830434/c-sharp-get-total-usage-of-gpu-in-percentage https://gist.github.com/fecf/2103a82afc76b5c88829c4383944a5aa https://stackoverflow.com/questions/29611611/c-windows-gpu-usage-load
https://stackoverflow.com/questions/13017148/how-do-i-get-gpu-usage-per-process
https://github.com/winsiderss/systeminformer/blob/master/plugins/ExtendedTools/gpumon.c
https://stackoverflow.com/questions/34363404/how-do-i-query-direct3d9-for-the-total-amount-of-video-memory
#pragma comment(lib, "dxgi.lib")
#include <dxgi.h>
HMODULE hModule = LoadLibraryW(L"dxgi.dll");
typedef HRESULT(WINAPI* FuncCreateDXGIFactory)(REFIID, void**);
FuncCreateDXGIFactory pCreateDXGIFactory = NULL;
if (hModule != NULL)
{
pCreateDXGIFactory = (FuncCreateDXGIFactory)GetProcAddress(hModule, "CreateDXGIFactory");
}
if (pCreateDXGIFactory != NULL)
{
IDXGIFactory* pFactory = nullptr;
if (SUCCEEDED(pCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&pFactory)))
{
IDXGIAdapter* pAdapter = nullptr;
DXGI_ADAPTER_DESC adapterDesc;
for (UINT i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i)
{
pAdapter->GetDesc(&adapterDesc);
printf("DESC: %ls\n", adapterDesc.Description);
printf("RAM: %llu MB\n", adapterDesc.DedicatedVideoMemory / (1024ULL * 1024));
pAdapter->Release();
}
pFactory->Release();
}
}