radv: fix DCC fast clear code for intensity formats (correctly)
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 16 Oct 2019 20:51:08 +0000 (22:51 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 17 Oct 2019 13:29:43 +0000 (15:29 +0200)
Previous fix was pretty bogus.

This fixes a rendering regression with Nier (minimap too large).

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1943
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1952
Fixes: ea92273cea8 ("radv: fix DCC fast clear code for intensity formats")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_clear.c

index 6002fc87a61f40fe9683263225a50ef3b83945bb..0a967fc177ad4b06576fc02b37d7f1a6548ac4c9 100644 (file)
@@ -1461,6 +1461,8 @@ static void vi_get_fast_clear_parameters(struct radv_device *device,
        int extra_channel;
        bool main_value = false;
        bool extra_value = false;
+       bool has_color = false;
+       bool has_alpha = false;
        int i;
        *can_avoid_fast_clear_elim = false;
 
@@ -1479,9 +1481,6 @@ static void vi_get_fast_clear_parameters(struct radv_device *device,
        } else
                return;
 
-       bool image_alpha_is_on_msb = vi_alpha_is_on_msb(device, image_format);
-       bool view_alpha_is_on_msb = vi_alpha_is_on_msb(device, view_format);
-
        for (i = 0; i < 4; i++) {
                int index = desc->swizzle[i] - VK_SWIZZLE_X;
                if (desc->swizzle[i] < VK_SWIZZLE_X ||
@@ -1510,23 +1509,21 @@ static void vi_get_fast_clear_parameters(struct radv_device *device,
                                return;
                }
 
-               if (index == extra_channel)
+               if (index == extra_channel) {
                        extra_value = values[i];
-               else
+                       has_alpha = true;
+               } else {
                        main_value = values[i];
+                       has_color = true;
+               }
        }
 
        /* If alpha isn't present, make it the same as color, and vice versa. */
-       if (!extra_value)
+       if (!has_alpha)
                extra_value = main_value;
-       else if (!main_value)
+       else if (!has_color)
                main_value = extra_value;
 
-       if (main_value != extra_value) {
-               assert(image_alpha_is_on_msb == view_alpha_is_on_msb);
-               return; /* require ELIMINATE_FAST_CLEAR */
-       }
-
        for (int i = 0; i < 4; ++i)
                if (values[i] != main_value &&
                    desc->swizzle[i] - VK_SWIZZLE_X != extra_channel &&