diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index a287298da..6928ad2bc 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -206,3 +206,33 @@ const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { FF_DEBUG("GPU detection failed in all enabled backends"); return "GPU detection failed"; } + +bool ffGPUFillVendorByDeviceName(FFGPUResult* gpu) { + if (gpu->type == FF_GPU_TYPE_UNKNOWN) { + return true; + } + + FF_DEBUG("Using fallback GPU type detection"); + if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA) { + if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") || + ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") || + ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla")) { + gpu->type = FF_GPU_TYPE_DISCRETE; + } + } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS) { + if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT ")) { gpu->type = FF_GPU_TYPE_DISCRETE; } + } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) { + // 0000:00:02.0 is reserved for Intel integrated graphics + gpu->type = gpu->deviceId == ffGPUPciAddr2Id(0, 0, 2, 0) ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; + } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_VMWARE || gpu->vendor.chars == FF_GPU_VENDOR_NAME_PARALLELS) { + // Virtualized GPUs + gpu->type = FF_GPU_TYPE_INTEGRATED; + } + + if (gpu->type != FF_GPU_TYPE_UNKNOWN) { + FF_DEBUG("Determined GPU type based on vendor (%s) and name: %u", gpu->vendor.chars, gpu->type); + return true; + } + + return false; +} diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 10bd02b3f..b4d66b267 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -87,3 +87,5 @@ static inline uint64_t ffGPUGeneral2Id(uint64_t originalId) { // Note: originalId may already have the MSB set return (1ULL << 63) | originalId; } + +bool ffGPUFillVendorByDeviceName(FFGPUResult* gpu); diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index 6ed52f51a..be4ebd677 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -11,31 +11,12 @@ #include // DragonFly #endif -static void fillGPUTypeGeneric(FFGPUResult* gpu) { - if (gpu->type == FF_GPU_TYPE_UNKNOWN) { - if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla")) { - gpu->type = FF_GPU_TYPE_DISCRETE; - } - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT ")) { - gpu->type = FF_GPU_TYPE_DISCRETE; - } - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) { - // 0000:00:02.0 is reserved for Intel integrated graphics - gpu->type = gpu->deviceId == ffGPUPciAddr2Id(0, 0, 2, 0) ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; - } - } -} - #if FF_HAVE_DRM #include "common/library.h" #include "common/strutil.h" #include - + // https://github.com/freebsd/drm-kmod/blob/8fea1f06b3ac3fa24217e24ba7b2133abad705a9/include/uapi/drm/drm.h#L1095 struct drm_pciinfo { uint16_t domain; @@ -86,14 +67,14 @@ static const char* detectByDrm(const FFGPUOptions* options, FFlist* gpus) { // dev.drm.drm_debug_persist: 0 // dev.drm.skip_ddb: 0 // dev.drm.__drm_debug: 0 - + // hw.dri.timestamp_precision: 20 // hw.dri.vblank_offdelay: 5000 // hw.dri.0.modesetting: 1 // hw.dri.0.busid: pci:0000:01:00.0 - // hw.dri.0.vblank: + // hw.dri.0.vblank: // crtc ref count last enabled inmodeset - // hw.dri.0.clients: + // hw.dri.0.clients: // a dev pid uid magic ioctls // y drm/128 101655 0 0 0 // n drm/128 101655 0 0 0 @@ -180,7 +161,7 @@ static const char* detectByDrm(const FFGPUOptions* options, FFlist* gpus) { } } - fillGPUTypeGeneric(gpu); + ffGPUFillVendorByDeviceName(gpu); } return NULL; @@ -252,7 +233,7 @@ static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) { } } - fillGPUTypeGeneric(gpu); + ffGPUFillVendorByDeviceName(gpu); } return NULL; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 3aaa09cb0..d10252137 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -478,19 +478,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffGPUFillVendorAndName(subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu); } - if (gpu->type == FF_GPU_TYPE_UNKNOWN) { - if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla")) { - gpu->type = FF_GPU_TYPE_DISCRETE; - } - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT ")) { - gpu->type = FF_GPU_TYPE_DISCRETE; - } - } - } + ffGPUFillVendorByDeviceName(gpu); return NULL; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 796c1c566..6c542c18e 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -553,25 +553,8 @@ ffGPUDetectWsl2 } if (gpu->type == FF_GPU_TYPE_UNKNOWN) { - FF_DEBUG("Using fallback GPU type detection"); - if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") || - ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla")) { - gpu->type = FF_GPU_TYPE_DISCRETE; - } - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS) { - if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT ")) { gpu->type = FF_GPU_TYPE_DISCRETE; } - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) { - // 0000:00:02.0 is reserved for Intel integrated graphics - gpu->type = gpu->deviceId == ffGPUPciAddr2Id(0, 0, 2, 0) ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; - } else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_VMWARE || gpu->vendor.chars == FF_GPU_VENDOR_NAME_PARALLELS) { - // Virtualized GPUs - gpu->type = FF_GPU_TYPE_INTEGRATED; - } - - if (gpu->type != FF_GPU_TYPE_UNKNOWN) { - FF_DEBUG("Determined GPU type based on vendor (%s) and name: %u", gpu->vendor.chars, gpu->type); + if (ffGPUFillVendorByDeviceName(gpu)) { + // OK } #if _WIN32 else if (ffIsWindows10OrGreater()) {