radv: add radv_dcc_clear_level() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Jun 2019 07:17:34 +0000 (09:17 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 20 Jun 2019 09:03:53 +0000 (11:03 +0200)
For clearing only one level.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta.h
src/amd/vulkan/radv_meta_clear.c

index 0cb31b9a7ec788c7dbd958595cddecca025620d8..5880064ff30ed307db72ec0d1725b98fb42f6d75 100644 (file)
@@ -218,6 +218,9 @@ uint32_t radv_clear_fmask(struct radv_cmd_buffer *cmd_buffer,
 uint32_t radv_clear_dcc(struct radv_cmd_buffer *cmd_buffer,
                        struct radv_image *image,
                        const VkImageSubresourceRange *range, uint32_t value);
+uint32_t radv_dcc_clear_level(struct radv_cmd_buffer *cmd_buffer,
+                             const struct radv_image *image,
+                             uint32_t level, uint32_t value);
 uint32_t radv_clear_htile(struct radv_cmd_buffer *cmd_buffer,
                          struct radv_image *image,
                          const VkImageSubresourceRange *range, uint32_t value);
index c43ed6eeef165d9649430f54fd496a7f37e1ec4d..dea0cae6d967f9d72bab9f8aea251b4ca4c9f535 100644 (file)
@@ -1333,6 +1333,32 @@ radv_clear_fmask(struct radv_cmd_buffer *cmd_buffer,
                                image->fmask.size, value);
 }
 
+uint32_t
+radv_dcc_clear_level(struct radv_cmd_buffer *cmd_buffer,
+                    const struct radv_image *image,
+                    uint32_t level, uint32_t value)
+{
+       uint64_t offset = image->offset + image->dcc_offset;
+       uint32_t size;
+
+       if (cmd_buffer->device->physical_device->rad_info.chip_class >= GFX9) {
+               /* Mipmap levels aren't implemented. */
+               assert(level == 0);
+               size = image->planes[0].surface.dcc_size;
+       } else {
+               const struct legacy_surf_level *surf_level =
+                       &image->planes[0].surface.u.legacy.level[level];
+
+               /* If this is 0, fast clear isn't possible. */
+               assert(surf_level->dcc_fast_clear_size);
+
+               offset += surf_level->dcc_offset;
+               size = surf_level->dcc_fast_clear_size;
+       }
+
+       return radv_fill_buffer(cmd_buffer, image->bo, offset, size, value);
+}
+
 uint32_t
 radv_clear_dcc(struct radv_cmd_buffer *cmd_buffer,
               struct radv_image *image,
@@ -1341,9 +1367,7 @@ radv_clear_dcc(struct radv_cmd_buffer *cmd_buffer,
        /* Mark the image as being compressed. */
        radv_update_dcc_metadata(cmd_buffer, image, range, true);
 
-       return radv_fill_buffer(cmd_buffer, image->bo,
-                               image->offset + image->dcc_offset,
-                               image->planes[0].surface.dcc_size, value);
+       return radv_dcc_clear_level(cmd_buffer, image, 0, value);
 }
 
 uint32_t