[Mesa-dev] [PATCH 06/29] anv/image: Add a helper for determining when fast clears are supported

Pohjolainen, Topi topi.pohjolainen at gmail.com
Wed Nov 29 18:42:05 UTC 2017


On Mon, Nov 27, 2017 at 07:05:56PM -0800, Jason Ekstrand wrote:
> ---
>  src/intel/vulkan/anv_image.c   | 58 ++++++++++++++++++++++++++++++++++++++++++
>  src/intel/vulkan/anv_private.h |  5 ++++
>  2 files changed, 63 insertions(+)

This seems to be pretty much inline with anv_layout_to_aux_usage(). First I
thought why can't we try calling anv_layout_to_aux_usage() regardless of the
aspect. I was looking at the duplicated asserts and checks for the aux size.
But then I realized it hits unreachacble() with VK_IMAGE_ASPECT_COLOR_BIT. So

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

> 
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index a872149..561da28 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -837,6 +837,64 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
>     unreachable("layout is not a VkImageLayout enumeration member.");
>  }
>  
> +/**
> + * This function returns true if the given image in the given VkImageLayout
> + * supports unresolved fast-clears.
> + *
> + * @param devinfo The device information of the Intel GPU.
> + * @param image The image that may contain a collection of buffers.
> + * @param aspect The aspect of the image to be accessed.
> + * @param layout The current layout of the image aspect(s).
> + */
> +bool
> +anv_layout_supports_fast_clear(const struct gen_device_info * const devinfo,
> +                               const struct anv_image * const image,
> +                               const VkImageAspectFlagBits aspect,
> +                               const VkImageLayout layout)
> +{
> +   /* The aspect must be exactly one of the image aspects. */
> +   assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
> +
> +   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> +
> +   /* If there is no auxiliary surface allocated, there are no fast-clears */
> +   if (image->planes[plane].aux_surface.isl.size == 0)
> +      return false;
> +
> +   /* All images that use an auxiliary surface are required to be tiled. */
> +   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
> +
> +   /* Stencil has no aux */
> +   assert(aspect != VK_IMAGE_ASPECT_STENCIL_BIT);
> +
> +   if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
> +      /* For depth images (with HiZ), the layout supports fast-clears if and
> +       * only if it supports HiZ.
> +       */
> +      enum isl_aux_usage aux_usage =
> +         anv_layout_to_aux_usage(devinfo, image, aspect, layout);
> +      return aux_usage == ISL_AUX_USAGE_HIZ;
> +   }
> +
> +   assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
> +
> +   /* Multisample fast-clear is not yet supported. */
> +   if (image->samples > 1)
> +      return false;
> +
> +   /* The only layout which actually supports fast-clears today is
> +    * VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL.  Some day in the future
> +    * this may change if our ability to track clear colors improves.
> +    */
> +   switch (layout) {
> +   case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
> +      return true;
> +
> +   default:
> +      return false;
> +   }
> +}
> +
>  
>  static struct anv_state
>  alloc_surface_state(struct anv_device *device)
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index 5dd95a3..461bfed 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -2559,6 +2559,11 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
>                          const struct anv_image *image,
>                          const VkImageAspectFlagBits aspect,
>                          const VkImageLayout layout);
> +bool
> +anv_layout_supports_fast_clear(const struct gen_device_info * const devinfo,
> +                               const struct anv_image * const image,
> +                               const VkImageAspectFlagBits aspect,
> +                               const VkImageLayout layout);
>  
>  /* This is defined as a macro so that it works for both
>   * VkImageSubresourceRange and VkImageSubresourceLayers
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> 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