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, VulkanRenderer *renderer,
VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice,
VulkanExtensions *physicalDeviceExtensions, VulkanExtensions *physicalDeviceExtensions,
Uint32 *queueFamilyIndex, Uint32 *queueFamilyIndex)
Uint64 *deviceRank)
{ {
Uint32 queueFamilyCount, queueFamilyRank, queueFamilyBest; Uint32 queueFamilyCount, queueFamilyRank, queueFamilyBest;
VkQueueFamilyProperties *queueProps; VkQueueFamilyProperties *queueProps;
@@ -11499,15 +11498,6 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable(
return 0; 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 // FIXME: Need better structure for checking vs storing swapchain support details
return 1; return 1;
} }
@@ -11519,8 +11509,8 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
VulkanExtensions *physicalDeviceExtensions; VulkanExtensions *physicalDeviceExtensions;
Uint32 i, physicalDeviceCount; Uint32 i, physicalDeviceCount;
Sint32 suitableIndex; Sint32 suitableIndex;
Uint32 queueFamilyIndex, suitableQueueFamilyIndex; Uint32 suitableQueueFamilyIndex;
Uint64 deviceRank, highestRank; Uint64 highestRank;
vulkanResult = renderer->vkEnumeratePhysicalDevices( vulkanResult = renderer->vkEnumeratePhysicalDevices(
renderer->instance, renderer->instance,
@@ -11566,12 +11556,23 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
suitableQueueFamilyIndex = 0; suitableQueueFamilyIndex = 0;
highestRank = 0; highestRank = 0;
for (i = 0; i < physicalDeviceCount; i += 1) { for (i = 0; i < physicalDeviceCount; i += 1) {
deviceRank = highestRank; Uint32 queueFamilyIndex;
if (VULKAN_INTERNAL_IsDeviceSuitable( 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, renderer,
physicalDevices[i], physicalDevices[i],
&physicalDeviceExtensions[i], &physicalDeviceExtensions[i],
&queueFamilyIndex,
&deviceRank)) { &deviceRank)) {
/* Use this for rendering. /* Use this for rendering.
* Note that this may override a previous device that * Note that this may override a previous device that