From 408d939664fe8655f75beec1927310b37e75bf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 28 Mar 2026 12:11:29 +0800 Subject: [PATCH] GPU (Windows/WSL): adds basic GPU type detection code --- src/detection/gpu/gpu_windows.c | 23 +++++++++++++++++++---- src/detection/gpu/gpu_wsl.c | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 6a7f393a6..ff8247a92 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -486,11 +486,26 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* if (gpu->type == FF_GPU_TYPE_UNKNOWN) { FF_DEBUG("Using fallback GPU type detection"); - if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL) + if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA) { - gpu->type = gpu->deviceId == ffGPUPciAddr2Id(0, 0, 2, 0) ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; - FF_DEBUG("Intel GPU type determined: %s", gpu->type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete"); + 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 (gpu->type != FF_GPU_TYPE_UNKNOWN) + FF_DEBUG("Determined GPU type based on vendor (%s) and name: %u", gpu->vendor.chars, gpu->type); else if (ffIsWindows10OrGreater()) { const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult* gpu); @@ -498,7 +513,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* FF_DEBUG("DXCore GPU type detection result: %s", error ?: "Success"); } else - FF_DEBUG("Unable to determine GPU type"); + FF_DEBUG("Unable to determine GPU type by any method for this adapter"); } FF_DEBUG("Completed processing GPU #%d - Vendor: %s, Name: %s, Type: %d", deviceCount, gpu->vendor.chars, gpu->name.chars, gpu->type); diff --git a/src/detection/gpu/gpu_wsl.c b/src/detection/gpu/gpu_wsl.c index 882b0e6c3..5ea44782c 100644 --- a/src/detection/gpu/gpu_wsl.c +++ b/src/detection/gpu/gpu_wsl.c @@ -335,6 +335,27 @@ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus) FF_DEBUG("Failed to query temperature for adapter #%u: %s", i, strerror(errno)); } + 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; + } + } + FF_DEBUG("Adapter #%u summary: name='%s', vendor='%s', type=%u, deviceId=%lu", i, gpu->name.length ? gpu->name.chars : "unknown",