<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 28, 2017 at 3:01 PM, 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"><div class="HOEnZb"><div class="h5">On Tue, Feb 28, 2017 at 11:00:14AM -0800, Jason Ekstrand wrote:<br>
> On Tue, Feb 28, 2017 at 10:53 AM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>><br>
> wrote:<br>
><br>
> > On Tue, Feb 28, 2017 at 10:38:12AM -0800, Jason Ekstrand wrote:<br>
> > > On Tue, Feb 28, 2017 at 10:32 AM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>><br>
> > > wrote:<br>
> > ><br>
> > > > On Tue, Feb 28, 2017 at 08:26:56AM -0800, Jason Ekstrand wrote:<br>
> > > > > On Mon, Feb 27, 2017 at 5:20 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a><br>
> > ><br>
> > > > wrote:<br>
> > > > ><br>
> > > > > > This function supersedes layout_to_hiz_usage().<br>
> > > > > ><br>
> > > > > > Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> > > > > > ---<br>
> > > > > >  src/intel/vulkan/anv_image.c   | 149<br>
> > ++++++++++++++++++++++++++++++<br>
> > > > > > +++++++++++<br>
> > > > > >  src/intel/vulkan/anv_private.h |   4 ++<br>
> > > > > >  2 files changed, 153 insertions(+)<br>
> > > > > ><br>
> > > > > > diff --git a/src/intel/vulkan/anv_image.c<br>
> > > > b/src/intel/vulkan/anv_image.c<br>
> > > > > > index cd142938e7..716cdf3a38 100644<br>
> > > > > > --- a/src/intel/vulkan/anv_image.c<br>
> > > > > > +++ b/src/intel/vulkan/anv_image.c<br>
> > > > > > @@ -432,6 +432,155 @@ void anv_GetImageSubresourceLayout(<br>
> > > > > >     }<br>
> > > > > >  }<br>
> > > > > ><br>
> > > > > > +/**<br>
> > > > > > + * @brief This function determines the optimal buffer to use for<br>
> > > > device<br>
> > > > > > + * accesses given a VkImageLayout and other pieces of information<br>
> > > > needed<br>
> > > > > > to<br>
> > > > > > + * make that determination. Device accesses may include normal<br>
> > > > sampling<br>
> > > > > > and<br>
> > > > > > + * rendering operations or resolves.<br>
> > > > > > + *<br>
> > > > > > + * @param gen The generation of the Intel GPU.<br>
> > > > > > + * @param image The image that may contain a collection of<br>
> > buffers.<br>
> > > > > > + * @param aspects The aspect(s) of the image to be accessed.<br>
> > > > > > + * @param layout The current layout of the image aspect(s).<br>
> > > > > > + * @param future_layout The next layout of the image aspect(s), if<br>
> > > > known.<br>
> > > > > > + *                      Otherwise this should be equal to the<br>
> > current<br>
> > > > > > layout.<br>
> > > > > > + *<br>
> > > > > > + * @return The primary buffer that should be used for the given<br>
> > > > layout.<br>
> > > > > > + */<br>
> > > > > > +enum isl_aux_usage<br>
> > > > > > +anv_layout_to_aux_usage(const uint8_t gen, const struct anv_image<br>
> > *<br>
> > > > const<br>
> > > > > > image,<br>
> > > > > ><br>
> > > > ><br>
> > > > > Might be better to take a gen_device_info rather than just the<br>
> > integer.<br>
> > > > > Since we're doing run-time checks anyway, the cost should be small.<br>
> > > > ><br>
> > > ><br>
> > > > What does this buy us?<br>
> > > ><br>
> > ><br>
> > > Nothing at the moment.  However, it is the more standard thing to pass in<br>
> > > and, if we ever need more information in the future, device_info is what<br>
> > > we'll want.  Or you could just pass in the anv_device to guarantee that<br>
> > we<br>
> > > have everything we would ever need.<br>
> > ><br>
> ><br>
> > I'm in favor of adding it when we need it, but I can make it take the<br>
> > device_info if you insist. My rationale is that if the function takes a<br>
> > device_info or anv_device, the function prototype would be unnecessarily<br>
> > ambiguous with respect to what device-related information is necessary<br>
> > to perform the mapping.<br>
> ><br>
><br>
> Certainly anv_device is probably a bit much since it doesn't (yet) depend<br>
> on any run-time information.  I could see that changing in the future<br>
> (environment variables, per-app parameters, etc.) but we can cross that<br>
> bridge when we come to it.  I don't really see an "information" difference<br>
> between an integer "gen" and a device info.  The one completely describes<br>
> the hardware and the other sort-of describes the hardware.  Also, I<br>
> wouldn't be terribly surprised if, in the future, whether or not we can<br>
> sample from HiZ starts to depend on half-gen or whether or not it's an atom<br>
> part.<br>
><br>
<br>
</div></div>Do you want me to use the device_info struct in the v2?<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>I'd prefer it but I'm not going to be too upset if it's not there.<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>
><br>
> > -Nanley<br>
> ><br>
> > ><br>
> > > > -Nanley<br>
> > > ><br>
> > > > ><br>
> > > > > > +                        const VkImageAspectFlags aspects,<br>
> > > > VkImageLayout<br>
> > > > > > layout,<br>
> > > > > > +                        const VkImageLayout future_layout)<br>
> > > > > > +{<br>
> > > > > > +   /* Validate the inputs. */<br>
> > > > > > +<br>
> > > > > > +   /* Intel GPUs prior to Gen7 are not supported in anv. */<br>
> > > > > > +   assert(gen >= 7);<br>
> > > > > > +<br>
> > > > > > +   /* The layout of a NULL image is not properly defined. */<br>
> > > > > > +   assert(image != NULL);<br>
> > > > > > +<br>
> > > > > > +   /* The aspects must be a subset of the image aspects. */<br>
> > > > > > +   assert(aspects & image->aspects && aspects <= image->aspects);<br>
> > > > > > +<br>
> > > > > > +   /* According to the Vulkan Spec, the following layouts are<br>
> > valid<br>
> > > > only<br>
> > > > > > as<br>
> > > > > > +    * initial layouts in a layout transition and don't support<br>
> > device<br>
> > > > > > access.<br>
> > > > > > +    * Therefore, the caller should not be setting the future<br>
> > layout to<br>
> > > > > > either.<br>
> > > > > > +    */<br>
> > > > > > +   assert(future_layout != VK_IMAGE_LAYOUT_UNDEFINED &&<br>
> > > > > > +          future_layout != VK_IMAGE_LAYOUT_<wbr>PREINITIALIZED);<br>
> > > > > > +<br>
> > > > > > +   /* Determine the optimal buffer. */<br>
> > > > > > +<br>
> > > > > > +   /* If there is no auxiliary surface allocated, we must use the<br>
> > one<br>
> > > > and<br>
> > > > > > only<br>
> > > > > > +    * main buffer.<br>
> > > > > > +    */<br>
> > > > > > +   if (image->aux_surface.isl.size == 0)<br>
> > > > > > +      return ISL_AUX_USAGE_NONE;<br>
> > > > > > +<br>
> > > > > > +   /* All images that use an auxiliary surface are required to be<br>
> > > > tiled.<br>
> > > > > > */<br>
> > > > > > +   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);<br>
> > > > > > +<br>
> > > > > > +   /* On BDW+, when clearing the stencil aspect of a depth stencil<br>
> > > > image,<br>
> > > > > > +    * the HiZ buffer allows us to record the clear with a<br>
> > relatively<br>
> > > > small<br>
> > > > > > +    * number of packets. Prior to BDW, the HiZ buffer provides no<br>
> > > > known<br>
> > > > > > benefit<br>
> > > > > > +    * to the stencil aspect.<br>
> > > > > > +    */<br>
> > > > > > +   if (gen < 8 && aspects == VK_IMAGE_ASPECT_STENCIL_BIT)<br>
> > > > > > +      return ISL_AUX_USAGE_NONE;<br>
> > > > > > +<br>
> > > > > > +   /* The undefined layout indicates that the user doesn't care<br>
> > about<br>
> > > > the<br>
> > > > > > data<br>
> > > > > > +    * that's currently in the buffer. Therefore, the optimal<br>
> > buffer to<br>
> > > > > > use is<br>
> > > > > > +    * the same buffer that would be used in the next layout. This<br>
> > > > avoids<br>
> > > > > > the<br>
> > > > > > +    * possibility of having to resolve in order to maintain<br>
> > coherency.<br>
> > > > > > +    *<br>
> > > > > > +    * The pre-initialized layout is undefined for optimally-tiled<br>
> > > > images.<br>
> > > > > > As<br>
> > > > > > +    * guaranteed by the assertion above, all images that have<br>
> > reached<br>
> > > > this<br>
> > > > > > +    * point are tiled.<br>
> > > > > > +   */<br>
> > > > > > +   if (layout == VK_IMAGE_LAYOUT_UNDEFINED ||<br>
> > > > > > +       layout == VK_IMAGE_LAYOUT_<wbr>PREINITIALIZED)<br>
> > > > > > +      layout = future_layout;<br>
> > > > > > +<br>
> > > > > > +   const bool has_depth = aspects & VK_IMAGE_ASPECT_DEPTH_BIT;<br>
> > > > > > +   const bool color_aspect = aspects == VK_IMAGE_ASPECT_COLOR_BIT;<br>
> > > > > > +<br>
> > > > > > +   /* The following switch currently only handles depth stencil<br>
> > > > aspects.<br>
> > > > > > +    * TODO: Handle the color aspect.<br>
> > > > > > +    */<br>
> > > > > > +   if (color_aspect)<br>
> > > > > > +      return image->aux_usage;<br>
> > > > > > +<br>
> > > > > > +   switch (layout) {<br>
> > > > > > +<br>
> > > > > > +   /* Invalid Layouts */<br>
> > > > > > +   case VK_IMAGE_LAYOUT_UNDEFINED:<br>
> > > > > > +   case VK_IMAGE_LAYOUT_<wbr>PREINITIALIZED:<br>
> > > > > > +   case VK_IMAGE_LAYOUT_RANGE_SIZE:<br>
> > > > > > +   case VK_IMAGE_LAYOUT_MAX_ENUM:<br>
> > > > > > +      unreachable("Invalid image layout.");<br>
> > > > > > +<br>
> > > > > > +<br>
> > > > > > +   /* Transfer Layouts<br>
> > > > > > +    *<br>
> > > > > > +    * This buffer could be a depth buffer used in a transfer<br>
> > > > operation.<br>
> > > > > > BLORP<br>
> > > > > > +    * currently doesn't use HiZ for transfer operations so we<br>
> > must use<br>
> > > > > > the main<br>
> > > > > > +    * buffer for this layout. TODO: Enable HiZ in BLORP.<br>
> > > > > > +    */<br>
> > > > > > +   case VK_IMAGE_LAYOUT_GENERAL:<br>
> > > > > > +   case VK_IMAGE_LAYOUT_TRANSFER_DST_<wbr>OPTIMAL:<br>
> > > > > > +   case VK_IMAGE_LAYOUT_TRANSFER_SRC_<wbr>OPTIMAL:<br>
> > > > > > +      return ISL_AUX_USAGE_NONE;<br>
> > > > > > +<br>
> > > > > > +<br>
> > > > > > +   /* Sampling Layouts */<br>
> > > > > > +   case VK_IMAGE_LAYOUT_DEPTH_STENCIL_<wbr>READ_ONLY_OPTIMAL:<br>
> > > > > > +      assert(!color_aspect);<br>
> > > > > > +      /* Fall-through */<br>
> > > > > > +   case VK_IMAGE_LAYOUT_SHADER_READ_<wbr>ONLY_OPTIMAL:<br>
> > > > > > +      if (has_depth && anv_can_sample_with_hiz(gen,<br>
> > image->samples))<br>
> > > > > > +         return ISL_AUX_USAGE_HIZ;<br>
> > > > > > +      else<br>
> > > > > > +         return ISL_AUX_USAGE_NONE;<br>
> > > > > > +<br>
> > > > > > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_<wbr>KHR:<br>
> > > > > > +      assert(color_aspect);<br>
> > > > > > +<br>
> > > > > > +      /* On SKL+, the render buffer can be decompressed by the<br>
> > > > > > presentation<br>
> > > > > > +       * engine. Support for this feature has not yet landed in<br>
> > the<br>
> > > > wider<br>
> > > > > > +       * ecosystem. TODO: Update this code when support lands.<br>
> > > > > > +       *<br>
> > > > > > +       * From the BDW PRM, Vol 7, Render Target Resolve:<br>
> > > > > > +       *<br>
> > > > > > +       *    If the MCS is enabled on a non-multisampled render<br>
> > > > target, the<br>
> > > > > > +       *    render target must be resolved before being used for<br>
> > other<br>
> > > > > > +       *    purposes (display, texture, CPU lock) The clear value<br>
> > from<br>
> > > > > > +       *    SURFACE_STATE is written into pixels in the render<br>
> > target<br>
> > > > > > +       *    indicated as clear in the MCS.<br>
> > > > > > +       *<br>
> > > > > > +       * Pre-SKL, the render buffer must be resolved before being<br>
> > > > used for<br>
> > > > > > +       * presentation. We can infer that the auxiliary buffer is<br>
> > not<br>
> > > > used.<br>
> > > > > > +       */<br>
> > > > > > +      return ISL_AUX_USAGE_NONE;<br>
> > > > > > +<br>
> > > > > > +<br>
> > > > > > +   /* Rendering Layouts */<br>
> > > > > > +   case VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL:<br>
> > > > > > +      assert(color_aspect);<br>
> > > > > > +      unreachable("Color images are not yet supported.");<br>
> > > > > > +<br>
> > > > > > +   case VK_IMAGE_LAYOUT_DEPTH_STENCIL_<wbr>ATTACHMENT_OPTIMAL:<br>
> > > > > > +      assert(!color_aspect);<br>
> > > > > > +      return ISL_AUX_USAGE_HIZ;<br>
> > > > > > +   }<br>
> > > > > > +<br>
> > > > > > +   /* If the layout isn't recognized in the exhaustive switch<br>
> > above,<br>
> > > > the<br>
> > > > > > +    * VkImageLayout value is not defined in vulkan.h.<br>
> > > > > > +    */<br>
> > > > > > +   unreachable("layout is not a VkImageLayout enumeration<br>
> > member.");<br>
> > > > > > +}<br>
> > > > > > +<br>
> > > > > > +<br>
> > > > > >  static struct anv_state<br>
> > > > > >  alloc_surface_state(struct anv_device *device)<br>
> > > > > >  {<br>
> > > > > > diff --git a/src/intel/vulkan/anv_<wbr>private.h<br>
> > b/src/intel/vulkan/anv_<br>
> > > > > > private.h<br>
> > > > > > index 2527c2cc5a..5ce9027f88 100644<br>
> > > > > > --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> > > > > > +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> > > > > > @@ -1671,6 +1671,10 @@ anv_gen8_hiz_op_resolve(struct<br>
> > anv_cmd_buffer<br>
> > > > > > *cmd_buffer,<br>
> > > > > >                          const struct anv_image *image,<br>
> > > > > >                          enum blorp_hiz_op op);<br>
> > > > > ><br>
> > > > > > +enum isl_aux_usage<br>
> > > > > > +anv_layout_to_aux_usage(const uint8_t gen, const struct anv_image<br>
> > > > *image,<br>
> > > > > > +                        const VkImageAspectFlags aspects,<br>
> > > > VkImageLayout<br>
> > > > > > layout,<br>
> > > > > > +                        const VkImageLayout future_layout);<br>
> > > > > >  static inline uint32_t<br>
> > > > > >  anv_get_layerCount(const struct anv_image *image,<br>
> > > > > >                     const VkImageSubresourceRange *range)<br>
> > > > > > --<br>
> > > > > > 2.11.1<br>
> > > > > ><br>
> > > > > > ______________________________<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>
> > > > > ><br>
> > > ><br>
> ><br>
</div></div></blockquote></div><br></div></div>