From 3050e202833ab3c3ee5e91ee82ee823d8efac563 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 19 Oct 2021 10:25:46 -0700 Subject: [PATCH] freedreno/fdl6: Add support for texture swizzles of A/L/I/LA/RGBx. 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: --- src/freedreno/fdl/fd6_view.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/freedreno/fdl/fd6_view.c b/src/freedreno/fdl/fd6_view.c index 37a46781ccf..8b611080996 100644 --- a/src/freedreno/fdl/fd6_view.c +++ b/src/freedreno/fdl/fd6_view.c @@ -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; }