zink: only reject non-blittable resource creation if it has no other binds
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 20 Apr 2022 13:45:51 +0000 (09:45 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 18 May 2022 02:29:18 +0000 (02:29 +0000)
the idea here is that if a resource is intended to be used solely as a rendertarget
and can't be blitted to or drawn to, then resource creation should fail

but if the resource might be e.g., a texture, then it can probably hit the subdata
path and be fine

Fixes: 37ac8647fca ("zink: reject resource creation if format features don't match attachment")

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

src/gallium/drivers/zink/zink_resource.c

index 442a471..0bb1d1c 100644 (file)
@@ -258,7 +258,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 || !(feats & VK_FORMAT_FEATURE_BLIT_DST_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 */
          return 0;
    }