2022-09-05 17:42:42 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "fastfetch.h"
|
2025-08-04 14:25:14 +08:00
|
|
|
#include "modules/gpu/option.h"
|
2022-09-05 17:42:42 +02:00
|
|
|
|
2025-08-14 09:47:14 +08:00
|
|
|
#define FF_GPU_TEMP_UNSET (-DBL_MAX)
|
2022-09-16 18:11:39 +08:00
|
|
|
#define FF_GPU_CORE_COUNT_UNSET -1
|
2023-02-11 02:29:26 +08:00
|
|
|
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
|
2024-07-17 14:52:35 +08:00
|
|
|
#define FF_GPU_FREQUENCY_UNSET 0
|
2025-08-14 09:47:14 +08:00
|
|
|
#define FF_GPU_CORE_USAGE_UNSET (-DBL_MAX)
|
2024-09-23 14:32:38 +08:00
|
|
|
#define FF_GPU_INDEX_UNSET ((uint32_t)-1)
|
2022-09-05 17:42:42 +02:00
|
|
|
|
2023-02-06 11:07:49 +08:00
|
|
|
extern const char* FF_GPU_VENDOR_NAME_APPLE;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_AMD;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_INTEL;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_NVIDIA;
|
2024-08-02 16:00:54 +08:00
|
|
|
extern const char* FF_GPU_VENDOR_NAME_MTHREADS;
|
2023-10-21 17:36:13 +08:00
|
|
|
extern const char* FF_GPU_VENDOR_NAME_VMWARE;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_PARALLEL;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_MICROSOFT;
|
2023-10-31 15:11:22 +08:00
|
|
|
extern const char* FF_GPU_VENDOR_NAME_REDHAT;
|
|
|
|
|
extern const char* FF_GPU_VENDOR_NAME_ORACLE;
|
2022-11-22 19:25:49 +08:00
|
|
|
|
2023-02-11 12:34:57 +08:00
|
|
|
typedef struct FFGPUMemory
|
|
|
|
|
{
|
|
|
|
|
uint64_t total;
|
|
|
|
|
uint64_t used;
|
|
|
|
|
} FFGPUMemory;
|
|
|
|
|
|
2022-09-05 17:42:42 +02:00
|
|
|
typedef struct FFGPUResult
|
|
|
|
|
{
|
2024-09-19 15:38:43 +08:00
|
|
|
uint32_t index;
|
2023-03-26 20:42:18 +08:00
|
|
|
FFGPUType type;
|
2022-09-05 17:42:42 +02:00
|
|
|
FFstrbuf vendor;
|
|
|
|
|
FFstrbuf name;
|
|
|
|
|
FFstrbuf driver;
|
2023-12-29 15:12:41 +08:00
|
|
|
FFstrbuf platformApi;
|
2025-03-24 15:19:34 +08:00
|
|
|
FFstrbuf memoryType;
|
2022-09-05 17:42:42 +02:00
|
|
|
double temperature;
|
2024-08-10 21:08:35 +08:00
|
|
|
double coreUsage;
|
2023-12-20 14:45:27 +08:00
|
|
|
int32_t coreCount;
|
2024-07-17 14:52:35 +08:00
|
|
|
uint32_t frequency; // Maximum time clock frequency in MHz
|
2023-02-11 12:34:57 +08:00
|
|
|
FFGPUMemory dedicated;
|
|
|
|
|
FFGPUMemory shared;
|
2024-09-23 14:32:38 +08:00
|
|
|
uint64_t deviceId;
|
2022-09-05 17:42:42 +02:00
|
|
|
} FFGPUResult;
|
|
|
|
|
|
2023-06-24 10:59:53 +08:00
|
|
|
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result);
|
|
|
|
|
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus);
|
2022-09-05 17:42:42 +02:00
|
|
|
|
2024-12-28 15:26:17 +08:00
|
|
|
const char* ffGPUGetVendorString(unsigned vendorId);
|
2024-01-31 13:29:11 +08:00
|
|
|
|
2025-06-18 18:53:29 +08:00
|
|
|
typedef struct FFGpuDriverPciBusId
|
|
|
|
|
{
|
|
|
|
|
uint32_t domain;
|
|
|
|
|
uint32_t bus;
|
|
|
|
|
uint32_t device;
|
|
|
|
|
uint32_t func;
|
|
|
|
|
} FFGpuDriverPciBusId;
|
|
|
|
|
|
2025-11-01 17:26:49 +08:00
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__GNU__)
|
2024-09-25 16:41:55 +08:00
|
|
|
void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu);
|
2025-02-13 10:43:11 +08:00
|
|
|
void ffGPUQueryAmdGpuName(uint16_t deviceId, uint8_t revisionId, FFGPUResult* gpu);
|
2025-06-18 10:01:32 +08:00
|
|
|
|
|
|
|
|
#if FF_HAVE_DRM
|
2025-06-18 16:37:04 +08:00
|
|
|
const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath);
|
2025-06-18 10:01:32 +08:00
|
|
|
const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath);
|
|
|
|
|
const char* ffDrmDetectI915(FFGPUResult* gpu, int fd);
|
|
|
|
|
const char* ffDrmDetectXe(FFGPUResult* gpu, int fd);
|
|
|
|
|
const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd);
|
2025-07-19 16:27:38 +08:00
|
|
|
const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd);
|
2025-06-18 10:01:32 +08:00
|
|
|
#endif // FF_HAVE_DRM
|
|
|
|
|
|
|
|
|
|
const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFGpuDriverPciBusId pciBusId);
|
|
|
|
|
#endif // defined(XXX)
|
2025-10-30 10:26:35 +08:00
|
|
|
|
|
|
|
|
static inline uint64_t ffGPUPciAddr2Id(uint64_t domain, uint64_t bus, uint64_t device, uint64_t function)
|
|
|
|
|
{
|
|
|
|
|
return (domain << 16) | (bus << 8) | (device << 3) | function;
|
|
|
|
|
}
|
2025-10-30 11:01:06 +08:00
|
|
|
|
|
|
|
|
static inline uint64_t ffGPUGeneral2Id(uint64_t originalId)
|
|
|
|
|
{
|
|
|
|
|
// Note: originalId may already have the MSB set
|
|
|
|
|
return (1ULL << 63) | originalId;
|
|
|
|
|
}
|