<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 22, 2018 at 10:48 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Jan 19, 2018 at 03:47:23PM -0800, Jason Ekstrand wrote:<br>
</span><div><div class="h5">> v2 (Jason Ekstrand):<br>
>  - Return an enum instead of a boolean<br>
><br>
> Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> ---<br>
>  src/intel/vulkan/anv_image.c   | 70 ++++++++++++++++++++++++++++++<wbr>++++++++++++<br>
>  src/intel/vulkan/anv_private.h | 13 ++++++++<br>
>  2 files changed, 83 insertions(+)<br>
><br>
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c<br>
> index 1218c00..84e4b96 100644<br>
> --- a/src/intel/vulkan/anv_image.c<br>
> +++ b/src/intel/vulkan/anv_image.c<br>
> @@ -863,6 +863,76 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,<br>
>     unreachable("layout is not a VkImageLayout enumeration member.");<br>
>  }<br>
><br>
> +/**<br>
> + * This function returns the level of unresolved fast-clear support of the<br>
> + * given image in the given VkImageLayout.<br>
> + *<br>
> + * @param devinfo The device information of the Intel GPU.<br>
> + * @param image The image that may contain a collection of buffers.<br>
> + * @param aspect The aspect of the image to be accessed.<br>
> + * @param layout The current layout of the image aspect(s).<br>
> + */<br>
> +enum anv_fast_clear_type<br>
> +anv_layout_to_fast_clear_<wbr>type(const struct gen_device_info * const devinfo,<br>
> +                              const struct anv_image * const image,<br>
> +                              const VkImageAspectFlagBits aspect,<br>
> +                              const VkImageLayout layout)<br>
> +{<br>
> +   /* The aspect must be exactly one of the image aspects. */<br>
> +   assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));<br>
> +<br>
> +   uint32_t plane = anv_image_aspect_to_plane(<wbr>image->aspects, aspect);<br>
> +<br>
> +   /* If there is no auxiliary surface allocated, there are no fast-clears */<br>
> +   if (image->planes[plane].aux_<wbr>surface.isl.size == 0)<br>
> +      return false;<br>
> +<br>
> +   /* All images that use an auxiliary surface are required to be tiled. */<br>
> +   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);<br>
> +<br>
> +   /* Stencil has no aux */<br>
> +   assert(aspect != VK_IMAGE_ASPECT_STENCIL_BIT);<br>
> +<br>
> +   if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {<br>
> +      /* For depth images (with HiZ), the layout supports fast-clears if and<br>
> +       * only if it supports HiZ.<br>
> +       */<br>
> +      enum isl_aux_usage aux_usage =<br>
> +         anv_layout_to_aux_usage(<wbr>devinfo, image, aspect, layout);<br>
> +      return aux_usage == ISL_AUX_USAGE_HIZ ?<br>
> +             ANV_FAST_CLEAR_ANY : ANV_FAST_CLEAR_NONE;<br>
> +   }<br>
> +<br>
> +   assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_<wbr>ANV);<br>
> +<br>
> +   /* Multisample fast-clear is not yet supported. */<br>
> +   if (image->samples > 1)<br>
> +      return false;<br>
> +<br>
> +   /* The only layout which actually supports fast-clears today is<br>
> +    * VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL.  Some day in the future<br>
> +    * this may change if our ability to track clear colors improves.<br>
> +    */<br>
<br>
</div></div>Stale comment.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Removed locally.  I think the switch and the one comment below are probably documentation enough.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
-Nanley<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> +   switch (layout) {<br>
> +   case VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL:<br>
> +      return ANV_FAST_CLEAR_ANY;<br>
> +<br>
> +   case VK_IMAGE_LAYOUT_PRESENT_SRC_<wbr>KHR:<br>
> +      return ANV_FAST_CLEAR_NONE;<br>
> +<br>
> +   default:<br>
> +      /* If the image has CCS_E enabled all the time then we can use<br>
> +       * fast-clear as long as the clear color is zero since this is the<br>
> +       * default value we program into every surface state used for<br>
> +       * texturing.<br>
> +       */<br>
> +      if (image->planes[plane].aux_<wbr>usage == ISL_AUX_USAGE_CCS_E)<br>
> +         return ANV_FAST_CLEAR_ZERO_ONLY;<br>
> +      else<br>
> +         return ANV_FAST_CLEAR_NONE;<br>
> +   }<br>
> +}<br>
> +<br>
><br>
>  static struct anv_state<br>
>  alloc_surface_state(struct anv_device *device)<br>
> diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
> index a837860..f81f8e1 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> @@ -2443,6 +2443,13 @@ struct anv_image {<br>
>     } planes[3];<br>
>  };<br>
><br>
> +/* The ordering of this enum is important */<br>
> +enum anv_fast_clear_type {<br>
> +   ANV_FAST_CLEAR_NONE = 0,<br>
> +   ANV_FAST_CLEAR_ZERO_ONLY = 1,<br>
> +   ANV_FAST_CLEAR_ANY = 2,<br>
> +};<br>
> +<br>
>  /* Returns the number of auxiliary buffer levels attached to an image. */<br>
>  static inline uint8_t<br>
>  anv_image_aux_levels(const struct anv_image * const image,<br>
> @@ -2565,6 +2572,12 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,<br>
>                          const VkImageAspectFlagBits aspect,<br>
>                          const VkImageLayout layout);<br>
><br>
> +enum anv_fast_clear_type<br>
> +anv_layout_to_fast_clear_<wbr>type(const struct gen_device_info * const devinfo,<br>
> +                              const struct anv_image * const image,<br>
> +                              const VkImageAspectFlagBits aspect,<br>
> +                              const VkImageLayout layout);<br>
> +<br>
>  /* This is defined as a macro so that it works for both<br>
>   * VkImageSubresourceRange and VkImageSubresourceLayers<br>
>   */<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>