Browse Source

testvulkan: Add call to SDL_Vulkan_GetPresentationSupport

Ethan Lee 9 months ago
parent
commit
5d506a53a6
1 changed files with 17 additions and 0 deletions
  1. 17 0
      test/testvulkan.c

+ 17 - 0
test/testvulkan.c

@@ -307,6 +307,7 @@ static void findPhysicalDevice(void)
         uint32_t queueFamilyIndex;
         uint32_t deviceExtensionCount = 0;
         SDL_bool hasSwapchainExtension = SDL_FALSE;
+        SDL_bool supportsPresent;
         uint32_t i;
 
         VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
@@ -354,6 +355,22 @@ static void findPhysicalDevice(void)
                 quit(2);
             }
             if (supported) {
+                /* This check isn't necessary if you are able to check a
+                 * VkSurfaceKHR like above, but just as a sanity check we do
+                 * this here as part of testing the API.
+                 * -flibit
+                 */
+                supportsPresent = SDL_Vulkan_GetPresentationSupport(vulkanContext->instance, physicalDevice, queueFamilyIndex);
+                if (!supportsPresent) {
+                    SDL_free(physicalDevices);
+                    SDL_free(queueFamiliesProperties);
+                    SDL_free(deviceExtensions);
+                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                                 "SDL_Vulkan_GetPresentationSupport(): %s\n",
+                                 SDL_GetError());
+                    quit(2);
+                }
+
                 vulkanContext->presentQueueFamilyIndex = queueFamilyIndex;
                 if (queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
                     break; // use this queue because it can present and do graphics