Vulkan: detect vmem (#416)

This commit is contained in:
李通洲
2023-02-11 12:34:57 +08:00
parent b90d543afc
commit 662ddac050
9 changed files with 119 additions and 88 deletions
+8 -4
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+9 -9
View File
@@ -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"