<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 20, 2017 at 2:38 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Jul 19, 2017 at 02:01:29PM -0700, Jason Ekstrand wrote:<br>
> It turns out that if you have rendering in-flight with CCS_E enabled and<br>
> you go to do a depth resolve without flushing, the CCS data may never<br>
> hit the memory.<br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>blorp.c | 150 ++++++++++++++++--------------<wbr>----<br>
>  1 file changed, 72 insertions(+), 78 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> index 5335fae..efa3b39 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> @@ -1079,51 +1079,48 @@ intel_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
>         __func__, opname, mt, level, start_layer, start_layer + num_layers - 1);<br>
><br>
>     /* The following stalls and flushes are only documented to be required for<br>
> -    * HiZ clear operations.  However, they also seem to be required for the<br>
> -    * HiZ resolve operation which is basically the same as a fast clear only a<br>
> -    * different value is written into the HiZ surface.<br>
> +    * HiZ clear operations.  However, they also seem to be required for<br>
> +    * resolve operations.<br>
<br>
</span>How would feel putting some of the rational in the commit message here? Sounds<br>
valuable.<br><div><div class="h5"></div></div></blockquote><div><br></div><div>Hrm... I can, but I think the problem is most likely more general than CCS_E.  The fact that CCS_E happens to show it off doesn't mean that's why we need to do it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
>      */<br>
> -   if (op == BLORP_HIZ_OP_DEPTH_CLEAR || op == BLORP_HIZ_OP_HIZ_RESOLVE) {<br>
> -      if (brw->gen == 6) {<br>
> -         /* From the Sandy Bridge PRM, volume 2 part 1, page 313:<br>
> -          *<br>
> -          *   "If other rendering operations have preceded this clear, a<br>
> -          *   PIPE_CONTROL with write cache flush enabled and Z-inhibit<br>
> -          *   disabled must be issued before the rectangle primitive used for<br>
> -          *   the depth buffer clear operation.<br>
> -          */<br>
> -          brw_emit_pipe_control_flush(<wbr>brw,<br>
> -                                      PIPE_CONTROL_RENDER_TARGET_<wbr>FLUSH |<br>
> -                                      PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> -                                      PIPE_CONTROL_CS_STALL);<br>
> -      } else if (brw->gen >= 7) {<br>
> -         /*<br>
> -          * From the Ivybridge PRM, volume 2, "Depth Buffer Clear":<br>
> -          *<br>
> -          *   If other rendering operations have preceded this clear, a<br>
> -          *   PIPE_CONTROL with depth cache flush enabled, Depth Stall bit<br>
> -          *   enabled must be issued before the rectangle primitive used for<br>
> -          *   the depth buffer clear operation.<br>
> -          *<br>
> -          * Same applies for Gen8 and Gen9.<br>
> -          *<br>
> -          * In addition, from the Ivybridge PRM, volume 2, 1.10.4.1<br>
> -          * PIPE_CONTROL, Depth Cache Flush Enable:<br>
> -          *<br>
> -          *   This bit must not be set when Depth Stall Enable bit is set in<br>
> -          *   this packet.<br>
> -          *<br>
> -          * This is confirmed to hold for real, HSW gets immediate gpu hangs.<br>
> -          *<br>
> -          * Therefore issue two pipe control flushes, one for cache flush and<br>
> -          * another for depth stall.<br>
> -          */<br>
> -          brw_emit_pipe_control_flush(<wbr>brw,<br>
> -                                      PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> -                                      PIPE_CONTROL_CS_STALL);<br>
> +   if (brw->gen == 6) {<br>
> +      /* From the Sandy Bridge PRM, volume 2 part 1, page 313:<br>
> +       *<br>
> +       *   "If other rendering operations have preceded this clear, a<br>
> +       *   PIPE_CONTROL with write cache flush enabled and Z-inhibit<br>
> +       *   disabled must be issued before the rectangle primitive used for<br>
> +       *   the depth buffer clear operation.<br>
> +       */<br>
> +       brw_emit_pipe_control_flush(<wbr>brw,<br>
> +                                   PIPE_CONTROL_RENDER_TARGET_<wbr>FLUSH |<br>
> +                                   PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> +                                   PIPE_CONTROL_CS_STALL);<br>
> +   } else if (brw->gen >= 7) {<br>
> +      /*<br>
> +       * From the Ivybridge PRM, volume 2, "Depth Buffer Clear":<br>
> +       *<br>
> +       *   If other rendering operations have preceded this clear, a<br>
> +       *   PIPE_CONTROL with depth cache flush enabled, Depth Stall bit<br>
> +       *   enabled must be issued before the rectangle primitive used for<br>
> +       *   the depth buffer clear operation.<br>
> +       *<br>
> +       * Same applies for Gen8 and Gen9.<br>
> +       *<br>
> +       * In addition, from the Ivybridge PRM, volume 2, 1.10.4.1<br>
> +       * PIPE_CONTROL, Depth Cache Flush Enable:<br>
> +       *<br>
> +       *   This bit must not be set when Depth Stall Enable bit is set in<br>
> +       *   this packet.<br>
> +       *<br>
> +       * This is confirmed to hold for real, HSW gets immediate gpu hangs.<br>
> +       *<br>
> +       * Therefore issue two pipe control flushes, one for cache flush and<br>
> +       * another for depth stall.<br>
> +       */<br>
> +       brw_emit_pipe_control_flush(<wbr>brw,<br>
> +                                   PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> +                                   PIPE_CONTROL_CS_STALL);<br>
><br>
> -          brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_DEPTH_STALL);<br>
> -      }<br>
> +       brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_DEPTH_STALL);<br>
>     }<br>
><br>
><br>
> @@ -1140,42 +1137,39 @@ intel_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
>     blorp_batch_finish(&batch);<br>
><br>
>     /* The following stalls and flushes are only documented to be required for<br>
> -    * HiZ clear operations.  However, they also seem to be required for the<br>
> -    * HiZ resolve operation which is basically the same as a fast clear only a<br>
> -    * different value is written into the HiZ surface.<br>
> +    * HiZ clear operations.  However, they also seem to be required for<br>
> +    * resolve operations.<br>
>      */<br>
> -   if (op == BLORP_HIZ_OP_DEPTH_CLEAR || op == BLORP_HIZ_OP_HIZ_RESOLVE) {<br>
> -      if (brw->gen == 6) {<br>
> -         /* From the Sandy Bridge PRM, volume 2 part 1, page 314:<br>
> -          *<br>
> -          *     "DevSNB, DevSNB-B{W/A}]: Depth buffer clear pass must be<br>
> -          *     followed by a PIPE_CONTROL command with DEPTH_STALL bit set<br>
> -          *     and Then followed by Depth FLUSH'<br>
> -         */<br>
> -         brw_emit_pipe_control_flush(<wbr>brw,<br>
> -                                     PIPE_CONTROL_DEPTH_STALL);<br>
> -<br>
> -         brw_emit_pipe_control_flush(<wbr>brw,<br>
> -                                     PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> -                                     PIPE_CONTROL_CS_STALL);<br>
> -      } else if (brw->gen >= 8) {<br>
> -         /*<br>
> -          * From the Broadwell PRM, volume 7, "Depth Buffer Clear":<br>
> -          *<br>
> -          *    "Depth buffer clear pass using any of the methods (WM_STATE,<br>
> -          *    3DSTATE_WM or 3DSTATE_WM_HZ_OP) must be followed by a<br>
> -          *    PIPE_CONTROL command with DEPTH_STALL bit and Depth FLUSH bits<br>
> -          *    "set" before starting to render.  DepthStall and DepthFlush are<br>
> -          *    not needed between consecutive depth clear passes nor is it<br>
> -          *    required if the depth clear pass was done with<br>
> -          *    'full_surf_clear' bit set in the 3DSTATE_WM_HZ_OP."<br>
> -          *<br>
> -          *  TODO: Such as the spec says, this could be conditional.<br>
> -          */<br>
> -         brw_emit_pipe_control_flush(<wbr>brw,<br>
> -                                     PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> -                                     PIPE_CONTROL_DEPTH_STALL);<br>
> +   if (brw->gen == 6) {<br>
> +      /* From the Sandy Bridge PRM, volume 2 part 1, page 314:<br>
> +       *<br>
> +       *     "DevSNB, DevSNB-B{W/A}]: Depth buffer clear pass must be<br>
> +       *     followed by a PIPE_CONTROL command with DEPTH_STALL bit set<br>
> +       *     and Then followed by Depth FLUSH'<br>
> +      */<br>
> +      brw_emit_pipe_control_flush(<wbr>brw,<br>
> +                                  PIPE_CONTROL_DEPTH_STALL);<br>
> +<br>
> +      brw_emit_pipe_control_flush(<wbr>brw,<br>
> +                                  PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> +                                  PIPE_CONTROL_CS_STALL);<br>
> +   } else if (brw->gen >= 8) {<br>
> +      /*<br>
> +       * From the Broadwell PRM, volume 7, "Depth Buffer Clear":<br>
> +       *<br>
> +       *    "Depth buffer clear pass using any of the methods (WM_STATE,<br>
> +       *    3DSTATE_WM or 3DSTATE_WM_HZ_OP) must be followed by a<br>
> +       *    PIPE_CONTROL command with DEPTH_STALL bit and Depth FLUSH bits<br>
> +       *    "set" before starting to render.  DepthStall and DepthFlush are<br>
> +       *    not needed between consecutive depth clear passes nor is it<br>
> +       *    required if the depth clear pass was done with<br>
> +       *    'full_surf_clear' bit set in the 3DSTATE_WM_HZ_OP."<br>
> +       *<br>
> +       *  TODO: Such as the spec says, this could be conditional.<br>
> +       */<br>
> +      brw_emit_pipe_control_flush(<wbr>brw,<br>
> +                                  PIPE_CONTROL_DEPTH_CACHE_FLUSH |<br>
> +                                  PIPE_CONTROL_DEPTH_STALL);<br>
><br>
> -      }<br>
>     }<br>
>  }<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>