From 7ea8882843d4e42a09b61b08f07a256bd22d746f Mon Sep 17 00:00:00 2001 From: Carter Date: Mon, 12 Feb 2024 18:09:11 +0800 Subject: [PATCH] GPU (FreeBSD): detect correct AMD card names --- src/detection/gpu/gpu_bsd.c | 17 ++++++++++++++--- src/util/platform/FFPlatform_unix.c | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index cb9f39c54..ed0f7337d 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -1,9 +1,9 @@ #include "gpu_driver_specific.h" #include "common/io/io.h" +#include "common/properties.h" #include "3rdparty/nvml/nvml.h" #include "util/mallocHelper.h" -#include "common/io/io.h" #include #include @@ -46,7 +46,6 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) return "ioctl(fd, PCIOCGETCONF, &pc) returned error"; FF_STRBUF_AUTO_DESTROY pciids = ffStrbufCreate(); - loadPciIds(&pciids); for (uint32_t i = 0; i < pcio.num_matches; ++i) { @@ -64,7 +63,19 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) gpu->deviceId = ((uint64_t) pc->pc_sel.pc_domain << 6) | ((uint64_t) pc->pc_sel.pc_bus << 4) | ((uint64_t) pc->pc_sel.pc_dev << 2) | pc->pc_sel.pc_func; gpu->frequency = FF_GPU_FREQUENCY_UNSET; - ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, pc->pc_subvendor, pc->pc_subdevice, gpu); + if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) + { + char query[32]; + snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid); + ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); + } + + if (gpu->name.length == 0) + { + if (pciids.length == 0) + loadPciIds(&pciids); + ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, pc->pc_subvendor, pc->pc_subdevice, gpu); + } #ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->driverSpecific)) diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 255211a34..b57bb499d 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef __APPLE__ #include @@ -135,6 +136,9 @@ static void getDataDirs(FFPlatform* platform) ffPlatformPathAddHome(&platform->dataDirs, platform, ""); platformPathAddEnv(&platform->dataDirs, "XDG_DATA_DIRS"); +#ifdef _PATH_LOCALBASE + ffPlatformPathAddAbsolute(&platform->dataDirs, _PATH_LOCALBASE "/share/"); +#endif ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/"); ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/"); }