<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 31, 2016 at 8:29 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">Provides an FPS increase of ~30% on the Sascha triangle and multisampling<br>
demos.<br>
<br>
Clears that happen within a render pass via vkCmdClearAttachments are safe<br>
even if the clear color changes. This is because the meta implementation does<br>
not use LOAD_OP_CLEAR which avoids any conflicts with 3DSTATE_CLEAR_PARAMS.<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/anv_pass.c        | 11 +++++++++++<br>
 src/intel/vulkan/gen8_cmd_<wbr>buffer.c |  6 ++++++<br>
 src/intel/vulkan/genX_cmd_<wbr>buffer.c |  4 +---<br>
 3 files changed, 18 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c<br>
index 69c3c7e..823f9cf 100644<br>
--- a/src/intel/vulkan/anv_pass.c<br>
+++ b/src/intel/vulkan/anv_pass.c<br>
@@ -155,5 +155,16 @@ void anv_GetRenderAreaGranularity(<br>
     VkRenderPass                                renderPass,<br>
     VkExtent2D*                                 pGranularity)<br>
 {<br>
+   ANV_FROM_HANDLE(anv_render_<wbr>pass, pass, renderPass);<br>
+<br>
+   /* This granularity is needed for HiZ fast clears */<br>
+   for (unsigned i = 0; i < pass->subpass_count; ++i) {<br>
+      if (pass->subpasses[i].depth_<wbr>stencil_attachment !=<br>
+          VK_ATTACHMENT_UNUSED) {<br>
+         *pGranularity = (VkExtent2D) { 8, 4 };<br>
+         return;<br>
+      }<br>
+   }<br></blockquote><div> </div>Thanks for remembering this!  As mentioned in an earlier e-mail, I'm not sure this is needed for Sky Lake or Broadwell with a format other than D16_UNORM but setting it all the time doesn't hurt.  8x4 isn't onerous and once we get fast clears, it'll get much bigger anyway.<br><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
    *pGranularity = (VkExtent2D) { 1, 1 };<br>
 }<br>
diff --git a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
index 7f65fe2..ec91ecd 100644<br>
--- a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
@@ -451,6 +451,12 @@ genX(cmd_buffer_do_hz_op)(<wbr>struct anv_cmd_buffer *cmd_buffer, enum anv_hz_op op)<br>
              cmd_state->render_area.extent.<wbr>height % align_h)<br>
             return;<br>
       }<br>
+<br>
+      anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_CLEAR_PARAMS), cp) {<br>
+         cp.DepthClearValueValid = true;<br>
+         cp.DepthClearValue =<br>
+            cmd_buffer->state.attachments[<wbr>ds].clear_value.depthStencil.<wbr>depth;<br>
+      }<br></blockquote><div><br></div><div>Hrm... I'm not sure where the best place to set CLEAR_PARAMS is.  It might almost be better in BeginSubpass...  In any case, I think this works.  We can move it later if we want.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       break;<br>
    case ANV_HZ_OP_DEPTH_RESOLVE:<br>
       if (cmd_buffer->state.pass-><wbr>attachments[ds].store_op !=<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 349d2a4..7d2a6bd 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -1159,9 +1159,6 @@ cmd_buffer_emit_depth_stencil(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
    } else {<br>
       anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
    }<br>
-<br>
-   /* Clear the clear params. */<br>
-   anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(3DSTATE_CLEAR_PARAMS), cp);<br>
 }<br>
<br>
 /**<br>
@@ -1196,6 +1193,7 @@ void genX(CmdBeginRenderPass)(<br>
<br>
    genX(cmd_buffer_set_subpass)(<wbr>cmd_buffer, pass->subpasses);<br>
    genX(cmd_buffer_do_hz_op)(cmd_<wbr>buffer, ANV_HZ_OP_HIZ_RESOLVE);<br>
+   genX(cmd_buffer_do_hz_op)(cmd_<wbr>buffer, ANV_HZ_OP_CLEAR);<br>
    anv_cmd_buffer_clear_subpass(<wbr>cmd_buffer);<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.9.3<br>
<br>
</font></span></blockquote></div><br></div></div>