Mesa (master): zink: verify that src/dst support blitting

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 14 15:58:51 UTC 2021


Module: Mesa
Branch: master
Commit: 0ba3cf1f953ed2a342ef729211ecf90d241385f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ba3cf1f953ed2a342ef729211ecf90d241385f8

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Wed Apr 14 16:03:38 2021 +0200

zink: verify that src/dst support blitting

Some Vulkan-drivers don't support blitting between all formats and
layouts. So let's verify this while blitting, and fall back to the
normal rendering code-path instead.

This fixes a crash on start-up in OpenArena on V3DV.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10234>

---

 src/gallium/drivers/zink/zink_blit.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c
index 980b8fad6cc..6900e42281f 100644
--- a/src/gallium/drivers/zink/zink_blit.c
+++ b/src/gallium/drivers/zink/zink_blit.c
@@ -91,6 +91,14 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info)
    return true;
 }
 
+static VkFormatFeatureFlags
+get_resource_features(struct zink_screen *screen, struct zink_resource *res)
+{
+   VkFormatProperties props = screen->format_props[res->base.b.format];
+   return res->optimal_tiling ? props.optimalTilingFeatures :
+                                props.linearTilingFeatures;
+}
+
 static bool
 blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
 {
@@ -120,6 +128,10 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
        dst->format != zink_get_format(screen, info->dst.format))
       return false;
 
+   if (!(get_resource_features(screen, src) & VK_FORMAT_FEATURE_BLIT_SRC_BIT) ||
+       !(get_resource_features(screen, dst) & VK_FORMAT_FEATURE_BLIT_DST_BIT))
+      return false;
+
    zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), false);
    zink_fb_clears_apply_region(ctx, info->src.resource, zink_rect_from_box(&info->src.box));
    struct zink_batch *batch = zink_batch_no_rp(ctx);



More information about the mesa-commit mailing list