Skip to content

Commit 1b79ba9

Browse files
committed
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.
1 parent 6976b57 commit 1b79ba9

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/gpu/vulkan/SDL_gpu_vulkan.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11395,8 +11395,7 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable(
1139511395
VulkanRenderer *renderer,
1139611396
VkPhysicalDevice physicalDevice,
1139711397
VulkanExtensions *physicalDeviceExtensions,
11398-
Uint32 *queueFamilyIndex,
11399-
Uint64 *deviceRank)
11398+
Uint32 *queueFamilyIndex)
1140011399
{
1140111400
Uint32 queueFamilyCount, queueFamilyRank, queueFamilyBest;
1140211401
VkQueueFamilyProperties *queueProps;
@@ -11499,15 +11498,6 @@ static Uint8 VULKAN_INTERNAL_IsDeviceSuitable(
1149911498
return 0;
1150011499
}
1150111500

11502-
// Now that we know this device supports what we need, rank it against any other devices
11503-
if (!VULKAN_INTERNAL_GetDeviceRank(
11504-
renderer,
11505-
physicalDevice,
11506-
physicalDeviceExtensions,
11507-
deviceRank)) {
11508-
return 0;
11509-
}
11510-
1151111501
// FIXME: Need better structure for checking vs storing swapchain support details
1151211502
return 1;
1151311503
}
@@ -11519,8 +11509,8 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
1151911509
VulkanExtensions *physicalDeviceExtensions;
1152011510
Uint32 i, physicalDeviceCount;
1152111511
Sint32 suitableIndex;
11522-
Uint32 queueFamilyIndex, suitableQueueFamilyIndex;
11523-
Uint64 deviceRank, highestRank;
11512+
Uint32 suitableQueueFamilyIndex;
11513+
Uint64 highestRank;
1152411514

1152511515
vulkanResult = renderer->vkEnumeratePhysicalDevices(
1152611516
renderer->instance,
@@ -11566,12 +11556,23 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
1156611556
suitableQueueFamilyIndex = 0;
1156711557
highestRank = 0;
1156811558
for (i = 0; i < physicalDeviceCount; i += 1) {
11559+
Uint32 queueFamilyIndex;
11560+
Uint64 deviceRank;
11561+
11562+
if (!VULKAN_INTERNAL_IsDeviceSuitable(
11563+
renderer,
11564+
physicalDevices[i],
11565+
&physicalDeviceExtensions[i],
11566+
&queueFamilyIndex)) {
11567+
// Device does not meet the minimum requirements, skip it entirely
11568+
continue;
11569+
}
11570+
1156911571
deviceRank = highestRank;
11570-
if (VULKAN_INTERNAL_IsDeviceSuitable(
11572+
if (VULKAN_INTERNAL_GetDeviceRank(
1157111573
renderer,
1157211574
physicalDevices[i],
1157311575
&physicalDeviceExtensions[i],
11574-
&queueFamilyIndex,
1157511576
&deviceRank)) {
1157611577
/* Use this for rendering.
1157711578
* Note that this may override a previous device that

0 commit comments

Comments
 (0)