zink: don't force attachment usage for images when unsupported
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 10 Oct 2022 11:58:13 +0000 (07:58 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 28 Oct 2022 00:51:48 +0000 (00:51 +0000)
this is illegal even with EXTENDED_USAGE, but it will also probably
explode later when trying to populate the image

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

src/gallium/drivers/zink/zink_resource.c

index 2e558c6..66fe35c 100644 (file)
@@ -421,6 +421,17 @@ get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const struct
       }
       if (double_check_ici(screen, ici, usage, mod))
          return usage;
+      if (util_format_is_depth_or_stencil(templ->format)) {
+         if (!(templ->bind & PIPE_BIND_DEPTH_STENCIL)) {
+            usage &= ~VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
+            if (double_check_ici(screen, ici, usage, mod))
+               return usage;
+         }
+      } else if (!(templ->bind & PIPE_BIND_RENDER_TARGET)) {
+         usage &= ~VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+         if (double_check_ici(screen, ici, usage, mod))
+            return usage;
+      }
    }
    *mod = DRM_FORMAT_MOD_INVALID;
    return 0;