radeonsi: fix ALPHA_IS_ON_MSB determination
authorMarek Olšák <marek.olsak@amd.com>
Tue, 22 Mar 2022 07:15:01 +0000 (03:15 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 22 Apr 2022 20:52:26 +0000 (20:52 +0000)
based on PAL

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15965>

src/gallium/drivers/radeonsi/si_clear.c

index c54f1fd..69b1163 100644 (file)
@@ -169,15 +169,15 @@ bool vi_alpha_is_on_msb(struct si_screen *sscreen, enum pipe_format format)
 {
    format = si_simplify_cb_format(format);
    const struct util_format_description *desc = util_format_description(format);
+   unsigned comp_swap = si_translate_colorswap(format, false);
 
-   /* Formats with 3 channels can't have alpha. */
-   if (desc->nr_channels == 3)
-      return true; /* same as xxxA; is any value OK here? */
-
-   if (sscreen->info.chip_class >= GFX10 && desc->nr_channels == 1)
-      return desc->swizzle[3] == PIPE_SWIZZLE_X;
+   /* The following code matches the hw behavior. */
+   if (desc->nr_channels == 1) {
+      return (comp_swap == V_028C70_SWAP_ALT_REV) != (sscreen->info.family == CHIP_RAVEN2 ||
+                                                      sscreen->info.family == CHIP_RENOIR);
+   }
 
-   return si_translate_colorswap(format, false) <= 1;
+   return comp_swap != V_028C70_SWAP_STD_REV && comp_swap != V_028C70_SWAP_ALT_REV;
 }
 
 static bool vi_get_fast_clear_parameters(struct si_screen *sscreen, enum pipe_format base_format,