[4/7] radv: select the depth/stencil resolve method based on some conditions

Submitted by Samuel Pitoiset on May 27, 2019, 3:41 p.m.

Details

Message ID 20190527154150.23144-5-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv: implement VK_KHR_depth_stencil_resolve" ( rev: 1 ) in Mesa

Commit Message

Samuel Pitoiset May 27, 2019, 3:41 p.m.
Only fallback to the compute path for layers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_meta_resolve.c | 77 +++++++++++++++++++++++++-----
 1 file changed, 64 insertions(+), 13 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 1544513a9bc..2d048207b7a 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -341,20 +341,28 @@  static void radv_pick_resolve_method_images(struct radv_image *src_image,
 	                                                   cmd_buffer->queue_family_index,
 	                                                   cmd_buffer->queue_family_index);
 
-	if (src_image->vk_format == VK_FORMAT_R16G16_UNORM ||
-	    src_image->vk_format == VK_FORMAT_R16G16_SNORM)
-		*method = RESOLVE_COMPUTE;
-	else if (vk_format_is_int(src_image->vk_format))
-		*method = RESOLVE_COMPUTE;
-	else if (src_image->info.array_size > 1 ||
-		 dest_image->info.array_size > 1)
-		*method = RESOLVE_COMPUTE;
+	if (vk_format_is_color(src_image->vk_format)) {
+		if (src_image->vk_format == VK_FORMAT_R16G16_UNORM ||
+		    src_image->vk_format == VK_FORMAT_R16G16_SNORM)
+			*method = RESOLVE_COMPUTE;
+		else if (vk_format_is_int(src_image->vk_format))
+			*method = RESOLVE_COMPUTE;
+		else if (src_image->info.array_size > 1 ||
+			 dest_image->info.array_size > 1)
+			*method = RESOLVE_COMPUTE;
 	
-	if (radv_layout_dcc_compressed(dest_image, dest_image_layout, queue_mask)) {
-		*method = RESOLVE_FRAGMENT;
-	} else if (dest_image->planes[0].surface.micro_tile_mode !=
-	           src_image->planes[0].surface.micro_tile_mode) {
-		*method = RESOLVE_COMPUTE;
+		if (radv_layout_dcc_compressed(dest_image, dest_image_layout, queue_mask)) {
+			*method = RESOLVE_FRAGMENT;
+		} else if (dest_image->planes[0].surface.micro_tile_mode !=
+		           src_image->planes[0].surface.micro_tile_mode) {
+			*method = RESOLVE_COMPUTE;
+		}
+	} else {
+		if (src_image->info.array_size > 1 ||
+		    dest_image->info.array_size > 1)
+			*method = RESOLVE_COMPUTE;
+		else
+			*method = RESOLVE_FRAGMENT;
 	}
 }
 
@@ -621,6 +629,49 @@  radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
 	if (!subpass->has_resolve)
 		return;
 
+	if (subpass->ds_resolve_attachment) {
+		struct radv_subpass_attachment src_att = *subpass->depth_stencil_attachment;
+		struct radv_subpass_attachment dst_att = *subpass->ds_resolve_attachment;
+		struct radv_image_view *src_iview =
+			cmd_buffer->state.framebuffer->attachments[src_att.attachment].attachment;
+		struct radv_image_view *dst_iview =
+			cmd_buffer->state.framebuffer->attachments[dst_att.attachment].attachment;
+
+		radv_pick_resolve_method_images(src_iview->image,
+						dst_iview->image,
+						dst_att.layout,
+						cmd_buffer,
+						&resolve_method);
+
+		if ((src_iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) &&
+		    subpass->depth_resolve_mode != VK_RESOLVE_MODE_NONE_KHR) {
+			if (resolve_method == RESOLVE_FRAGMENT) {
+				radv_depth_stencil_resolve_subpass_fs(cmd_buffer,
+								      VK_IMAGE_ASPECT_DEPTH_BIT,
+								      subpass->depth_resolve_mode);
+			} else {
+				assert(resolve_method == RESOLVE_COMPUTE);
+				radv_depth_stencil_resolve_subpass_cs(cmd_buffer,
+								      VK_IMAGE_ASPECT_DEPTH_BIT,
+								      subpass->depth_resolve_mode);
+			}
+		}
+
+		if ((src_iview->aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) &&
+		    subpass->stencil_resolve_mode != VK_RESOLVE_MODE_NONE_KHR) {
+			if (resolve_method == RESOLVE_FRAGMENT) {
+				radv_depth_stencil_resolve_subpass_fs(cmd_buffer,
+								      VK_IMAGE_ASPECT_STENCIL_BIT,
+								      subpass->stencil_resolve_mode);
+			} else {
+				assert(resolve_method == RESOLVE_COMPUTE);
+				radv_depth_stencil_resolve_subpass_cs(cmd_buffer,
+								      VK_IMAGE_ASPECT_STENCIL_BIT,
+								      subpass->stencil_resolve_mode);
+			}
+		}
+	}
+
 	for (uint32_t i = 0; i < subpass->color_count; ++i) {
 		struct radv_subpass_attachment src_att = subpass->color_attachments[i];
 		struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];