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

Jason Ekstrand jason at jlekstrand.net
Mon Jan 22 07:26:53 UTC 2018


On Sun, Jan 21, 2018 at 11:16 PM, Pohjolainen, Topi <
topi.pohjolainen at gmail.com> wrote:

> On Fri, Jan 19, 2018 at 03:47:23PM -0800, Jason Ekstrand wrote:
> > v2 (Jason Ekstrand):
> >  - Return an enum instead of a boolean
> >
> > Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> > ---
> >  src/intel/vulkan/anv_image.c   | 70 ++++++++++++++++++++++++++++++
> ++++++++++++
> >  src/intel/vulkan/anv_private.h | 13 ++++++++
> >  2 files changed, 83 insertions(+)
> >
> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> > index 1218c00..84e4b96 100644
> > --- a/src/intel/vulkan/anv_image.c
> > +++ b/src/intel/vulkan/anv_image.c
> > @@ -863,6 +863,76 @@ anv_layout_to_aux_usage(const struct
> gen_device_info * const devinfo,
> >     unreachable("layout is not a VkImageLayout enumeration member.");
> >  }
> >
> > +/**
> > + * This function returns the level of unresolved fast-clear support of
> the
> > + * given image in the given VkImageLayout.
> > + *
> > + * @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).
> > + */
> > +enum anv_fast_clear_type
> > +anv_layout_to_fast_clear_type(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;
>
>          return ANV_FAST_CLEAR_NONE;
>

Thanks!  Fixed locally.

This reminds me that I also discussed with Nanley changing ZERO_ONLY to
DEFAULT_VALUE so that we can better represent HiZ.  I'm going to do that
(and add some documentation) while I"m fixing this problem.


> > +
> > +   /* 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 ?
> > +             ANV_FAST_CLEAR_ANY : ANV_FAST_CLEAR_NONE;
> > +   }
> > +
> > +   assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
> > +
> > +   /* Multisample fast-clear is not yet supported. */
> > +   if (image->samples > 1)
> > +      return false;
>
>          return ANV_FAST_CLEAR_NONE;
>
> > +
> > +   /* 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 ANV_FAST_CLEAR_ANY;
> > +
> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> > +      return ANV_FAST_CLEAR_NONE;
> > +
> > +   default:
> > +      /* If the image has CCS_E enabled all the time then we can use
> > +       * fast-clear as long as the clear color is zero since this is the
> > +       * default value we program into every surface state used for
> > +       * texturing.
> > +       */
> > +      if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E)
> > +         return ANV_FAST_CLEAR_ZERO_ONLY;
> > +      else
> > +         return ANV_FAST_CLEAR_NONE;
> > +   }
> > +}
> > +
> >
> >  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 a837860..f81f8e1 100644
> > --- a/src/intel/vulkan/anv_private.h
> > +++ b/src/intel/vulkan/anv_private.h
> > @@ -2443,6 +2443,13 @@ struct anv_image {
> >     } planes[3];
> >  };
> >
> > +/* The ordering of this enum is important */
> > +enum anv_fast_clear_type {
> > +   ANV_FAST_CLEAR_NONE = 0,
> > +   ANV_FAST_CLEAR_ZERO_ONLY = 1,
> > +   ANV_FAST_CLEAR_ANY = 2,
> > +};
> > +
> >  /* Returns the number of auxiliary buffer levels attached to an image.
> */
> >  static inline uint8_t
> >  anv_image_aux_levels(const struct anv_image * const image,
> > @@ -2565,6 +2572,12 @@ anv_layout_to_aux_usage(const struct
> gen_device_info * const devinfo,
> >                          const VkImageAspectFlagBits aspect,
> >                          const VkImageLayout layout);
> >
> > +enum anv_fast_clear_type
> > +anv_layout_to_fast_clear_type(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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180121/2a3cd50d/attachment-0001.html>


More information about the mesa-dev mailing list