2
votes

Let's say I have more physical devices supporting Vulkan (dedicated + integrated GPU, or 2 dedicated, or other possibilities). The user can choose the device to use in the options screen. I need to be able to persist his choice on disk.

What field can I use to uniquely identify a physical device across different executions?

  • vendorID + deviceID is not enough: I could have 2 identical GPUs connected
  • deviceName is not enough for the same reason
  • deviceLUID is not guaranteed to be present, and may have the same problems as deviceUUID (below)
  • deviceUUID looks like the correct choice, but the spec says:

    While VkPhysicalDeviceIDPropertiesKHR::deviceUUID is specified to remain consistent across driver versions and system reboots, it is not intended to be usable as a serializable persistent identifier for a device. It may change when a device is physically added to, removed from, or moved to a different connector in a system while that system is powered down.

So... what should I use?

1

1 Answers

5
votes

deviceUUID is the best you're going to get.

Think it like this. If the deviceUUID matches a cached copy, then you are certain that it's the same device. And if the cached ID doesn't match any existing device, then either that hardware was removed or something radical happened. Either way, you need to pop up that dialog again to let the user decide what to do.