Description
Currently, vk-bootstrap supports preferring a single device type to others, but it is unclear if there is any selection priority beyond that. I'd like to propose that an API is added such that it is possible to define physical device selection priority.
Possible APIs:
Option One: This takes a variadic template that would be restricted to only take vkb::PreferredDeviceType
values. The order that the options are provided in is the order in which physical devices would be preferred.
template <typename ... DeviceTypes>
vkb::PhysicalDeviceSelector& prefer_gpu_device_type(DeviceTypes ... types);
Option Two: This option utilizes a struct to abstract a chain of responsibility, in which earlier GPU types in the chain take selection priority. It could look something like:
struct physical_device_type_preference
{
physical_device_type_preference& next_prefer(vkb::PreferredDeviceType type);
std::vector<vkb::PreferredDeviceType> preferences;
};
The downside to this approach is that it uses dynamically allocated memory in the vector as opposed to the variadic template argument approach. However, I think this is a relatively minor drawback, as this shouldn't be called frequently (most likely once on startup) and vectors are used elsewhere in the code.
As an aside for documentation, I think the preference order should be documented somewhere.