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@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10234>
diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c
index 980b8fa..6900e42 100644
--- a/src/gallium/drivers/zink/zink_blit.c
+++ b/src/gallium/drivers/zink/zink_blit.c
@@ -91,6 +91,14 @@
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 @@
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);