radv: add radv_image_view_can_fast_clear() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 23 Nov 2018 16:04:11 +0000 (17:04 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 29 Nov 2018 09:18:42 +0000 (10:18 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_clear.c

index d9acd194ce5c92d992ac255160d5c957c690b29f..9c124c9b6775dadab64ae99d1e393fab4b409a4c 100644 (file)
@@ -909,6 +909,31 @@ radv_image_can_fast_clear(struct radv_device *device,  struct radv_image *image)
        return true;
 }
 
+/**
+ * Determine if the given image view can be fast cleared.
+ */
+static bool
+radv_image_view_can_fast_clear(struct radv_device *device,
+                              const struct radv_image_view *iview)
+{
+       struct radv_image *image = iview->image;
+
+       /* Only fast clear if the image itself can be fast cleared. */
+       if (!radv_image_can_fast_clear(device, image))
+               return false;
+
+       /* Only fast clear if all layers are bound. */
+       if (iview->base_layer > 0 ||
+           iview->layer_count != image->info.array_size)
+               return false;
+
+       /* Only fast clear if the view covers the whole image. */
+       if (!radv_image_extent_compare(image, &iview->extent))
+               return false;
+
+       return true;
+}
+
 static bool
 emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
                      const VkClearAttachment *clear_att,
@@ -926,21 +951,12 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
        uint32_t clear_word, flush_bits;
        uint32_t htile_mask;
 
-       if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
+       if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
                return false;
 
        if (!radv_layout_is_htile_compressed(iview->image, image_layout, radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index)))
                return false;
 
-       /* all layers are bound */
-       if (iview->base_layer > 0)
-               return false;
-       if (iview->image->info.array_size != iview->layer_count)
-               return false;
-
-       if (!radv_image_extent_compare(iview->image, &iview->extent))
-               return false;
-
        if (clear_rect->rect.offset.x || clear_rect->rect.offset.y ||
            clear_rect->rect.extent.width != iview->image->info.width ||
            clear_rect->rect.extent.height != iview->image->info.height)
@@ -1369,21 +1385,12 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
        uint32_t cmask_clear_value;
        bool ret;
 
-       if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
+       if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
                return false;
 
        if (!radv_layout_can_fast_clear(iview->image, image_layout, radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index)))
                return false;
 
-       /* all layers are bound */
-       if (iview->base_layer > 0)
-               return false;
-       if (iview->image->info.array_size != iview->layer_count)
-               return false;
-
-       if (!radv_image_extent_compare(iview->image, &iview->extent))
-               return false;
-
        if (clear_rect->rect.offset.x || clear_rect->rect.offset.y ||
            clear_rect->rect.extent.width != iview->image->info.width ||
            clear_rect->rect.extent.height != iview->image->info.height)