Currently, the vulkan-cpp API's allow you to construct the physical devices and implicitly invoking the default constructor.
Rather then having constructing the vk::physical_device separately. This would be better suited for requesting from vk::instance rather then constructing a new object.
Reasons for this is the requirements needed to retrieve the physical devices available. This is information, the VkInstance handle allows you to retrieve (other words enumerate). Which should automatically just allow the instance to have the API to request what physical devices to request to perform the operation.
Goal is to reduce requirements the users may need to do to ensure they can get the objects they need to continue instantiating other handles such as the logical devices and other handles.
API Previously
vk::instance api_instance = ...;
// Does enumeration here rather then already provided to the user.
vk::physical_enumeration physical_device_params = {
.device_type = vk::physical_gpu::discrete,
};
vk::physical_device physical_device(api_instance, physical_device_params);
New API Proposal
vk::instance api_instance = ...;
// Option 1: Enumerates the available physical devices.
std::span<const vk::physical_device> gpu_devices = api_instance.request_physical_devices();
// Option 2: Might consider an API for requesting a specific single physical device
std::optional<vk::physical_device> gpu_device = api_instance.request_device(vk::physical_gpu::integrated);
std::optional<vk::physical_device> physical_device = gpu_devices[0]; // retrieve the first-most physical device (GPU).
vk::device logical_device(physical_device.value(), ...);
// Do more stuff...
Currently, the vulkan-cpp API's allow you to construct the physical devices and implicitly invoking the default constructor.
Rather then having constructing the
vk::physical_deviceseparately. This would be better suited for requesting fromvk::instancerather then constructing a new object.Reasons for this is the requirements needed to retrieve the physical devices available. This is information, the
VkInstancehandle allows you to retrieve (other words enumerate). Which should automatically just allow the instance to have the API to request what physical devices to request to perform the operation.Goal is to reduce requirements the users may need to do to ensure they can get the objects they need to continue instantiating other handles such as the logical devices and other handles.
API Previously
New API Proposal