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+deviceIDis not enough: I could have 2 identical GPUs connecteddeviceNameis not enough for the same reasondeviceLUIDis not guaranteed to be present, and may have the same problems asdeviceUUID(below)deviceUUIDlooks like the correct choice, but the spec says:While
VkPhysicalDeviceIDPropertiesKHR::deviceUUIDis 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?
deviceUUIDis the best you're going to get.Think it like this. If the
deviceUUIDmatches 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.