radv: handle layered fast clears.
authorDave Airlie <airlied@redhat.com>
Sun, 19 Feb 2017 06:33:14 +0000 (16:33 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 19 Feb 2017 10:30:01 +0000 (20:30 +1000)
This iterates the fast clear flush across the layers in the
specified range.

It also moves the compute resolve flush into the function
and builds the range in there.

This fixes:
dEQP-VK.geometry.layered.* regressions since fast clears.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_meta.h
src/amd/vulkan/radv_meta_fast_clear.c
src/amd/vulkan/radv_meta_resolve.c
src/amd/vulkan/radv_meta_resolve_cs.c

index 661d98282510e9526958e36940e1cf4623b40b91..ef44859ccf03095febcecf423cd59fe40036522d 100644 (file)
@@ -2702,7 +2702,7 @@ static void radv_handle_cmask_image_transition(struct radv_cmd_buffer *cmd_buffe
                        radv_initialise_cmask(cmd_buffer, image, 0xffffffffu);
        } else if (radv_layout_can_fast_clear(image, src_layout, src_queue_mask) &&
                   !radv_layout_can_fast_clear(image, dst_layout, dst_queue_mask)) {
-               radv_fast_clear_flush_image_inplace(cmd_buffer, image);
+               radv_fast_clear_flush_image_inplace(cmd_buffer, image, range);
        }
 }
 
@@ -2736,7 +2736,7 @@ static void radv_handle_dcc_image_transition(struct radv_cmd_buffer *cmd_buffer,
                radv_initialize_dcc(cmd_buffer, image, 0x20202020u);
        } else if (radv_layout_can_fast_clear(image, src_layout, src_queue_mask) &&
                   !radv_layout_can_fast_clear(image, dst_layout, dst_queue_mask)) {
-               radv_fast_clear_flush_image_inplace(cmd_buffer, image);
+               radv_fast_clear_flush_image_inplace(cmd_buffer, image, range);
        }
 }
 
index 55f3a4b132788671e59fe0ec82209aca501c3730..8eb3df3a2de96b4bd351854dbaa2dde44aea0efb 100644 (file)
@@ -194,7 +194,8 @@ void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                          struct radv_image *image,
                                          VkImageSubresourceRange *subresourceRange);
 void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
-                                        struct radv_image *image);
+                                        struct radv_image *image,
+                                        const VkImageSubresourceRange *subresourceRange);
 
 void radv_meta_save_graphics_reset_vport_scissor(struct radv_meta_saved_state *saved_state,
                                                 struct radv_cmd_buffer *cmd_buffer);
index 950b438df7c40779529b8bb83e55ccdacc8bfe78..0902c4550375e6a236c0b571e18011c3b5f0dd44 100644 (file)
@@ -412,7 +412,8 @@ emit_fast_clear_flush(struct radv_cmd_buffer *cmd_buffer,
  */
 void
 radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
-                                   struct radv_image *image)
+                                   struct radv_image *image,
+                                   const VkImageSubresourceRange *subresourceRange)
 {
        struct radv_meta_saved_state saved_state;
        struct radv_meta_saved_pass_state saved_pass_state;
@@ -423,38 +424,42 @@ radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
        radv_meta_save_pass(&saved_pass_state, cmd_buffer);
        radv_meta_save_graphics_reset_vport_scissor(&saved_state, cmd_buffer);
 
-       struct radv_image_view iview;
-       radv_image_view_init(&iview, cmd_buffer->device,
-                            &(VkImageViewCreateInfo) {
-                                    .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
+       for (uint32_t layer = 0; layer < subresourceRange->layerCount;
+            ++layer) {
+               struct radv_image_view iview;
+
+               radv_image_view_init(&iview, cmd_buffer->device,
+                                    &(VkImageViewCreateInfo) {
+                                            .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
                                             .image = radv_image_to_handle(image),
+                                            .viewType = radv_meta_get_view_type(image),
                                             .format = image->vk_format,
                                             .subresourceRange = {
                                                     .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                                                     .baseMipLevel = 0,
                                                     .levelCount = 1,
-                                                    .baseArrayLayer = 0,
+                                                    .baseArrayLayer = subresourceRange->baseArrayLayer + layer,
                                                     .layerCount = 1,
-                                            },
+                                             },
                                     },
                                     cmd_buffer, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
-       VkFramebuffer fb_h;
-       radv_CreateFramebuffer(device_h,
-                              &(VkFramebufferCreateInfo) {
-                                      .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
-                                      .attachmentCount = 1,
-                                      .pAttachments = (VkImageView[]) {
-                                              radv_image_view_to_handle(&iview)
-                                      },
+               VkFramebuffer fb_h;
+               radv_CreateFramebuffer(device_h,
+                               &(VkFramebufferCreateInfo) {
+                                       .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
+                                       .attachmentCount = 1,
+                                       .pAttachments = (VkImageView[]) {
+                                               radv_image_view_to_handle(&iview)
+                                       },
                                       .width = image->extent.width,
                                       .height = image->extent.height,
                                       .layers = 1
-                             },
-                             &cmd_buffer->pool->alloc,
-                             &fb_h);
+                               },
+                               &cmd_buffer->pool->alloc,
+                               &fb_h);
 
-       radv_CmdBeginRenderPass(cmd_buffer_h,
+               radv_CmdBeginRenderPass(cmd_buffer_h,
                                      &(VkRenderPassBeginInfo) {
                                              .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
                                                      .renderPass = cmd_buffer->device->meta_state.fast_clear_flush.pass,
@@ -474,14 +479,15 @@ radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                     },
                                     VK_SUBPASS_CONTENTS_INLINE);
 
-       emit_fast_clear_flush(cmd_buffer,
-                             &(VkExtent2D) { image->extent.width, image->extent.height },
-                             image->fmask.size > 0);
-       radv_CmdEndRenderPass(cmd_buffer_h);
+               emit_fast_clear_flush(cmd_buffer,
+                                     &(VkExtent2D) { image->extent.width, image->extent.height },
+                                     image->fmask.size > 0);
+               radv_CmdEndRenderPass(cmd_buffer_h);
 
-       radv_DestroyFramebuffer(device_h, fb_h,
-                               &cmd_buffer->pool->alloc);
+               radv_DestroyFramebuffer(device_h, fb_h,
+                                       &cmd_buffer->pool->alloc);
 
+       }
        radv_meta_restore(&saved_state, cmd_buffer);
        radv_meta_restore_pass(&saved_pass_state, cmd_buffer);
 }
index 23ca569d801b76600c12acc82bcff90a277c02af..288a1479debecba7dbc4998baa23a135c3b45247 100644 (file)
@@ -404,7 +404,6 @@ void radv_CmdResolveImage(
 
        if (use_compute_resolve) {
 
-               radv_fast_clear_flush_image_inplace(cmd_buffer, src_image);
                radv_meta_resolve_compute_image(cmd_buffer,
                                                src_image,
                                                src_image_layout,
index bfe4ceed8e6fc9b82c4fe6d887a8fff2d7ceb1ac..9cb4ce810946fd14f74018dd48ae4d3621dc85e5 100644 (file)
@@ -350,6 +350,14 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
                const struct VkOffset3D dstOffset =
                        radv_sanitize_image_offset(dest_image->type, region->dstOffset);
 
+               VkImageSubresourceRange range;
+               range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+               range.baseMipLevel = region->srcSubresource.mipLevel;
+               range.levelCount = 1;
+               range.baseArrayLayer = src_base_layer;
+               range.layerCount = region->srcSubresource.layerCount;
+               radv_fast_clear_flush_image_inplace(cmd_buffer, src_image, &range);
+
                for (uint32_t layer = 0; layer < region->srcSubresource.layerCount;
                     ++layer) {