<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 22, 2018 at 12:17 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:26PM -0800, Jason Ekstrand wrote:<br>
> This moves it to being based on layout_to_aux_usage instead of being<br>
> hard-coded based on bits of a priori knowledge of how transitions<br>
> interact with layouts.  This conceptually simplifies things because<br>
> we're now using layout_to_aux_usage and layout_supports_fast_clear to<br>
> make resolve decisions so changes to those functions will do what one<br>
> expects.<br>
><br>
> This fixes a potential bug with window system integration on gen9+ where<br>
> we wouldn't do a resolve when transitioning to the PRESENT_SRC layout<br>
> because we just assume that everything that handles CCS_E can handle it<br>
> all the time.  When handing a CCS_E image off to the window system, we<br>
> may need to do a full resolve if the window system does not support the<br>
> CCS_E modifier.  The only reason why this hasn't been a problem yet is<br>
> because we don't support modifiers in Vulkan WSI and so we always get X<br>
> tiling which implies no CCS on gen9+.<br>
><br>
> v2 (Jason Ekstrand):<br>
>  - Make a few more things const<br>
>  - Use the anv_fast_clear_support enum<br>
><br>
> Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> ---<br>
>  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 56 ++++++++++++++++++++++++++++++<wbr>--------<br>
>  1 file changed, 44 insertions(+), 12 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 6a6d8b2..fd27463 100644<br>
> --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> @@ -593,6 +593,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>                          VkImageLayout initial_layout,<br>
>                          VkImageLayout final_layout)<br>
>  {<br>
> +   const struct gen_device_info *devinfo = &cmd_buffer->device->info;<br>
>     /* Validate the inputs. */<br>
>     assert(cmd_buffer);<br>
>     assert(image && image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_<wbr>ANV);<br>
> @@ -733,17 +734,51 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>                                   VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL,<br>
>                                   final_layout);<br>
>        }<br>
> -   } else if (initial_layout != VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL) {<br>
> -      /* Resolves are only necessary if the subresource may contain blocks<br>
> -       * fast-cleared to values unsupported in other layouts. This only occurs<br>
> -       * if the initial layout is COLOR_ATTACHMENT_OPTIMAL.<br>
> -       */<br>
> -      return;<br>
> -   } else if (image->samples > 1) {<br>
> -      /* MCS buffers don't need resolving. */<br>
>        return;<br>
>     }<br>
><br>
> +   /* If initial aux usage is NONE, there is nothing to resolve */<br>
> +   const enum isl_aux_usage initial_aux_usage =<br>
> +      anv_layout_to_aux_usage(<wbr>devinfo, image, aspect, initial_layout);<br>
> +   if (initial_aux_usage == ISL_AUX_USAGE_NONE)<br>
> +      return;<br>
> +<br>
> +   enum isl_aux_op resolve_op = ISL_AUX_OP_NONE;<br>
> +<br>
> +   /* If the initial layout supports more fast clear than the final layout<br>
> +    * then we need at least a partial resolve.<br>
> +    */<br>
> +   const enum anv_fast_clear_type initial_fast_clear =<br>
> +      anv_layout_to_fast_clear_type(<wbr>devinfo, image, aspect, initial_layout);<br>
> +   const enum anv_fast_clear_type final_fast_clear =<br>
> +      anv_layout_to_fast_clear_type(<wbr>devinfo, image, aspect, final_layout);<br>
> +   if (final_fast_clear < initial_fast_clear)<br>
> +      resolve_op = ISL_AUX_OP_PARTIAL_RESOLVE;<br>
> +<br>
> +   const enum isl_aux_usage final_aux_usage =<br>
> +      anv_layout_to_aux_usage(<wbr>devinfo, image, aspect, final_layout);<br>
> +   if (initial_aux_usage == ISL_AUX_USAGE_CCS_E &&<br>
> +       final_aux_usage != ISL_AUX_USAGE_CCS_E)<br>
> +      resolve_op = ISL_AUX_OP_FULL_RESOLVE;<br>
> +<br>
> +   /* CCS_D only supports full resolves and BLORP will assert on us if we try<br>
> +    * to do a partial resolve on a CCS_D surface.<br>
> +    */<br>
> +   if (resolve_op == ISL_AUX_OP_PARTIAL_RESOLVE &&<br>
> +       initial_aux_usage == ISL_AUX_USAGE_CCS_D)<br>
> +      resolve_op = ISL_AUX_OP_FULL_RESOLVE;<br>
> +<br>
> +   if (resolve_op == ISL_AUX_OP_NONE)<br>
> +      return;<br>
> +<br>
> +   /* Even though the above code can theoretically handle multiple resolve<br>
> +    * types such as CCS_D -> CCS_E, the predication code below can't.  We only<br>
> +    * really handle a couple of cases.<br>
> +    */<br>
> +   assert(initial_aux_usage == ISL_AUX_USAGE_NONE ||<br>
<br>
</div></div>Earlier there is explicit early return for<br>
"initial_aux_usage == ISL_AUX_USAGE_NONE". Just checking if you really meant<br>
to assert it here.<span class=""><br></span></blockquote><div><br></div><div>I don't know.  I'm trying to make the point with the assert of what the code can handle.  I can't do this assert any earlier because we don't have final_aux_usage until we get here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +          final_aux_usage == ISL_AUX_USAGE_NONE ||<br>
> +          initial_aux_usage == final_aux_usage);<br>
> +<br>
>     /* Perform a resolve to synchronize data between the main and aux buffer.<br>
>      * Before we begin, we must satisfy the cache flushing requirement specified<br>
>      * in the Sky Lake PRM Vol. 7, "MCS Buffer for Render Target(s)":<br>
> @@ -774,10 +809,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
>        genX(load_needs_resolve_<wbr>predicate)(cmd_buffer, image, aspect, level);<br>
><br>
>        anv_image_ccs_op(cmd_buffer, image, aspect, level,<br>
> -                       base_layer, layer_count,<br>
> -                       image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E ?<br>
> -                       ISL_AUX_OP_PARTIAL_RESOLVE : ISL_AUX_OP_FULL_RESOLVE,<br>
> -                       true);<br>
> +                       base_layer, layer_count, resolve_op, true);<br>
><br>
>        genX(set_image_needs_resolve)(<wbr>cmd_buffer, image, aspect, level, false);<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>