From c52353b4b8bcc150d9254c51f6c345ab85fd4c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 28 Oct 2023 20:14:22 +0800 Subject: [PATCH] Vulkan: remove used GPU memory detection, which is unreliable Ref: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_memory_budget.html#_description --- CHANGELOG.md | 3 ++- src/detection/vulkan/vulkan.c | 36 ++++++++--------------------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e3e76451..828298ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,13 +15,14 @@ Features: * Support st version detection (Terminal, Linux) * Support st terminal font detection (TerminalFont, Linux) * Add option `--migrate-config ` -* Support Nvidia GPU temp detection via nvml (GPU) +* Support Nvidia GPU temp and cuda core count detection via nvml (GPU) * Try supporting Wifi authentication type detection in macOS Sonoma. Please file a feature request if you get `to be supported (num)` with result of `/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep auth` (Wifi, macOS) Bugfixes: * Better GPU memory and type detection (GPU, Windows) * Don't print display type twice (Display) * Detect BSSID instead of Wifi MAC address to align with other platforms (Wifi, macOS) +* Remove support of used GPU memory detection, which is not reliable and only supported with `--gpu-force-vulkan`. (GPU) Logos: * Add Black Mesa diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index dd337e8d2..07d10a57a 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -117,11 +117,7 @@ static const char* detectVulkan(FFVulkanResult* result) if(!ffvkGetPhysicalDeviceProperties2) ffvkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceProperties"); - PFN_vkGetPhysicalDeviceMemoryProperties ffvkGetPhysicalDeviceMemoryProperties = NULL; - PFN_vkGetPhysicalDeviceMemoryProperties2 ffvkGetPhysicalDeviceMemoryProperties2 = - instance.config.general.allowSlowOperations ? (PFN_vkGetPhysicalDeviceMemoryProperties2) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties2") : NULL; // 1.1 - if(!ffvkGetPhysicalDeviceMemoryProperties2) - ffvkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties"); + PFN_vkGetPhysicalDeviceMemoryProperties ffvkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties"); FFVersion maxDeviceApiVersion = FF_VERSION_INIT; FFVersion maxDeviceConformanceVersion = FF_VERSION_INIT; @@ -187,38 +183,22 @@ static const char* detectVulkan(FFVulkanResult* result) gpu->vulkanDeviceId = physicalDeviceProperties.properties.deviceID; - ffStrbufInit(&gpu->name); - ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName); + ffStrbufInitS(&gpu->name, physicalDeviceProperties.properties.deviceName); - if(physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) - gpu->type = FF_GPU_TYPE_DISCRETE; - else - gpu->type = FF_GPU_TYPE_INTEGRATED; + gpu->type = physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; ffStrbufInitS(&gpu->vendor, ffGetGPUVendorString(physicalDeviceProperties.properties.vendorID)); ffStrbufInitS(&gpu->driver, driverProperties.driverInfo); - VkPhysicalDeviceMemoryBudgetPropertiesEXT budgetProperties = { - .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT, - }; - VkPhysicalDeviceMemoryProperties2 memoryProperties2 = { - .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, - .pNext = &budgetProperties, - }; - - if(ffvkGetPhysicalDeviceMemoryProperties2) - ffvkGetPhysicalDeviceMemoryProperties2(physicalDevices[i], &memoryProperties2); - else - ffvkGetPhysicalDeviceMemoryProperties(physicalDevices[i], &memoryProperties2.memoryProperties); + VkPhysicalDeviceMemoryProperties memoryProperties = {}; + ffvkGetPhysicalDeviceMemoryProperties(physicalDevices[i], &memoryProperties); gpu->dedicated.total = gpu->shared.total = 0; - gpu->dedicated.used = gpu->shared.used = ffvkGetPhysicalDeviceMemoryProperties2 ? 0 : FF_GPU_VMEM_SIZE_UNSET; - for(uint32_t index = 0; index < memoryProperties2.memoryProperties.memoryHeapCount; ++index) + gpu->dedicated.used = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; + for(uint32_t index = 0; index < memoryProperties.memoryHeapCount; ++index) { - const VkMemoryHeap* heap = &memoryProperties2.memoryProperties.memoryHeaps[index]; + const VkMemoryHeap* heap = &memoryProperties.memoryHeaps[index]; FFGPUMemory* vmem = gpu->type == FF_GPU_TYPE_DISCRETE && (heap->flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) ? &gpu->dedicated : &gpu->shared; vmem->total += heap->size; - if(ffvkGetPhysicalDeviceMemoryProperties2) - vmem->used += heap->size - budgetProperties.heapBudget[index]; } //No way to detect those using vulkan