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

Matt Turner mattst88 at gmail.com
Fri Nov 21 16:55:56 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 gen8. 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 | 100 ++++++++++++++++++++++++++
>  1 file changed, 100 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index e6ee8d7..c62b0b8 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -1497,6 +1497,104 @@ intel_gen7_hiz_buf_create(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_gen8_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!");

Use unreachable().


More information about the mesa-dev mailing list