[Mesa-dev] [PATCH] anv: fix multiview for clear commands

Jason Ekstrand jason at jlekstrand.net
Tue May 16 16:39:39 UTC 2017


On Tue, May 16, 2017 at 4:03 AM, Iago Toral Quiroga <itoral at igalia.com>
wrote:

> According to the spec for VkRenderPassMultiviewCreateInfoKHX:
>
> "Multiview causes all drawing and clear commands in the subpass to
> behave as if they were broadcast to each view, where each view is
> represented by one layer of the framebuffer attachments."
>
> This patch implements the broadcast for clear commands, which was
> missing in the original implementation.
>
> Fixes new CTS multiview tests:
> dEQP-VK.multiview.clear_attachments.*
> ---
>  src/intel/vulkan/anv_blorp.c | 58 ++++++++++++++++++++++++++----
> --------------
>  1 file changed, 35 insertions(+), 23 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index 7b6944a..2e2f915 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -999,16 +999,22 @@ clear_color_attachment(struct anv_cmd_buffer
> *cmd_buffer,
>     union isl_color_value clear_color =
>        vk_to_isl_color(attachment->clearValue.color);
>
> -   for (uint32_t r = 0; r < rectCount; ++r) {
> -      const VkOffset2D offset = pRects[r].rect.offset;
> -      const VkExtent2D extent = pRects[r].rect.extent;
> -      blorp_clear_attachments(batch, binding_table,
> -                              ISL_FORMAT_UNSUPPORTED, pass_att->samples,
> -                              pRects[r].baseArrayLayer,
> -                              pRects[r].layerCount,
> -                              offset.x, offset.y,
> -                              offset.x + extent.width, offset.y +
> extent.height,
> -                              true, clear_color, false, 0.0f, 0, 0);
> +   const uint32_t num_views = MAX2(1, util_last_bit(subpass->view_mask));
> +   for(uint32_t view_idx = 0; view_idx < num_views; view_idx++) {
>

This may be a good place to use anv_for_each_bit :-)  Then again, what
you're doing here also handles the regular case.  I think I might still be
inclined to split them because you don't want to respect layerCount and
baseArrayLayer in multiview.


> +      if (subpass->view_mask && !(subpass->view_mask & (1 << view_idx)))
> +         continue;
> +
> +      for (uint32_t r = 0; r < rectCount; ++r) {
> +         const VkOffset2D offset = pRects[r].rect.offset;
> +         const VkExtent2D extent = pRects[r].rect.extent;
> +         blorp_clear_attachments(batch, binding_table,
> +                                 ISL_FORMAT_UNSUPPORTED,
> pass_att->samples,
> +                                 pRects[r].baseArrayLayer + view_idx,
> +                                 pRects[r].layerCount,
> +                                 offset.x, offset.y,
> +                                 offset.x + extent.width, offset.y +
> extent.height,
> +                                 true, clear_color, false, 0.0f, 0, 0);
> +      }
>     }
>  }
>
> @@ -1047,19 +1053,25 @@ clear_depth_stencil_attachment(struct
> anv_cmd_buffer *cmd_buffer,
>     if (result != VK_SUCCESS)
>        return;
>
> -   for (uint32_t r = 0; r < rectCount; ++r) {
> -      const VkOffset2D offset = pRects[r].rect.offset;
> -      const VkExtent2D extent = pRects[r].rect.extent;
> -      VkClearDepthStencilValue value = attachment->clearValue.
> depthStencil;
> -      blorp_clear_attachments(batch, binding_table,
> -                              depth_format, pass_att->samples,
> -                              pRects[r].baseArrayLayer,
> -                              pRects[r].layerCount,
> -                              offset.x, offset.y,
> -                              offset.x + extent.width, offset.y +
> extent.height,
> -                              false, color_value,
> -                              clear_depth, value.depth,
> -                              clear_stencil ? 0xff : 0, value.stencil);
> +   const uint32_t num_views = MAX2(1, util_last_bit(subpass->view_mask));
> +   for(uint32_t view_idx = 0; view_idx < num_views; view_idx++) {
> +      if (subpass->view_mask && !(subpass->view_mask & (1 << view_idx)))
> +         continue;
> +
> +      for (uint32_t r = 0; r < rectCount; ++r) {
> +         const VkOffset2D offset = pRects[r].rect.offset;
> +         const VkExtent2D extent = pRects[r].rect.extent;
> +         VkClearDepthStencilValue value = attachment->clearValue.
> depthStencil;
> +         blorp_clear_attachments(batch, binding_table,
> +                                 depth_format, pass_att->samples,
> +                                 pRects[r].baseArrayLayer + view_idx,
> +                                 pRects[r].layerCount,
> +                                 offset.x, offset.y,
> +                                 offset.x + extent.width, offset.y +
> extent.height,
> +                                 false, color_value,
> +                                 clear_depth, value.depth,
> +                                 clear_stencil ? 0xff : 0, value.stencil);
> +      }
>     }
>  }
>
> --
> 2.7.4
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170516/c14c1194/attachment.html>


More information about the mesa-dev mailing list