radv: do not always initialize HTILE in compressed state
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 28 Mar 2019 15:03:03 +0000 (16:03 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 29 Mar 2019 07:28:18 +0000 (08:28 +0100)
Especially when performing a transtion from UNDEFINED->GENERAL,
the driver shouldn't initialize HTILE metadata in compressed
state because it doesn't decompress when the src layout is
GENERAL.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110259
Fixes: 3a2e93147f7 ("radv: always initialize HTILE when the src layout is UNDEFINED")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c

index bed899d686e3da083ed215c77185a7de48a3eecc..7ee5a5ca7dc46d0d24b155642762d5b50597d2ab 100644 (file)
@@ -4478,8 +4478,14 @@ static void radv_handle_depth_image_transition(struct radv_cmd_buffer *cmd_buffe
                return;
 
        if (src_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
-               /* TODO: merge with the clear if applicable */
-               radv_initialize_htile(cmd_buffer, image, range, 0);
+               uint32_t clear_value = vk_format_is_stencil(image->vk_format) ? 0xfffff30f : 0xfffc000f;
+
+               if (radv_layout_is_htile_compressed(image, dst_layout,
+                                                   dst_queue_mask)) {
+                       clear_value = 0;
+               }
+
+               radv_initialize_htile(cmd_buffer, image, range, clear_value);
        } else if (!radv_layout_is_htile_compressed(image, src_layout, src_queue_mask) &&
                   radv_layout_is_htile_compressed(image, dst_layout, dst_queue_mask)) {
                uint32_t clear_value = vk_format_is_stencil(image->vk_format) ? 0xfffff30f : 0xfffc000f;