2022-10-05 17:53:18 +08:00
|
|
|
extern "C" {
|
|
|
|
|
#include "gpu.h"
|
|
|
|
|
}
|
|
|
|
|
#include "util/windows/wmi.hpp"
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
|
|
|
|
{
|
|
|
|
|
FF_UNUSED(instance);
|
|
|
|
|
|
|
|
|
|
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT Name, AdapterCompatibility, DriverVersion FROM Win32_VideoController", nullptr);
|
|
|
|
|
|
|
|
|
|
if(!pEnumerator)
|
|
|
|
|
return "Query WMI service failed";
|
|
|
|
|
|
|
|
|
|
IWbemClassObject *pclsObj = NULL;
|
|
|
|
|
ULONG uReturn = 0;
|
|
|
|
|
|
|
|
|
|
while(SUCCEEDED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) && uReturn != 0)
|
|
|
|
|
{
|
|
|
|
|
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
|
|
|
|
|
|
|
|
|
ffStrbufInit(&gpu->vendor);
|
2022-10-06 22:56:56 +08:00
|
|
|
ffGetWmiObjString(pclsObj, L"AdapterCompatibility", &gpu->vendor);
|
2022-10-05 17:53:18 +08:00
|
|
|
if(ffStrbufStartsWithS(&gpu->vendor, "Intel "))
|
|
|
|
|
{
|
|
|
|
|
//Intel returns "Intel Corporation", not sure about AMD
|
|
|
|
|
ffStrbufSetS(&gpu->vendor, "Intel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ffStrbufInit(&gpu->name);
|
2022-10-06 22:56:56 +08:00
|
|
|
ffGetWmiObjString(pclsObj, L"Name", &gpu->name);
|
2022-10-05 17:53:18 +08:00
|
|
|
|
|
|
|
|
ffStrbufInit(&gpu->driver);
|
2022-10-06 22:56:56 +08:00
|
|
|
ffGetWmiObjString(pclsObj, L"DriverVersion", &gpu->driver);
|
2022-10-05 17:53:18 +08:00
|
|
|
|
|
|
|
|
gpu->temperature = FF_GPU_TEMP_UNSET;
|
|
|
|
|
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pclsObj->Release();
|
|
|
|
|
pEnumerator->Release();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|