<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 5:10 PM, 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">From: Chad Versace <<a href="mailto:chad.versace@intel.com">chad.versace@intel.com</a>><br>
<br>
Nanley Chery:<br>
(rebase)<br>
 - Resolve conflicts with new anv_batch_emit macro<br>
(amend)<br>
 - Handle a QPitch TODO<br>
 - Emit 3DSTATE_HIER_DEPTH_BUFFER on pre-BDW systems<br>
 - Only use HiZ for single-subpass renderpasses<br>
 - Emit the HiZ instruction before the stencil instruction to follow the<br>
   optimized clear sequence specified in the PRMs<br>
 - Don't modify clear params<br>
 - Enable resolves when a HiZ buffer is used to ensure depth buffer validity<br>
<br>
Provides an FPS increase of ~15% on the Sascha triangle and multisampling<br>
demos.<br>
<br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<br>
---<br>
<br>
v2: Emit zero'ed 3DSTATE_HIER_DEPTH_BUFFER when hiz is disabled<br>
    (Jason, Chad)<br>
<br>
 src/intel/vulkan/gen8_cmd_<wbr>buffer.c |  4 ++++<br>
 src/intel/vulkan/genX_cmd_<wbr>buffer.c | 43 ++++++++++++++++++++++++++++++<wbr>++++----<br>
 2 files changed, 43 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
index a13413c..14e6a7b 100644<br>
--- a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
@@ -417,6 +417,10 @@ genX(cmd_buffer_do_hz_op)(<wbr>struct anv_cmd_buffer *cmd_buffer,<br>
    if (iview == NULL || !anv_image_has_hiz(iview-><wbr>image))<br>
       return;<br>
<br>
+   /* FIXME: Implement multi-subpass HiZ */<br>
+   if (cmd_buffer->state.pass-><wbr>subpass_count > 1)<br>
+      return;<br>
+<br>
    const uint32_t ds = cmd_state->subpass->depth_<wbr>stencil_attachment;<br>
    const bool full_surface_op =<br>
              cmd_state->render_area.extent.<wbr>width == iview->extent.width &&<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 6a84383..2cb1539 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -1199,6 +1199,7 @@ cmd_buffer_emit_depth_stencil(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
       anv_cmd_buffer_get_depth_<wbr>stencil_view(cmd_buffer);<br>
    const struct anv_image *image = iview ? iview->image : NULL;<br>
    const bool has_depth = image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT);<br>
+   const bool has_hiz = image != NULL && anv_image_has_hiz(image);<br>
    const bool has_stencil =<br>
       image && (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT);<br>
<br>
@@ -1211,7 +1212,12 @@ cmd_buffer_emit_depth_stencil(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
          db.SurfaceType                   = SURFTYPE_2D;<br>
          db.DepthWriteEnable              = true;<br>
          db.StencilWriteEnable            = has_stencil;<br>
-         db.<wbr>HierarchicalDepthBufferEnable = false;<br>
+<br>
+         if (cmd_buffer->state.pass-><wbr>subpass_count == 1) {<br>
+            db.<wbr>HierarchicalDepthBufferEnable = has_hiz;<br>
+         } else {<br>
+            anv_finishme("Multiple-subpass HiZ not implemented");<br>
+         }<br>
<br>
          db.SurfaceFormat = isl_surf_get_depth_format(&<wbr>device->isl_dev,<br>
                                                       &image->depth_surface.isl);<br>
@@ -1263,6 +1269,36 @@ cmd_buffer_emit_depth_stencil(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
       }<br>
    }<br>
<br>
+   if (has_hiz) {<br>
+      anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hdb) {<br>
+         hdb.<wbr>HierarchicalDepthBufferObjectC<wbr>ontrolState = GENX(MOCS);<br>
+         hdb.SurfacePitch = image->hiz_surface.isl.row_<wbr>pitch - 1;<br>
+         hdb.SurfaceBaseAddress = (struct anv_address) {<br>
+            .bo = image->bo,<br>
+            .offset = image->offset + image->hiz_surface.offset,<br>
+         };<br>
+#if GEN_GEN >= 8<br>
+         /* From the SKL PRM Vol2a:<br>
+          *<br>
+          *    The interpretation of this field is dependent on Surface Type<br>
+          *    as follows:<br>
+          *    - SURFTYPE_1D: distance in pixels between array slices<br>
+          *    - SURFTYPE_2D/CUBE: distance in rows between array slices<br>
+          *    - SURFTYPE_3D: distance in rows between R - slices<br>
+          *<br>
+          * ISL implements HiZ surfaces for 1D depth buffers as 2D. Therefore<br>
+          * the depth buffer needs to be checked for the dimension.<br>
+          */<br>
+         hdb.SurfaceQPitch =<br>
+            image->depth_surface.isl.dim == ISL_SURF_DIM_1D ?<br>
+               isl_surf_get_array_pitch_el(&<wbr>image->hiz_surface.isl) >> 2 :<br>
+               isl_surf_get_array_pitch_el_<wbr>rows(&image->hiz_surface.isl) >> 2;<br>
+#endif<br>
+      }<br>
+   } else {<br>
+      anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hdb);<br>
+   }<br>
+<br>
    /* Emit 3DSTATE_STENCIL_BUFFER */<br>
    if (has_stencil) {<br>
       anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_STENCIL_BUFFER), sb) {<br>
@@ -1285,9 +1321,6 @@ cmd_buffer_emit_depth_stencil(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
       anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
    }<br>
<br>
-   /* Disable hierarchial depth buffers. */<br>
-   anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hz);<br>
-<br>
    /* Clear the clear params. */<br>
    anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_CLEAR_PARAMS), cp);<br>
 }<br>
@@ -1323,6 +1356,7 @@ void genX(CmdBeginRenderPass)(<br>
    genX(flush_pipeline_select_3d)<wbr>(cmd_buffer);<br>
<br>
    genX(cmd_buffer_set_subpass)(<wbr>cmd_buffer, pass->subpasses);<br>
+   genX(cmd_buffer_do_hz_op)(cmd_<wbr>buffer, BLORP_HIZ_OP_HIZ_RESOLVE);<br>
    anv_cmd_buffer_clear_subpass(<wbr>cmd_buffer);<br>
 }<br>
<br>
@@ -1344,6 +1378,7 @@ void genX(CmdEndRenderPass)(<br>
 {<br>
    ANV_FROM_HANDLE(anv_cmd_<wbr>buffer, cmd_buffer, commandBuffer);<br>
<br>
+   genX(cmd_buffer_do_hz_op)(cmd_<wbr>buffer, BLORP_HIZ_OP_DEPTH_RESOLVE);<br>
    anv_cmd_buffer_resolve_<wbr>subpass(cmd_buffer);<br>
<br>
 #ifndef NDEBUG<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.10.0<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>
</font></span></blockquote></div><br></div>