Hello Vulkan developers,
I’ve been thinking about a proper device selection mechanism for my Vulkan renderer.
I came up with this:
(CC0 1.0)
What do you think about this?
The method which checks if a device is suitable for the application’s purposes is obviously very custom to the application, but what do you think would be a valuable feature to look for?
Currently, I require a GPU to have the following features
- swapchain
- presentation must be supported
And what do you think are the criteria by which I should rank and prioritize GPUs?
Currently I rank them by memory:
std::size_t VulkanSettingsDecisionMaker::rate_graphics_card(const VkPhysicalDevice& graphics_card)
{
assert(graphics_card);
// The score of the graphics card.
std::size_t graphics_card_score = 0;
// For now, we will only score the memory of the graphics cards.
// Therefore we calculate the sum of all memory that is
// Check memory properties of this graphics card.
VkPhysicalDeviceMemoryProperties graphics_card_memory_properties;
vkGetPhysicalDeviceMemoryProperties(graphics_card, &graphics_card_memory_properties);
// Loop through all memory heaps.
for(std::size_t i=0; i<graphics_card_memory_properties.memoryHeapCount; i++)
{
auto &propertyFlag = graphics_card_memory_properties.memoryHeaps[i].flags;
if(propertyFlag & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
{
// Use real GPU memory as score.
graphics_card_score += graphics_card_memory_properties.memoryHeaps[i].size/(1000*1000);
}
}
// TODO: Check for more features or limits.
return graphics_card_score;
}
Sincere regards
Johannes