freedreno/fdl6: Add support for texture swizzles of A/L/I/LA/RGBx.
authorEmma Anholt <emma@anholt.net>
Tue, 19 Oct 2021 17:25:46 +0000 (10:25 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 Nov 2021 19:38:48 +0000 (19:38 +0000)
To convert freedreno over, we need to support these formats where we remap
R or RG formats to GL compat ones, or RGBA to RGBx.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13635>

src/freedreno/fdl/fd6_view.c

index 37a4678..8b61108 100644 (file)
@@ -89,7 +89,33 @@ fdl6_texswiz(const struct fdl_view_args *args, bool has_z24uint_s8uint)
          format_swiz[1] = PIPE_SWIZZLE_0;
       }
       break;
+
    default:
+      /* Our I, L, A, and LA formats use R or RG HW formats. */
+      if (util_format_is_alpha(args->format)) {
+         format_swiz[0] = PIPE_SWIZZLE_0;
+         format_swiz[1] = PIPE_SWIZZLE_0;
+         format_swiz[2] = PIPE_SWIZZLE_0;
+         format_swiz[3] = PIPE_SWIZZLE_X;
+      } else if (util_format_is_luminance(args->format)) {
+         format_swiz[0] = PIPE_SWIZZLE_X;
+         format_swiz[1] = PIPE_SWIZZLE_X;
+         format_swiz[2] = PIPE_SWIZZLE_X;
+         format_swiz[3] = PIPE_SWIZZLE_1;
+      } else if (util_format_is_intensity(args->format)) {
+         format_swiz[0] = PIPE_SWIZZLE_X;
+         format_swiz[1] = PIPE_SWIZZLE_X;
+         format_swiz[2] = PIPE_SWIZZLE_X;
+         format_swiz[3] = PIPE_SWIZZLE_X;
+      } else if (util_format_is_luminance_alpha(args->format)) {
+         format_swiz[0] = PIPE_SWIZZLE_X;
+         format_swiz[1] = PIPE_SWIZZLE_X;
+         format_swiz[2] = PIPE_SWIZZLE_X;
+         format_swiz[3] = PIPE_SWIZZLE_Y;
+      } else if (!util_format_has_alpha(args->format)) {
+         /* for rgbx, force A to 1.  Harmless for R/RG, where we already get 1. */
+         format_swiz[3] = PIPE_SWIZZLE_1;
+      }
       break;
    }