[Mesa-dev] [PATCH 4/5] i965/gen7: Don't allocate hiz miptree structure

Matt Turner mattst88 at gmail.com
Fri Nov 21 19:11:44 PST 2014


On Fri, Nov 21, 2014 at 3:09 PM, Jordan Justen
<jordan.l.justen at intel.com> wrote:
> We now skip allocating a hiz miptree for gen7. Instead, we calculate
> the required hiz buffer parameters and allocate a bo directly.
>
> v2:
>  * Update hz_height calculation as suggested by Topi
> v3:
>  * Bail if we failed to create the bo (Ben)
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 102 +++++++++++++++++++++++++-
>  1 file changed, 100 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 8800867..e6ee8d7 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -851,7 +851,10 @@ intel_miptree_release(struct intel_mipmap_tree **mt)
>        drm_intel_bo_unreference((*mt)->bo);
>        intel_miptree_release(&(*mt)->stencil_mt);
>        if ((*mt)->hiz_buf) {
> -         intel_miptree_release(&(*mt)->hiz_buf->mt);
> +         if ((*mt)->hiz_buf->mt)
> +            intel_miptree_release(&(*mt)->hiz_buf->mt);
> +         else
> +            drm_intel_bo_unreference((*mt)->hiz_buf->bo);
>           free((*mt)->hiz_buf);
>        }
>        intel_miptree_release(&(*mt)->mcs_mt);
> @@ -1404,6 +1407,96 @@ intel_miptree_level_enable_hiz(struct brw_context *brw,
>  }
>
>
> +/**
> + * Helper for intel_miptree_alloc_hiz() that determines the required hiz
> + * buffer dimensions and allocates a bo for the hiz buffer.
> + */
> +static struct intel_miptree_aux_buffer *
> +intel_gen7_hiz_buf_create(struct brw_context *brw,
> +                          struct intel_mipmap_tree *mt)
> +{
> +   unsigned z_width = mt->logical_width0;
> +   unsigned z_height = mt->logical_height0;
> +   const unsigned z_depth = mt->logical_depth0;
> +   unsigned hz_width, hz_height;
> +   struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);
> +
> +   if (!buf)
> +      return NULL;
> +
> +   /* Gen7 PRM Volume 2, Part 1, 11.5.3 "Hierarchical Depth Buffer" documents
> +    * adjustments required for Z_Height and Z_Width based on multisampling.
> +    */
> +   switch (mt->num_samples) {
> +   case 0:
> +   case 1:
> +      break;
> +   case 2:
> +   case 4:
> +      z_width *= 2;
> +      z_height *= 2;
> +      break;
> +   case 8:
> +      z_width *= 4;
> +      z_height *= 2;
> +      break;
> +   default:
> +      assert(!"Unsupported sample count!");

unreachable here.


More information about the mesa-dev mailing list