Closed Cleptomania closed 1 year ago
Many thanks for the suggestion.
Actually, the code iterates over available phsysical devices and checks if they support swap chain and graphics queue. With all of these candidates, we try to select the one that is on the properties file. It is explained that you may want to add additional heuristics, such as the approach tou propose, to select the most performant device. In any case, I would prefer not to add more code and complicate first chapters.
Currently in (I believe) every chapter of the book from the point at which physical devices are introduced onwards uses a hard set device name in the
eng.properties
file to select a device. A better approach could be to find the first available device with the required features(like the KHR swapchain extension and a graphics queue family for example).To expand on that, could even have it score devices based on extra features, such as prioritize a discrete over integrated GPU, etc. This technique shows a quick implementation in the C vulkan-tutorial here.
A rough idea of what this might look like in this project might be something like below. This is definitely open to further thoughts and development but I've tested the implementation and it works at least. I would think if this were to be included it would make sense to include from the physical devices initial implementation onwards
Create a new method
rateDeviceSuitability
in PhysicalDevice:Then update the
createPhysicalDevice
function to work something like this: