cube: Remove unncessary VK_FORMAT_UNDEFINED check for surface formats
authorJoshua Ashton <joshua@froggi.es>
Thu, 2 Apr 2020 05:07:47 +0000 (06:07 +0100)
committerjeremyk-lunarg <jeremyk@lunarg.com>
Mon, 6 Apr 2020 19:54:26 +0000 (13:54 -0600)
From the spec: The number of format pairs supported must be greater than or equal to 1. pSurfaceFormats must not contain an entry whose value for format is VK_FORMAT_UNDEFINED.

cube/cube.c

index 83c5318..7de8e26 100644 (file)
@@ -3489,15 +3489,8 @@ static void demo_init_vk_swapchain(struct demo *demo) {
     VkSurfaceFormatKHR *surfFormats = (VkSurfaceFormatKHR *)malloc(formatCount * sizeof(VkSurfaceFormatKHR));
     err = demo->fpGetPhysicalDeviceSurfaceFormatsKHR(demo->gpu, demo->surface, &formatCount, surfFormats);
     assert(!err);
-    // If the format list includes just one entry of VK_FORMAT_UNDEFINED,
-    // the surface has no preferred format.  Otherwise, at least one
-    // supported format will be returned.
-    if (formatCount == 1 && surfFormats[0].format == VK_FORMAT_UNDEFINED) {
-        demo->format = VK_FORMAT_B8G8R8A8_UNORM;
-    } else {
-        assert(formatCount >= 1);
-        demo->format = surfFormats[0].format;
-    }
+    assert(formatCount >= 1);
+    demo->format = surfFormats[0].format;
     demo->color_space = surfFormats[0].colorSpace;
     free(surfFormats);