Files
fastfetch/src/detection/gpu/gpu_driver_specific.h
T

91 lines
2.9 KiB
C
Raw Normal View History

#pragma once
#include "gpu.h"
2026-04-09 16:20:59 +08:00
typedef enum FF_A_PACKED 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,
FF_GPU_DRIVER_CONDITION_TYPE_FORCE_UNSIGNED = UINT8_MAX,
} FFGpuDriverConditionType;
2026-03-29 09:28:49 +08:00
typedef struct FFGpuDriverPciDeviceId {
uint32_t deviceId;
uint32_t vendorId;
uint32_t subSystemId;
uint32_t revId;
} FFGpuDriverPciDeviceId;
// Use pciBusId if not NULL; use pciDeviceId otherwise
2026-03-29 09:28:49 +08:00
typedef struct FFGpuDriverCondition {
FFGpuDriverConditionType type;
FFGpuDriverPciBusId pciBusId;
FFGpuDriverPciDeviceId pciDeviceId;
uint64_t luid;
} FFGpuDriverCondition;
// detect x if not NULL
2026-03-29 09:28:49 +08:00
typedef struct FFGpuDriverResult {
2024-09-19 15:38:43 +08:00
uint32_t* index;
double* temp;
FFGPUMemory* memory;
FFstrbuf* memoryType;
FFGPUMemory* sharedMemory;
uint32_t* coreCount;
2024-08-01 14:10:07 +08:00
double* coreUsage;
FFGPUType* type;
2024-07-17 14:52:35 +08:00
uint32_t* frequency;
FFstrbuf* name;
} FFGpuDriverResult;
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
2023-12-21 14:53:35 +08:00
const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
#ifndef FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
#define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
#endif
2026-04-09 16:20:59 +08:00
FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) {
2026-03-29 09:28:49 +08:00
if (vendor == FF_GPU_VENDOR_NAME_NVIDIA) {
*pDetectFn = ffDetectNvidiaGpuInfo;
2026-03-29 09:28:49 +08:00
#ifdef _WIN32
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "nvml.dll";
2026-03-29 09:28:49 +08:00
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "libnvidia-ml.so";
2026-03-29 09:28:49 +08:00
#endif
} else if (vendor == FF_GPU_VENDOR_NAME_MTHREADS) {
*pDetectFn = ffDetectMthreadsGpuInfo;
2026-03-29 09:28:49 +08:00
#ifdef _WIN32
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "mtml.dll";
2026-03-29 09:28:49 +08:00
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "libmtml.so";
2026-03-29 09:28:49 +08:00
#endif
}
2026-03-29 09:28:49 +08:00
#ifdef _WIN32
else if (vendor == FF_GPU_VENDOR_NAME_INTEL) {
*pDetectFn = ffDetectIntelGpuInfo;
#ifdef _WIN64
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib.dll";
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib32.dll";
#endif
2026-03-29 09:28:49 +08:00
} else if (vendor == FF_GPU_VENDOR_NAME_AMD) {
*pDetectFn = ffDetectAmdGpuInfo;
#ifdef _WIN64
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxx.dll";
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxy.dll";
#endif
}
2026-03-29 09:28:49 +08:00
#endif
else {
*pDetectFn = NULL;
*pDllName = NULL;
return false;
}
return true;
}