Mesa (master): radv: Decompress copy destination if formats are incompatible.

Bas Nieuwenhuizen bnieuwenhuizen at kemper.freedesktop.org
Fri Dec 29 11:25:12 UTC 2017


Module: Mesa
Branch: master
Commit: eb9a4c34647a05272610d343f5c0f323dd612278
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb9a4c34647a05272610d343f5c0f323dd612278

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Fri Dec 29 01:57:17 2017 +0100

radv: Decompress copy destination if formats are incompatible.

If both source and destination are DCC compressed, and their formats
are not compatible, we need to decompress one of them to make
sure we can do reinterpretation (which needs src format == dst format)
.

Reviewed-by: Dave Airlie <airlied at redhat.com>
Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>

---

 src/amd/vulkan/radv_meta_copy.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 29951f2ba4..7f7ef22efc 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -369,8 +369,31 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
 							dest_image_layout,
 							&pRegions[r].dstSubresource);
 
-		/* for DCC */
-		b_src.format = b_dst.format;
+		uint32_t dst_queue_mask = radv_image_queue_family_mask(dest_image,
+		                                                       cmd_buffer->queue_family_index,
+		                                                       cmd_buffer->queue_family_index);
+		bool dst_compressed = radv_layout_dcc_compressed(dest_image, dest_image_layout, dst_queue_mask);
+		uint32_t src_queue_mask = radv_image_queue_family_mask(src_image,
+		                                                       cmd_buffer->queue_family_index,
+		                                                       cmd_buffer->queue_family_index);
+		bool src_compressed = radv_layout_dcc_compressed(src_image, src_image_layout, src_queue_mask);
+
+		if (!src_compressed || radv_dcc_formats_compatible(b_src.format, b_dst.format)) {
+			b_src.format = b_dst.format;
+		} else if (!dst_compressed) {
+			b_dst.format = b_src.format;
+		} else {
+			radv_decompress_dcc(cmd_buffer, dest_image, &(VkImageSubresourceRange) {
+			                        .aspectMask = pRegions[r].dstSubresource.aspectMask,
+			                        .baseMipLevel = pRegions[r].dstSubresource.mipLevel,
+			                        .levelCount = 1,
+			                        .baseArrayLayer = pRegions[r].dstSubresource.baseArrayLayer,
+			                        .layerCount = pRegions[r].dstSubresource.layerCount,
+			                    });
+			b_dst.format = b_src.format;
+			b_dst.current_layout = VK_IMAGE_LAYOUT_GENERAL;
+		}
+
 
 		/**
 		 * From the Vulkan 1.0.6 spec: 18.4 Copying Data Between Buffers and Images




More information about the mesa-commit mailing list