[Mesa-dev] [PATCH 11/12] genX/cmd_buffer: Enable fast depth clears
Nanley Chery
nanleychery at gmail.com
Thu Sep 1 03:29:57 UTC 2016
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>
---
src/intel/vulkan/anv_pass.c | 11 +++++++++++
src/intel/vulkan/gen8_cmd_buffer.c | 6 ++++++
src/intel/vulkan/genX_cmd_buffer.c | 4 +---
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c
index 69c3c7e..823f9cf 100644
--- a/src/intel/vulkan/anv_pass.c
+++ b/src/intel/vulkan/anv_pass.c
@@ -155,5 +155,16 @@ void anv_GetRenderAreaGranularity(
VkRenderPass renderPass,
VkExtent2D* pGranularity)
{
+ ANV_FROM_HANDLE(anv_render_pass, pass, renderPass);
+
+ /* This granularity is needed for HiZ fast clears */
+ for (unsigned i = 0; i < pass->subpass_count; ++i) {
+ if (pass->subpasses[i].depth_stencil_attachment !=
+ VK_ATTACHMENT_UNUSED) {
+ *pGranularity = (VkExtent2D) { 8, 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 7f65fe2..ec91ecd 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -451,6 +451,12 @@ genX(cmd_buffer_do_hz_op)(struct anv_cmd_buffer *cmd_buffer, enum anv_hz_op op)
cmd_state->render_area.extent.height % align_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 ANV_HZ_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 349d2a4..7d2a6bd 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1159,9 +1159,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);
}
/**
@@ -1196,6 +1193,7 @@ void genX(CmdBeginRenderPass)(
genX(cmd_buffer_set_subpass)(cmd_buffer, pass->subpasses);
genX(cmd_buffer_do_hz_op)(cmd_buffer, ANV_HZ_OP_HIZ_RESOLVE);
+ genX(cmd_buffer_do_hz_op)(cmd_buffer, ANV_HZ_OP_CLEAR);
anv_cmd_buffer_clear_subpass(cmd_buffer);
}
--
2.9.3
More information about the mesa-dev
mailing list