From 3bb138ce3e98e7059351a707382d78ad5fb28d49 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sun, 13 Dec 2020 10:25:37 -0500 Subject: [PATCH] zink: handle blitting of color formats with ignored alpha channels for e.g., R8G8B8X8 -> R8G8B8A8, we have to force a u_blitter call in order to use a sampler which ignores alpha, otherwise we end up with broken rendering Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/zink/zink_blit.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c index dae9d08bd9f..829fbd357b0 100644 --- a/src/gallium/drivers/zink/zink_blit.c +++ b/src/gallium/drivers/zink/zink_blit.c @@ -182,13 +182,22 @@ zink_blit(struct pipe_context *pctx, const struct pipe_blit_info *info) { struct zink_context *ctx = zink_context(pctx); - if (info->src.resource->nr_samples > 1 && - info->dst.resource->nr_samples <= 1) { - if (blit_resolve(ctx, info)) - return; - } else { - if (blit_native(ctx, info)) - return; + const struct util_format_description *src_desc = util_format_description(info->src.format); + const struct util_format_description *dst_desc = util_format_description(info->dst.format); + if (src_desc == dst_desc || + src_desc->nr_channels != 4 || src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN || + (src_desc->nr_channels == 4 && src_desc->channel[3].type != UTIL_FORMAT_TYPE_VOID)) { + /* we can't blit RGBX -> RGBA formats directly since they're emulated + * so we have to use sampler views + */ + if (info->src.resource->nr_samples > 1 && + info->dst.resource->nr_samples <= 1) { + if (blit_resolve(ctx, info)) + return; + } else { + if (blit_native(ctx, info)) + return; + } } struct zink_resource *src = zink_resource(info->src.resource);