[Mesa-dev] [PATCH v5 12/19] i965: Add aux_buf variable to simplify code.

Jason Ekstrand jason at jlekstrand.net
Tue Apr 3 21:59:05 UTC 2018


On Thu, Mar 29, 2018 at 10:58 AM, Rafael Antognolli <
rafael.antognolli at intel.com> wrote:

> In a follow up patch, we make use of clear_color_bo, which is in
> mt->mcs_buf or mt->hiz_buf. To avoid duplicating more code that does the
> same thing on both aux buffers, just use aux_buf already.
>
> v5: Add aux_buf to brw_wm_surface_state too.
>
> Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_blorp.c            | 19 +++++++------------
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 15 ++++++++-------
>  2 files changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index 44064fc0cf3..a0977598309 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -155,10 +155,13 @@ blorp_surf_for_miptree(struct brw_context *brw,
>     };
>
>     struct isl_surf *aux_surf = NULL;
> +   struct intel_miptree_aux_buffer *aux_buf = NULL;
>     if (mt->mcs_buf)
> -      aux_surf = &mt->mcs_buf->surf;
> +      aux_buf = mt->mcs_buf;
>     else if (mt->hiz_buf)
> -      aux_surf = &mt->hiz_buf->surf;
> +      aux_buf = mt->hiz_buf;
> +
> +   aux_surf = &aux_buf->surf;
>

Let's just drop the aux_surf temporary.  It's only used a few lines below
to set surf->aux_surf and now that we have an aux_buf temporary, we can
easily just do "surf->aux_surf = &aux_buf->surf".  With that changed,

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>


>
>     if (mt->format == MESA_FORMAT_S_UINT8 && is_render_target &&
>         devinfo->gen <= 7)
> @@ -180,16 +183,8 @@ blorp_surf_for_miptree(struct brw_context *brw,
>           .mocs = surf->addr.mocs,
>        };
>
> -      if (mt->mcs_buf) {
> -         surf->aux_addr.buffer = mt->mcs_buf->bo;
> -         surf->aux_addr.offset = mt->mcs_buf->offset;
> -      } else {
> -         assert(mt->hiz_buf);
> -         assert(surf->aux_usage == ISL_AUX_USAGE_HIZ);
> -
> -         surf->aux_addr.buffer = mt->hiz_buf->bo;
> -         surf->aux_addr.offset = mt->hiz_buf->offset;
> -      }
> +      surf->aux_addr.buffer = aux_buf->bo;
> +      surf->aux_addr.offset = aux_buf->offset;
>     } else {
>        surf->aux_addr = (struct blorp_address) {
>           .buffer = NULL,
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index caa92d7d878..ea855916403 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -152,22 +152,19 @@ brw_emit_surface_state(struct brw_context *brw,
>
>     union isl_color_value clear_color = { .u32 = { 0, 0, 0, 0 } };
>
> -   struct brw_bo *aux_bo;
> +   struct brw_bo *aux_bo = NULL;
>     struct isl_surf *aux_surf = NULL;
>     uint64_t aux_offset = 0;
> +   struct intel_miptree_aux_buffer *aux_buf = NULL;
>     switch (aux_usage) {
>     case ISL_AUX_USAGE_MCS:
>     case ISL_AUX_USAGE_CCS_D:
>     case ISL_AUX_USAGE_CCS_E:
> -      aux_surf = &mt->mcs_buf->surf;
> -      aux_bo = mt->mcs_buf->bo;
> -      aux_offset = mt->mcs_buf->offset;
> +      aux_buf = mt->mcs_buf;
>        break;
>
>     case ISL_AUX_USAGE_HIZ:
> -      aux_surf = &mt->hiz_buf->surf;
> -      aux_bo = mt->hiz_buf->bo;
> -      aux_offset = 0;
> +      aux_buf = mt->hiz_buf;
>        break;
>
>     case ISL_AUX_USAGE_NONE:
> @@ -175,6 +172,10 @@ brw_emit_surface_state(struct brw_context *brw,
>     }
>
>     if (aux_usage != ISL_AUX_USAGE_NONE) {
> +      aux_surf = &aux_buf->surf;
> +      aux_bo = aux_buf->bo;
> +      aux_offset = aux_buf->offset;
> +
>        /* We only really need a clear color if we also have an auxiliary
>         * surface.  Without one, it does nothing.
>         */
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180403/a1f9035e/attachment.html>


More information about the mesa-dev mailing list