<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 22, 2018 at 2:18 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"><div class="HOEnZb"><div class="h5">On Fri, Jan 19, 2018 at 03:47:34PM -0800, Jason Ekstrand wrote:<br>
> Even though the blorp pass looks a bit on the sketchy side, the end<br>
> result in the Vulkan driver is very nice.  Instead of having this weird<br>
> case where you do a fast clear and then maybe have to resolve, we just<br>
> do the ambiguate and are done with it.  The ambiguate does exactly what<br>
> we want of setting all the CCS values to 0 which puts it inot the<br>
> pass-through state.<br>
><br>
> This should also improve performance a bit in certain cases.  For<br>
> instance, if we did a transition from UNDEFINED to GENERAL for a surface<br>
> that doesn't have CCS enabled all the time, we would end up doing a<br>
> fast-clear and then a full resolve which ends up touching every byte in<br>
> the main surface as well as the CCS.  With the ambiguate pass, that<br>
> transition only touches the CCS.<br>
> ---<br>
>  src/intel/vulkan/anv_blorp.c       |  5 ++++<br>
>  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 54 +++++++++---------------------<wbr>--------<br>
>  2 files changed, 17 insertions(+), 42 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> index 05efc6d..3698543 100644<br>
> --- a/src/intel/vulkan/anv_blorp.c<br>
> +++ b/src/intel/vulkan/anv_blorp.c<br>
> @@ -1792,6 +1792,11 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,<br>
>                          surf.surf->format, isl_to_blorp_fast_clear_op(<wbr>ccs_op));<br>
>        break;<br>
>     case ISL_AUX_OP_AMBIGUATE:<br>
> +      for (uint32_t a = 0; a < layer_count; a++) {<br>
> +         const uint32_t layer = base_layer + a;<br>
> +         blorp_ccs_ambiguate(&batch, &surf, level, layer);<br>
> +      }<br>
> +      break;<br>
>     default:<br>
>        unreachable("Unsupported CCS operation");<br>
>     }<br>
> diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> index 77fdadf..9e2eba3 100644<br>
> --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> @@ -486,15 +486,6 @@ init_fast_clear_state_entry(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
>     uint32_t plane = anv_image_aspect_to_plane(<wbr>image->aspects, aspect);<br>
>     enum isl_aux_usage aux_usage = image->planes[plane].aux_<wbr>usage;<br>
><br>
> -   /* The resolve flag should updated to signify that fast-clear/compression<br>
> -    * data needs to be removed when leaving the undefined layout. Such data<br>
> -    * may need to be removed if it would cause accesses to the color buffer<br>
> -    * to return incorrect data. The fast clear data in CCS_D buffers should<br>
> -    * be removed because CCS_D isn't enabled all the time.<br>
> -    */<br>
> -   genX(set_image_needs_resolve)(<wbr>cmd_buffer, image, aspect, level,<br>
> -                                 aux_usage == ISL_AUX_USAGE_NONE);<br>
> -<br>
>     /* The fast clear value dword(s) will be copied into a surface state object.<br>
>      * Ensure that the restrictions of the fields in the dword(s) are followed.<br>
>      *<br>
> @@ -677,10 +668,9 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>        for (unsigned level = base_level; level < last_level_num; level++)<br>
>           init_fast_clear_state_entry(<wbr>cmd_buffer, image, aspect, level);<br>
><br>
> -      /* Initialize the aux buffers to enable correct rendering. This operation<br>
> -       * requires up to two steps: one to rid the aux buffer of data that may<br>
> -       * cause GPU hangs, and another to ensure that writes done without aux<br>
> -       * will be visible to reads done with aux.<br>
> +      /* Initialize the aux buffers to enable correct rendering.  In order to<br>
> +       * ensure that things such as storage images work correctly, aux buffers<br>
> +       * are initialized to the pass-through state.<br>
>         *<br>
>         * Having an aux buffer with invalid data is possible for CCS buffers<br>
>         * SKL+ and for MCS buffers with certain sample counts (2x and 8x). One<br>
> @@ -692,16 +682,18 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>         * We don't have any data to show that this is a problem, but we want to<br>
>         * avoid causing difficult-to-debug problems.<br>
>         */<br>
> -      if (GEN_GEN >= 9 && image->samples == 1) {<br>
> +      if (image->samples == 1) {<br>
>           for (uint32_t l = 0; l < level_count; l++) {<br>
>              const uint32_t level = base_level + l;<br>
>              const uint32_t level_layer_count =<br>
>                 MIN2(layer_count, anv_image_aux_layers(image, aspect, level));<br>
>              anv_image_ccs_op(cmd_buffer, image, aspect, level,<br>
>                               base_layer, level_layer_count,<br>
> -                             ISL_AUX_OP_FAST_CLEAR, false);<br>
> +                             ISL_AUX_OP_AMBIGUATE, false);<br>
> +            genX(set_image_needs_resolve)(<wbr>cmd_buffer, image,<br>
> +                                          aspect, level, false);<br>
>           }<br>
> -      } else if (image->samples > 1) {<br>
> +      } else {<br>
>           if (image->samples == 4 || image->samples == 16) {<br>
>              anv_perf_warn(cmd_buffer-><wbr>device->instance, image,<br>
>                            "Doing a potentially unnecessary fast-clear to "<br>
> @@ -712,32 +704,10 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>           anv_image_mcs_op(cmd_buffer, image, aspect,<br>
>                            base_layer, layer_count,<br>
>                            ISL_AUX_OP_FAST_CLEAR, false);<br>
> -      }<br>
> -      /* At this point, some elements of the CCS buffer may have the fast-clear<br>
> -       * bit-arrangement. As the user writes to a subresource, we need to have<br>
> -       * the associated CCS elements enter the ambiguated state. This enables<br>
> -       * reads (implicit or explicit) to reflect the user-written data instead<br>
> -       * of the clear color. The only time such elements will not change their<br>
> -       * state as described above, is in a final layout that doesn't have CCS<br>
> -       * enabled. In this case, we must force the associated CCS buffers of the<br>
> -       * specified range to enter the ambiguated state in advance.<br>
> -       */<br>
> -      if (image->samples == 1 &&<br>
> -          image->planes[plane].aux_usage != ISL_AUX_USAGE_CCS_E &&<br>
> -          final_layout != VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL) {<br>
> -         /* The CCS_D buffer may not be enabled in the final layout. Call this<br>
> -          * function again with a initial layout of COLOR_ATTACHMENT_OPTIMAL<br>
> -          * to perform a resolve.<br>
> -          */<br>
> -          anv_perf_warn(cmd_buffer-><wbr>device->instance, image,<br>
> -                        "Performing an additional resolve for CCS_D layout "<br>
> -                        "transition. Consider always leaving it on or "<br>
> -                        "performing an ambiguation pass.");<br>
> -         transition_color_buffer(cmd_<wbr>buffer, image, aspect,<br>
> -                                 base_level, level_count,<br>
> -                                 base_layer, layer_count,<br>
> -                                 VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL,<br>
> -                                 final_layout);<br>
> +         for (unsigned level = base_level; level < last_level_num; level++) {<br>
<br>
</div></div>There shouldn't be need to iterate over levels here as this is now the block<br>
for multisampled images, right?<span class=""><br></span></blockquote><div><br></div><div>Yup.  I'll drop the loop.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +            genX(set_image_needs_resolve)(<wbr>cmd_buffer, image,<br>
> +                                          aspect, level, true);<br>
> +         }<br>
>        }<br>
>        return;<br>
>     }<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>