diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 98bc7b2..7c9f247 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -172,6 +172,8 @@ const char* validation_layer_name = "VK_LAYER_KHRONOS_validation"; const char* to_string (InstanceError err) { switch (err) { + case InstanceError::unavailable_vulkan_version: + return "unavailable_vulkan_version"; case InstanceError::failed_create_debug_messenger: return "failed_create_debug_messenger"; case InstanceError::failed_create_instance: @@ -276,6 +278,19 @@ SystemInfo InstanceBuilder::get_system_info () const { return system; } detail::Expected> InstanceBuilder::build () const { + if (VK_VERSION_MINOR (info.api_version) > 0) { + PFN_vkEnumerateInstanceVersion pfn_vkEnumerateInstanceVersion; + detail::get_inst_proc_addr ( + pfn_vkEnumerateInstanceVersion, "vkEnumerateInstanceVersion", nullptr, vkGetInstanceProcAddr); + if (pfn_vkEnumerateInstanceVersion == nullptr) { + return detail::Error{ InstanceError::unavailable_vulkan_version }; + } else if (pfn_vkEnumerateInstanceVersion != nullptr) { + uint32_t api_version = 0; + pfn_vkEnumerateInstanceVersion (&api_version); + if (VK_VERSION_MINOR (api_version) < VK_VERSION_MINOR (info.api_version)) + return detail::Error{ InstanceError::unavailable_vulkan_version }; + } + } VkApplicationInfo app_info = {}; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app_info.pNext = nullptr; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 73c043f..d08ee06 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -98,6 +98,7 @@ template class Expected { } // namespace detail enum class InstanceError { + unavailable_vulkan_version, failed_create_instance, failed_create_debug_messenger, requested_layers_not_present,