Skip to content

Commit b6b2ddd

Browse files
Simplify portability enumeration variables
1 parent 19f2004 commit b6b2ddd

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

loader/loader_common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,6 @@ struct loader_instance {
379379
loader_settings settings;
380380

381381
bool portability_enumeration_enabled;
382-
bool portability_enumeration_flag_bit_set;
383-
bool portability_enumeration_extension_enabled;
384382

385383
bool create_terminator_invalid_extension;
386384
bool supports_get_dev_prop_2;

loader/trampoline.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
483483
VkInstance created_instance = VK_NULL_HANDLE;
484484
VkResult res = VK_ERROR_INITIALIZATION_FAILED;
485485
VkInstanceCreateInfo ici = {0};
486+
bool portability_enumeration_flag_bit_set = false;
487+
bool portability_enumeration_extension_enabled = false;
486488
struct loader_envvar_all_filters layer_filters = {0};
487489

488490
LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
@@ -561,18 +563,19 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
561563

562564
// Check the VkInstanceCreateInfoFlags wether to allow the portability enumeration flag
563565
if ((pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR) == 1) {
564-
ptr_instance->portability_enumeration_flag_bit_set = true;
566+
portability_enumeration_flag_bit_set = true;
565567
}
566-
// Make sure the extension has been enabled
568+
// Make sure the portability extension extension has been enabled before enabling portability driver enumeration
567569
if (pCreateInfo->ppEnabledExtensionNames) {
568570
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
569571
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0) {
570-
ptr_instance->portability_enumeration_extension_enabled = true;
571-
if (ptr_instance->portability_enumeration_flag_bit_set) {
572+
portability_enumeration_extension_enabled = true;
573+
if (portability_enumeration_flag_bit_set) {
572574
ptr_instance->portability_enumeration_enabled = true;
573575
loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0,
574576
"Portability enumeration bit was set, enumerating portability drivers.");
575577
}
578+
break;
576579
}
577580
}
578581
}
@@ -622,14 +625,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
622625
if (ptr_instance->icd_tramp_list.count == 0) {
623626
// No drivers found
624627
if (skipped_portability_drivers) {
625-
if (ptr_instance->portability_enumeration_extension_enabled && !ptr_instance->portability_enumeration_flag_bit_set) {
628+
if (portability_enumeration_extension_enabled && !portability_enumeration_flag_bit_set) {
626629
loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
627630
"vkCreateInstance: Found drivers that contain devices which support the portability subset, but "
628631
"the instance does not enumerate portability drivers! Applications that wish to enumerate portability "
629632
"drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo "
630633
"flags.");
631-
} else if (ptr_instance->portability_enumeration_flag_bit_set &&
632-
!ptr_instance->portability_enumeration_extension_enabled) {
634+
} else if (portability_enumeration_flag_bit_set && !portability_enumeration_extension_enabled) {
633635
loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
634636
"VkInstanceCreateInfo: If flags has the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit set, the "
635637
"list of enabled extensions in ppEnabledExtensionNames must contain VK_KHR_portability_enumeration "

0 commit comments

Comments
 (0)