<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 2, 2017 at 4:28 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, May 02, 2017 at 04:15:42PM -0700, Jason Ekstrand wrote:<br>
> On Thu, Apr 27, 2017 at 11:32 AM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>><br>
> wrote:<br>
><br>
> > The lifespan of the fast-clear data will surpass the render pass scope.<br>
> > We need CCS_D to be enabled in order to invalidate blocks previously<br>
> > marked as cleared and to sample cleared data correctly.<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_blorp.c       | 15 ++----<br>
> >  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 94 +++++++++++++++++++-----------<br>
> > --------<br>
> >  2 files changed, 52 insertions(+), 57 deletions(-)<br>
> ><br>
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> > index d17b73dcc7..5e7d4b06b8 100644<br>
> > --- a/src/intel/vulkan/anv_blorp.c<br>
> > +++ b/src/intel/vulkan/anv_blorp.c<br>
> > @@ -1383,7 +1383,8 @@ ccs_resolve_attachment(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> >        &cmd_buffer->state.<wbr>attachments[att];<br>
> ><br>
> >     if (att_state->aux_usage == ISL_AUX_USAGE_NONE ||<br>
> > -       att_state->aux_usage == ISL_AUX_USAGE_MCS)<br>
> > +       att_state->aux_usage == ISL_AUX_USAGE_MCS ||<br>
> > +       att_state->fast_clear == false)<br>
> >        return; /* Nothing to resolve */<br>
> ><br>
> >     assert(att_state->aux_usage == ISL_AUX_USAGE_CCS_E ||<br>
> > @@ -1432,7 +1433,7 @@ ccs_resolve_attachment(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> >            * the render pass.  We need a full resolve.<br>
> >            */<br>
> >           resolve_op = BLORP_FAST_CLEAR_OP_RESOLVE_<wbr>FULL;<br>
> > -      } else if (att_state->fast_clear) {<br>
> > +      } else {<br>
> >           /* We don't know what to do with clear colors outside the render<br>
> >            * pass.  We need a partial resolve. Only transparent black is<br>
> >            * built into the surface state object and thus no resolve is<br>
> > @@ -1443,11 +1444,6 @@ ccs_resolve_attachment(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> >               att_state->clear_value.color.<wbr>uint32[2] ||<br>
> >               att_state->clear_value.color.<wbr>uint32[3])<br>
> >              resolve_op = BLORP_FAST_CLEAR_OP_RESOLVE_<wbr>PARTIAL;<br>
> > -      } else {<br>
> > -         /* The image "natively" supports all the compression we care<br>
> > about<br>
> > -          * and we don't need to resolve at all.  If this is the case, we<br>
> > also<br>
> > -          * don't need to resolve for any of the input attachment cases<br>
> > below.<br>
> > -          */<br>
> >        }<br>
> >     } else if (usage & ANV_SUBPASS_USAGE_INPUT) {<br>
> >        /* Input attachments are clear-color aware so, at least on Sky<br>
> > Lake, we<br>
> > @@ -1474,8 +1470,7 @@ ccs_resolve_attachment(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> >     struct blorp_surf surf;<br>
> >     get_blorp_surf_for_anv_image(<wbr>image, VK_IMAGE_ASPECT_COLOR_BIT,<br>
> >                                  att_state->aux_usage, &surf);<br>
> > -   if (att_state->fast_clear)<br>
> > -      surf.clear_color = vk_to_isl_color(att_state-><wbr>clear_value.color);<br>
> > +   surf.clear_color = vk_to_isl_color(att_state-><wbr>clear_value.color);<br>
> ><br>
> >     /* From the Sky Lake PRM Vol. 7, "Render Target Resolve":<br>
> >      *<br>
> > @@ -1504,8 +1499,6 @@ ccs_resolve_attachment(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> ><br>
> >     /* Once we've done any sort of resolve, we're no longer fast-cleared */<br>
> >     att_state->fast_clear = false;<br>
> > -   if (att_state->aux_usage == ISL_AUX_USAGE_CCS_D)<br>
> > -      att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
> >  }<br>
> ><br>
> >  void<br>
> > diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> > b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> > index ddb22c4539..0ea378fde2 100644<br>
> > --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> > +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> > @@ -232,6 +232,50 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device<br>
> > *device,<br>
> >        att_state->input_aux_usage = ISL_AUX_USAGE_MCS;<br>
> >        att_state->fast_clear = false;<br>
> >        return;<br>
> > +   } else if (GEN_GEN == 7 &&<br>
> > +              (iview->isl.base_level > 0 ||<br>
> > +               iview->isl.base_array_layer > 0 ||<br>
> > +               iview->isl.array_len > 1)) {<br>
> > +      /* On gen7, we can't do multi-LOD or multi-layer CCS. We technically<br>
> > +       * can, but it comes with crazy restrictions that we don't want to<br>
> > deal<br>
> > +       * with now.<br>
> > +       */<br>
> > +      att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
> > +      att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
> > +      att_state->fast_clear = false;<br>
> > +      return;<br>
> > +   } else if (iview->image->aux_usage == ISL_AUX_USAGE_CCS_E) {<br>
> > +      att_state->aux_usage = ISL_AUX_USAGE_CCS_E;<br>
> > +      att_state->input_aux_usage = ISL_AUX_USAGE_CCS_E;<br>
> > +   } else {<br>
> > +      att_state->aux_usage = ISL_AUX_USAGE_CCS_D;<br>
> > +      if (isl_format_supports_ccs_e(&<wbr>device->info, iview->isl.format)) {<br>
> > +         /* SKL can sample from CCS with one restriction.<br>
> > +          *<br>
> > +          * From the Sky Lake PRM, RENDER_SURFACE_STATE::<br>
> > AuxiliarySurfaceMode:<br>
> > +          *<br>
> > +          *    "If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_D<br>
> > +          *    setting is only allowed if Surface Format supported for<br>
> > Fast<br>
> > +          *    Clear. In addition, if the surface is bound to the sampling<br>
> > +          *    engine, Surface Format must be supported for Render Target<br>
> > +          *    Compression for surfaces bound to the sampling engine."<br>
> > +          *<br>
> > +          * In other words, we can only sample from a fast-cleared image<br>
> > if it<br>
> > +          * also supports color compression.<br>
> > +          *<br>
> > +          * TODO: Consider using a heuristic to determine if temporarily<br>
> > enabling<br>
> > +          * CCS_E for this image view would be beneficial.<br>
> > +          *<br>
> > +          * While fast-clear resolves and partial resolves are fairly<br>
> > cheap in the<br>
> > +          * case where you render to most of the pixels, full resolves<br>
> > are not<br>
> > +          * because they potentially involve reading and writing the<br>
> > entire<br>
> > +          * framebuffer.  If we can't texture with CCS_E, we should leave<br>
> > it off and<br>
> > +          * limit ourselves to fast clears.<br>
> > +          */<br>
> > +         att_state->input_aux_usage = ISL_AUX_USAGE_CCS_D;<br>
> > +      } else {<br>
> > +         att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
> > +      }<br>
> ><br>
><br>
> Is this refactor needed?  I don't see how this code does anything different<br>
> from what we had before.<br>
><br>
><br>
<br>
</div></div>Prior to this patch CCS_D would only enabled if a fast clear would occur<br>
on the attachment. With this patch, CCS_D is always enabled regardless<br>
of whether a fast clear operation is performed.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>I think I see it now.  It's a bit hard to see the delta with all of the code moving around everywhere.<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>
> ><br>
> >     assert(iview->image->aux_<wbr>surface.isl.usage & ISL_SURF_USAGE_CCS_BIT);<br>
> > @@ -240,6 +284,10 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device<br>
> > *device,<br>
> >        color_is_zero_one(att_state-><wbr>clear_value.color, iview->isl.format);<br>
> ><br>
> >     if (att_state->pending_clear_<wbr>aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
> > +<br>
> > +      /* We should have returned early if the aux buffer will not be<br>
> > used. */<br>
> > +      assert(att_state->aux_usage != ISL_AUX_USAGE_NONE);<br>
> > +<br>
> >        /* Start off assuming fast clears are possible */<br>
> >        att_state->fast_clear = true;<br>
> ><br>
> > @@ -253,17 +301,6 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device<br>
> > *device,<br>
> >            render_area.extent.height != iview->extent.height)<br>
> >           att_state->fast_clear = false;<br>
> ><br>
> > -      if (GEN_GEN <= 7) {<br>
> > -         /* On gen7, we can't do multi-LOD or multi-layer fast-clears.  We<br>
> > -          * technically can, but it comes with crazy restrictions that we<br>
> > -          * don't want to deal with now.<br>
> > -          */<br>
> > -         if (iview->isl.base_level > 0 ||<br>
> > -             iview->isl.base_array_layer > 0 ||<br>
> > -             iview->isl.array_len > 1)<br>
> > -            att_state->fast_clear = false;<br>
> > -      }<br>
> > -<br>
> >        /* On Broadwell and earlier, we can only handle 0/1 clear colors */<br>
> >        if (GEN_GEN <= 8 && !att_state->clear_color_is_<wbr>zero_one)<br>
> >           att_state->fast_clear = false;<br>
> > @@ -275,41 +312,6 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device<br>
> > *device,<br>
> >     } else {<br>
> >        att_state->fast_clear = false;<br>
> >     }<br>
> > -<br>
> > -   /**<br>
> > -    * TODO: Consider using a heuristic to determine if temporarily<br>
> > enabling<br>
> > -    * CCS_E for this image view would be beneficial.<br>
> > -    *<br>
> > -    * While fast-clear resolves and partial resolves are fairly cheap in<br>
> > the<br>
> > -    * case where you render to most of the pixels, full resolves are not<br>
> > -    * because they potentially involve reading and writing the entire<br>
> > -    * framebuffer.  If we can't texture with CCS_E, we should leave it<br>
> > off and<br>
> > -    * limit ourselves to fast clears.<br>
> > -    */<br>
> > -   if (iview->image->aux_usage == ISL_AUX_USAGE_CCS_E) {<br>
> > -      att_state->aux_usage = ISL_AUX_USAGE_CCS_E;<br>
> > -      att_state->input_aux_usage = ISL_AUX_USAGE_CCS_E;<br>
> > -   } else if (att_state->fast_clear) {<br>
> > -      att_state->aux_usage = ISL_AUX_USAGE_CCS_D;<br>
> > -      /* From the Sky Lake PRM, RENDER_SURFACE_STATE::<br>
> > AuxiliarySurfaceMode:<br>
> > -       *<br>
> > -       *    "If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_D<br>
> > -       *    setting is only allowed if Surface Format supported for Fast<br>
> > -       *    Clear. In addition, if the surface is bound to the sampling<br>
> > -       *    engine, Surface Format must be supported for Render Target<br>
> > -       *    Compression for surfaces bound to the sampling engine."<br>
> > -       *<br>
> > -       * In other words, we can only sample from a fast-cleared image if<br>
> > it<br>
> > -       * also supports color compression.<br>
> > -       */<br>
> > -      if (isl_format_supports_ccs_e(&<wbr>device->info, iview->isl.format))<br>
> > -         att_state->input_aux_usage = ISL_AUX_USAGE_CCS_D;<br>
> > -      else<br>
> > -         att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
> > -   } else {<br>
> > -      att_state->aux_usage = ISL_AUX_USAGE_NONE;<br>
> > -      att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
> > -   }<br>
> >  }<br>
> ><br>
> >  static bool<br>
> > --<br>
> > 2.12.2<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>
</div></div></blockquote></div><br></div></div>