GPU: support driver version detection

This commit is contained in:
李通洲
2023-02-07 11:03:09 +08:00
parent 92c744d971
commit 82b10a527b
3 changed files with 10 additions and 4 deletions
+2
View File
@@ -12,6 +12,8 @@ Features:
* Support `--localip-compact-type` option (#408)
* Terminator terminal font detection (@Zerogiven, #415)
* Windows 32bit compatibility
* Support global configuration in MSYS2 environment (Windows)
* Support GPU driver version detection on Windows 11
Bugfixes:
+1
View File
@@ -27,6 +27,7 @@ typedef struct FFGPUResult
FFstrbuf name;
FFstrbuf driver;
double temperature;
uint64_t memory;
int coreCount;
} FFGPUResult;
+7 -4
View File
@@ -6,6 +6,7 @@ extern "C" {
#include <dxgi.h>
#include <wchar.h>
#include <inttypes.h>
static const char* detectWithRegistry(FFlist* gpus)
{
@@ -13,11 +14,11 @@ static const char* detectWithRegistry(FFlist* gpus)
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectX", &hKey, nullptr))
return "Open \"SOFTWARE\\Microsoft\\DirectX\" failed";
return "Open \"HKLM\\SOFTWARE\\Microsoft\\DirectX\" failed";
uint64_t lastSeen;
if(!ffRegReadUint64(hKey, L"LastSeen", &lastSeen, nullptr))
return "Read \"SOFTWARE\\Microsoft\\DirectX\\LastSeen\" failed";
return "Read \"HKLM\\SOFTWARE\\Microsoft\\DirectX\\LastSeen\" failed";
DWORD index = 0;
wchar_t subKeyName[64];
@@ -55,9 +56,11 @@ static const char* detectWithRegistry(FFlist* gpus)
uint64_t dedicatedVideoMemory;
if(ffRegReadUint64(hSubKey, L"DedicatedVideoMemory", &dedicatedVideoMemory, nullptr))
{
gpu->type = dedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
}
uint64_t driverVersion;
if(ffRegReadUint64(hSubKey, L"DriverVersion", &driverVersion, nullptr))
ffStrbufSetF(&gpu->driver, "%" PRIu64 ".%" PRIu64, (driverVersion >> 16) & 0xFFFF, driverVersion & 0xFFFF);
}
return nullptr;