[Mesa-dev] [PATCH 2/2] radv: handle layered fast clears.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Sun Feb 19 09:17:09 UTC 2017


Series is

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Sun, Feb 19, 2017 at 7:33 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> 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 at redhat.com>
> ---
>  src/amd/vulkan/radv_cmd_buffer.c      |  4 +--
>  src/amd/vulkan/radv_meta.h            |  3 +-
>  src/amd/vulkan/radv_meta_fast_clear.c | 64 +++++++++++++++++++----------------
>  src/amd/vulkan/radv_meta_resolve.c    |  1 -
>  src/amd/vulkan/radv_meta_resolve_cs.c |  8 +++++
>  5 files changed, 47 insertions(+), 33 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index f09318b..404d223 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -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);
>         }
>  }
>
> diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
> index 55f3a4b..8eb3df3 100644
> --- a/src/amd/vulkan/radv_meta.h
> +++ b/src/amd/vulkan/radv_meta.h
> @@ -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);
> diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
> index 950b438..244c1f5 100644
> --- a/src/amd/vulkan/radv_meta_fast_clear.c
> +++ b/src/amd/vulkan/radv_meta_fast_clear.c
> @@ -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,
> -                                            .image = radv_image_to_handle(image),
> -                                            .format = image->vk_format,
> -                                            .subresourceRange = {
> +       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);
>  }
> diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
> index 23ca569..288a147 100644
> --- a/src/amd/vulkan/radv_meta_resolve.c
> +++ b/src/amd/vulkan/radv_meta_resolve.c
> @@ -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,
> diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
> index bfe4cee..9cb4ce8 100644
> --- a/src/amd/vulkan/radv_meta_resolve_cs.c
> +++ b/src/amd/vulkan/radv_meta_resolve_cs.c
> @@ -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) {
>
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list