<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Feb 27, 2017 5:21 PM, "Nanley Chery" <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br type="attribution"><blockquote class="m_4964689379129372670quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
---<br>
 src/intel/vulkan/genX_cmd_buf<wbr>fer.c | 57 ++++++++++--------------------<wbr>--------<br>
 1 file changed, 15 insertions(+), 42 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c b/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
index 5171e6f587..60230bf14b 100644<br>
--- a/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
@@ -326,27 +326,6 @@ need_input_attachment_state(co<wbr>nst struct anv_render_pass_attachment *att)<br>
    return vk_format_is_color(att->format<wbr>);<br>
 }<br>
<br>
-static enum isl_aux_usage<br>
-layout_to_hiz_usage(VkImageLa<wbr>yout 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_ON<wbr>LY_OPTIMAL:<br>
-      if (anv_can_sample_with_hiz(GEN_G<wbr>EN, 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 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. 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 *cmd_buffer,<br>
    if (image->aux_usage != ISL_AUX_USAGE_HIZ || final_layout == initial_layout)<br>
       return;<br>
<br>
-   const bool hiz_enabled = layout_to_hiz_usage(initial_la<wbr>yout, image->samples) ==<br>
-                            ISL_AUX_USAGE_HIZ;<br>
-   const bool enable_hiz = layout_to_hiz_usage(final_layo<wbr>ut, image->samples) ==<br>
-                           ISL_AUX_USAGE_HIZ;<br>
+   const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==<br>
+      anv_layout_to_aux_usage(GEN_GE<wbr>N, image, image->aspects,<br>
+                              initial_layout, final_layout);<br>
+   const bool enable_hiz = ISL_AUX_USAGE_HIZ ==<br>
+      anv_layout_to_aux_usage(GEN_GE<wbr>N, 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></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I'm not sure how I feel about handling this in layout_to_aux_usage.  It seems like a conflation of two things.  If this is the only reason for the future_layout parameter, then it seems like it would be better handled here.  In any case, I'll keep reading</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_4964689379129372670quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-      /* We've already initialized the aux HiZ buffer at BindImageMemory time,<br>
-       * so there's no need to perform a HIZ resolve or clear to avoid GPU hangs.<br>
-       * This initial layout indicates that the user doesn't care about the data<br>
-       * that's currently in the buffer, so resolves are not necessary 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_attachme<wbr>nts)(struct anv_cmd_buffer *cmd_buffer,<br>
                                   state->attachments[i].aux_usa<wbr>ge,<br>
                                   state->attachments[i].color_r<wbr>t_state);<br>
          } else {<br>
-            if (iview->image->aux_usage == ISL_AUX_USAGE_HIZ) {<br>
-               state->attachments[i].aux_usa<wbr>ge =<br>
-                  layout_to_hiz_usage(att->initi<wbr>al_layout, iview->image->samples);<br>
-            } else {<br>
-               state->attachments[i].aux_usa<wbr>ge = ISL_AUX_USAGE_NONE;<br>
-            }<br>
+            /* This field will be initialized after the first subpass<br>
+             * transition.<br>
+             */<br>
+            state->attachments[i].aux_usag<wbr>e = ISL_AUX_USAGE_NONE;<br>
+<br>
             state->attachments[i].input_a<wbr>ux_usage = ISL_AUX_USAGE_NONE;<br>
          }<br>
<br>
@@ -2399,8 +2371,9 @@ genX(cmd_buffer_set_subpass)(s<wbr>truct anv_cmd_buffer *cmd_buffer,<br>
       cmd_buffer->state.<wbr>attachments[ds].current_layout =<br>
          cmd_buffer->state.subpass->dep<wbr>th_stencil_layout;<br>
       cmd_buffer->state.<wbr>attachments[ds].aux_usage =<br>
-         layout_to_hiz_usage(cmd_buffe<wbr>r->state.subpass->depth_stenci<wbr>l_layout,<br>
-                             iview->image->samples);<br>
+         anv_layout_to_aux_usage(GEN_G<wbr>EN, iview->image, iview->aspect_mask,<br>
+            cmd_buffer->state.subpass->dep<wbr>th_stencil_layout,<br>
+            cmd_buffer->state.subpass->dep<wbr>th_stencil_layout);<br>
    }<br>
<br>
    cmd_buffer_emit_depth_stencil(<wbr>cmd_buffer);<br>
<font color="#888888">--<br>
2.11.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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>
</font></blockquote></div><br></div></div></div>