@@ -7122,6 +7122,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices(VkInstance in
71227122// device_configurations in the settings file.
71237123VkResult loader_apply_settings_device_configurations (struct loader_instance * inst , uint32_t * pPhysicalDeviceCount ,
71247124 VkPhysicalDevice * pPhysicalDevices ) {
7125+ loader_log (inst , VULKAN_LOADER_INFO_BIT , 0 ,
7126+ "Reordering the output of vkEnumeratePhysicalDevices to match the loader settings device configurations list" );
7127+
7128+ bool * pd_was_added = loader_stack_alloc (inst -> phys_dev_count_term * sizeof (bool ));
7129+ if (NULL == pd_was_added ) {
7130+ return VK_ERROR_OUT_OF_HOST_MEMORY ;
7131+ }
7132+ memset (pd_was_added , 0 , inst -> phys_dev_count_term * sizeof (bool ));
7133+
71257134 bool * pd_supports_11 = loader_stack_alloc (inst -> phys_dev_count_term * sizeof (bool ));
71267135 if (NULL == pd_supports_11 ) {
71277136 return VK_ERROR_OUT_OF_HOST_MEMORY ;
@@ -7177,9 +7186,10 @@ VkResult loader_apply_settings_device_configurations(struct loader_instance *ins
71777186 * pPhysicalDeviceCount = written_output_index ; // write out how many were written
71787187 return VK_INCOMPLETE ;
71797188 }
7189+ loader_log (inst , VULKAN_LOADER_DEBUG_BIT , 0 , "pPhysicalDevices array index %d is set to \"%s\" " ,
7190+ written_output_index , pd_props [j ].deviceName );
71807191 pPhysicalDevices [written_output_index ++ ] = (VkPhysicalDevice )inst -> phys_devs_term [j ];
7181- loader_log (inst , VULKAN_LOADER_INFO_BIT , 0 , "Insert VkPhysicalDevice \"%s\" to the pPhysicalDevices list" ,
7182- pd_props [j ].deviceName );
7192+ pd_was_added [j ] = true;
71837193 break ;
71847194 }
71857195 }
@@ -7205,6 +7215,23 @@ VkResult loader_apply_settings_device_configurations(struct loader_instance *ins
72057215 }
72067216 }
72077217 }
7218+
7219+ for (uint32_t j = 0 ; j < inst -> phys_dev_count_term ; j ++ ) {
7220+ if (!pd_was_added [j ]) {
7221+ loader_log (inst , VULKAN_LOADER_INFO_BIT , 0 ,
7222+ "VkPhysicalDevice \"%s\" did not appear in the settings file device configurations list, so was not added "
7223+ "to the pPhysicalDevices array" ,
7224+ pd_props [j ].deviceName );
7225+ }
7226+ }
7227+
7228+ if (written_output_index == 0 ) {
7229+ loader_log (inst , VULKAN_LOADER_WARN_BIT , 0 ,
7230+ "loader_apply_settings_device_configurations: None of the settings file device configurations had "
7231+ "deviceUUID's that corresponded to enumerated VkPhysicalDevices. Returning VK_ERROR_INITIALIZATION_FAILED" );
7232+ return VK_ERROR_INITIALIZATION_FAILED ;
7233+ }
7234+
72087235 * pPhysicalDeviceCount = written_output_index ; // update with how many were written
72097236 return VK_SUCCESS ;
72107237}
0 commit comments