From 1f799d16c99c7b245a23e6328b1312003d5635c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 15:06:47 +0800 Subject: [PATCH] GPU (Windows): add debug logs for #484 --- src/detection/gpu/gpu.c | 5 +++++ src/detection/gpu/gpu_windows.c | 12 ++++++++++++ src/modules/gpu/gpu.c | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 9300b2484..28040cd5c 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -32,15 +32,20 @@ const char* ffGetGPUVendorString(unsigned vendorId) const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { + fputs("ffDetectGPU start\n", stderr); if (!options->forceVulkan) { const char* error = ffDetectGPUImpl(options, result); + fputs("ffDetectGPU end 1\n", stderr); if (!error) return NULL; } + fputs("ffDetectVulkan start\n", stderr); FFVulkanResult* vulkan = ffDetectVulkan(); + fputs("ffDetectVulkan end\n", stderr); if (vulkan->error) return "GPU detection failed"; ffListDestroy(result); ffListInitMove(result, &vulkan->gpus); + fputs("ffDetectGPU end 2\n", stderr); return NULL; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 621681e62..ee1f9abf2 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -6,6 +6,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { + fputs("ffDetectGPUImpl: start\n", stderr); DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; const uint32_t regKeyPrefixLength = (uint32_t) wcslen(regKey); @@ -15,9 +16,12 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* { if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; + fwprintf(stderr, L"ffDetectGPUImpl EnumDisplayDevicesW %ls\n", displayDevice.DeviceKey); const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey); + fprintf(stderr, "ffDetectGPUImpl deviceKeyLength %d\n", (int) deviceKeyLength); if (deviceKeyLength != 100 || wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; + fputs("ffDetectGPUImpl ffListAdd\n", stderr); FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInit(&gpu->vendor); ffStrbufInitWS(&gpu->name, displayDevice.DeviceString); @@ -29,12 +33,17 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* if (displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') { + fputs("ffDetectGPUImpl displayDevice.DeviceKey[deviceKeyPrefixLength - 1]\n", stderr); wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1); FF_HKEY_AUTO_DESTROY hKey = NULL; + fputs("ffDetectGPUImpl ffRegOpenKeyForRead start\n", stderr); if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regKey, &hKey, NULL)) continue; + fputs("ffDetectGPUImpl ffRegOpenKeyForRead end\n", stderr); ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL); + fputs("ffDetectGPUImpl DriverVersion end\n", stderr); ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL); + fputs("ffDetectGPUImpl ProviderName end\n", stderr); if(ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD); @@ -43,8 +52,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* else if(ffStrbufContainS(&gpu->vendor, "NVIDIA")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA); + fputs("ffDetectGPUImpl HardwareInformation.qwMemorySize start\n", stderr); if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL)) { + fputs("ffDetectGPUImpl HardwareInformation.MemorySize start\n", stderr); uint32_t vmem = 0; if (ffRegReadUint(hKey, L"HardwareInformation.MemorySize", &vmem, NULL)) gpu->dedicated.total = vmem; @@ -52,6 +63,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; } } + fputs("ffDetectGPUImpl end\n", stderr); return NULL; } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index d7ec2d246..35571a1dd 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -79,6 +79,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu void ffPrintGPU(FFGPUOptions* options) { + fputs("ffPrintGPU start\n", stderr); FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult)); const char* error = ffDetectGPU(options, &gpus); if (error) @@ -86,6 +87,7 @@ void ffPrintGPU(FFGPUOptions* options) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } + fputs("ffPrintGPU 1\n", stderr); FF_LIST_AUTO_DESTROY selectedGPUs; ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus.length); @@ -100,12 +102,15 @@ void ffPrintGPU(FFGPUOptions* options) * (const FFGPUResult**) ffListAdd(&selectedGPUs) = gpu; } + fputs("ffPrintGPU 2\n", stderr); for(uint32_t i = 0; i < selectedGPUs.length; i++) printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); + fputs("ffPrintGPU 3\n", stderr); if(selectedGPUs.length == 0) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); + fputs("ffPrintGPU 4\n", stderr); FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) {