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

Jason Ekstrand jason at jlekstrand.net
Sat Sep 3 00:12:58 UTC 2016


On Wed, Aug 31, 2016 at 8:29 PM, Nanley Chery <nanleychery at gmail.com> wrote:

> 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;
> +      }
> +   }
>

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.


> +
>     *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;
> +      }
>

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.


>        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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160902/991710a6/attachment-0001.html>


More information about the mesa-dev mailing list