<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 28, 2017 at 5:54 AM, 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 27, 2017 at 08:41:56PM -0800, Jason Ekstrand wrote:<br>
> On Feb 27, 2017 5:21 PM, "Nanley Chery" <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
><br>
> Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> ---<br>
>  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 57 ++++++++++--------------------<br>
> --------<br>
>  1 file changed, 15 insertions(+), 42 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> index 5171e6f587..60230bf14b 100644<br>
> --- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
> @@ -326,27 +326,6 @@ need_input_attachment_state(<wbr>const struct<br>
> anv_render_pass_attachment *att)<br>
>     return vk_format_is_color(att-><wbr>format);<br>
>  }<br>
><br>
> -static enum isl_aux_usage<br>
> -layout_to_hiz_usage(<wbr>VkImageLayout layout, uint8_t samples)<br>
> -{<br>
> -   switch (layout) {<br>
> -   case VK_IMAGE_LAYOUT_DEPTH_STENCIL_<wbr>ATTACHMENT_OPTIMAL:<br>
> -      return ISL_AUX_USAGE_HIZ;<br>
> -   case VK_IMAGE_LAYOUT_DEPTH_STENCIL_<wbr>READ_ONLY_OPTIMAL:<br>
> -   case VK_IMAGE_LAYOUT_SHADER_READ_<wbr>ONLY_OPTIMAL:<br>
> -      if (anv_can_sample_with_hiz(GEN_<wbr>GEN, samples))<br>
> -         return ISL_AUX_USAGE_HIZ;<br>
> -      /* Fall-through */<br>
> -   case VK_IMAGE_LAYOUT_GENERAL:<br>
> -      /* This buffer could be used as a source or destination in a transfer<br>
> -       * operation. Transfer operations current don't perform HiZ-enabled<br>
> reads<br>
> -       * and writes.<br>
> -       */<br>
> -   default:<br>
> -      return ISL_AUX_USAGE_NONE;<br>
> -   }<br>
> -}<br>
> -<br>
>  /* Transitions a HiZ-enabled depth buffer from one layout to another.<br>
> Unless<br>
>   * the initial layout is undefined, the HiZ buffer and depth buffer will<br>
>   * represent the same data at the end of this operation.<br>
> @@ -362,21 +341,15 @@ transition_depth_buffer(struct anv_cmd_buffer<br>
> *cmd_buffer,<br>
>     if (image->aux_usage != ISL_AUX_USAGE_HIZ || final_layout ==<br>
> initial_layout)<br>
>        return;<br>
><br>
> -   const bool hiz_enabled = layout_to_hiz_usage(initial_<wbr>layout,<br>
> image->samples) ==<br>
> -                            ISL_AUX_USAGE_HIZ;<br>
> -   const bool enable_hiz = layout_to_hiz_usage(final_<wbr>layout,<br>
> image->samples) ==<br>
> -                           ISL_AUX_USAGE_HIZ;<br>
> +   const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==<br>
> +      anv_layout_to_aux_usage(GEN_<wbr>GEN, image, image->aspects,<br>
> +                              initial_layout, final_layout);<br>
> +   const bool enable_hiz = ISL_AUX_USAGE_HIZ ==<br>
> +      anv_layout_to_aux_usage(GEN_<wbr>GEN, image, image->aspects,<br>
> +                              final_layout, final_layout);<br>
><br>
>     enum blorp_hiz_op hiz_op;<br>
> -   if (initial_layout == VK_IMAGE_LAYOUT_UNDEFINED) {<br>
><br>
><br>
> I'm not sure how I feel about handling this in layout_to_aux_usage.  It<br>
> seems like a conflation of two things.  If this is the only reason for the<br>
> future_layout parameter, then it seems like it would be better handled<br>
> here.  In any case, I'll keep reading<br>
><br>
<br>
</div></div>Yes, that is the only reason for the future_layout parameter. I can<br>
remove it if you'd like.<br>
<br>
Currently the layout_to_aux_usage function determines the optimal<br>
aux_usage for all device accesses: sampling, rendering, transferring,<br>
and resolves. Removing the future_layout parameter would remove its<br>
responsibility for the last access type.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>In my brain, a transition from LAYOUT_UNDEFINED to LAYOUT_* is a transition from AUX_USAGE_NONE to AUX_USAGE_*.  However, we know based on some other bits of the driver, that we can skip that particular resolve because the HiZ surface is in a non-hanging state.  Also, the second parameter makes the function far less obvious and every other call sight of the function, even though it doesn't care, has to think about that parmeter.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
-Nanley<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> -      /* We've already initialized the aux HiZ buffer at BindImageMemory<br>
> time,<br>
> -       * so there's no need to perform a HIZ resolve or clear to avoid GPU<br>
> hangs.<br>
> -       * This initial layout indicates that the user doesn't care about<br>
> the data<br>
> -       * that's currently in the buffer, so resolves are not necessary<br>
> except<br>
> -       * for the special case noted below.<br>
> -       */<br>
> -      hiz_op = BLORP_HIZ_OP_NONE;<br>
> -   } else if (hiz_enabled && !enable_hiz) {<br>
> +   if (hiz_enabled && !enable_hiz) {<br>
>        hiz_op = BLORP_HIZ_OP_DEPTH_RESOLVE;<br>
>     } else if (!hiz_enabled && enable_hiz) {<br>
>        hiz_op = BLORP_HIZ_OP_HIZ_RESOLVE;<br>
> @@ -556,12 +529,11 @@ genX(cmd_buffer_setup_<wbr>attachments)(struct<br>
> anv_cmd_buffer *cmd_buffer,<br>
>                                    state->attachments[i].aux_<wbr>usage,<br>
>                                    state->attachments[i].color_<wbr>rt_state);<br>
>           } else {<br>
> -            if (iview->image->aux_usage == ISL_AUX_USAGE_HIZ) {<br>
> -               state->attachments[i].aux_<wbr>usage =<br>
> -                  layout_to_hiz_usage(att-><wbr>initial_layout,<br>
> iview->image->samples);<br>
> -            } else {<br>
> -               state->attachments[i].aux_<wbr>usage = ISL_AUX_USAGE_NONE;<br>
> -            }<br>
> +            /* This field will be initialized after the first subpass<br>
> +             * transition.<br>
> +             */<br>
> +            state->attachments[i].aux_<wbr>usage = ISL_AUX_USAGE_NONE;<br>
> +<br>
>              state->attachments[i].input_<wbr>aux_usage = ISL_AUX_USAGE_NONE;<br>
>           }<br>
><br>
> @@ -2399,8 +2371,9 @@ genX(cmd_buffer_set_subpass)(<wbr>struct anv_cmd_buffer<br>
> *cmd_buffer,<br>
>        cmd_buffer->state.attachments[<wbr>ds].current_layout =<br>
>           cmd_buffer->state.subpass-><wbr>depth_stencil_layout;<br>
>        cmd_buffer->state.attachments[<wbr>ds].aux_usage =<br>
> -         layout_to_hiz_usage(cmd_<wbr>buffer->state.subpass->depth_<wbr>stenci<br>
> l_layout,<br>
> -                             iview->image->samples);<br>
> +         anv_layout_to_aux_usage(GEN_<wbr>GEN, iview->image, iview->aspect_mask,<br>
> +            cmd_buffer->state.subpass-><wbr>depth_stencil_layout,<br>
> +            cmd_buffer->state.subpass-><wbr>depth_stencil_layout);<br>
>     }<br>
><br>
>     cmd_buffer_emit_depth_stencil(<wbr>cmd_buffer);<br>
> --<br>
> 2.11.1<br>
><br>
> ______________________________<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>
</div></div></blockquote></div><br></div></div>