From 424ca923fcd1e4b7636934cdd03101ad0181dca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 16 May 2023 20:52:14 +0800 Subject: [PATCH] Vulkan: try fixing #456 --- src/detection/gpu/gpu.h | 1 + src/detection/vulkan/vulkan.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 17f34e68d..1d34958bf 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -37,6 +37,7 @@ typedef struct FFGPUResult int coreCount; FFGPUMemory dedicated; FFGPUMemory shared; + uint32_t vulkanDeviceId; // Only used for vulkan } FFGPUResult; const FFlist* ffDetectGPU(const FFinstance* instance); diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 29769da5a..878017e95 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -176,8 +176,17 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu if(physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) continue; + // #456 + FF_LIST_FOR_EACH(FFGPUResult, gpu, result->gpus) + { + if (gpu->vulkanDeviceId == physicalDeviceProperties.properties.deviceID) + goto next; + } + FFGPUResult* gpu = ffListAdd(&result->gpus); + gpu->vulkanDeviceId = physicalDeviceProperties.properties.deviceID; + ffStrbufInit(&gpu->name); ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName); @@ -215,6 +224,9 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu //No way to detect those using vulkan gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; + + next: + continue; } //If the highest device version is lower than the instance version, use it as our vulkan version