<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 30, 2017 at 2:06 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, Mar 14, 2017 at 07:55:53AM -0700, Jason Ekstrand wrote:<br>
> Instead of figuring it all out ourselves, just use the information given<br>
> to us by the client.<br>
> ---<br>
>  src/intel/vulkan/anv_blorp.c       | 88 ++++--------------------------<wbr>--------<br>
>  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 10 +++++<br>
>  2 files changed, 18 insertions(+), 80 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> index 8de339c..41966d6 100644<br>
> --- a/src/intel/vulkan/anv_blorp.c<br>
> +++ b/src/intel/vulkan/anv_blorp.c<br>
> @@ -1070,80 +1070,6 @@ enum subpass_stage {<br>
>  };<br>
><br>
>  static bool<br>
> -attachment_needs_flush(struct anv_cmd_buffer *cmd_buffer,<br>
> -                       struct anv_render_pass_attachment *att,<br>
> -                       enum subpass_stage stage)<br>
> -{<br>
> -   struct anv_render_pass *pass = cmd_buffer->state.pass;<br>
> -   const uint32_t subpass_idx = anv_get_subpass_id(&cmd_<wbr>buffer->state);<br>
> -<br>
> -   /* We handle this subpass specially based on the current stage */<br>
> -   enum anv_subpass_usage usage = att->subpass_usage[subpass_<wbr>idx];<br>
> -   switch (stage) {<br>
> -   case SUBPASS_STAGE_LOAD:<br>
> -      if (usage & (ANV_SUBPASS_USAGE_INPUT | ANV_SUBPASS_USAGE_RESOLVE_SRC)<wbr>)<br>
> -         return true;<br>
> -      break;<br>
> -<br>
> -   case SUBPASS_STAGE_DRAW:<br>
> -      if (usage & ANV_SUBPASS_USAGE_RESOLVE_SRC)<br>
> -         return true;<br>
> -      break;<br>
> -<br>
> -   default:<br>
> -      break;<br>
> -   }<br>
> -<br>
> -   for (uint32_t s = subpass_idx + 1; s < pass->subpass_count; s++) {<br>
> -      usage = att->subpass_usage[s];<br>
> -<br>
> -      /* If this attachment is going to be used as an input in this or any<br>
> -       * future subpass, then we need to flush its cache and invalidate the<br>
> -       * texture cache.<br>
> -       */<br>
> -      if (att->subpass_usage[s] & ANV_SUBPASS_USAGE_INPUT)<br>
> -         return true;<br>
> -<br>
> -      if (usage & (ANV_SUBPASS_USAGE_DRAW | ANV_SUBPASS_USAGE_RESOLVE_DST)<wbr>) {<br>
> -         /* We found another subpass that draws to this attachment.  We'll<br>
> -          * wait to resolve until then.<br>
> -          */<br>
> -         return false;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   return false;<br>
> -}<br>
> -<br>
> -static void<br>
> -anv_cmd_buffer_flush_<wbr>attachments(struct anv_cmd_buffer *cmd_buffer,<br>
> -                                 enum subpass_stage stage)<br>
> -{<br>
> -   struct anv_subpass *subpass = cmd_buffer->state.subpass;<br>
> -   struct anv_render_pass *pass = cmd_buffer->state.pass;<br>
> -<br>
> -   for (uint32_t i = 0; i < subpass->color_count; ++i) {<br>
> -      uint32_t att = subpass->color_attachments[i].<wbr>attachment;<br>
> -      assert(att < pass->attachment_count);<br>
> -      if (attachment_needs_flush(cmd_<wbr>buffer, &pass->attachments[att], stage)) {<br>
> -         cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> -            ANV_PIPE_TEXTURE_CACHE_<wbr>INVALIDATE_BIT |<br>
> -            ANV_PIPE_RENDER_TARGET_CACHE_<wbr>FLUSH_BIT;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   if (subpass->depth_stencil_<wbr>attachment.attachment != VK_ATTACHMENT_UNUSED) {<br>
> -      uint32_t att = subpass->depth_stencil_<wbr>attachment.attachment;<br>
> -      assert(att < pass->attachment_count);<br>
> -      if (attachment_needs_flush(cmd_<wbr>buffer, &pass->attachments[att], stage)) {<br>
> -         cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> -            ANV_PIPE_TEXTURE_CACHE_<wbr>INVALIDATE_BIT |<br>
> -            ANV_PIPE_DEPTH_CACHE_FLUSH_<wbr>BIT;<br>
> -      }<br>
> -   }<br>
> -}<br>
> -<br>
> -static bool<br>
>  subpass_needs_clear(const struct anv_cmd_buffer *cmd_buffer)<br>
>  {<br>
>     const struct anv_cmd_state *cmd_state = &cmd_buffer->state;<br>
> @@ -1327,8 +1253,6 @@ anv_cmd_buffer_clear_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
>     }<br>
><br>
>     blorp_batch_finish(&batch);<br>
> -<br>
> -   anv_cmd_buffer_flush_<wbr>attachments(cmd_buffer, SUBPASS_STAGE_LOAD);<br>
>  }<br>
><br>
>  static void<br>
> @@ -1554,9 +1478,15 @@ anv_cmd_buffer_resolve_<wbr>subpass(struct anv_cmd_buffer *cmd_buffer)<br>
>                               subpass->color_attachments[i].<wbr>attachment);<br>
>     }<br>
><br>
> -   anv_cmd_buffer_flush_<wbr>attachments(cmd_buffer, SUBPASS_STAGE_DRAW);<br>
> -<br>
>     if (subpass->has_resolve) {<br>
> +      /* We are about to do some MSAA resolves.  We need to flush so that the<br>
> +       * result of writes to the MSAA color attachments show up in the sampler<br>
> +       * when we blit to the single-sampled resolve target.<br>
> +       */<br>
> +      cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> +         ANV_PIPE_TEXTURE_CACHE_<wbr>INVALIDATE_BIT |<br>
> +         ANV_PIPE_RENDER_TARGET_CACHE_<wbr>FLUSH_BIT;<br>
> +<br>
>        for (uint32_t i = 0; i < subpass->color_count; ++i) {<br>
>           uint32_t src_att = subpass->color_attachments[i].<wbr>attachment;<br>
>           uint32_t dst_att = subpass->resolve_attachments[<wbr>i].attachment;<br>
> @@ -1594,8 +1524,6 @@ anv_cmd_buffer_resolve_<wbr>subpass(struct anv_cmd_buffer *cmd_buffer)<br>
><br>
>           ccs_resolve_attachment(cmd_<wbr>buffer, &batch, dst_att);<br>
>        }<br>
> -<br>
> -      anv_cmd_buffer_flush_<wbr>attachments(cmd_buffer, SUBPASS_STAGE_RESOLVE);<br>
>     }<br>
><br>
>     blorp_batch_finish(&batch);<br>
> diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> index acb59d5..02dff44 100644<br>
> --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> @@ -2456,6 +2456,9 @@ void genX(CmdBeginRenderPass)(<br>
>     genX(flush_pipeline_select_3d)<wbr>(cmd_buffer);<br>
><br>
>     genX(cmd_buffer_set_subpass)(<wbr>cmd_buffer, pass->subpasses);<br>
> +<br>
> +   cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> +      cmd_buffer->state.pass-><wbr>subpass_flushes[0];<br>
>  }<br>
><br>
>  void genX(CmdNextSubpass)(<br>
> @@ -2473,6 +2476,10 @@ void genX(CmdNextSubpass)(<br>
>     cmd_buffer_subpass_transition_<wbr>layouts(cmd_buffer, true);<br>
><br>
>     genX(cmd_buffer_set_subpass)(<wbr>cmd_buffer, cmd_buffer->state.subpass + 1);<br>
> +<br>
> +   uint32_t subpass_id = anv_get_subpass_id(&cmd_<wbr>buffer->state);<br>
> +   cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> +      cmd_buffer->state.pass-><wbr>subpass_flushes[subpass_id];<br>
<br>
</div></div>Looks like we could move this hunk into genX(cmd_buffer_set_subpass)()<wbr>.<br></blockquote><div><br></div><div>We could, yes, and I thought about doing so.  I elected not to because the subpass flushes are really something that happens *between* subpasses so you have to have it Begin, Next, and End.  If we rolled it into set_subpass, I think it would be more confusing what's going on.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Nanley<br>
<span class=""><br>
>  }<br>
><br>
>  void genX(CmdEndRenderPass)(<br>
> @@ -2486,6 +2493,9 @@ void genX(CmdEndRenderPass)(<br>
>      */<br>
>     cmd_buffer_subpass_transition_<wbr>layouts(cmd_buffer, true);<br>
><br>
> +   cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> +      cmd_buffer->state.pass-><wbr>subpass_flushes[cmd_buffer-><wbr>state.pass->subpass_count];<br>
> +<br>
>     cmd_buffer->state.hiz_enabled = false;<br>
><br>
>  #ifndef NDEBUG<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</span>> ______________________________<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>