<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 13, 2018 at 4:35 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 Mon, Feb 05, 2018 at 02:35:00PM -0800, Jason Ekstrand wrote:<br>
> This is quite a bit cleaner because we now sync the clear values at the<br>
> same time as we do the fast clear.  For loading the clear values into<br>
> the surface state, we now do it once when we handle the LOAD_OP_LOAD<br>
> instead of every subpass.<br>
> ---<br>
>  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 148 ++++++++++++------------------<wbr>-------<br>
>  1 file changed, 48 insertions(+), 100 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> index f92e86f..4eee85a 100644<br>
> --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> @@ -3392,97 +3392,6 @@ cmd_buffer_subpass_transition_<wbr>layouts(struct anv_cmd_buffer * const cmd_buffer,<br>
>     }<br>
>  }<br>
><br>
> -/* Update the clear value dword(s) in surface state objects or the fast clear<br>
> - * state buffer entry for the color attachments used in this subpass.<br>
> - */<br>
> -static void<br>
> -cmd_buffer_subpass_sync_fast_<wbr>clear_values(struct anv_cmd_buffer *cmd_buffer)<br>
> -{<br>
> -   assert(cmd_buffer && cmd_buffer->state.subpass);<br>
> -<br>
> -   const struct anv_cmd_state *state = &cmd_buffer->state;<br>
> -<br>
> -   /* Iterate through every color attachment used in this subpass. */<br>
> -   for (uint32_t i = 0; i < state->subpass->color_count; ++i) {<br>
> -<br>
> -      /* The attachment should be one of the attachments described in the<br>
> -       * render pass and used in the subpass.<br>
> -       */<br>
> -      const uint32_t a = state->subpass->color_<wbr>attachments[i].attachment;<br>
> -      if (a == VK_ATTACHMENT_UNUSED)<br>
> -         continue;<br>
> -<br>
> -      assert(a < state->pass->attachment_count)<wbr>;<br>
> -<br>
> -      /* Store some information regarding this attachment. */<br>
> -      const struct anv_attachment_state *att_state = &state->attachments[a];<br>
> -      const struct anv_image_view *iview = state->framebuffer-><wbr>attachments[a];<br>
> -      const struct anv_render_pass_attachment *rp_att =<br>
> -         &state->pass->attachments[a];<br>
> -<br>
> -      if (att_state->aux_usage == ISL_AUX_USAGE_NONE)<br>
> -         continue;<br>
> -<br>
> -      /* The fast clear state entry must be updated if a fast clear is going to<br>
> -       * happen. The surface state must be updated if the clear value from a<br>
> -       * prior fast clear may be needed.<br>
> -       */<br>
> -      if (att_state->pending_clear_<wbr>aspects && att_state->fast_clear) {<br>
> -         /* Update the fast clear state entry. */<br>
> -         genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->color.state,<br>
> -                                      iview->image,<br>
> -                                      VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                      true /* copy from ss */);<br>
> -<br>
> -         /* Fast-clears impact whether or not a resolve will be necessary. */<br>
> -         if (att_state->clear_color_is_<wbr>zero) {<br>
> -            /* This image always has the auxiliary buffer enabled. We can mark<br>
> -             * the subresource as not needing a resolve because the clear color<br>
> -             * will match what's in every RENDER_SURFACE_STATE object when it's<br>
> -             * being used for sampling.<br>
> -             */<br>
> -            set_image_fast_clear_state(<wbr>cmd_buffer, iview->image,<br>
> -                                       VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                       ANV_FAST_CLEAR_DEFAULT_VALUE);<br>
> -         } else {<br>
> -            set_image_fast_clear_state(<wbr>cmd_buffer, iview->image,<br>
> -                                       VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                       ANV_FAST_CLEAR_ANY);<br>
> -         }<br>
> -      } else if (rp_att->load_op == VK_ATTACHMENT_LOAD_OP_LOAD &&<br>
> -                 iview->planes[0].isl.base_<wbr>level == 0 &&<br>
> -                 iview->planes[0].isl.base_<wbr>array_layer == 0) {<br>
> -         /* The attachment may have been fast-cleared in a previous render<br>
> -          * pass and the value is needed now. Update the surface state(s).<br>
> -          *<br>
> -          * TODO: Do this only once per render pass instead of every subpass.<br>
> -          */<br>
> -         genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->color.state,<br>
> -                                      iview->image,<br>
> -                                      VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                      false /* copy to ss */);<br>
> -<br>
> -         if (need_input_attachment_state(<wbr>rp_att) &&<br>
> -             att_state->input_aux_usage != ISL_AUX_USAGE_NONE) {<br>
> -            genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->input.state,<br>
> -                                         iview->image,<br>
> -                                         VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                         false /* copy to ss */);<br>
> -         }<br>
> -      }<br>
> -<br>
> -      /* We assume that if we're starting a subpass, we're going to do some<br>
> -       * rendering so we may end up with compressed data.<br>
> -       */<br>
> -      genX(cmd_buffer_mark_image_<wbr>written)(cmd_buffer, iview->image,<br>
> -                                          VK_IMAGE_ASPECT_COLOR_BIT,<br>
> -                                          att_state->aux_usage,<br>
> -                                          iview->planes[0].isl.base_<wbr>level,<br>
> -                                          iview->planes[0].isl.base_<wbr>array_layer,<br>
> -                                          state->framebuffer->layers);<br>
> -   }<br>
> -}<br>
> -<br>
>  static void<br>
>  cmd_buffer_begin_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
>                           uint32_t subpass_id)<br>
> @@ -3523,15 +3432,6 @@ cmd_buffer_begin_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
>      */<br>
>     cmd_buffer_subpass_transition_<wbr>layouts(cmd_buffer, false);<br>
><br>
> -   /* Update clear values *after* performing automatic layout transitions.<br>
> -    * This ensures that transitions from the UNDEFINED layout have had a chance<br>
> -    * to populate the clear value buffer with the correct values for the<br>
> -    * LOAD_OP_LOAD loadOp and that the fast-clears will update the buffer<br>
> -    * without the aforementioned layout transition overwriting the fast-clear<br>
> -    * value.<br>
> -    */<br>
> -   cmd_buffer_subpass_sync_fast_<wbr>clear_values(cmd_buffer);<br>
> -<br>
>     VkRect2D render_area = cmd_buffer->state.render_area;<br>
>     struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;<br>
><br>
> @@ -3565,6 +3465,25 @@ cmd_buffer_begin_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
>                               0, 0, 1, ISL_AUX_OP_FAST_CLEAR, false);<br>
>              base_layer++;<br>
>              layer_count--;<br>
> +<br>
> +            genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->color.state,<br>
> +                                         image, VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                         true /* copy from ss */);<br>
> +<br>
> +            if (att_state->clear_color_is_<wbr>zero) {<br>
> +               /* This image always has the auxiliary buffer enabled. We can<br>
> +                * mark the subresource as not needing a resolve because the<br>
> +                * clear color will match what's in every RENDER_SURFACE_STATE<br>
> +                * object when it's being used for sampling.<br>
> +                */<br>
<br>
</div></div>This comment is stale. Fast-clearing to zero doesn't imply that the<br>
image always has the aux buffer enabled.<br></blockquote><div><br></div><div>No, it doesn't.  However, this is in a block that's predicated on att_state->fast_clear which does.  Looking at the latest version, I've removed the word "always".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
With that updated, this patch is<br>
Reviewed-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<div><div class="h5"><br>
<br>
> +               set_image_fast_clear_state(<wbr>cmd_buffer, iview->image,<br>
> +                                          VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                          ANV_FAST_CLEAR_DEFAULT_VALUE);<br>
> +            } else {<br>
> +               set_image_fast_clear_state(<wbr>cmd_buffer, iview->image,<br>
> +                                          VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                          ANV_FAST_CLEAR_ANY);<br>
> +            }<br>
>           }<br>
><br>
>           if (layer_count > 0) {<br>
> @@ -3605,7 +3524,36 @@ cmd_buffer_begin_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
>           assert(att_state->pending_<wbr>clear_aspects == 0);<br>
>        }<br>
><br>
> +      if (att_state->pending_load_<wbr>aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_<wbr>ANV) {<br>
> +         if (att_state->aux_usage != ISL_AUX_USAGE_NONE) {<br>
> +            genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->color.state,<br>
> +                                         image, VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                         false /* copy to ss */);<br>
> +         }<br>
> +<br>
> +         if (need_input_attachment_state(&<wbr>cmd_state->pass->attachments[<wbr>a]) &&<br>
> +             att_state->input_aux_usage != ISL_AUX_USAGE_NONE) {<br>
> +            genX(copy_fast_clear_dwords)(<wbr>cmd_buffer, att_state->input.state,<br>
> +                                         image, VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                         false /* copy to ss */);<br>
> +         }<br>
> +      }<br>
> +<br>
> +      if (subpass->attachments[i].usage ==<br>
> +          VK_IMAGE_USAGE_COLOR_<wbr>ATTACHMENT_BIT) {<br>
> +         /* We assume that if we're starting a subpass, we're going to do some<br>
> +          * rendering so we may end up with compressed data.<br>
> +          */<br>
> +         genX(cmd_buffer_mark_image_<wbr>written)(cmd_buffer, iview->image,<br>
> +                                             VK_IMAGE_ASPECT_COLOR_BIT,<br>
> +                                             att_state->aux_usage,<br>
> +                                             iview->planes[0].isl.base_<wbr>level,<br>
> +                                             iview->planes[0].isl.base_<wbr>array_layer,<br>
> +                                             fb->layers);<br>
> +      }<br>
> +<br>
>        att_state->pending_clear_<wbr>aspects = 0;<br>
> +      att_state->pending_load_<wbr>aspects = 0;<br>
>     }<br>
><br>
>     cmd_buffer_emit_depth_stencil(<wbr>cmd_buffer);<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<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>
</blockquote></div><br></div></div>