Feedback on device selection mechanism

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)

source code

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)
	// 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;

			// 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

This flowchart seems decidedly overcomplicated, so long as you already have a mechanism to determine if a device is “suitable for the application’s purpose” as well as a mechanism to rank devices. A much simpler flowchart would be:

  1. Enumerate the devices into a list.
  2. Remove all devices which are not suitable. If none are left, error.
  3. If the user specified a GPU that’s in the list, use it.
  4. Score the suitable devices.
  5. Use the device with the highest score.

If you’re feeling fancy, you can have an early out with #4 if there is only 1 device left. Your scoring mechanism can be designed to prefer discrete GPUs over embedded ones, so that would just be part of the scoring mechanism.

And what do you think are the criteria by which I should rank and prioritize GPUs?

Whatever is appropriate for your application. That’s not something anyone else can tell you.

Thank you very much for your feedback!
I will simplify the code.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.