radv: do not resolve all image layers with compute inside a subpass
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 10 Jun 2019 15:45:29 +0000 (17:45 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 11 Jun 2019 06:06:28 +0000 (08:06 +0200)
When resolving inside a subpass, we should rely on the framebuffer
layer count instead of resolving all images layers. This should
improve performance of layered resolves a bit.

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

index b6c9e1c2b1faa9076115be2939a8c626c0570706..fc4bcf27bb904b19cc8da147fe216e4e3a2d067b 100644 (file)
@@ -508,6 +508,10 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
        struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
        const struct radv_subpass *subpass = cmd_buffer->state.subpass;
        struct radv_subpass_barrier barrier;
+       uint32_t layer_count = fb->layers;
+
+       if (subpass->view_mask)
+               layer_count = util_last_bit(subpass->view_mask);
 
        /* Resolves happen before the end-of-subpass barriers get executed, so
         * we have to make the attachment shader-readable.
@@ -531,14 +535,14 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
                        .srcSubresource = (VkImageSubresourceLayers) {
                                .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                                .mipLevel = src_iview->base_mip,
-                               .baseArrayLayer = 0,
-                               .layerCount = src_iview->image->info.array_size
+                               .baseArrayLayer = src_iview->base_layer,
+                               .layerCount = layer_count,
                        },
                        .dstSubresource = (VkImageSubresourceLayers) {
                                .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                                .mipLevel = dst_iview->base_mip,
-                               .baseArrayLayer = 0,
-                               .layerCount = dst_iview->image->info.array_size
+                               .baseArrayLayer = dst_iview->base_layer,
+                               .layerCount = layer_count,
                        },
                        .srcOffset = (VkOffset3D){ 0, 0, 0 },
                        .dstOffset = (VkOffset3D){ 0, 0, 0 },