zink: handle blitting of color formats with ignored alpha channels
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sun, 13 Dec 2020 15:25:37 +0000 (10:25 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 23 Mar 2021 15:55:20 +0000 (15:55 +0000)
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 <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9607>

src/gallium/drivers/zink/zink_blit.c

index dae9d08..829fbd3 100644 (file)
@@ -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);