Vulkan-Loader icon indicating copy to clipboard operation
Vulkan-Loader copied to clipboard

Loader Settings: Invalid `deviceUUID` report a warning and exit

Open christophe-lunarg opened this issue 5 months ago • 4 comments

Using the following vk_loader_settings.json:

vk_loader_settings.json

I am using "additional_drivers_use_exclusively": true because of https://github.com/KhronosGroup/Vulkan-Loader/issues/1718 bug

But here I am using un invalid deviceUUID leading to not finding the device.

Running vulkaninfoSDK, I am getting the following log:

Launching Vulkan Application:
- Executable: E:\VulkanSDK\1.4.321.0-rc\Bin\vulkaninfoSDK.exe
- Working Directory: C:\Users\Piranha\VulkanSDK
- Command-line Arguments:
  - --summary
- Log file: C:\Users\Piranha\VulkanSDK\vulkaninfo.txt

WARNING: [Loader Message] Code 0 : Layer VK_LAYER_NV_optimus uses API version 1.3 which is older than the application specified API version of 1.4. May cause issues.

WARNING: [Loader Message] Code 0 : loader_apply_settings_device_configurations: settings file contained device_configuration which does not appear in the enumerated VkPhysicalDevices. Missing VkPhysicalDevice with deviceName: "llvmpipe (LLVM 20.1.6, 256 bits)" and deviceUUID: 6e667462-3336-2f31-2f38-111111

Process terminated

If the behavior is to exit the program, I would suggest to report an error. Another approach could be to ignore the the device_configurations and report the warning.

christophe-lunarg avatar Jul 23 '25 11:07 christophe-lunarg

"additional_drivers_use_exclusively" was intended to allow vkconfig to say "here are the drivers to use, do not use any other drivers." device_configurations allows controlling the order of physical devices. It can be used to order physical devices, but it can also be used to select physical devices by only returning physical devices that have their deviceUUID in the device configuration list. So if you put a single deviceUUID in the device configurations list, and no physical devices match it, then yeah it would be expected that vkEnumeratePhysicalDevices returns 0. This is intended, but I completely agree is very surprising. There is a warning emitted, but the return value is VK_SUCCESS which I believe is the 'bug' that needs to be fixed, as the loader isn't terminating, vulkaninfo is. Or actually, it might just find zero physical devices and do nothing since a lot of its logic is looping over the available physical devices. No devices, no looping, early exit.

So to summarize:

  • The behavior described is exactly as expected. That doesn't mean it is good behavior.
  • Loader should log when device_configurations culls the list to zero
  • Loader should also log when a physical device was not added.
  • Loader should return error code when physical devices is zero, since that is surprising behavior.

charles-lunarg avatar Aug 04 '25 03:08 charles-lunarg

I agree this bug will be resolved by "Loader should return error code when physical devices is zero, since that is surprising behavior."

"additional_drivers_use_exclusively" was intended to allow vkconfig to say "here are the drivers to use, do not use any other drivers." It can be used to order physical devices, but it can also be used to select physical devices

This is understood but I will have no use for additional_drivers_use_exclusively once https://github.com/KhronosGroup/Vulkan-Loader/issues/1720 is fixed because I use deviceUUID to specify the list of devices and I know which one are "installed" devices and which one are "additional" devices.

christophe-lunarg avatar Aug 04 '25 08:08 christophe-lunarg

I didn't think about how device_configurations makes additional_drivers_use_exclusively redundant. For your use case with vkconfig, it makes sense to not use additional_drivers_use_exclusively. It defaults to false anyhow, so leaving it out is fine. I wont remove it because it is good for anyone using settings file to specify a driver and want to only use that driver.

charles-lunarg avatar Aug 05 '25 16:08 charles-lunarg

#1751 should fix the issues reported here. The changes are:

  • returning VK_ERROR_INITIALIZATION_FAILED when no VkPhysicalDevices matched the deviceUUID's in the settings file device_configurations list
  • Logging which VkPhysicalDevices were not in the settings file device_configurations list
  • Logging that the output list is being reordered
  • Log the deviceName's in the settings file logging
  • Allowing for invalid array elements in the device_configuration array - previously if any element was invalid, the WHOLE array was discarded.
  • Print deviceUUID's correctly (used to only print every other character)

I chose to return VK_ERROR_INITIALIZATION_FAILED as when the settings file is active, that means vkconfig (or someone else) is actively trying to set the order. Failing hard with an error makes it clear something broke, whereas just printing a warning and returning the normal physical device array means users could not realize something broke.

Also, because the re-ordering is happening next to the driver, there is the possibility of other ordering mechanisms coming in and re-doing what the settings file did. Like the Mesa Device Select layer. This isn't a great situation, but disabling layers using vkconfig is easy, so I don't think its a major issue. And if vkconfig removes all but 1 physical device, then there is no chance for that order to be wrong :D

charles-lunarg avatar Aug 05 '25 16:08 charles-lunarg