zink: only try to create srgb mutable images if the vk format is supported
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 8 Jun 2023 01:21:04 +0000 (21:21 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Jun 2023 17:45:38 +0000 (17:45 +0000)
otherwise this is just a regular single-format image

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23626>

src/gallium/drivers/zink/zink_resource.c

index 4046996..d685117 100644 (file)
@@ -741,14 +741,19 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
       VkFormat formats[2];
       VkImageFormatListCreateInfo format_list;
       if (srgb) {
-         format_list.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO;
-         format_list.pNext = NULL;
-         format_list.viewFormatCount = 2;
-         format_list.pViewFormats = formats;
-
          formats[0] = zink_get_format(screen, templ->format);
          formats[1] = zink_get_format(screen, srgb);
-         ici.pNext = &format_list;
+         /* only use format list if both formats have supported vk equivalents */
+         if (formats[0] && formats[1]) {
+            format_list.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO;
+            format_list.pNext = NULL;
+            format_list.viewFormatCount = 2;
+            format_list.pViewFormats = formats;
+
+            ici.pNext = &format_list;
+         } else {
+            ici.pNext = NULL;
+         }
       } else {
          ici.pNext = NULL;
       }