Mesa (staging/22.1): zink: add extended usage and retry if resource creation fails

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 18 02:46:09 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 6c790f145dd0e7cece957453e6070008a96f8844
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c790f145dd0e7cece957453e6070008a96f8844

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Apr 20 13:29:52 2022 -0400

zink: add extended usage and retry if resource creation fails

this is one of those cases where some bizarro format is being created
for sampling only, but gallium blasts out all the bind flags at once

trust that we're not going to do anything too crazy and let surface
usage pruning handle the rest

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16563>

---

 src/gallium/drivers/zink/zink_resource.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index e9c3fb249ed..fef79c56cf5 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -268,8 +268,7 @@ get_image_usage_for_feats(struct zink_screen *screen, VkFormatFeatureFlags feats
          usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
          if ((bind & (PIPE_BIND_LINEAR | PIPE_BIND_SHARED)) != (PIPE_BIND_LINEAR | PIPE_BIND_SHARED))
             usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
-      } else if (templ->nr_samples || (bind == PIPE_BIND_RENDER_TARGET && !(feats & VK_FORMAT_FEATURE_BLIT_DST_BIT)))
-         /* this can't be populated, so we can't do it */
+      } else
          return 0;
    }
 
@@ -346,6 +345,8 @@ get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const struct
    {
       VkFormatProperties props = screen->format_props[templ->format];
       VkFormatFeatureFlags feats = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures;
+      if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)
+         feats = UINT32_MAX;
       VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, templ, bind);
       if (usage) {
          ici->usage = usage;
@@ -446,6 +447,7 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo *ici, const struct pipe
    bool first = true;
    bool tried[2] = {0};
    uint64_t mod = DRM_FORMAT_MOD_INVALID;
+retry:
    while (!ici->usage) {
       if (!first) {
          switch (ici->tiling) {
@@ -467,8 +469,15 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo *ici, const struct pipe
             unreachable("unhandled tiling mode");
          }
          if (tried[ici->tiling]) {
-            *success = false;
+            if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) {
+               *success = false;
                return DRM_FORMAT_MOD_INVALID;
+            }
+            ici->flags |= VK_IMAGE_CREATE_EXTENDED_USAGE_BIT;
+            tried[0] = false;
+            tried[1] = false;
+            first = true;
+            goto retry;
          }
       }
       ici->usage = get_image_usage(screen, ici, templ, bind, modifiers_count, modifiers, &mod);



More information about the mesa-commit mailing list