From: Charles Giessen Date: Mon, 24 Jul 2023 16:37:25 +0000 (-0600) Subject: Enhance warning messages for portability enumeration X-Git-Tag: upstream/1.3.268~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84b63d45489ed3a58c557d22381e5e1deffc0a32;p=platform%2Fupstream%2FVulkan-Loader.git Enhance warning messages for portability enumeration There are three different ways for applications to fail to enumerate portability drivers, not enabling the flag bit, not enabling the extension, and both. These were all reported as the same error, which isn't as helpful as it printing a separate message for each case. This also makes it possible to emit a VUID for the case of setting the flag bit but not the extension. --- diff --git a/loader/loader_common.h b/loader/loader_common.h index 249d96fa..7d05e17e 100644 --- a/loader/loader_common.h +++ b/loader/loader_common.h @@ -311,6 +311,8 @@ struct loader_instance { loader_settings settings; bool portability_enumeration_enabled; + bool portability_enumeration_flag_bit_set; + bool portability_enumeration_extension_enabled; bool wsi_surface_enabled; #if defined(VK_USE_PLATFORM_WIN32_KHR) diff --git a/loader/trampoline.c b/loader/trampoline.c index 51cd17f0..bae33ff0 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -517,12 +517,18 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr // Check the VkInstanceCreateInfoFlags wether to allow the portability enumeration flag if ((pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR) == 1) { - // Make sure the extension has been enabled + ptr_instance->portability_enumeration_flag_bit_set = true; + } + // Make sure the extension has been enabled + if (pCreateInfo->ppEnabledExtensionNames) { for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0) { - ptr_instance->portability_enumeration_enabled = true; - loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0, - "Portability enumeration bit was set, enumerating portability drivers."); + ptr_instance->portability_enumeration_extension_enabled = true; + if (ptr_instance->portability_enumeration_flag_bit_set) { + ptr_instance->portability_enumeration_enabled = true; + loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0, + "Portability enumeration bit was set, enumerating portability drivers."); + } } } } @@ -566,12 +572,27 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr if (ptr_instance->icd_tramp_list.count == 0) { // No drivers found if (skipped_portability_drivers) { - loader_log( - ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, - "vkCreateInstance: Found drivers that contain devices which support the portability subset, but the " - "portability enumeration bit was not set! Applications that wish to enumerate portability drivers must set the " - "VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo flags and " - "enable the VK_KHR_portability_enumeration instance extension."); + if (ptr_instance->portability_enumeration_extension_enabled && !ptr_instance->portability_enumeration_flag_bit_set) { + loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, + "vkCreateInstance: Found drivers that contain devices which support the portability subset, but " + "the instance does not enumerate portability drivers! Applications that wish to enumerate portability " + "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo " + "flags."); + } else if (ptr_instance->portability_enumeration_flag_bit_set && + !ptr_instance->portability_enumeration_extension_enabled) { + loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, + "VkInstanceCreateInfo: If flags has the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit set, the " + "list of enabled extensions in ppEnabledExtensionNames must contain VK_KHR_portability_enumeration " + "[VUID-VkInstanceCreateInfo-flags-06559 ]" + "Applications that wish to enumerate portability drivers must enable the VK_KHR_portability_enumeration " + "instance extension."); + } else { + loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, + "vkCreateInstance: Found drivers that contain devices which support the portability subset, but " + "the instance does not enumerate portability drivers! Applications that wish to enumerate portability " + "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo " + "flags and enable the VK_KHR_portability_enumeration instance extension."); + } } loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "vkCreateInstance: Found no drivers!"); res = VK_ERROR_INCOMPATIBLE_DRIVER; diff --git a/tests/loader_regression_tests.cpp b/tests/loader_regression_tests.cpp index 39fa0d4a..dd6a6301 100644 --- a/tests/loader_regression_tests.cpp +++ b/tests/loader_regression_tests.cpp @@ -3532,10 +3532,23 @@ TEST(SortedPhysicalDevices, DeviceGroupsSortedDisabled) { #endif // __linux__ || __FreeBSD__ || __OpenBSD__ || __GNU__ const char* portability_driver_warning = - "vkCreateInstance: Found drivers that contain devices which support the portability subset, but the " - "portability enumeration bit was not set! Applications that wish to enumerate portability drivers must set the " - "VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo flags and " - "enable the VK_KHR_portability_enumeration instance extension."; + "vkCreateInstance: Found drivers that contain devices which support the portability subset, but " + "the instance does not enumerate portability drivers! Applications that wish to enumerate portability " + "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo " + "flags and enable the VK_KHR_portability_enumeration instance extension."; + +const char* portability_flag_missing = + "vkCreateInstance: Found drivers that contain devices which support the portability subset, but " + "the instance does not enumerate portability drivers! Applications that wish to enumerate portability " + "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo " + "flags."; + +const char* portability_extension_missing = + "VkInstanceCreateInfo: If flags has the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit set, the " + "list of enabled extensions in ppEnabledExtensionNames must contain VK_KHR_portability_enumeration " + "[VUID-VkInstanceCreateInfo-flags-06559 ]" + "Applications that wish to enumerate portability drivers must enable the VK_KHR_portability_enumeration " + "instance extension."; TEST(PortabilityICDConfiguration, PortabilityICDOnly) { FrameworkEnvironment env{}; @@ -3561,6 +3574,8 @@ TEST(PortabilityICDConfiguration, PortabilityICDOnly) { DeviceWrapper dev_info{inst}; dev_info.CheckCreate(phys_dev); ASSERT_FALSE(log.find(portability_driver_warning)); + ASSERT_FALSE(log.find(portability_flag_missing)); + ASSERT_FALSE(log.find(portability_extension_missing)); } { // enable portability flag but not extension - shouldn't be able to create an instance when filtering is enabled InstWrapper inst{env.vulkan_functions}; @@ -3568,7 +3583,7 @@ TEST(PortabilityICDConfiguration, PortabilityICDOnly) { inst.create_info.add_extension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); FillDebugUtilsCreateDetails(inst.create_info, env.debug_log); inst.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER); - ASSERT_TRUE(env.debug_log.find(portability_driver_warning)); + ASSERT_TRUE(env.debug_log.find(portability_extension_missing)); } { // enable portability extension but not flag - shouldn't be able to create an instance when filtering is enabled InstWrapper inst{env.vulkan_functions}; @@ -3576,7 +3591,7 @@ TEST(PortabilityICDConfiguration, PortabilityICDOnly) { inst.create_info.add_extension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); FillDebugUtilsCreateDetails(inst.create_info, env.debug_log); inst.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER); - ASSERT_TRUE(env.debug_log.find(portability_driver_warning)); + ASSERT_TRUE(env.debug_log.find(portability_flag_missing)); } { // enable neither the portability extension or the flag - shouldn't be able to create an instance when filtering is enabled InstWrapper inst{env.vulkan_functions};