mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Vulkan: detect vmem (#416)
This commit is contained in:
@@ -21,6 +21,12 @@ typedef enum FFGpuType
|
||||
FF_GPU_TYPE_DISCRETE,
|
||||
} FFGpuType;
|
||||
|
||||
typedef struct FFGPUMemory
|
||||
{
|
||||
uint64_t total;
|
||||
uint64_t used;
|
||||
} FFGPUMemory;
|
||||
|
||||
typedef struct FFGPUResult
|
||||
{
|
||||
uint64_t id;
|
||||
@@ -30,10 +36,8 @@ typedef struct FFGPUResult
|
||||
FFstrbuf driver;
|
||||
double temperature;
|
||||
int coreCount;
|
||||
uint64_t dedicatedTotal;
|
||||
uint64_t dedicatedUsed;
|
||||
uint64_t sharedTotal;
|
||||
uint64_t sharedUsed;
|
||||
FFGPUMemory dedicated;
|
||||
FFGPUMemory shared;
|
||||
} FFGPUResult;
|
||||
|
||||
const FFlist* ffDetectGPU(const FFinstance* instance);
|
||||
|
||||
@@ -61,7 +61,7 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
FFGPUResult* gpu = ffListAdd(gpus);
|
||||
|
||||
gpu->id = 0;
|
||||
gpu->dedicatedTotal = gpu->dedicatedUsed = gpu->sharedTotal = gpu->sharedUsed = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
|
||||
@@ -200,7 +200,7 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
|
||||
FFGPUResult* gpu = ffListAdd(results);
|
||||
|
||||
gpu->id = 0;
|
||||
gpu->dedicatedTotal = gpu->dedicatedUsed = gpu->sharedTotal = gpu->sharedUsed = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
pciDetectVendorName(gpu, pci, device);
|
||||
|
||||
@@ -49,7 +49,7 @@ static const char* detectWithRegistry(FFlist* gpus)
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
gpu->id = 0;
|
||||
gpu->dedicatedTotal = gpu->dedicatedUsed = gpu->sharedTotal = gpu->sharedUsed = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
|
||||
ffRegReadUint64(hSubKey, L"AdapterLuid", &gpu->id, nullptr);
|
||||
|
||||
@@ -67,8 +67,8 @@ static const char* detectWithRegistry(FFlist* gpus)
|
||||
if(ffRegReadUint64(hSubKey, L"DedicatedSystemMemory", &dedicatedSystemMemory, nullptr) &&
|
||||
ffRegReadUint64(hSubKey, L"SharedSystemMemory", &sharedSystemMemory, nullptr))
|
||||
{
|
||||
gpu->dedicatedTotal = dedicatedVideoMemory + dedicatedSystemMemory;
|
||||
gpu->sharedTotal = sharedSystemMemory;
|
||||
gpu->dedicated.total = dedicatedVideoMemory + dedicatedSystemMemory;
|
||||
gpu->shared.total = sharedSystemMemory;
|
||||
}
|
||||
|
||||
uint64_t driverVersion;
|
||||
@@ -102,7 +102,7 @@ static const char* detectWithDxgi(FFlist* gpus)
|
||||
continue;
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
||||
gpu->dedicatedTotal = gpu->dedicatedUsed = gpu->sharedTotal = gpu->sharedUsed = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->dedicated.total = gpu->dedicated.total = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufAppendS(&gpu->vendor, ffGetGPUVendorString(desc.VendorId));
|
||||
@@ -115,8 +115,8 @@ static const char* detectWithDxgi(FFlist* gpus)
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
gpu->type = desc.DedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
gpu->dedicatedTotal = desc.DedicatedVideoMemory + desc.DedicatedSystemMemory;
|
||||
gpu->sharedTotal = desc.SharedSystemMemory;
|
||||
gpu->dedicated.total = desc.DedicatedVideoMemory + desc.DedicatedSystemMemory;
|
||||
gpu->shared.total = desc.SharedSystemMemory;
|
||||
|
||||
adapter->Release();
|
||||
|
||||
@@ -149,13 +149,13 @@ static const char* detectMemoryUsage(FFlist* gpus)
|
||||
FF_LIST_FOR_EACH(FFGPUResult, gpu, *gpus)
|
||||
{
|
||||
if (gpu->id != luid) continue;
|
||||
record.getUnsigned(L"DedicatedUsage", &gpu->dedicatedUsed);
|
||||
record.getUnsigned(L"SharedUsage", &gpu->sharedUsed);
|
||||
record.getUnsigned(L"DedicatedUsage", &gpu->dedicated.used);
|
||||
record.getUnsigned(L"SharedUsage", &gpu->shared.used);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
||||
Reference in New Issue
Block a user