GPU: huge improvement of driver specific detection code

This commit is contained in:
李通洲
2023-12-20 14:45:27 +08:00
parent 961e9a6a5f
commit 4a1bbb6a03
13 changed files with 174 additions and 116 deletions
+4 -2
View File
@@ -5,6 +5,7 @@
#define FF_GPU_TEMP_UNSET (0/0.0)
#define FF_GPU_CORE_COUNT_UNSET -1
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
#define FF_GPU_FREQUENCY_UNSET -1u
extern const char* FF_GPU_VENDOR_NAME_APPLE;
extern const char* FF_GPU_VENDOR_NAME_AMD;
@@ -29,10 +30,11 @@ typedef struct FFGPUResult
FFstrbuf name;
FFstrbuf driver;
double temperature;
int coreCount;
int32_t coreCount;
uint32_t frequency;
FFGPUMemory dedicated;
FFGPUMemory shared;
uint32_t vulkanDeviceId; // Only used for vulkan
uint64_t deviceId; // Used internally, may be uninitialized
} FFGPUResult;
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result);
+1
View File
@@ -54,6 +54,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
gpu->type = FF_GPU_TYPE_UNKNOWN;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
ffStrbufInit(&gpu->driver); // Ok for both Apple and Intel
ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver);
+48
View File
@@ -0,0 +1,48 @@
#pragma once
#include "gpu.h"
typedef enum FFGpuDriverConditionType
{
FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID = 1 << 0,
FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID = 1 << 1,
FF_GPU_DRIVER_CONDITION_TYPE_LUID = 1 << 2,
} FFGpuDriverConditionType;
typedef struct FFGpuDriverPciBusId
{
uint32_t domain;
uint32_t bus;
uint32_t device;
uint32_t func;
} FFGpuDriverPciBusId;
typedef struct FFGpuDriverPciDeviceId
{
uint32_t deviceId;
uint32_t vendorId;
uint32_t subSystemId;
uint32_t revId;
} FFGpuDriverPciDeviceId;
// Use pciBusId if not NULL; use pciDeviceId otherwise
typedef struct FFGpuDriverCondition
{
FFGpuDriverConditionType type;
FFGpuDriverPciBusId pciBusId;
FFGpuDriverPciDeviceId pciDeviceId;
uint64_t luid;
} FFGpuDriverCondition;
// detect x if not NULL
typedef struct FFGpuDriverResult
{
double* temp;
FFGPUMemory* memory;
uint32_t* coreCount;
FFGPUType* type;
uint32_t* frequency;
} FFGpuDriverResult;
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
+38 -10
View File
@@ -1,4 +1,4 @@
#include "gpu_intel.h"
#include "gpu_driver_specific.h"
#include "3rdparty/igcl/igcl_api.h"
#include "common/library.h"
@@ -12,6 +12,8 @@ struct FFIgclData {
FF_LIBRARY_SYMBOL(ctlTemperatureGetState)
FF_LIBRARY_SYMBOL(ctlEnumMemoryModules)
FF_LIBRARY_SYMBOL(ctlMemoryGetState)
FF_LIBRARY_SYMBOL(ctlEnumFrequencyDomains)
FF_LIBRARY_SYMBOL(ctlFrequencyGetState)
bool inited;
ctl_api_handle_t apiHandle;
@@ -26,7 +28,7 @@ static void shutdownIgcl()
}
}
const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult result, const char* soName)
const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName)
{
if (!igclData.inited)
{
@@ -40,6 +42,8 @@ const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult resu
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlTemperatureGetState)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumMemoryModules)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlMemoryGetState)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumFrequencyDomains)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlFrequencyGetState)
if (ffctlInit(&(ctl_init_args_t) {
.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION),
@@ -66,7 +70,7 @@ const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult resu
ctl_device_adapter_handle_t device = NULL;
LUID deviceId;
uint64_t /* LUID */ deviceId = 0;
ctl_device_adapter_properties_t properties = {
.Size = sizeof(properties),
.pDeviceID = &deviceId,
@@ -81,14 +85,35 @@ const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult resu
if (properties.device_type != CTL_DEVICE_TYPE_GRAPHICS)
continue;
if (
cond.pciDeviceId == properties.pci_device_id &&
cond.pciVendorId == properties.pci_vendor_id &&
cond.pciSubSystemId == (((uint32_t) properties.pci_subsys_id << 16u) + (uint32_t) properties.pci_subsys_vendor_id) &&
cond.revId == properties.rev_id)
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_LUID)
{
device = devices[iDev];
break;
if (cond->luid == deviceId)
{
device = devices[iDev];
break;
}
}
else if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID)
{
if (cond->pciBusId.bus == properties.adapter_bdf.bus &&
cond->pciBusId.device == properties.adapter_bdf.device &&
cond->pciBusId.func == properties.adapter_bdf.function)
{
device = devices[iDev];
break;
}
}
else if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID)
{
if (
cond->pciDeviceId.deviceId == properties.pci_device_id &&
cond->pciDeviceId.vendorId == properties.pci_vendor_id &&
cond->pciDeviceId.subSystemId == (uint32_t) ((properties.pci_subsys_id << 16u) | properties.pci_subsys_vendor_id) &&
cond->pciDeviceId.revId == properties.rev_id)
{
device = devices[iDev];
break;
}
}
}
@@ -148,5 +173,8 @@ const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult resu
}
}
if (result.frequency)
*result.frequency = properties.Frequency;
return NULL;
}
-23
View File
@@ -1,23 +0,0 @@
#pragma once
#include "gpu.h"
// Use pciBusId if not NULL; use pciDeviceId and pciSubSystemId otherwise
typedef struct FFGpuIntelCondition
{
uint32_t pciDeviceId;
uint32_t pciVendorId;
uint32_t pciSubSystemId;
uint32_t revId;
} FFGpuIntelCondition;
// detect x if not NULL
typedef struct FFGpuIntelResult
{
double* temp;
FFGPUMemory* memory;
uint32_t* coreCount;
FFGPUType* type;
} FFGpuIntelResult;
const char* ffDetectIntelGpuInfo(FFGpuIntelCondition cond, FFGpuIntelResult result, const char* soName);
+13 -5
View File
@@ -1,5 +1,5 @@
#include "detection/gpu/gpu.h"
#include "detection/gpu/gpu_nvidia.h"
#include "detection/gpu/gpu_driver_specific.h"
#include "detection/vulkan/vulkan.h"
#ifdef FF_HAVE_LIBPCI
@@ -239,16 +239,24 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->useNvml))
{
char pciDeviceId[32];
snprintf(pciDeviceId, sizeof(pciDeviceId) - 1, "%04x:%02x:%02x.%d", device->domain, device->bus, device->dev, device->func);
ffDetectNvidiaGpuInfo((FFGpuNvidiaCondition) { .pciBusId = pciDeviceId }, (FFGpuNvidiaResult) {
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID,
.pciDeviceId = {
.domain = device->domain,
.bus = device->bus,
.device = device->dev,
.func = device->func,
},
}, (FFGpuNvidiaResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
.type = options->useNvml ? (uint32_t*) &gpu->type : NULL,
.frequency = options->useNvml ? &gpu->frequency : NULL,
}, "libnvidia-ml.so");
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET)
+15 -6
View File
@@ -1,4 +1,4 @@
#include "gpu_nvidia.h"
#include "gpu_driver_specific.h"
#include "3rdparty/nvml/nvml.h"
#include "common/library.h"
@@ -11,11 +11,12 @@ struct FFNvmlData {
FF_LIBRARY_SYMBOL(nvmlDeviceGetTemperature)
FF_LIBRARY_SYMBOL(nvmlDeviceGetMemoryInfo_v2)
FF_LIBRARY_SYMBOL(nvmlDeviceGetNumGpuCores)
FF_LIBRARY_SYMBOL(nvmlDeviceGetClockInfo)
bool inited;
} nvmlData;
const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult result, const char* soName)
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName)
{
if (!nvmlData.inited)
{
@@ -30,6 +31,7 @@ const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult r
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetTemperature)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetMemoryInfo_v2)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetNumGpuCores)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetClockInfo)
if (ffnvmlInit_v2() != NVML_SUCCESS)
{
@@ -44,13 +46,16 @@ const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult r
return "loading nvml library failed";
nvmlDevice_t device = NULL;
if (cond.pciBusId)
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID)
{
nvmlReturn_t ret = nvmlData.ffnvmlDeviceGetHandleByPciBusId_v2(cond.pciBusId, &device);
char pciBusIdStr[32];
snprintf(pciBusIdStr, sizeof(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
nvmlReturn_t ret = nvmlData.ffnvmlDeviceGetHandleByPciBusId_v2(pciBusIdStr, &device);
if (ret != NVML_SUCCESS)
return "nvmlDeviceGetHandleByPciBusId_v2() failed";
}
else
else if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID)
{
uint32_t count;
if (nvmlData.ffnvmlDeviceGetCount_v2(&count) != NVML_SUCCESS)
@@ -65,7 +70,8 @@ const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult r
if (nvmlData.ffnvmlDeviceGetPciInfo_v3(device, &pciInfo) != NVML_SUCCESS)
continue;
if (pciInfo.pciDeviceId != cond.pciDeviceId || pciInfo.pciSubSystemId != cond.pciSubSystemId)
if (pciInfo.pciDeviceId != ((cond->pciDeviceId.deviceId << 16u) | cond->pciDeviceId.vendorId) ||
pciInfo.pciSubSystemId != cond->pciDeviceId.subSystemId)
continue;
break;
@@ -93,5 +99,8 @@ const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult r
if (result.coreCount)
nvmlData.ffnvmlDeviceGetNumGpuCores(device, result.coreCount);
if (result.frequency)
nvmlData.ffnvmlDeviceGetClockInfo(device, NVML_CLOCK_GRAPHICS, result.frequency);
return NULL;
}
-23
View File
@@ -1,23 +0,0 @@
#pragma once
#include "gpu.h"
// Use pciBusId if not NULL; use pciDeviceId and pciSubSystemId otherwise
typedef struct FFGpuNvidiaCondition
{
// "domain:bus:device.function"
const char* pciBusId;
// (deviceId << 16) | vendorId
uint32_t pciDeviceId;
uint32_t pciSubSystemId;
} FFGpuNvidiaCondition;
// detect x if not NULL
typedef struct FFGpuNvidiaResult
{
double* temp;
FFGPUMemory* memory;
uint32_t* coreCount;
} FFGpuNvidiaResult;
const char* ffDetectNvidiaGpuInfo(FFGpuNvidiaCondition cond, FFGpuNvidiaResult result, const char* soName);
+29 -38
View File
@@ -1,6 +1,5 @@
#include "gpu.h"
#include "detection/gpu/gpu_intel.h"
#include "detection/gpu/gpu_nvidia.h"
#include "detection/gpu/gpu_driver_specific.h"
#include "util/windows/unicode.h"
#include "util/windows/registry.h"
@@ -44,6 +43,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->type = FF_GPU_TYPE_UNKNOWN;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
gpu->deviceId = 0;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
if (deviceKeyLength == 100 && displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{')
{
@@ -76,6 +77,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->dedicated.total = dedicatedVideoMemory + dedicatedSystemMemory;
gpu->shared.total = sharedSystemMemory;
}
ffRegReadUint64(hDirectxKey, L"AdapterLuid", &gpu->deviceId, NULL);
}
else if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL))
{
@@ -86,47 +89,35 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
}
}
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->useNvml))
{
uint32_t vendorId, deviceId, subSystemId;
// See: https://download.nvidia.com/XFree86/Linux-x86_64/545.23.06/README/supportedchips.html
// displayDevice.DeviceID = MatchingDeviceId "PCI\\VEN_10DE&DEV_2782&SUBSYS_513417AA&REV_A1"
if (swscanf(displayDevice.DeviceID, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x", &vendorId, &deviceId, &subSystemId) == 3)
{
ffDetectNvidiaGpuInfo((FFGpuNvidiaCondition) {
.pciDeviceId = (deviceId << 16) | vendorId,
.pciSubSystemId = subSystemId,
}, (FFGpuNvidiaResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
}, "nvml.dll");
}
}
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL && (options->temp || options->useNvml))
if ((gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA || gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) &&
(options->temp || options->useNvml))
{
uint32_t vendorId, deviceId, subSystemId, revId;
// See: https://download.nvidia.com/XFree86/Linux-x86_64/545.23.06/README/supportedchips.html
// displayDevice.DeviceID = MatchingDeviceId "PCI\\VEN_8086&DEV_46A6&SUBSYS_13241462&REV_0C"
// displayDevice.DeviceID = MatchingDeviceId "PCI\\VEN_10DE&DEV_2782&SUBSYS_513417AA&REV_A1"
if (swscanf(displayDevice.DeviceID, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId) == 4)
{
ffDetectIntelGpuInfo((FFGpuIntelCondition) {
.pciDeviceId = deviceId,
.pciVendorId = vendorId,
.pciSubSystemId = subSystemId,
.revId = revId,
}, (FFGpuIntelResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
.type = options->useNvml ? (uint32_t*) &gpu->type : NULL,
},
#ifdef _WIN64
"ControlLib.dll"
#else
"ControlLib32.dll"
#endif
(gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA ? ffDetectNvidiaGpuInfo : ffDetectIntelGpuInfo)(
&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID | FF_GPU_DRIVER_CONDITION_TYPE_LUID,
.pciDeviceId = {
.deviceId = deviceId,
.vendorId = vendorId,
.subSystemId = subSystemId,
.revId = revId,
},
}, (FFGpuDriverResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
.type = options->useNvml ? (uint32_t*) &gpu->type : NULL,
.frequency = options->useNvml ? &gpu->frequency : NULL,
}, gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA ? "nvml.dll" :
#ifdef _WIN64
"ControlLib.dll"
#else
"ControlLib32.dll"
#endif
);
}
}
+12 -5
View File
@@ -4,7 +4,7 @@
extern "C" {
#include "common/library.h"
#include "detection/gpu/gpu.h"
#include "detection/gpu/gpu_nvidia.h"
#include "detection/gpu/gpu_driver_specific.h"
}
#include <wsl/winadapter.h>
@@ -65,6 +65,7 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
ffStrbufInitS(&gpu->name, desc);
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
ffStrbufInit(&gpu->driver);
uint64_t value = 0;
@@ -97,14 +98,20 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
if (vendorStr == FF_GPU_VENDOR_NAME_NVIDIA && options->useNvml)
{
ffDetectNvidiaGpuInfo((FFGpuNvidiaCondition) {
.pciBusId = nullptr,
.pciDeviceId = (hardwareId.deviceID << 16) | hardwareId.vendorID,
.pciSubSystemId = hardwareId.subSysID
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID,
.pciDeviceId = {
.deviceId = hardwareId.deviceID,
.vendorId = hardwareId.vendorID,
.subSystemId = hardwareId.subSysID,
.revId = hardwareId.revision,
},
}, (FFGpuNvidiaResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
.type = options->useNvml ? (uint32_t*) &gpu->type : NULL,
.frequency = options->useNvml ? &gpu->frequency : NULL,
}, "/usr/lib/wsl/lib/libnvidia-ml.so");
}
}
+3 -2
View File
@@ -175,13 +175,13 @@ static const char* detectVulkan(FFVulkanResult* result)
// #456
FF_LIST_FOR_EACH(FFGPUResult, gpu, result->gpus)
{
if (gpu->vulkanDeviceId == physicalDeviceProperties.properties.deviceID)
if (gpu->deviceId == physicalDeviceProperties.properties.deviceID)
goto next;
}
FFGPUResult* gpu = ffListAdd(&result->gpus);
gpu->vulkanDeviceId = physicalDeviceProperties.properties.deviceID;
gpu->deviceId = physicalDeviceProperties.properties.deviceID;
ffStrbufInitS(&gpu->name, physicalDeviceProperties.properties.deviceName);
@@ -204,6 +204,7 @@ static const char* detectVulkan(FFVulkanResult* result)
//No way to detect those using vulkan
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
next:
continue;
+10 -1
View File
@@ -9,7 +9,7 @@
#include <stdlib.h>
#define FF_GPU_NUM_FORMAT_ARGS 10
#define FF_GPU_NUM_FORMAT_ARGS 11
static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
{
@@ -38,6 +38,9 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
if(gpu->frequency != FF_GPU_FREQUENCY_UNSET)
ffStrbufAppendF(&output, " @ %.2f MHz", gpu->frequency / 1e6);
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
{
ffStrbufAppendS(&output, " - ");
@@ -80,6 +83,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.used},
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.total},
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.used},
{FF_FORMAT_ARG_TYPE_UINT, &gpu->frequency},
});
}
}
@@ -304,6 +308,11 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
yyjson_mut_obj_add_str(doc, obj, "type", type);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &gpu->vendor);
if (gpu->frequency == FF_GPU_FREQUENCY_UNSET)
yyjson_mut_obj_add_null(doc, obj, "frequency");
else
yyjson_mut_obj_add_uint(doc, obj, "frequency", gpu->frequency);
}
FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus)
+1 -1
View File
@@ -130,7 +130,7 @@ void ffGenerateVulkanJsonResult(FF_MAYBE_UNUSED FFVulkanOptions* options, yyjson
yyjson_mut_obj_add_null(doc, sharedMemory, "used");
}
yyjson_mut_obj_add_uint(doc, gpuObj, "deviceId", vulkanGpu->vulkanDeviceId);
yyjson_mut_obj_add_uint(doc, gpuObj, "deviceId", vulkanGpu->deviceId);
}
}