GPU (Windows): add debug logs for #484

This commit is contained in:
李通洲
2023-07-01 15:06:47 +08:00
parent 1c62a07099
commit 1f799d16c9
3 changed files with 22 additions and 0 deletions
+5
View File
@@ -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;
}
+12
View File
@@ -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;
}
+5
View File
@@ -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)
{