[Mesa-dev] [PATCH V2 10/11] genX/cmd_buffer: Enable fast depth clears

Nanley Chery nanleychery at gmail.com
Tue Sep 27 00:10:24 UTC 2016


From: Nanley Chery <nanleychery at gmail.com>

Provides an FPS increase of ~30% on the Sascha triangle and multisampling
demos.

Clears that happen within a render pass via vkCmdClearAttachments are safe
even if the clear color changes. This is because the meta implementation does
not use LOAD_OP_CLEAR which avoids any conflicts with 3DSTATE_CLEAR_PARAMS.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

v2. Update granularity comment for accuracy

 src/intel/vulkan/anv_pass.c        | 13 +++++++++++++
 src/intel/vulkan/gen8_cmd_buffer.c |  6 ++++++
 src/intel/vulkan/genX_cmd_buffer.c |  4 +---
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c
index 69c3c7e..595c2ea 100644
--- a/src/intel/vulkan/anv_pass.c
+++ b/src/intel/vulkan/anv_pass.c
@@ -155,5 +155,18 @@ void anv_GetRenderAreaGranularity(
     VkRenderPass                                renderPass,
     VkExtent2D*                                 pGranularity)
 {
+   ANV_FROM_HANDLE(anv_render_pass, pass, renderPass);
+
+   /* This granularity satisfies HiZ fast clear alignment requirements
+    * for all sample counts.
+    */
+   for (unsigned i = 0; i < pass->subpass_count; ++i) {
+      if (pass->subpasses[i].depth_stencil_attachment !=
+          VK_ATTACHMENT_UNUSED) {
+         *pGranularity = (VkExtent2D) { .width = 8, .height = 4 };
+         return;
+      }
+   }
+
    *pGranularity = (VkExtent2D) { 1, 1 };
 }
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c
index 14e6a7b..96e972c 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -479,6 +479,12 @@ genX(cmd_buffer_do_hz_op)(struct anv_cmd_buffer *cmd_buffer,
              cmd_state->render_area.extent.height % px_dim.h)
             return;
       }
+
+      anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CLEAR_PARAMS), cp) {
+         cp.DepthClearValueValid = true;
+         cp.DepthClearValue =
+            cmd_buffer->state.attachments[ds].clear_value.depthStencil.depth;
+      }
       break;
    case BLORP_HIZ_OP_DEPTH_RESOLVE:
       if (cmd_buffer->state.pass->attachments[ds].store_op !=
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 2cb1539..290fefc 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1320,9 +1320,6 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
    } else {
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_STENCIL_BUFFER), sb);
    }
-
-   /* Clear the clear params. */
-   anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CLEAR_PARAMS), cp);
 }
 
 /**
@@ -1357,6 +1354,7 @@ void genX(CmdBeginRenderPass)(
 
    genX(cmd_buffer_set_subpass)(cmd_buffer, pass->subpasses);
    genX(cmd_buffer_do_hz_op)(cmd_buffer, BLORP_HIZ_OP_HIZ_RESOLVE);
+   genX(cmd_buffer_do_hz_op)(cmd_buffer, BLORP_HIZ_OP_DEPTH_CLEAR);
    anv_cmd_buffer_clear_subpass(cmd_buffer);
 }
 
-- 
2.10.0



More information about the mesa-dev mailing list