gpu: Separate device suitability from device rank when enumerating Vulkan devices.

This makes it a bit clearer what the "minimum" is vs. the "best", which should be two separate queries.
This commit is contained in:
Ethan Lee
2025-11-07 12:33:04 -05:00
parent 6976b57988
commit 1b79ba9ab6

View File

@@ -11395,8 +11395,7 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable(
VulkanRenderer *renderer,
VkPhysicalDevice physicalDevice,
VulkanExtensions *physicalDeviceExtensions,
Uint32 *queueFamilyIndex,
Uint64 *deviceRank)
Uint32 *queueFamilyIndex)
{
Uint32 queueFamilyCount, queueFamilyRank, queueFamilyBest;
VkQueueFamilyProperties *queueProps;
@@ -11499,15 +11498,6 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable(
return 0;
}
// Now that we know this device supports what we need, rank it against any other devices
if (!VULKAN_INTERNAL_GetDeviceRank(
renderer,
physicalDevice,
physicalDeviceExtensions,
deviceRank)) {
return 0;
}
// FIXME: Need better structure for checking vs storing swapchain support details
return 1;
}
@@ -11519,8 +11509,8 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
VulkanExtensions *physicalDeviceExtensions;
Uint32 i, physicalDeviceCount;
Sint32 suitableIndex;
Uint32 queueFamilyIndex, suitableQueueFamilyIndex;
Uint64 deviceRank, highestRank;
Uint32 suitableQueueFamilyIndex;
Uint64 highestRank;
vulkanResult = renderer->vkEnumeratePhysicalDevices(
renderer->instance,
@@ -11566,12 +11556,23 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
suitableQueueFamilyIndex = 0;
highestRank = 0;
for (i = 0; i < physicalDeviceCount; i += 1) {
deviceRank = highestRank;
if (VULKAN_INTERNAL_IsDeviceSuitable(
Uint32 queueFamilyIndex;
Uint64 deviceRank;
if (!VULKAN_INTERNAL_IsDeviceSuitable(
renderer,
physicalDevices[i],
&physicalDeviceExtensions[i],
&queueFamilyIndex)) {
// Device does not meet the minimum requirements, skip it entirely
continue;
}
deviceRank = highestRank;
if (VULKAN_INTERNAL_GetDeviceRank(
renderer,
physicalDevices[i],
&physicalDeviceExtensions[i],
&queueFamilyIndex,
&deviceRank)) {
/* Use this for rendering.
* Note that this may override a previous device that