From 3cac3937571667d54cdf7a50a38b43621a0d4975 Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Wed, 21 Jan 2026 06:21:06 +0100 Subject: [PATCH] vulkan: handle Vulkan 1.1 in ggml_vk_device_is_supported() Check required exstensions when using Vulkan 1.1 and use VkPhysicalDevice16BitStorageFeatures --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 40 ++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 7d48d6b1..c1fd458f 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -15343,17 +15343,47 @@ static bool ggml_vk_instance_debug_utils_ext_available( } static bool ggml_vk_device_is_supported(const vk::PhysicalDevice & vkdev) { + vk::PhysicalDeviceProperties device_props = vkdev.getProperties(); + const bool device_is_vulkan_12 = device_props.apiVersion >= VK_API_VERSION_1_2; + + if (!device_is_vulkan_12) { + // Check for required extensions on Vulkan 1.1 + std::vector ext_props = vkdev.enumerateDeviceExtensionProperties(); + bool timeline_semaphore_khr = false; + bool int8_storage_khr = false; + + for (const auto& properties : ext_props) { + if (strcmp("VK_KHR_timeline_semaphore", properties.extensionName) == 0) { + timeline_semaphore_khr = true; + } else if (strcmp("VK_KHR_8bit_storage", properties.extensionName) == 0) { + int8_storage_khr = true; + } + } + + if (!timeline_semaphore_khr || !int8_storage_khr) { + return false; + } + } + VkPhysicalDeviceFeatures2 device_features2; device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; - VkPhysicalDeviceVulkan11Features vk11_features; - vk11_features.pNext = nullptr; - vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; - device_features2.pNext = &vk11_features; + VkPhysicalDeviceVulkan11Features vk11_features {}; + VkPhysicalDevice16BitStorageFeatures storage_16bit_features {}; + + if (device_is_vulkan_12) { + vk11_features.pNext = nullptr; + vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; + device_features2.pNext = &vk11_features; + } else { + storage_16bit_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES; + storage_16bit_features.pNext = nullptr; + device_features2.pNext = &storage_16bit_features; + } vkGetPhysicalDeviceFeatures2(vkdev, &device_features2); - return vk11_features.storageBuffer16BitAccess; + return device_is_vulkan_12 ? vk11_features.storageBuffer16BitAccess : storage_16bit_features.storageBuffer16BitAccess; } static bool ggml_vk_khr_cooperative_matrix_support(const vk::PhysicalDeviceProperties& props, const vk::PhysicalDeviceDriverProperties& driver_props, vk_device_architecture arch) {